zx 3 years ago
parent e07a5f0816
commit 549de8f490

@ -50,13 +50,13 @@
:total="pagination.total"
/>
</div>
<el-drawer v-model="drawerVisible">
<el-drawer @close="drawerClose" v-model="drawerVisible">
<template #header>
<span style="font-size: 16px;font-weight: bold">角色权限</span>
</template>
<el-tree ref="tree" node-key="name" default-expand-all
:data="treeData" :props="defaultProps" :default-checked-keys="checkedName"
show-checkbox @check="checkChange()">
<el-tree ref="tree" node-key="id" default-expand-all
:data="treeData" :props="defaultProps" :default-checked-keys="checkedId.ids"
show-checkbox @check="checkChange">
</el-tree>
<template #footer>
<el-button type="primary" @click="authorChangeComfirm" size="default">确定</el-button>
@ -106,15 +106,16 @@ export default defineComponent({
label: 'name',
};
const treeData = ref([]);
const checkedName = ref([]);
const checkedId = ref([]);
const checkedId = reactive({
ids: [],
});
return {
form,setForm,proxy,
tableData,activeId,
pagination,
statusFormatter,
visible,editVisible,drawerVisible,
defaultProps, treeData,checkedName,checkedId
defaultProps, treeData, checkedId
}
},
mounted() {
@ -178,20 +179,24 @@ export default defineComponent({
handlerAuthor(value) {
this.activeId = value;
this.proxy.$post("/userJurisdiction/findByRoleId", {roleId: value}).then(res => {
const data = res.data
let data = res.data
this.treeData = data;
const arr = [];
let arr = [];
this.treeData.forEach(ele => {
ele.operationVoList.forEach(e => {
if(e.check == true) {
arr.push(e.name)
arr.push(e.id)
}
})
});
this.checkedName = arr;
this.checkedId.ids = arr;
this.drawerVisible = true
}).catch(() => {});
},
drawerClose() {
this.checkedId.ids = [];
this.drawerVisible = false;
},
checkChange() {
let selectedKeys = this.$refs.tree.getCheckedNodes()
let arr = []
@ -200,11 +205,10 @@ export default defineComponent({
arr.push(ele.id)
}
});
console.log(arr)
this.checkedId = arr;
this.checkedId.ids = arr;
},
authorChangeComfirm() {
let obj = {roleId: this.activeId,jurisdictionIds: this.checkedId}
let obj = {roleId: this.activeId,jurisdictionIds: this.checkedId.ids}
this.proxy.$post("/userJurisdiction/operationRoleJurisdiction", obj).then(res => {
if(res.code == 200) {
this.$message.success('修改成功');

Loading…
Cancel
Save