6 changed files with 55 additions and 53 deletions
@ -1,46 +1,44 @@
@@ -1,46 +1,44 @@
|
||||
import {AddressParams,AddressItem,AddressItemListResult} from '/@/api/platform/system/entity/addressModel'; |
||||
/** |
||||
* 提供api模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||
* author entfrm开发团队-王翔 |
||||
*/ |
||||
import {AddressParams,AddressItem} from '/@/api/platform/system/entity/addressModel'; |
||||
import { defHttp } from '/@/utils/http/axios'; |
||||
import {isDef} from '/@/utils/is'; |
||||
import {listToTree} from '/@/utils/helper/treeHelper'; |
||||
|
||||
const prefix = '/system_proxy/system'; |
||||
|
||||
enum Api { |
||||
QueryById = '/address/query', |
||||
List = '/address/list', |
||||
QueryByParentIds = '/address/queryByParentIds', |
||||
Add = '/address/add', |
||||
Update = '/address/update', |
||||
Remove = '/address/remove' |
||||
get = '/system_proxy/system/address', |
||||
QueryById = '/system_proxy/system/address/query', |
||||
list = '/system_proxy/system/address/list', |
||||
QueryByParentIds = '/system_proxy/system/address/queryByParentIds', |
||||
add = '/system_proxy/system/address/add', |
||||
edit = '/system_proxy/system/address/update', |
||||
del = '/system_proxy/system/address/remove' |
||||
} |
||||
|
||||
export const queryById = (params: { id: String }) => |
||||
defHttp.get<AddressItem>({url: prefix + Api.QueryById + `/${params.id}`}); |
||||
defHttp.get<AddressItem>({url: Api.QueryById + `/${params.id}`}); |
||||
|
||||
export const treeList = (params: AddressParams) => { |
||||
return defHttp.get({url: prefix + Api.List, params}).then(data =>{ |
||||
return listToTree(data, { |
||||
id: 'code', |
||||
parentId: 'parentId' |
||||
}); |
||||
}); |
||||
}; |
||||
export const treeList = (params: AddressParams) => defHttp.get({url: Api.list, params}); |
||||
|
||||
export const list = (params: AddressParams) => |
||||
defHttp.get({url: prefix + Api.List, params}); |
||||
export const listAddr = (params?: Partial<AddressParams>) => |
||||
defHttp.get({url: Api.list, params}); |
||||
|
||||
|
||||
export const queryByParentIds = (params) => |
||||
defHttp.get({url: prefix + Api.QueryByParentIds + `/${params}`}); |
||||
defHttp.get({url: Api.QueryByParentIds + `/${params}`}); |
||||
|
||||
|
||||
|
||||
export const set = (params: AddressItem) => { |
||||
if (isDef(params.code)){ |
||||
defHttp.put<AddressItem>({url: prefix + Api.Update, params}); |
||||
}else { |
||||
defHttp.post<AddressItem>({url: prefix + Api.Add, params}); |
||||
} |
||||
}; |
||||
/**新增地址 */ |
||||
export const addAddr = (params: Partial<AddressItem>) => |
||||
defHttp.post({url:Api.add, data: params}); |
||||
|
||||
export const remove = (params: {ids: String}) => |
||||
defHttp.delete<boolean>({url: prefix + Api.Remove + `/${params.ids}`}); |
||||
/**修改地址 */ |
||||
export const editAddr=(params: Partial<AddressItem>)=> |
||||
defHttp.put({url: Api.edit,data:params}); |
||||
/**查询详细 */ |
||||
export const getAddr = (id: string) =>defHttp.get<AddressItem>({url:`${Api.get}/${id}`}); |
||||
/**删除 */ |
||||
export const delAddr =(id: string)=> |
||||
defHttp.delete({url:`${Api.del}/${id}`}); |
@ -1,26 +1,26 @@
@@ -1,26 +1,26 @@
|
||||
// 引入基础包
|
||||
import type { R } from '/#/axios'; |
||||
import type { TreeEntity,Page } from '/@/api/common/data/entity'; |
||||
import type { CommonEntity,Page } from '/@/api/common/data/entity'; |
||||
|
||||
export type AddressParams = { |
||||
parentId?: string; |
||||
code?: string; |
||||
level?:string; |
||||
name?: string; |
||||
beginTime?: string; |
||||
endTime?: string; |
||||
} & Page; |
||||
export type AddressParams =AddressItem & Page; |
||||
|
||||
|
||||
export interface AddressItem extends TreeEntity{ |
||||
|
||||
export interface AddressItem extends CommonEntity{ |
||||
id: string; |
||||
parentId: string; |
||||
//level?:string;
|
||||
sort: number; |
||||
name: string; |
||||
// beginTime?: string;
|
||||
// endTime?: string;
|
||||
code: string; |
||||
|
||||
level: number; |
||||
// level: number;
|
||||
|
||||
lastLevel: boolean; |
||||
// lastLevel: boolean;
|
||||
[key: string]: any |
||||
|
||||
|
||||
} |
||||
|
||||
export type AddressItemListResult = R<AddressItem>; |
||||
export type AddressItemListResult = R<AddressItem[]>; |
Loading…
Reference in new issue