diff --git a/src/views/userManage/roleManage/roleList/components/CrudPopup/index.vue b/src/views/userManage/roleManage/roleList/components/CrudPopup/index.vue index 3894776..c9fadd3 100644 --- a/src/views/userManage/roleManage/roleList/components/CrudPopup/index.vue +++ b/src/views/userManage/roleManage/roleList/components/CrudPopup/index.vue @@ -29,9 +29,10 @@ show-checkbox node-key="id" @check="(_, val) => handleSelectMenuChange(val, 'doctorWorkChecks')" - :props="{ children: 'children', label: 'menuName', isLeaf: true }" + :props="{ children: 'children', label: 'menuName', }" default-expand-all > +
@@ -115,9 +116,6 @@ export default { loading: false, }; }, - created() { - this.loadAllMenuList(); - }, methods: { loadAllMenuList() { return geMenuTreeList().then((res) => { @@ -127,6 +125,7 @@ export default { }); }, async loadMenuIdList(roleId) { + await this.loadAllMenuList(); this.loading = true; const [err, res] = await to(getRoleMenuList({ roleId })); if (!err) { @@ -134,6 +133,9 @@ export default { this.form.saleManageChecks = res?.data?.saleManage || []; this.form.saleProcessChecks = res?.data?.saleProcess || []; } + this.form.doctorWorkChecks = this.form.doctorWorkChecks.filter(item => this.treeData.findIndex(item2 => item2.id === item) < 0) + this.form.saleManageChecks = this.form.doctorWorkChecks.filter(item => this.treeData2.findIndex(item2 => item2.id === item) <0) + this.form.saleProcessChecks = this.form.doctorWorkChecks.filter(item => this.treeData3.findIndex(item2 => item2.id === item) <0) this.$nextTick(() => { console.log("this.$refs.tree=", this.$refs.tree); this.$refs.tree.setCheckedKeys(this.form.doctorWorkChecks); @@ -145,7 +147,6 @@ export default { handleSelectMenuChange({ checkedKeys, halfCheckedKeys }, property) { console.log("property=", property); this.form[property] = checkedKeys; - // this.form.menuIdList = checkedKeys; this.$nextTick(() => { this.$refs.form?.validateField("menuIdList"); }); @@ -187,8 +188,12 @@ export default { try { const { menuIdList, doctorWorkChecks, saleManageChecks, saleProcessChecks, ...params } = this.form; + await this.$nextTick(); + const halfChecks1 = this.$refs.tree.getHalfCheckedKeys(); + const halfChecks2 = this.$refs.tree2.getHalfCheckedKeys(); + const halfChecks3 = this.$refs.tree3.getHalfCheckedKeys(); const res = await saveRole({ - menuIdList: [...doctorWorkChecks, ...saleManageChecks, ...saleProcessChecks], + menuIdList: [...doctorWorkChecks, ...saleManageChecks, ...saleProcessChecks, ...halfChecks1, ...halfChecks2, ...halfChecks3], ...params, }); if (this.form.roleId) {