|
|
|
@ -11,7 +11,7 @@
|
|
|
|
|
<el-tree
|
|
|
|
|
:data="treeData"
|
|
|
|
|
show-checkbox
|
|
|
|
|
node-key="id"
|
|
|
|
|
node-key="compositeKey"
|
|
|
|
|
ref="tree"
|
|
|
|
|
highlight-current
|
|
|
|
|
:default-expanded-keys="defaultExpandedArr"
|
|
|
|
@ -42,6 +42,7 @@ export default {
|
|
|
|
|
//指定参数格式回显数据
|
|
|
|
|
children: "list",
|
|
|
|
|
label: "name",
|
|
|
|
|
key: "compositeKey", // 确保这里使用的是 uniqueKey
|
|
|
|
|
},
|
|
|
|
|
treeLoading: false,
|
|
|
|
|
rowData: "",
|
|
|
|
@ -60,7 +61,6 @@ export default {
|
|
|
|
|
//判断
|
|
|
|
|
getdataform(val) {
|
|
|
|
|
this.rowData = JSON.parse(JSON.stringify(val));
|
|
|
|
|
this.getPermissionRole();
|
|
|
|
|
},
|
|
|
|
|
//获取权限树结构
|
|
|
|
|
getPermissionList() {
|
|
|
|
@ -69,40 +69,66 @@ export default {
|
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.treeLoading = false;
|
|
|
|
|
this.treeData = res.data.list;
|
|
|
|
|
// this.treeLoading = false;
|
|
|
|
|
//this.treeData = res.data.list;
|
|
|
|
|
this.treeData = this.processData(res.data);
|
|
|
|
|
console.log(this.treeData);
|
|
|
|
|
// this.treeData.forEach((item) => {
|
|
|
|
|
// this.defaultExpandedArr.push(item.id);
|
|
|
|
|
// });
|
|
|
|
|
this.defaultExpandedArr.push(this.treeData[0].id);
|
|
|
|
|
this.defaultExpandedArr.push(this.treeData[0].compositeKey);
|
|
|
|
|
// console.log("我是默认展开的id", this.defaultExpandedArr);
|
|
|
|
|
this.getPermissionRole();
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {});
|
|
|
|
|
},
|
|
|
|
|
processData(data, level = 0) {
|
|
|
|
|
return data.map((node) => {
|
|
|
|
|
const compositeKey = `${level}-${node.id}`; // 创建复合标识符
|
|
|
|
|
node.compositeKey = compositeKey; // 将复合标识符添加到节点属性中
|
|
|
|
|
if (node.list) {
|
|
|
|
|
node.list = this.processData(node.list, level + 1); // 递归处理子节点
|
|
|
|
|
}
|
|
|
|
|
return node;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
//获取查询杈限
|
|
|
|
|
getPermissionRole() {
|
|
|
|
|
console.log(this.rowData);
|
|
|
|
|
getPermission({ id: this.rowData.id })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.premissData = res.data;
|
|
|
|
|
|
|
|
|
|
let setCheckedKeysList = this.premissData.map(function (item) {
|
|
|
|
|
return item.resourceId;
|
|
|
|
|
// let setCheckedKeysList = this.premissData.map(function (item) {
|
|
|
|
|
// return item.resourceId;
|
|
|
|
|
// });
|
|
|
|
|
let setCheckedKeysList = [];
|
|
|
|
|
this.premissData.forEach((node) => {
|
|
|
|
|
if (node.resourceType == 1) {
|
|
|
|
|
console.log(node);
|
|
|
|
|
setCheckedKeysList.push("0-" + node.resourceId);
|
|
|
|
|
} else if (node.resourceType == 2) {
|
|
|
|
|
setCheckedKeysList.push("1-" + node.resourceId);
|
|
|
|
|
} else if (node.resourceType == 3) {
|
|
|
|
|
setCheckedKeysList.push("2-" + node.resourceId);
|
|
|
|
|
} else if (node.resourceType == 4) {
|
|
|
|
|
setCheckedKeysList.push("3-" + node.resourceId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log(setCheckedKeysList);
|
|
|
|
|
this.$refs.tree.setCheckedKeys(setCheckedKeysList);
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.tree.setCheckedKeys(setCheckedKeysList);
|
|
|
|
|
this.treeLoading = false;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 保存确定操作
|
|
|
|
|
submitForm() {
|
|
|
|
|
//获取勾选的父节点和子节点
|
|
|
|
@ -131,8 +157,10 @@ export default {
|
|
|
|
|
paramsList.push({ resourceType: 1, resourceId: node.id });
|
|
|
|
|
} else if ("bsManufacturer" in node) {
|
|
|
|
|
paramsList.push({ resourceType: 2, resourceId: node.id });
|
|
|
|
|
} else if ("id" in node) {
|
|
|
|
|
} else if ("lineId" in node) {
|
|
|
|
|
paramsList.push({ resourceType: 3, resourceId: node.id });
|
|
|
|
|
} else if ("towerid" in node) {
|
|
|
|
|
paramsList.push({ resourceType: 4, resourceId: node.id });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log(paramsList);
|
|
|
|
|