import dbRequest from '@/utils/http/db' import type { InventoryRecord } from '@/api/db/inventory' import type { Plan } from '@/api/db/plans' 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 interface WeighingListParams { q?: string dateFrom?: string dateTo?: string planNo?: string batchNo?: string vehicleNo?: string cargoName?: string supplier?: string consignee?: string businessType?: '入库' | '出库' } export const weighingApi = { list(params?: WeighingListParams) { return dbRequest.get('/weighing', { params }) }, export(data: Record) { return dbRequest.post('/weighing/export', data, { responseType: 'blob' }) }, get(id: string) { return dbRequest.get(`/weighing/${id}`) }, getRelated(id: string) { return dbRequest.get(`/weighing/${id}/related`) }, create(payload: WeighingCreate) { return dbRequest.post('/weighing', payload) }, update(id: string, payload: WeighingUpdate) { return dbRequest.patch(`/weighing/${id}`, payload) }, void(id: string) { return dbRequest.post(`/weighing/${id}/void`) }, delete(id: string) { return dbRequest.delete(`/weighing/${id}`) } }