138 lines
3.1 KiB
TypeScript
138 lines
3.1 KiB
TypeScript
import db from '@/utils/http/db'
|
|
import type { Plan } from './plansApi'
|
|
import type { InventoryRecord } from './inventoryApi'
|
|
|
|
// ==================== 地磅单管理 API ====================
|
|
|
|
export interface WeighingRecord {
|
|
id: string
|
|
vehicleNo: string
|
|
planNo?: string
|
|
productId?: string
|
|
cargoName: string
|
|
specification?: string
|
|
businessType: '入库' | '出库'
|
|
batchNo?: string
|
|
supplier: string
|
|
consignee: string
|
|
grossWeight: number
|
|
grossWeightTime: string
|
|
tareWeight: number
|
|
tareWeightTime: string
|
|
deduction?: number
|
|
netWeight: number
|
|
plannedQuantity?: number
|
|
executedQuantity?: number
|
|
purchasePlanId?: string
|
|
inboundOutboundId?: string
|
|
weighingPoint?: string
|
|
remarks?: string
|
|
currentQuantity?: number
|
|
isVoided: number
|
|
createdAt: string
|
|
createBy?: string
|
|
createByName?: string
|
|
inventoryDate?: string
|
|
}
|
|
|
|
export interface WeighingCreate {
|
|
vehicleNo: string
|
|
planNo?: string
|
|
productId: string
|
|
businessType: '入库' | '出库'
|
|
batchNo?: string
|
|
supplier: string
|
|
consignee: string
|
|
grossWeight: number
|
|
grossWeightTime: string
|
|
tareWeight: number
|
|
tareWeightTime: string
|
|
deduction?: number
|
|
netWeight: number
|
|
plannedQuantity?: number
|
|
executedQuantity?: number
|
|
purchasePlanId?: string
|
|
inboundOutboundId?: string
|
|
weighingPoint?: string
|
|
remarks?: string
|
|
currentQuantity?: number
|
|
}
|
|
|
|
export interface WeighingUpdate {
|
|
vehicleNo?: string
|
|
planNo?: string
|
|
productId?: string
|
|
cargoName?: string
|
|
specification?: string
|
|
businessType?: '入库' | '出库'
|
|
batchNo?: string
|
|
supplier?: string
|
|
consignee?: string
|
|
grossWeight?: number
|
|
grossWeightTime?: string
|
|
tareWeight?: number
|
|
tareWeightTime?: string
|
|
deduction?: number
|
|
netWeight?: number
|
|
plannedQuantity?: number
|
|
executedQuantity?: number
|
|
purchasePlanId?: string
|
|
inboundOutboundId?: string
|
|
weighingPoint?: string
|
|
remarks?: string
|
|
currentQuantity?: number
|
|
isVoided?: number
|
|
}
|
|
|
|
export interface WeighingRelatedData {
|
|
plan: Plan | null
|
|
inventory: InventoryRecord | null
|
|
}
|
|
|
|
export const weighingApi = {
|
|
list: async (params?: {
|
|
dateFrom?: string
|
|
dateTo?: string
|
|
vehicleNo?: string
|
|
cargoName?: string
|
|
businessType?: '入库' | '出库'
|
|
}): Promise<WeighingRecord[]> => {
|
|
return db.get<WeighingRecord[]>({
|
|
url: '/weighing',
|
|
params
|
|
})
|
|
},
|
|
get: async (id: string): Promise<WeighingRecord> => {
|
|
return db.get<WeighingRecord>({
|
|
url: `/weighing/${id}`
|
|
})
|
|
},
|
|
getRelated: async (id: string): Promise<WeighingRelatedData> => {
|
|
return db.get<WeighingRelatedData>({
|
|
url: `/weighing/${id}/related`
|
|
})
|
|
},
|
|
create: async (payload: WeighingCreate): Promise<WeighingRecord> => {
|
|
return db.post<WeighingRecord>({
|
|
url: '/weighing',
|
|
data: payload
|
|
})
|
|
},
|
|
update: async (id: string, payload: WeighingUpdate): Promise<WeighingRecord> => {
|
|
return db.patch<WeighingRecord>({
|
|
url: `/weighing/${id}`,
|
|
data: payload
|
|
})
|
|
},
|
|
void: async (id: string): Promise<void> => {
|
|
return db.post({
|
|
url: `/weighing/${id}/void`
|
|
})
|
|
},
|
|
delete: async (id: string): Promise<void> => {
|
|
return db.del({
|
|
url: `/weighing/${id}`
|
|
})
|
|
}
|
|
}
|