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