update 优化 新增编辑用户 过滤禁用的部门
This commit is contained in:
parent
84888c3c28
commit
7a9ccedadc
@ -28,6 +28,18 @@ export interface DeptVO extends BaseEntity {
|
|||||||
menuId: string | number;
|
menuId: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门类型
|
||||||
|
*/
|
||||||
|
export interface DeptTreeVO extends BaseEntity {
|
||||||
|
id: number | string;
|
||||||
|
label: string;
|
||||||
|
parentId: number | string;
|
||||||
|
weight: number;
|
||||||
|
children: DeptTreeVO[];
|
||||||
|
disabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门表单类型
|
* 部门表单类型
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DeptVO } from './../dept/types';
|
import {DeptTreeVO, DeptVO} from './../dept/types';
|
||||||
import { RoleVO } from '@/api/system/role/types';
|
import { RoleVO } from '@/api/system/role/types';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import { AxiosPromise } from 'axios';
|
import { AxiosPromise } from 'axios';
|
||||||
@ -202,7 +202,7 @@ export const listUserByDeptId = (deptId: string | number): AxiosPromise<UserVO[]
|
|||||||
/**
|
/**
|
||||||
* 查询部门下拉树结构
|
* 查询部门下拉树结构
|
||||||
*/
|
*/
|
||||||
export const deptTreeSelect = (): AxiosPromise<DeptVO[]> => {
|
export const deptTreeSelect = (): AxiosPromise<DeptTreeVO[]> => {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/deptTree',
|
url: '/system/user/deptTree',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
|
@ -154,7 +154,7 @@
|
|||||||
<el-form-item label="归属部门" prop="deptId">
|
<el-form-item label="归属部门" prop="deptId">
|
||||||
<el-tree-select
|
<el-tree-select
|
||||||
v-model="form.deptId"
|
v-model="form.deptId"
|
||||||
:data="deptOptions"
|
:data="enabledDeptOptions"
|
||||||
:props="{ value: 'id', label: 'label', children: 'children' }"
|
:props="{ value: 'id', label: 'label', children: 'children' }"
|
||||||
value-key="id"
|
value-key="id"
|
||||||
placeholder="请选择归属部门"
|
placeholder="请选择归属部门"
|
||||||
@ -287,7 +287,7 @@
|
|||||||
<script setup name="User" lang="ts">
|
<script setup name="User" lang="ts">
|
||||||
import api from '@/api/system/user';
|
import api from '@/api/system/user';
|
||||||
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
|
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
|
||||||
import { DeptVO } from '@/api/system/dept/types';
|
import {DeptTreeVO, DeptVO} from '@/api/system/dept/types';
|
||||||
import { RoleVO } from '@/api/system/role/types';
|
import { RoleVO } from '@/api/system/role/types';
|
||||||
import { PostQuery, PostVO } from '@/api/system/post/types';
|
import { PostQuery, PostVO } from '@/api/system/post/types';
|
||||||
import { treeselect } from '@/api/system/dept';
|
import { treeselect } from '@/api/system/dept';
|
||||||
@ -307,7 +307,8 @@ const multiple = ref(true);
|
|||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
|
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
|
||||||
const deptName = ref('');
|
const deptName = ref('');
|
||||||
const deptOptions = ref<DeptVO[]>([]);
|
const deptOptions = ref<DeptTreeVO[]>([]);
|
||||||
|
const enabledDeptOptions = ref<DeptTreeVO[]>([]);
|
||||||
const initPassword = ref<string>('');
|
const initPassword = ref<string>('');
|
||||||
const postOptions = ref<PostVO[]>([]);
|
const postOptions = ref<PostVO[]>([]);
|
||||||
const roleOptions = ref<RoleVO[]>([]);
|
const roleOptions = ref<RoleVO[]>([]);
|
||||||
@ -431,12 +432,6 @@ watchEffect(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/** 查询部门下拉树结构 */
|
|
||||||
const getTreeSelect = async () => {
|
|
||||||
const res = await api.deptTreeSelect();
|
|
||||||
deptOptions.value = res.data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@ -446,6 +441,26 @@ const getList = async () => {
|
|||||||
total.value = res.total;
|
total.value = res.total;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 查询部门下拉树结构 */
|
||||||
|
const getDeptTree = async () => {
|
||||||
|
const res = await api.deptTreeSelect();
|
||||||
|
deptOptions.value = res.data;
|
||||||
|
enabledDeptOptions.value = filterDisabledDept(res.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 过滤禁用的部门 */
|
||||||
|
const filterDisabledDept = (deptList: DeptTreeVO[]) => {
|
||||||
|
return deptList.filter(dept => {
|
||||||
|
if (dept.disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (dept.children && dept.children.length) {
|
||||||
|
dept.children = filterDisabledDept(dept.children);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/** 节点单击事件 */
|
/** 节点单击事件 */
|
||||||
const handleNodeClick = (data: DeptVO) => {
|
const handleNodeClick = (data: DeptVO) => {
|
||||||
queryParams.value.deptId = data.id;
|
queryParams.value.deptId = data.id;
|
||||||
@ -643,7 +658,7 @@ const resetForm = () => {
|
|||||||
form.value.status = '1';
|
form.value.status = '1';
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getTreeSelect(); // 初始化部门数据
|
getDeptTree(); // 初始化部门数据
|
||||||
getList(); // 初始化列表数据
|
getList(); // 初始化列表数据
|
||||||
proxy?.getConfigKey('sys.user.initPassword').then((response) => {
|
proxy?.getConfigKey('sys.user.initPassword').then((response) => {
|
||||||
initPassword.value = response.data;
|
initPassword.value = response.data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user