Skip to content

Commit 3e5890b

Browse files
committed
perf: 用户管理过滤掉已禁用部门
1 parent e21bde5 commit 3e5890b

File tree

1 file changed

+21
-7
lines changed
  • ruoyi-fastapi-frontend/src/views/system/user

1 file changed

+21
-7
lines changed

ruoyi-fastapi-frontend/src/views/system/user/index.vue

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
<el-form-item label="归属部门" prop="deptId">
316316
<el-tree-select
317317
v-model="form.deptId"
318-
:data="deptOptions"
318+
:data="enabledDeptOptions"
319319
:props="{ value: 'id', label: 'label', children: 'children' }"
320320
value-key="id"
321321
placeholder="请选择归属部门"
@@ -533,6 +533,7 @@ const title = ref("");
533533
const dateRange = ref([]);
534534
const deptName = ref("");
535535
const deptOptions = ref(undefined);
536+
const enabledDeptOptions = ref(undefined);
536537
const initPassword = ref(undefined);
537538
const postOptions = ref([]);
538539
const roleOptions = ref([]);
@@ -627,12 +628,6 @@ const filterNode = (value, data) => {
627628
watch(deptName, (val) => {
628629
proxy.$refs["deptTreeRef"].filter(val);
629630
});
630-
/** 查询部门下拉树结构 */
631-
function getDeptTree() {
632-
deptTreeSelect().then((response) => {
633-
deptOptions.value = response.data;
634-
});
635-
}
636631
/** 查询用户列表 */
637632
function getList() {
638633
loading.value = true;
@@ -644,6 +639,25 @@ function getList() {
644639
}
645640
);
646641
}
642+
/** 查询部门下拉树结构 */
643+
function getDeptTree() {
644+
deptTreeSelect().then(response => {
645+
deptOptions.value = response.data;
646+
enabledDeptOptions.value = filterDisabledDept(JSON.parse(JSON.stringify(response.data)));
647+
});
648+
};
649+
/** 过滤禁用的部门 */
650+
function filterDisabledDept(deptList) {
651+
return deptList.filter(dept => {
652+
if (dept.disabled) {
653+
return false;
654+
}
655+
if (dept.children && dept.children.length) {
656+
dept.children = filterDisabledDept(dept.children);
657+
}
658+
return true;
659+
});
660+
};
647661
/** 节点单击事件 */
648662
function handleNodeClick(data) {
649663
queryParams.value.deptId = data.id;

0 commit comments

Comments
 (0)