From b9b7978412e3e1e0df18de9dc9273d150606f98d Mon Sep 17 00:00:00 2001 From: jameszow Date: Fri, 29 Sep 2023 19:52:29 +0800 Subject: [PATCH 1/3] Add Dept add update delete api --- src/api/sys/dept.ts | 31 ++++++++++++++++++++++++++----- src/api/sys/model/dpetModel.ts | 14 +++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/api/sys/dept.ts b/src/api/sys/dept.ts index 758dc73..44b1c62 100644 --- a/src/api/sys/dept.ts +++ b/src/api/sys/dept.ts @@ -1,21 +1,42 @@ import { + addOrUpdateDeptReq, DeptListItem, GetDeptInfoModel, } from './model/dpetModel'; import { defHttp } from '/@/utils/http/axios'; -import {BaseDataResp} from "@/api/model/baseModel"; +import {BaseDataResp, BaseResp} from "@/api/model/baseModel"; +import {ErrorMessageMode} from "#/axios"; enum Api { DeptList = '/dept/list', UserBindDept = '/dept/userBindDept', + AddOrUpdateDept = '/dept/addOrUpdate', + DeleteDept = '/dept/delete', } - - export function getDeptList(params?: DeptListItem) { return defHttp.get>({url: Api.DeptList, params}) } - -export function getUserBindDept(params?: DeptListItem) { +export function getUserBindDept() { return defHttp.get>({url: Api.UserBindDept}) +} + +export function addOrUpdateDept(params: addOrUpdateDeptReq, mode: ErrorMessageMode = 'notice') { + return defHttp.post({ + url: Api.AddOrUpdateDept, params}, + { + errorMessageMode: mode, + successMessageMode: mode, + } + ) +} + +export function deleteDept(id: number | string, mode: ErrorMessageMode = 'notice') { + return defHttp.post({ + url: `${Api.DeleteDept}?id=${id}`}, + { + errorMessageMode: mode, + successMessageMode: mode, + } + ) } \ No newline at end of file diff --git a/src/api/sys/model/dpetModel.ts b/src/api/sys/model/dpetModel.ts index a244b88..88d92ab 100644 --- a/src/api/sys/model/dpetModel.ts +++ b/src/api/sys/model/dpetModel.ts @@ -17,7 +17,15 @@ export interface GetDeptInfoModel { parentId: string; // 排序 sort: number; - } - +} -export type DeptListGetResultModel = BasicFetchResult; +export interface addOrUpdateDeptReq { + id: number | string; + deptName: string; + parentId: number; + deptNumber: string; + leader: string; + status: number; + remark: string; + sort: string; +} From fb557fd20472bbedafe130be4fd05cfa150b286f Mon Sep 17 00:00:00 2001 From: jameszow Date: Fri, 29 Sep 2023 19:52:38 +0800 Subject: [PATCH 2/3] remove not use getUserBindDept --- src/views/sys/user/account.data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/sys/user/account.data.ts b/src/views/sys/user/account.data.ts index eea53a8..f057818 100644 --- a/src/views/sys/user/account.data.ts +++ b/src/views/sys/user/account.data.ts @@ -4,7 +4,7 @@ import { h } from 'vue'; import { Switch } from 'ant-design-vue'; import { useMessage } from '/@/hooks/web/useMessage'; import { updateStatus } from "@/api/sys/user"; -import {getDeptList, getUserBindDept} from "@/api/sys/dept"; +import {getDeptList} from "@/api/sys/dept"; import { getRoleList } from "@/api/sys/role"; const { t } = useI18n(); From 38f2ae1e0c7d5f9fe685529b1d7542d1aff9e0fa Mon Sep 17 00:00:00 2001 From: jameszow Date: Fri, 29 Sep 2023 19:52:53 +0800 Subject: [PATCH 3/3] Add Dept add update views --- src/views/sys/department/DeptModal.vue | 74 +++++++++++++++++++++++++- src/views/sys/department/dept.data.ts | 70 +++++++++++++++++++++++- src/views/sys/department/index.vue | 8 ++- 3 files changed, 148 insertions(+), 4 deletions(-) diff --git a/src/views/sys/department/DeptModal.vue b/src/views/sys/department/DeptModal.vue index f373bfe..145417f 100644 --- a/src/views/sys/department/DeptModal.vue +++ b/src/views/sys/department/DeptModal.vue @@ -1,8 +1,80 @@