refactor: API类型声明优化调整
Former-commit-id: 0ae696c2e872fa90feba0c5df9a92391c02d3e0b
This commit is contained in:
77
src/api/dept/index.ts
Normal file
77
src/api/dept/index.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { DeptForm, DeptQuery, Dept } from './types';
|
||||
|
||||
/**
|
||||
* 部门树形表格
|
||||
*
|
||||
* @param queryParams
|
||||
*/
|
||||
export function listDepartments(queryParams?: DeptQuery): AxiosPromise<Dept[]> {
|
||||
return request({
|
||||
url: '/api/v1/dept',
|
||||
method: 'get',
|
||||
params: queryParams
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门下拉列表
|
||||
*/
|
||||
export function listDeptOptions(): AxiosPromise<OptionType[]> {
|
||||
return request({
|
||||
url: '/api/v1/dept/options',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门详情
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
export function getDeptForm(id: string): AxiosPromise<DeptForm> {
|
||||
return request({
|
||||
url: '/api/v1/dept/' + id + '/form',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
export function addDept(data: DeptForm) {
|
||||
return request({
|
||||
url: '/api/v1/dept',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*
|
||||
* @param id
|
||||
* @param data
|
||||
*/
|
||||
export function updateDept(id: string, data: DeptForm) {
|
||||
return request({
|
||||
url: '/api/v1/dept/' + id,
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
export function deleteDept(ids: string) {
|
||||
return request({
|
||||
url: '/api/v1/dept/' + ids,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
34
src/api/dept/types.ts
Normal file
34
src/api/dept/types.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 部门查询参数
|
||||
*/
|
||||
export interface DeptQuery {
|
||||
keywords: string | undefined;
|
||||
status: number | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门类型
|
||||
*/
|
||||
export interface Dept {
|
||||
id: string;
|
||||
name: string;
|
||||
parentId: string;
|
||||
treePath: string;
|
||||
sort: number;
|
||||
status: number;
|
||||
leader?: string;
|
||||
mobile?: string;
|
||||
email?: string;
|
||||
children: Dept[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门表单类型
|
||||
*/
|
||||
export interface DeptForm {
|
||||
id?: string;
|
||||
parentId: string;
|
||||
name: string;
|
||||
sort: number;
|
||||
status: number;
|
||||
}
|
||||
Reference in New Issue
Block a user