Make dynamic column-facet values respect other active filters (Excel-style), with backend facet context helpers, list-page wiring, slip print/sidebar fixes, and refreshed graphify graphs. Co-authored-by: Cursor <cursoragent@cursor.com>
155 lines
4.0 KiB
TypeScript
155 lines
4.0 KiB
TypeScript
import type { AxiosRequestConfig } from 'axios'
|
|
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
|
|
}
|
|
|
|
/** @deprecated 列筛透传后 list/export 使用 Record;保留类型供阅读参考 */
|
|
export interface WeighingListParams {
|
|
q?: string
|
|
dateFrom?: string
|
|
dateTo?: string
|
|
planNo?: string
|
|
batchNo?: string
|
|
vehicleNo?: string
|
|
cargoName?: string
|
|
supplier?: string
|
|
consignee?: string
|
|
businessType?: '入库' | '出库'
|
|
businessTypeIn?: string
|
|
netWeightOp?: string
|
|
netWeight?: string
|
|
netWeightMin?: string
|
|
netWeightMax?: string
|
|
grossWeightOp?: string
|
|
grossWeight?: string
|
|
grossWeightMin?: string
|
|
grossWeightMax?: string
|
|
}
|
|
|
|
export const weighingApi = {
|
|
list(params?: Record<string, any>) {
|
|
return dbRequest.get<WeighingRecord[]>('/weighing', { params })
|
|
},
|
|
export(data: Record<string, any>) {
|
|
return dbRequest.post<Blob>('/weighing/export', data, { responseType: 'blob' })
|
|
},
|
|
get(id: string) {
|
|
return dbRequest.get<WeighingRecord>(`/weighing/${id}`)
|
|
},
|
|
getRelated(id: string) {
|
|
return dbRequest.get<WeighingRelatedData>(`/weighing/${id}/related`)
|
|
},
|
|
create(payload: WeighingCreate) {
|
|
return dbRequest.post<WeighingRecord>('/weighing', payload)
|
|
},
|
|
update(id: string, payload: WeighingUpdate) {
|
|
return dbRequest.patch<WeighingRecord>(`/weighing/${id}`, payload)
|
|
},
|
|
void(id: string, data?: { voidReason?: string }) {
|
|
return dbRequest.post<void>(`/weighing/${id}/void`, data || {})
|
|
},
|
|
delete(id: string) {
|
|
return dbRequest.delete<void>(`/weighing/${id}`)
|
|
}
|
|
}
|
|
|
|
/** 地磅单列头可选值(计划号/单号/车牌/货物/单位去重;可附带列表上下文) */
|
|
export function fetchWeighingColumnFacetValues(
|
|
data: {
|
|
field: 'planNo' | 'batchNo' | 'vehicleNo' | 'cargoName' | 'supplier' | 'consignee'
|
|
keyword?: string
|
|
limit?: number
|
|
} & Record<string, unknown>
|
|
) {
|
|
return dbRequest.post<{ list: Array<{ value: string; label: string; count: number }> }>(
|
|
'/weighing/column-facet-values',
|
|
data,
|
|
{ showErrorMessage: false } as AxiosRequestConfig & { showErrorMessage?: boolean }
|
|
)
|
|
}
|