From 2bb0e066fdc522beb51dd13f6a72cd67bd5d6a58 Mon Sep 17 00:00:00 2001 From: “dzb” <2632970487@qq.com> Date: 星期日, 09 十月 2022 18:06:46 +0800 Subject: [PATCH] 修改bug,店铺管理新增、查询 --- src/views/systemSetting/baseSetting/role/updateUser/index.vue | 107 +++++++++++++++++++++++++++-------------------------- 1 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/views/systemSetting/baseSetting/role/updateUser/index.vue b/src/views/systemSetting/baseSetting/role/updateUser/index.vue index d0d18e1..295bcbe 100644 --- a/src/views/systemSetting/baseSetting/role/updateUser/index.vue +++ b/src/views/systemSetting/baseSetting/role/updateUser/index.vue @@ -4,8 +4,8 @@ <div class="mainContent"> <div class="my-tree"> <div class="my-tree__wrap"> - <el-tree :data="roleList" :props="defaultProps" @node-click="handleNodeClick" show-checkbox - @check-change="handleCheckChange" default-expand-all node-key="id"> + <el-tree ref="tree" :data="roleList" :props="defaultProps" show-checkbox @check="handleCheck" + :default-checked-keys="checkedIds" default-expand-all node-key="id"> </el-tree> </div> <div class="my-tree__bottom"></div> @@ -41,29 +41,10 @@ }, created() { const that = this; + this.getRoleMenus(this.userInfo.id); this.getMenuList(); }, methods: { - handleUser() { - this.$refs.user.validate((valid) => { - if (valid) { - const { role } = this; - console.log(role); - this.$axios.post('/sccg/role/update/' + role.id, { - id: role.id, - status: role.status, - description: role.description, - name: role.name, - sort: 0 - }).then(res => { - this.$emit('changeDialog', { dialogUpdate: false }); - this.getUserList(); - }) - } else { - return false; - } - }) - }, // 鑾峰彇绯荤粺鑿滃崟 getMenuList() { this.$axios({ @@ -72,42 +53,58 @@ }) .then(res => { this.roleList = res.data; - console.log(res); }) }, - // 鐐瑰嚮鏍戣妭鐐� - handleNodeClick({ title, id }) { - // console.log(obj); - this.role.sort = title; - this.treeLabel = title; - this.treeId = id; - - }, - // 鏍戝舰鎺т欢閫変腑鏇存敼 - handleCheckChange(data, checked, indeterminate) { - // console.log(data,checked,indeterminate); - if (checked) { - this.checkedIds.push(data.id); - } else { - let index = 0; - this.checkedIds.forEach((item, idx) => { - if (item.id === data.id) { - index = idx; - } - }) - this.checkedIds.splice(index, 1); - } + // 鏍戝舰鎺т欢澶嶉�夋鐐瑰嚮浜嬩欢 + handleCheck(data, checked) { + console.log(checked.checkedKeys); + this.checkedIds = checked.checkedKeys; console.log(this.checkedIds); }, // 淇濆瓨role saveRole() { this.resCheckedIds = []; + const { userInfo } = this; this.resCheckedIds = this.checkedIds; - this.$emit('changeDialog',{dialogUpdate:false}); + this.$axios({ + method: 'post', + url: 'sccg/role/allocMenu?roleId=' + userInfo.id + '&menuIds=' + this.checkedIds, + }) + .then(res => { + if (res.code === 200) { + this.$message({ + type: 'success', + message: '淇敼瑙掕壊鏉冮檺鎴愬姛', + }) + this.getRoleMenus(userInfo.id); + this.$emit('changeDialog', { flag: false }); + this.getUserList(); + } else { + this.$message({ + type: 'warning', + message: res.message + }) + } + }) + // this.$emit('changeDialog',{dialogUpdate:false}); }, // 娑堥櫎role resetRole() { - this.resCheckedIds = [] + this.resCheckedIds = []; + this.$emit('changeDialog', { dialogUpdate: false }); + }, + // 鑾峰彇瑙掕壊鑿滃崟 + getRoleMenus(roleId) { + this.$axios({ + method: 'get', + url: `sccg/role/listMenu/${roleId}` + }) + .then(res => { + this.checkedIds = []; + res.data.forEach(item => { + this.checkedIds.push(item.id); + }) + }) } }, props: ['userInfo', 'updateFlag', 'getUserList', 'changeDialog'] @@ -117,10 +114,12 @@ .updateUser { border-radius: 1px; background-color: #09152f; + main { text-align: left; padding: 50px 55px; background-color: #09152f; + .mainContent { .my-tree { height: 200px; @@ -128,24 +127,27 @@ background-color: #17324c; position: relative; border-radius: 4px; - .my-tree__wrap{ + + .my-tree__wrap { overflow: scroll; height: 200px; } - .my-tree__bottom{ + + .my-tree__bottom { position: absolute; left: 0px; bottom: 0px; - background-color: #17324c; + background-color: #09152f; width: 100%; height: 20px; border-bottom-left-radius: 4px; } - .my-tree__right{ + + .my-tree__right { position: absolute; right: 0px; top: 0px; - background-color: #17324c; + background-color: #09152f; width: 20px; height: 100%; } @@ -168,6 +170,7 @@ margin-top: 10px; display: flex; justify-content: space-between; + .el-button { padding: 10px 20px; border-radius: 4px; -- Gitblit v1.8.0