106 lines
2.5 KiB
TypeScript
106 lines
2.5 KiB
TypeScript
import request from '@/utils/http'
|
|
|
|
export interface SupplierInfoQuery {
|
|
pageNum?: number
|
|
pageSize?: number
|
|
supplierName?: string
|
|
status?: string
|
|
}
|
|
|
|
export interface SupplierInfoForm {
|
|
id?: string
|
|
supplierName: string
|
|
supplierAddress?: string
|
|
legalPerson?: string
|
|
agent?: string
|
|
phoneFax?: string
|
|
bankName?: string
|
|
bankAccount?: string
|
|
allowToxic?: number
|
|
allowExplosive?: number
|
|
status?: string
|
|
remark?: string
|
|
}
|
|
|
|
export interface SupplierInfoVO {
|
|
id: string | number
|
|
supplierName: string
|
|
shortName?: string
|
|
supplierCode?: string
|
|
supplierAddress?: string
|
|
legalPerson?: string
|
|
agent?: string
|
|
phoneFax?: string
|
|
bankName?: string
|
|
bankAccount?: string
|
|
allowToxic?: number
|
|
allowExplosive?: number
|
|
status?: string
|
|
remark?: string
|
|
createTime?: string
|
|
updateTime?: string
|
|
}
|
|
|
|
const BASE = '/web/crm/supplierInfo'
|
|
|
|
function unwrapData(res: any) {
|
|
return res?.data ?? res ?? {}
|
|
}
|
|
|
|
export async function listSupplierInfo(query: SupplierInfoQuery = {}) {
|
|
const res = await request.post({
|
|
url: `${BASE}/list`,
|
|
data: {
|
|
page: query.pageNum ?? 1,
|
|
pageSize: query.pageSize ?? 20,
|
|
supplierName: query.supplierName,
|
|
status: query.status
|
|
}
|
|
})
|
|
const data = unwrapData(res)
|
|
return { rows: data.list || data.rows || [], total: data.total ?? 0 }
|
|
}
|
|
|
|
export async function listAllSupplierInfo(query?: SupplierInfoQuery) {
|
|
const res = await request.post({
|
|
url: `${BASE}/listAll`,
|
|
data: {
|
|
supplierName: query?.supplierName,
|
|
status: query?.status
|
|
}
|
|
})
|
|
const data = unwrapData(res)
|
|
return { data: data.list || data.rows || data || [] }
|
|
}
|
|
|
|
export async function getSupplierInfo(id: number | string) {
|
|
const res = await request.post({ url: `${BASE}/detail`, data: { id: String(id) } })
|
|
return { data: unwrapData(res) }
|
|
}
|
|
|
|
export function addSupplierInfo(data: SupplierInfoForm) {
|
|
return request.post({ url: `${BASE}/add`, data })
|
|
}
|
|
|
|
export function updateSupplierInfo(data: SupplierInfoForm) {
|
|
return request.post({ url: `${BASE}/update`, data })
|
|
}
|
|
|
|
export function delSupplierInfo(ids: number | number[] | string | string[]) {
|
|
const idList = Array.isArray(ids) ? ids.map(String) : [String(ids)]
|
|
return request.post({ url: `${BASE}/delete`, data: { ids: idList } })
|
|
}
|
|
|
|
export async function exportSupplierInfo(query: SupplierInfoQuery) {
|
|
return request.post({
|
|
url: `${BASE}/export`,
|
|
data: {
|
|
page: query.pageNum ?? 1,
|
|
pageSize: query.pageSize ?? 20,
|
|
supplierName: query.supplierName,
|
|
status: query.status
|
|
},
|
|
responseType: 'blob'
|
|
})
|
|
}
|