16 changed files with 388 additions and 439 deletions
@ -1,58 +1,31 @@ |
|||||||
import { DepartVO, DeptDto, Depart, DeptListItem, DeptListGetResultModel } from './model/deptModel'; |
/** |
||||||
import { defHttp } from '/@/utils/http/axios'; |
* 提供api模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
import {listToTree} from "/@/utils/helper/treeHelper"; |
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
import {isDef} from "/@/utils/is"; |
* author entfrm开发团队-王翔 |
||||||
|
*/ |
||||||
|
|
||||||
const prefix = '/system_proxy/system'; |
import { DeptDto, Dept } from './model/deptModel'; |
||||||
|
import { defHttp } from '/@/utils/http/axios'; |
||||||
|
|
||||||
enum Api { |
enum Api { |
||||||
List = '/dept/list', |
list = '/system_proxy/system/dept/list', |
||||||
Save = '/dept/save', |
add = '/system_proxy/system/dept/save', |
||||||
Update = '/dept/update', |
get = '/system_proxy/system/dept', |
||||||
Remove = '/dept/remove', |
edit = '/system_proxy/system/dept/update', |
||||||
DeptList = '/dept/deptTree', |
del = '/system_proxy/system/dept/remove', |
||||||
} |
} |
||||||
|
|
||||||
//获取部门根据id
|
// 查询部门列表
|
||||||
export const getDeptById = (params: {id: string}) => |
export const listDept = (params?: Partial<DeptDto>) => defHttp.get({ url: Api.list, params }); |
||||||
defHttp.get({url: prefix + `/dept/${params.id}` }) |
|
||||||
|
|
||||||
//部门列表
|
// 新增部门
|
||||||
export const deptList = (params?: Partial<DeptDto>) => defHttp.get({ url: prefix + Api.List, params }); |
export const addDept = (params: Partial<Dept>) => defHttp.post({ url: Api.add, data: params }); |
||||||
|
|
||||||
// 部门树
|
|
||||||
export const departTreeList = (params?: DepartVO) => { |
|
||||||
return defHttp.get({ url: prefix + Api.List, params }).then(data => { |
|
||||||
return listToTree(data, { |
|
||||||
id: 'deptId', |
|
||||||
children: 'children', |
|
||||||
parentId: 'parentId', |
|
||||||
}) as any[]; |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
export const departTreeHasTop = (params?: DepartVO) => { |
// 修改部门
|
||||||
return defHttp.get({ url: prefix + Api.List, params }).then(data => { |
export const editDept = (params: Partial<Dept>) => defHttp.put({ url: Api.edit, data: params }); |
||||||
data.unshift({ deptId: '0', sort: 0, name: '顶级部门', children: [] }); |
|
||||||
return listToTree(data, { |
|
||||||
id: 'deptId', |
|
||||||
children: 'children', |
|
||||||
parentId: 'parentId', |
|
||||||
}) as any[]; |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
export const departSet = (params: Depart) => { |
|
||||||
if (isDef(params.id)){ |
|
||||||
return defHttp.put({ url: prefix + Api.Update, params }); |
|
||||||
}else { |
|
||||||
return defHttp.post({ url: prefix + Api.Save, params }); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// 删除
|
// 查询部门详细
|
||||||
export const departRemove = (params: { id: String }) => |
export const getDept = (id: string) => defHttp.get<Dept>({ url: `${Api.get}/${id}` }); |
||||||
defHttp.delete<boolean>({ url: prefix + Api.Remove + `/${params.id}` }); |
|
||||||
|
|
||||||
export const getDeptList = (params?: DeptListItem) => |
// 删除部门
|
||||||
defHttp.get<DeptListGetResultModel>({ url: prefix + Api.DeptList, params }); |
export const delDept = (id: string) => defHttp.delete({ url: `${Api.del}/${id}` }); |
||||||
|
Loading…
Reference in new issue