|
|
@@ -1,59 +1,63 @@
|
|
|
-import api from '@/utils/http'
|
|
|
+import db from '@/utils/http/db'
|
|
|
import type { Plan } from './plansApi'
|
|
|
import type { WeighingRecord } from './weighingApi'
|
|
|
|
|
|
// ==================== 出入库管理 API ====================
|
|
|
|
|
|
export interface InventoryRecord {
|
|
|
- id: number
|
|
|
+ id: string
|
|
|
date: string
|
|
|
partnerCompany: string
|
|
|
businessType: '入库' | '出库'
|
|
|
+ productId?: string
|
|
|
product: string
|
|
|
+ specification?: string
|
|
|
quantity: number
|
|
|
planNo?: string
|
|
|
batchNo?: string
|
|
|
vehicleNo: string
|
|
|
status?: string
|
|
|
remarks?: string
|
|
|
- purchasePlanId?: number
|
|
|
+ purchasePlanId?: string
|
|
|
isDeleted: number
|
|
|
createdAt: string
|
|
|
- grossWeight?: number // 毛重(kg)- 汇总自关联地磅单
|
|
|
- tareWeight?: number // 皮重(kg)- 汇总自关联地磅单
|
|
|
- deduction?: number // 扣杂(kg)- 汇总自关联地磅单
|
|
|
- netWeight?: number // 净重(kg)- 汇总自关联地磅单
|
|
|
- grossWeightTime?: string // 毛重时间 - 来自关联地磅单
|
|
|
- tareWeightTime?: string // 皮重时间 - 来自关联地磅单
|
|
|
- hasWeighingSlip?: boolean // 是否已有关联的地磅单
|
|
|
+ grossWeight?: number
|
|
|
+ tareWeight?: number
|
|
|
+ deduction?: number
|
|
|
+ netWeight?: number
|
|
|
+ grossWeightTime?: string
|
|
|
+ tareWeightTime?: string
|
|
|
+ hasWeighingSlip?: boolean
|
|
|
}
|
|
|
|
|
|
export interface InventoryCreate {
|
|
|
date: string
|
|
|
partnerCompany: string
|
|
|
businessType: '入库' | '出库'
|
|
|
- product: string
|
|
|
+ productId: string
|
|
|
quantity: number
|
|
|
planNo?: string
|
|
|
batchNo?: string
|
|
|
vehicleNo: string
|
|
|
status?: string
|
|
|
remarks?: string
|
|
|
- purchasePlanId?: number
|
|
|
+ purchasePlanId?: string
|
|
|
}
|
|
|
|
|
|
export interface InventoryUpdate {
|
|
|
date?: string
|
|
|
partnerCompany?: string
|
|
|
businessType?: '入库' | '出库'
|
|
|
+ productId?: string
|
|
|
product?: string
|
|
|
+ specification?: string
|
|
|
quantity?: number
|
|
|
planNo?: string
|
|
|
batchNo?: string
|
|
|
vehicleNo?: string
|
|
|
status?: string
|
|
|
remarks?: string | null
|
|
|
- purchasePlanId?: number
|
|
|
+ purchasePlanId?: string
|
|
|
}
|
|
|
|
|
|
export interface InventoryRelatedData {
|
|
|
@@ -69,44 +73,43 @@ export const inventoryApi = {
|
|
|
status?: string
|
|
|
businessType?: '入库' | '出库'
|
|
|
}): Promise<InventoryRecord[]> => {
|
|
|
- return api.get<InventoryRecord[]>({
|
|
|
+ return db.get<InventoryRecord[]>({
|
|
|
url: '/inventory',
|
|
|
params,
|
|
|
- timeout: 60000 // 列表可能数据较多,60 秒超时避免被取消
|
|
|
+ timeout: 60000
|
|
|
})
|
|
|
},
|
|
|
- get: async (id: number): Promise<InventoryRecord> => {
|
|
|
- return api.get<InventoryRecord>({
|
|
|
+ get: async (id: string): Promise<InventoryRecord> => {
|
|
|
+ return db.get<InventoryRecord>({
|
|
|
url: `/inventory/${id}`
|
|
|
})
|
|
|
},
|
|
|
- getRelated: async (id: number): Promise<InventoryRelatedData> => {
|
|
|
- return api.get<InventoryRelatedData>({
|
|
|
+ getRelated: async (id: string): Promise<InventoryRelatedData> => {
|
|
|
+ return db.get<InventoryRelatedData>({
|
|
|
url: `/inventory/${id}/related`
|
|
|
})
|
|
|
},
|
|
|
create: async (payload: InventoryCreate): Promise<InventoryRecord> => {
|
|
|
- return api.post<InventoryRecord>({
|
|
|
+ return db.post<InventoryRecord>({
|
|
|
url: '/inventory',
|
|
|
data: payload
|
|
|
})
|
|
|
},
|
|
|
- update: async (id: number, payload: InventoryUpdate): Promise<InventoryRecord> => {
|
|
|
- return api.patch<InventoryRecord>({
|
|
|
+ update: async (id: string, payload: InventoryUpdate): Promise<InventoryRecord> => {
|
|
|
+ return db.patch<InventoryRecord>({
|
|
|
url: `/inventory/${id}`,
|
|
|
data: payload
|
|
|
})
|
|
|
},
|
|
|
- delete: async (id: number): Promise<void> => {
|
|
|
- return api.del({
|
|
|
+ delete: async (id: string): Promise<void> => {
|
|
|
+ return db.del({
|
|
|
url: `/inventory/${id}`
|
|
|
})
|
|
|
},
|
|
|
- createLinkForPlan: async (purchasePlanId: number, remarks?: string): Promise<InventoryRecord> => {
|
|
|
- return api.post<InventoryRecord>({
|
|
|
+ createLinkForPlan: async (purchasePlanId: string, remarks?: string): Promise<InventoryRecord> => {
|
|
|
+ return db.post<InventoryRecord>({
|
|
|
url: '/inventory/create-link-for-plan',
|
|
|
data: { purchasePlanId, remarks }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|