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("");
533533const dateRange = ref ([]);
534534const deptName = ref (" " );
535535const deptOptions = ref (undefined );
536+ const enabledDeptOptions = ref (undefined );
536537const initPassword = ref (undefined );
537538const postOptions = ref ([]);
538539const roleOptions = ref ([]);
@@ -627,12 +628,6 @@ const filterNode = (value, data) => {
627628watch (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/** 查询用户列表 */
637632function 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/** 节点单击事件 */
648662function handleNodeClick (data ) {
649663 queryParams .value .deptId = data .id ;
0 commit comments