From 5ae73339c02fee4823b91fa625736f1f665c752d Mon Sep 17 00:00:00 2001 From: valarchie <343928303@qq.com> Date: Thu, 20 Jul 2023 22:52:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/dept.ts | 82 +++++++ src/views/system/dept/form.vue | 134 +++++++++++ src/views/system/dept/index.vue | 138 ++++------- src/views/system/dept/utils/hook.tsx | 328 +++++++++++++-------------- src/views/system/dept/utils/rule.ts | 37 +++ types/index.d.ts | 5 +- 6 files changed, 462 insertions(+), 262 deletions(-) create mode 100644 src/api/system/dept.ts create mode 100644 src/views/system/dept/form.vue create mode 100644 src/views/system/dept/utils/rule.ts diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts new file mode 100644 index 0000000..e16524d --- /dev/null +++ b/src/api/system/dept.ts @@ -0,0 +1,82 @@ +import { http } from "@/utils/http"; + +export interface DeptQuery extends BaseQuery { + deptId?: number; + parentId?: number; +} + +/** + * DeptDTO + */ +export interface DeptDTO { + createTime?: Date; + id?: number; + deptName?: string; + email?: string; + leaderName?: string; + orderNum?: number; + parentId?: number; + phone?: string; + status?: number; + statusStr?: string; +} + +/** + * AddDeptCommand + */ +export interface DeptRequest { + deptName: string; + email?: string; + leaderName?: string; + orderNum: number; + parentId: number; + phone?: string; + status: number; +} + +export interface DeptTreeDTO { + id: number; + parentId: number; + label: string; + children: [DeptTreeDTO]; +} + +/** 获取部门列表 */ +export const getDeptListApi = (params?: DeptQuery) => { + return http.request>>("get", "/system/depts", { + params + }); +}; + +/** 新增部门 */ +export const addDeptApi = (data: DeptRequest) => { + console.log(data); + return http.request>("post", "/system/dept", { + data + }); +}; + +/** 部门详情 */ +export const getDeptInfoApi = (deptId: string) => { + return http.request>("get", `/system/dept/${deptId}`); +}; + +/** 修改部门 */ +export const updateDeptApi = (deptId: string, data: DeptRequest) => { + return http.request>("put", `/system/dept/${deptId}`, { + data + }); +}; + +/** 删除部门 */ +export const deleteDeptApi = (deptId: string) => { + return http.request>("delete", `/system/dept/${deptId}`); +}; + +/** 获取部门树级结构 */ +export const getDeptTree = () => { + return http.request>( + "get", + "/system/depts/dropdown" + ); +}; diff --git a/src/views/system/dept/form.vue b/src/views/system/dept/form.vue new file mode 100644 index 0000000..5cc322c --- /dev/null +++ b/src/views/system/dept/form.vue @@ -0,0 +1,134 @@ + + + diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index ab32c30..3139475 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -1,71 +1,49 @@