|
|
@ -32,9 +32,8 @@
|
|
|
|
v-model="checkedKeys"
|
|
|
|
v-model="checkedKeys"
|
|
|
|
v-if="treeShow != undefined"
|
|
|
|
v-if="treeShow != undefined"
|
|
|
|
checkable
|
|
|
|
checkable
|
|
|
|
:defaultExpandAll="true"
|
|
|
|
:expandedKeys="expandedKeys"
|
|
|
|
:replace-fields="replaceFields"
|
|
|
|
:replace-fields="replaceFields"
|
|
|
|
:expanded-keys="expandedKeys"
|
|
|
|
|
|
|
|
:selected-keys="selectedKeys"
|
|
|
|
:selected-keys="selectedKeys"
|
|
|
|
:tree-data="menus"
|
|
|
|
:tree-data="menus"
|
|
|
|
@expand="onExpand"
|
|
|
|
@expand="onExpand"
|
|
|
@ -78,6 +77,7 @@ export default {
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
roleId: null,
|
|
|
|
roleId: null,
|
|
|
|
|
|
|
|
defaultExpandAll: true,
|
|
|
|
roleList: [],
|
|
|
|
roleList: [],
|
|
|
|
expandedKeys: [],
|
|
|
|
expandedKeys: [],
|
|
|
|
replaceFields: {
|
|
|
|
replaceFields: {
|
|
|
@ -85,7 +85,10 @@ export default {
|
|
|
|
title: "name",
|
|
|
|
title: "name",
|
|
|
|
key: "id",
|
|
|
|
key: "id",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
checkedKeys: [],
|
|
|
|
checkedKeys: {
|
|
|
|
|
|
|
|
checked: [],
|
|
|
|
|
|
|
|
halfChecked: [],
|
|
|
|
|
|
|
|
},
|
|
|
|
selectedKeys: [],
|
|
|
|
selectedKeys: [],
|
|
|
|
menus: [], //页面菜单
|
|
|
|
menus: [], //页面菜单
|
|
|
|
actionsList: [], //操作
|
|
|
|
actionsList: [], //操作
|
|
|
@ -105,12 +108,14 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
rolechoose(data) {
|
|
|
|
rolechoose(data) {
|
|
|
|
this.checkedKeys = [];
|
|
|
|
this.checkedKeys = {
|
|
|
|
|
|
|
|
checked: [],
|
|
|
|
|
|
|
|
halfChecked: [],
|
|
|
|
|
|
|
|
};
|
|
|
|
if (data !== undefined) {
|
|
|
|
if (data !== undefined) {
|
|
|
|
this.roleId = data;
|
|
|
|
this.roleId = data;
|
|
|
|
FindAllMenus({ roleId: this.roleId }).then((res) => {
|
|
|
|
FindAllMenus({ roleId: this.roleId }).then((res) => {
|
|
|
|
this.menus = res.data;
|
|
|
|
this.menus = res.data;
|
|
|
|
// console.log(res.data)
|
|
|
|
|
|
|
|
this.defaultCheck(this.menus);
|
|
|
|
this.defaultCheck(this.menus);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (data === undefined) {
|
|
|
|
} else if (data === undefined) {
|
|
|
@ -120,7 +125,10 @@ export default {
|
|
|
|
rolechange(data) {
|
|
|
|
rolechange(data) {
|
|
|
|
this.treeShow = data;
|
|
|
|
this.treeShow = data;
|
|
|
|
if (data != undefined) {
|
|
|
|
if (data != undefined) {
|
|
|
|
this.checkedKeys = [];
|
|
|
|
this.checkedKeys = {
|
|
|
|
|
|
|
|
checked: [],
|
|
|
|
|
|
|
|
halfChecked: [],
|
|
|
|
|
|
|
|
};
|
|
|
|
this.roleId = this.roleList[data].id;
|
|
|
|
this.roleId = this.roleList[data].id;
|
|
|
|
FindAllMenus({ roleId: this.roleId }).then((res) => {
|
|
|
|
FindAllMenus({ roleId: this.roleId }).then((res) => {
|
|
|
|
this.menus = res.data;
|
|
|
|
this.menus = res.data;
|
|
|
@ -131,26 +139,68 @@ export default {
|
|
|
|
// this.menus = [];
|
|
|
|
// this.menus = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// defaultCheck(arr) {
|
|
|
|
|
|
|
|
// for (let item of arr) {
|
|
|
|
|
|
|
|
// if (item.childrenList != null) {
|
|
|
|
|
|
|
|
// if(item.isShow == true){
|
|
|
|
|
|
|
|
// this.checkedKeys.push(item.id);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// this.defaultCheck(item.childrenList);
|
|
|
|
|
|
|
|
// } else if (item.isShow == true) {
|
|
|
|
|
|
|
|
// this.checkedKeys.push(item.id);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// },
|
|
|
|
defaultCheck(arr) {
|
|
|
|
defaultCheck(arr) {
|
|
|
|
for (let item of arr) {
|
|
|
|
let res = {
|
|
|
|
if (item.childrenList !== null) {
|
|
|
|
checked: [],
|
|
|
|
if(item.isShow === true){
|
|
|
|
halfChecked: [],
|
|
|
|
this.checkedKeys.push(item.id);
|
|
|
|
};
|
|
|
|
|
|
|
|
for(let x = 0; x<arr.length; x++) {
|
|
|
|
|
|
|
|
let item = arr[x];
|
|
|
|
|
|
|
|
for(let y = 0; y<arr[x].childrenList.length; y++) {
|
|
|
|
|
|
|
|
let item = arr[x].childrenList[y];
|
|
|
|
|
|
|
|
let checkedNum = 0
|
|
|
|
|
|
|
|
if(item.childrenList) {
|
|
|
|
|
|
|
|
for(let z = 0; z<arr[x].childrenList[y].childrenList.length; z++) {
|
|
|
|
|
|
|
|
let item = arr[x].childrenList[y].childrenList[z];
|
|
|
|
|
|
|
|
let checkedNum = 0
|
|
|
|
|
|
|
|
if(item.isShow == true) {
|
|
|
|
|
|
|
|
res.checked.push(item.id)
|
|
|
|
|
|
|
|
checkedNum = checkedNum + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.defaultCheck(item.childrenList);
|
|
|
|
if( checkedNum == arr[x].childrenList[y].childrenList.length) {
|
|
|
|
} else if (item.isShow === true) {
|
|
|
|
res.checked.push(arr[x].childrenList[y].id)
|
|
|
|
this.checkedKeys.push(item.id);
|
|
|
|
} else if ( checkedNum != 0) {
|
|
|
|
|
|
|
|
res.halfChecked.push(arr[x].childrenList[y].id)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// console.log(this.checkedKeys)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
if(!item.childrenList) {
|
|
|
|
onExpand(expandedKeys) {
|
|
|
|
if(item.isShow == true) {
|
|
|
|
this.expandedKeys = expandedKeys;
|
|
|
|
res.checked.push(item.id);
|
|
|
|
this.autoExpandParent = false;
|
|
|
|
checkedNum = checkedNum + 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(checkedNum == arr[x].childrenList.length) {
|
|
|
|
|
|
|
|
res.checked.push(arr[x].id)
|
|
|
|
|
|
|
|
} else if (checkedNum != 0) {
|
|
|
|
|
|
|
|
res.halfChecked.push(arr[x].id)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!item.childrenList) {
|
|
|
|
|
|
|
|
if(item.isShow == true) {
|
|
|
|
|
|
|
|
res.checked.push(item.id)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.expandedKeys = res.halfChecked.concat(res.checked)
|
|
|
|
|
|
|
|
this.checkedKeys = res
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onCheck(checkedKeys, e) {
|
|
|
|
onCheck(checkedKeys, e) {
|
|
|
|
this.checkedKeys = checkedKeys;
|
|
|
|
this.checkedKeys = checkedKeys;
|
|
|
|
// console.log(e.node.eventKey);
|
|
|
|
|
|
|
|
changeMenuShow({
|
|
|
|
changeMenuShow({
|
|
|
|
roleId: this.roleId,
|
|
|
|
roleId: this.roleId,
|
|
|
|
showMenusId: e.node.eventKey,
|
|
|
|
showMenusId: e.node.eventKey,
|
|
|
@ -162,10 +212,11 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
onExpand(e) {
|
|
|
|
|
|
|
|
this.expandedKeys = e;
|
|
|
|
|
|
|
|
},
|
|
|
|
onSelect(selectedKeys, info) {
|
|
|
|
onSelect(selectedKeys, info) {
|
|
|
|
// console.log('onSelect', info);
|
|
|
|
|
|
|
|
this.selectedKeys = selectedKeys;
|
|
|
|
this.selectedKeys = selectedKeys;
|
|
|
|
// console.log(selectedKeys);
|
|
|
|
|
|
|
|
getActions({ roleId: this.roleId, menusId: this.selectedKeys[0] }).then(
|
|
|
|
getActions({ roleId: this.roleId, menusId: this.selectedKeys[0] }).then(
|
|
|
|
(res) => {
|
|
|
|
(res) => {
|
|
|
|
this.actionsList = res.data;
|
|
|
|
this.actionsList = res.data;
|
|
|
@ -193,7 +244,6 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
checkedKeys(val) {
|
|
|
|
checkedKeys(val) {
|
|
|
|
// console.log('onCheck', val);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
roleList: {
|
|
|
|
roleList: {
|
|
|
|
handler(val) {
|
|
|
|
handler(val) {
|
|
|
|