From 0b9022c8a5b26d368c44b0fe920fd51aa4f57dee Mon Sep 17 00:00:00 2001 From: chengyangwang <1223440313@qq.com> Date: Fri, 3 Mar 2023 12:52:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Del-tree=E7=BB=84?= =?UTF-8?q?=E4=BB=B6setCheckedKeys=E8=AE=BE=E7=BD=AE=E4=B8=80=E6=97=A6?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E7=88=B6=E7=BA=A7=E5=AD=90=E7=BA=A7=E4=B9=9F?= =?UTF-8?q?=E8=A2=AB=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/role/index.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index 72c602c1..b2f12af3 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -122,7 +122,6 @@ ref="treeRef" node-key="id" show-checkbox - :default-checked-keys="defaultCheckedKeys" :check-strictly="!checkStrictly" :props="defaultProps" :data="treeOptions" @@ -245,7 +244,6 @@ const dialogScopeVisible = ref(false) const dialogScopeTitle = ref('数据权限') const actionScopeType = ref('') const dataScopeDictDatas = ref() -const defaultCheckedKeys = ref() // 选项 const checkStrictly = ref(true) const treeNodeAll = ref(false) @@ -258,13 +256,17 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => { dataScopeForm.id = row.id dataScopeForm.name = row.name dataScopeForm.code = row.code + + actionScopeType.value = type + dialogScopeVisible.value = true if (type === 'menu') { const menuRes = await listSimpleMenusApi() treeOptions.value = handleTree(menuRes) const role = await PermissionApi.listRoleMenusApi(row.id) if (role) { - // treeRef.value!.setCheckedKeys(role as unknown as Array) - defaultCheckedKeys.value = role + role?.forEach((item: any) => { + unref(treeRef)?.setChecked(item, true,false); + }) } } else if (type === 'data') { const deptRes = await listSimpleDeptApi() @@ -272,12 +274,12 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => { const role = await RoleApi.getRoleApi(row.id) dataScopeForm.dataScope = role.dataScope if (role.dataScopeDeptIds) { - // treeRef.value!.setCheckedKeys(role.dataScopeDeptIds as unknown as Array, false) - defaultCheckedKeys.value = role.dataScopeDeptIds + role.dataScopeDeptIds?.forEach((item: any) => { + unref(treeRef)?.setChecked(item, true,false); + }) } } - actionScopeType.value = type - dialogScopeVisible.value = true + } // 保存权限 const submitScope = async () => {