优化:优化后端 CRUD 公共组件(移除 BaseService 中无用的默认实现,抽取 BaseRequest 基类来方便使用分组校验),并同步调整部门管理 API

This commit is contained in:
2023-01-30 22:35:17 +08:00
parent 2c6bef91e8
commit 83b01c2e4f
18 changed files with 144 additions and 111 deletions

View File

@@ -27,21 +27,22 @@ export function getDeptList(params: DeptParams) {
});
}
export interface CreateDeptReq {
export interface DeptReq {
parentId: number;
deptName: string;
deptSort: number;
description: string;
}
export function createDept(req: CreateDeptReq) {
export function createDept(req: DeptReq) {
return axios.post('/system/dept', req);
}
export interface UpdateDeptStatusReq {
status: number;
export interface UpdateDeptReq extends Partial<DeptReq> {
deptId: number;
status?: number;
}
export function updateDeptStatus(ids: Array<number>, req: UpdateDeptStatusReq) {
return axios.patch(`/system/dept/${ids}`, req);
export function updateDept(req: UpdateDeptReq) {
return axios.put(`/system/dept`, req);
}
export function deleteDept(ids: Array<number>) {

View File

@@ -281,7 +281,7 @@
DeptRecord,
DeptParams,
createDept,
updateDeptStatus,
updateDept,
deleteDept,
} from '@/api/system/dept';
import getDeptTree from '@/api/common';
@@ -405,7 +405,7 @@
// 改变状态
const handleChangeStatus = async (record: DeptRecord, val: number) => {
if (record.deptId) {
const res = await updateDeptStatus([record.deptId], { status: val });
const res = await updateDept({ deptId: record.deptId, status: val });
if (res.success) {
Message.success(res.msg);
} else {