6 changed files with 55 additions and 53 deletions
@ -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 { defHttp } from '/@/utils/http/axios'; |
||||||
import {isDef} from '/@/utils/is'; |
|
||||||
import {listToTree} from '/@/utils/helper/treeHelper'; |
|
||||||
|
|
||||||
const prefix = '/system_proxy/system'; |
|
||||||
|
|
||||||
enum Api { |
enum Api { |
||||||
QueryById = '/address/query', |
get = '/system_proxy/system/address', |
||||||
List = '/address/list', |
QueryById = '/system_proxy/system/address/query', |
||||||
QueryByParentIds = '/address/queryByParentIds', |
list = '/system_proxy/system/address/list', |
||||||
Add = '/address/add', |
QueryByParentIds = '/system_proxy/system/address/queryByParentIds', |
||||||
Update = '/address/update', |
add = '/system_proxy/system/address/add', |
||||||
Remove = '/address/remove' |
edit = '/system_proxy/system/address/update', |
||||||
|
del = '/system_proxy/system/address/remove' |
||||||
} |
} |
||||||
|
|
||||||
export const queryById = (params: { id: String }) => |
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) => { |
export const treeList = (params: AddressParams) => defHttp.get({url: Api.list, params}); |
||||||
return defHttp.get({url: prefix + Api.List, params}).then(data =>{ |
|
||||||
return listToTree(data, { |
|
||||||
id: 'code', |
|
||||||
parentId: 'parentId' |
|
||||||
}); |
|
||||||
}); |
|
||||||
}; |
|
||||||
|
|
||||||
export const list = (params: AddressParams) => |
export const listAddr = (params?: Partial<AddressParams>) => |
||||||
defHttp.get({url: prefix + Api.List, params}); |
defHttp.get({url: Api.list, params}); |
||||||
|
|
||||||
|
|
||||||
export const queryByParentIds = (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)){ |
export const addAddr = (params: Partial<AddressItem>) => |
||||||
defHttp.put<AddressItem>({url: prefix + Api.Update, params}); |
defHttp.post({url:Api.add, data: params}); |
||||||
}else { |
|
||||||
defHttp.post<AddressItem>({url: prefix + Api.Add, 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 @@ |
|||||||
// 引入基础包
|
// 引入基础包
|
||||||
import type { R } from '/#/axios'; |
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 = { |
export type AddressParams =AddressItem & Page; |
||||||
parentId?: string; |
|
||||||
code?: string; |
|
||||||
level?:string; |
|
||||||
name?: string; |
|
||||||
beginTime?: string; |
|
||||||
endTime?: string; |
|
||||||
} & 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; |
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