diff --git a/apps/web-antd/src/api/system/dept/index.ts b/apps/web-antd/src/api/system/dept/index.ts new file mode 100644 index 00000000..3b5e44a4 --- /dev/null +++ b/apps/web-antd/src/api/system/dept/index.ts @@ -0,0 +1,45 @@ +import type { Dept } from './model'; + +import type { ID, PageQuery } from '#/api/common'; + +import { requestClient } from '#/api/request'; + +enum Api { + deptList = '/system/dept/list', + deptNodeInfo = '/system/dept/list/exclude', + root = '/system/dept', +} + +export function deptList(params?: PageQuery) { + return requestClient.get(Api.deptList, { params }); +} + +/** + * 查询部门列表(排除节点) + * @param deptId 部门ID + * @returns void + */ +export function deptNodeList(deptId: ID) { + return requestClient.get(`${Api.deptNodeInfo}/${deptId}`); +} + +export function deptInfo(deptId: ID) { + return requestClient.get(`${Api.root}/${deptId}`); +} + +export function deptAdd(data: any) { + return requestClient.postWithMsg(Api.root, data); +} + +export function deptUpdate(data: any) { + return requestClient.putWithMsg(Api.root, data); +} + +/** + * 注意这里只允许单删除 + * @param deptId ID + * @returns void + */ +export function deptRemove(deptId: ID) { + return requestClient.deleteWithMsg(`${Api.root}/${deptId}`); +} diff --git a/apps/web-antd/src/api/system/dept/model.d.ts b/apps/web-antd/src/api/system/dept/model.d.ts new file mode 100644 index 00000000..1aaaf244 --- /dev/null +++ b/apps/web-antd/src/api/system/dept/model.d.ts @@ -0,0 +1,19 @@ +export interface Dept { + createBy: string; + createTime: string; + updateBy?: string; + updateTime?: string; + remark?: string; + deptId: number; + parentId: number; + ancestors: string; + deptName: string; + orderNum: number; + leader: string; + phone: string; + email: string; + status: string; + delFlag: string; + parentName?: string; + children?: Dept[]; +} diff --git a/apps/web-antd/src/views/system/dept/data.ts b/apps/web-antd/src/views/system/dept/data.ts new file mode 100644 index 00000000..68a29ddc --- /dev/null +++ b/apps/web-antd/src/views/system/dept/data.ts @@ -0,0 +1,99 @@ +import { DictEnum } from '@vben/constants'; +import { getPopupContainer } from '@vben/utils'; + +import { type FormSchemaGetter, z } from '#/adapter'; +import { getDictOptions } from '#/utils/dict'; + +export const drawerSchema: FormSchemaGetter = () => [ + { + component: 'Input', + dependencies: { + show: () => false, + triggerFields: [''], + }, + fieldName: 'deptId', + }, + { + component: 'TreeSelect', + componentProps: { + getPopupContainer, + placeholder: '请选择', + }, + dependencies: { + show: (model) => model.parentId !== 0, + triggerFields: ['parentId'], + }, + fieldName: 'parentId', + label: '上级部门', + rules: 'selectRequired', + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'deptName', + label: '部门名称', + rules: 'required', + }, + { + component: 'InputNumber', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'orderNum', + label: '显示排序', + rules: 'required', + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'deptCategory', + label: '类别编码', + }, + { + component: 'Select', + componentProps: { + // 选中了就只能修改 不能重置为无负责人 + allowClear: false, + getPopupContainer, + placeholder: '请选择', + }, + fieldName: 'leader', + label: '负责人', + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'phone', + label: '联系电话', + rules: z + .string() + .regex(/^\d{1,3}-\d{8,11}$/, { message: '请输入正确的手机号' }) + .optional(), + }, + { + component: 'Input', + componentProps: { + placeholder: '请输入', + }, + fieldName: 'email', + label: '邮箱', + rules: z.string().email({ message: '请输入正确的邮箱' }).optional(), + }, + { + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE), + optionType: 'button', + }, + defaultValue: '0', + fieldName: 'status', + label: '状态', + }, +]; diff --git a/apps/web-antd/src/views/system/dept/dept-drawer.vue b/apps/web-antd/src/views/system/dept/dept-drawer.vue new file mode 100644 index 00000000..27890733 --- /dev/null +++ b/apps/web-antd/src/views/system/dept/dept-drawer.vue @@ -0,0 +1,166 @@ + + + diff --git a/apps/web-antd/src/views/system/dept/index.vue b/apps/web-antd/src/views/system/dept/index.vue index 06372a15..a3e90277 100644 --- a/apps/web-antd/src/views/system/dept/index.vue +++ b/apps/web-antd/src/views/system/dept/index.vue @@ -1,9 +1,35 @@