|
|
@ -14,6 +14,7 @@
|
|
|
|
node-key="id"
|
|
|
|
node-key="id"
|
|
|
|
ref="tree"
|
|
|
|
ref="tree"
|
|
|
|
highlight-current
|
|
|
|
highlight-current
|
|
|
|
|
|
|
|
:default-expanded-keys="defaultExpandedArr"
|
|
|
|
:props="defaultProps"
|
|
|
|
:props="defaultProps"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
</el-tree>
|
|
|
|
</el-tree>
|
|
|
@ -46,6 +47,7 @@ export default {
|
|
|
|
rowData: "",
|
|
|
|
rowData: "",
|
|
|
|
premissData: [],
|
|
|
|
premissData: [],
|
|
|
|
selectTreeNode: [],
|
|
|
|
selectTreeNode: [],
|
|
|
|
|
|
|
|
defaultExpandedArr: [],
|
|
|
|
rules: {
|
|
|
|
rules: {
|
|
|
|
name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
|
|
|
name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -69,6 +71,9 @@ export default {
|
|
|
|
console.log(res);
|
|
|
|
console.log(res);
|
|
|
|
this.treeLoading = false;
|
|
|
|
this.treeLoading = false;
|
|
|
|
this.treeData = res.data.list;
|
|
|
|
this.treeData = res.data.list;
|
|
|
|
|
|
|
|
this.treeData.forEach((item) => {
|
|
|
|
|
|
|
|
this.defaultExpandedArr.push(item.id);
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -83,6 +88,12 @@ export default {
|
|
|
|
if (res.code == 200) {
|
|
|
|
if (res.code == 200) {
|
|
|
|
console.log(res);
|
|
|
|
console.log(res);
|
|
|
|
this.premissData = res.data;
|
|
|
|
this.premissData = res.data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let setCheckedKeysList = this.premissData.map(function (item) {
|
|
|
|
|
|
|
|
return item.resourceId;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(setCheckedKeysList);
|
|
|
|
|
|
|
|
this.$refs.tree.setCheckedKeys(setCheckedKeysList);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -92,18 +103,56 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
// 保存确定操作
|
|
|
|
// 保存确定操作
|
|
|
|
submitForm() {
|
|
|
|
submitForm() {
|
|
|
|
console.log(this.$refs.tree.getCheckedNodes());
|
|
|
|
//获取勾选的父节点和子节点
|
|
|
|
this.selectTreeNode = this.$refs.tree.getCheckedNodes();
|
|
|
|
let originData = this.$refs.tree.store;
|
|
|
|
console.log(this.selectTreeNode);
|
|
|
|
// 定义数组
|
|
|
|
// changePermission()
|
|
|
|
const checkedNodeIds = [];
|
|
|
|
// .then((res) => {
|
|
|
|
// 判断是否为全选,若为全选状态返回被选中的父节点数据,不为全选状态正常返回被选中的子节点的数据
|
|
|
|
// if (res.code == 200) {
|
|
|
|
const isAllChecked = function (node) {
|
|
|
|
// console.log(res);
|
|
|
|
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
|
|
// } else {
|
|
|
|
childNodes.forEach((child) => {
|
|
|
|
// this.$message.error(res.msg);
|
|
|
|
if (child.checked) {
|
|
|
|
// }
|
|
|
|
checkedNodeIds.push(child.data);
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
// .catch((err) => {});
|
|
|
|
if (child.indeterminate) {
|
|
|
|
|
|
|
|
isAllChecked(child);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
isAllChecked(originData);
|
|
|
|
|
|
|
|
console.log(checkedNodeIds);
|
|
|
|
|
|
|
|
//把获取到的节点遍历 组成想要的内容
|
|
|
|
|
|
|
|
let paramsList = [];
|
|
|
|
|
|
|
|
checkedNodeIds.forEach((node) => {
|
|
|
|
|
|
|
|
if ("dyValue" in node) {
|
|
|
|
|
|
|
|
console.log(node);
|
|
|
|
|
|
|
|
paramsList.push({ resourceType: 1, resourceId: node.id });
|
|
|
|
|
|
|
|
} else if ("bsManufacturer" in node) {
|
|
|
|
|
|
|
|
paramsList.push({ resourceType: 2, resourceId: node.id });
|
|
|
|
|
|
|
|
} else if ("towerid" in node) {
|
|
|
|
|
|
|
|
paramsList.push({ resourceType: 3, resourceId: node.towerid });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(paramsList);
|
|
|
|
|
|
|
|
changePermission({
|
|
|
|
|
|
|
|
list: paramsList,
|
|
|
|
|
|
|
|
roleId: this.rowData.id,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.then((res) => {
|
|
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
this.isShow = false;
|
|
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
|
|
duration: 1500,
|
|
|
|
|
|
|
|
showClose: true,
|
|
|
|
|
|
|
|
message: "权限绑定成功",
|
|
|
|
|
|
|
|
type: "success",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((err) => {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
display() {
|
|
|
|
display() {
|
|
|
|
this.isShow = true;
|
|
|
|
this.isShow = true;
|
|
|
|