122
122
ref =" treeRef"
123
123
node-key =" id"
124
124
show-checkbox
125
- :default-checked-keys =" defaultCheckedKeys"
126
125
:check-strictly =" !checkStrictly"
127
126
:props =" defaultProps"
128
127
:data =" treeOptions"
@@ -245,7 +244,6 @@ const dialogScopeVisible = ref(false)
245
244
const dialogScopeTitle = ref (' 数据权限' )
246
245
const actionScopeType = ref (' ' )
247
246
const dataScopeDictDatas = ref ()
248
- const defaultCheckedKeys = ref ()
249
247
// 选项
250
248
const checkStrictly = ref (true )
251
249
const treeNodeAll = ref (false )
@@ -258,26 +256,30 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => {
258
256
dataScopeForm .id = row .id
259
257
dataScopeForm .name = row .name
260
258
dataScopeForm .code = row .code
259
+
260
+ actionScopeType .value = type
261
+ dialogScopeVisible .value = true
261
262
if (type === ' menu' ) {
262
263
const menuRes = await listSimpleMenusApi ()
263
264
treeOptions .value = handleTree (menuRes )
264
265
const role = await PermissionApi .listRoleMenusApi (row .id )
265
266
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
+ })
268
270
}
269
271
} else if (type === ' data' ) {
270
272
const deptRes = await listSimpleDeptApi ()
271
273
treeOptions .value = handleTree (deptRes )
272
274
const role = await RoleApi .getRoleApi (row .id )
273
275
dataScopeForm .dataScope = role .dataScope
274
276
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
+ })
277
280
}
278
281
}
279
- actionScopeType .value = type
280
- dialogScopeVisible .value = true
282
+
281
283
}
282
284
// 保存权限
283
285
const submitScope = async () => {
0 commit comments