122122 ref =" treeRef"
123123 node-key =" id"
124124 show-checkbox
125- :default-checked-keys =" defaultCheckedKeys"
126125 :check-strictly =" !checkStrictly"
127126 :props =" defaultProps"
128127 :data =" treeOptions"
@@ -245,7 +244,6 @@ const dialogScopeVisible = ref(false)
245244const dialogScopeTitle = ref (' 数据权限' )
246245const actionScopeType = ref (' ' )
247246const dataScopeDictDatas = ref ()
248- const defaultCheckedKeys = ref ()
249247// 选项
250248const checkStrictly = ref (true )
251249const treeNodeAll = ref (false )
@@ -258,26 +256,30 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => {
258256 dataScopeForm .id = row .id
259257 dataScopeForm .name = row .name
260258 dataScopeForm .code = row .code
259+
260+ actionScopeType .value = type
261+ dialogScopeVisible .value = true
261262 if (type === ' menu' ) {
262263 const menuRes = await listSimpleMenusApi ()
263264 treeOptions .value = handleTree (menuRes )
264265 const role = await PermissionApi .listRoleMenusApi (row .id )
265266 if (role ) {
266- // treeRef.value!.setCheckedKeys(role as unknown as Array<number>)
267- defaultCheckedKeys .value = role
267+ role ?.forEach ((item : any ) => {
268+ unref (treeRef )?.setChecked (item , true ,false );
269+ })
268270 }
269271 } else if (type === ' data' ) {
270272 const deptRes = await listSimpleDeptApi ()
271273 treeOptions .value = handleTree (deptRes )
272274 const role = await RoleApi .getRoleApi (row .id )
273275 dataScopeForm .dataScope = role .dataScope
274276 if (role .dataScopeDeptIds ) {
275- // treeRef.value!.setCheckedKeys(role.dataScopeDeptIds as unknown as Array<number>, false)
276- defaultCheckedKeys .value = role .dataScopeDeptIds
277+ role .dataScopeDeptIds ?.forEach ((item : any ) => {
278+ unref (treeRef )?.setChecked (item , true ,false );
279+ })
277280 }
278281 }
279- actionScopeType .value = type
280- dialogScopeVisible .value = true
282+
281283}
282284// 保存权限
283285const submitScope = async () => {
0 commit comments