|
@@ -120,11 +120,12 @@
|
|
|
show-checkbox
|
|
|
:check-strictly="true"
|
|
|
:default-expand-all="true"
|
|
|
- :expand-on-click-node="false"
|
|
|
+ :expand-on-click-node="true"
|
|
|
node-key="moduleId"
|
|
|
ref="tree"
|
|
|
highlight-current
|
|
|
:props="defaultProps"
|
|
|
+ @check-change="getCheck"
|
|
|
>
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
<span>{{ node.label }}</span>
|
|
@@ -137,7 +138,13 @@
|
|
|
</span>
|
|
|
</el-tree>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="roleFormVisible = false">{{ editId != 1 ? '取 消' : '关 闭' }}</el-button>
|
|
|
+ <el-button
|
|
|
+ @click="
|
|
|
+ roleFormVisible = false
|
|
|
+ flag = false
|
|
|
+ "
|
|
|
+ >{{ editId != 1 ? '取 消' : '关 闭' }}</el-button
|
|
|
+ >
|
|
|
<el-button type="primary" @click="submitRoleForm" v-if="editId != 1">确 定</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
@@ -178,7 +185,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
roleFormVisible: false,
|
|
|
-
|
|
|
+ flag: false,
|
|
|
menuRoleList: [],
|
|
|
defaultProps: {
|
|
|
children: 'children',
|
|
@@ -289,20 +296,45 @@ export default {
|
|
|
this.editId = id
|
|
|
getMenuList({ adminUserId: this.userid }).then(res => {
|
|
|
this.menuRoleList = res.data
|
|
|
+
|
|
|
+ console.log(this.menuRoleList)
|
|
|
})
|
|
|
getMenuRoleIds({ adminRoleId: id }).then(res => {
|
|
|
this.$refs.tree.setCheckedKeys(res.data)
|
|
|
+ this.flag = true
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
+ getCheck(data, val, oval) {
|
|
|
+ // flag 限制初始化时出现卡顿
|
|
|
+ if (this.flag) {
|
|
|
+ const moduleIds = [
|
|
|
+ ...new Set([
|
|
|
+ ...this.$refs.tree.getCheckedNodes().map(e => {
|
|
|
+ return e.parentId
|
|
|
+ }),
|
|
|
+ ...this.$refs.tree.getCheckedKeys()
|
|
|
+ ])
|
|
|
+ ]
|
|
|
+ this.$refs.tree.setCheckedKeys(moduleIds)
|
|
|
+ }
|
|
|
+ },
|
|
|
// 设置权限 - 提交数据
|
|
|
submitRoleForm() {
|
|
|
+ const parenIds = [
|
|
|
+ ...new Set(
|
|
|
+ this.$refs.tree.getCheckedNodes().map(e => {
|
|
|
+ return e.parentId
|
|
|
+ })
|
|
|
+ )
|
|
|
+ ]
|
|
|
let params = {
|
|
|
adminModuleIds: this.$refs.tree.getCheckedKeys().join(','),
|
|
|
adminRoleId: this.editId
|
|
|
}
|
|
|
+
|
|
|
setMenuRole(params).then(res => {
|
|
|
this.roleFormVisible = false
|
|
|
+ this.flag = false
|
|
|
this.getList()
|
|
|
this.$successMsg()
|
|
|
})
|