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 () => { diff --git a/src/views/system/tenantPackage/index.vue b/src/views/system/tenantPackage/index.vue index a665b8af..f8b81171 100644 --- a/src/views/system/tenantPackage/index.vue +++ b/src/views/system/tenantPackage/index.vue @@ -125,7 +125,9 @@ const handleUpdate = async (rowId: number) => { const res = await TenantPackageApi.getTenantPackageApi(rowId) unref(formRef)?.setValues(res) // 设置选中 - unref(treeRef)?.setCheckedKeys(res.menuIds) + res.menuIds?.forEach((item: any) => { + unref(treeRef)?.setChecked(item, true,false); + }) } // 提交按钮