This commit is contained in:
liufumingren 2026-07-03 21:57:28 +08:00
parent a9ba68e0fd
commit 806f53d1d6
3 changed files with 52 additions and 15 deletions

View File

@ -171,6 +171,7 @@ export type EntryOrderDetail = {
entry_order_code?: string
purchase_order_code?: string
store_name?: string
store_remask?: string
order_status?: string
items?: EntryDetailItem[]
receivingBindings?: EntryOrderReceivingBinding[]
@ -185,6 +186,8 @@ export type GetEntryDetailResponse = {
entryOrder?: EntryOrderDetail
data?: {
entryOrder?: EntryOrderDetail
items?: EntryDetailItem[]
receivingBindings?: EntryOrderReceivingBinding[]
}
}

View File

@ -87,6 +87,7 @@ import {
commit,
getEntryDetail,
type EntryDetailItem,
type EntryDetailItemBarcode,
} from '@/api/storage.entry/entry'
import DirectInboundImportDialog, {
type DirectInboundImportRow,
@ -218,17 +219,46 @@ async function loadEntryDetail() {
const entryOrder = res.data.entryOrder
entryOrderStatus.value = entryOrder.order_status || ''
entryOrderCode.value = entryOrder.entry_order_code || ''
const items = entryOrder.items || []
tableData.value = items.map((item: EntryDetailItem) => ({
...item,
direct_inbound_quantity: item.direct_inbound_quantity ?? 0,
remaining_quantity: item.remaining_quantity ?? item.count ?? 0,
entry_order_code: entryOrder.entry_order_code || '',
purchase_order_code: entryOrder.purchase_order_code || '',
store_name: entryOrder.store_name || '',
}))
// items 与 entryOrder 同级,在 res.data 下
const rawItems: any[] = res.data.items || []
const items: EntryDetailItem[] = rawItems.map((item: any) => {
const stock = item.stock || {}
const barcodes: EntryDetailItemBarcode[] = (stock.barcodes || []).map((b: any) => ({
id: b.id,
barcode: b.barcode,
}))
const imageUrls: string[] = Array.isArray(stock.image_url) ? stock.image_url : []
return {
id: item.id,
stock_id: item.stock_id ?? stock.id,
external_item_code: item.external_item_code ?? '',
external_item_id: item.external_item_id,
warehouse_item_code: stock.item_code || '',
warehouse_item_name: stock.item_name || '',
warehouse_item_spec: stock.sku_property || '',
count: item.planned ?? item.count ?? 0,
received_quantity: item.completed ?? item.received_quantity ?? 0,
confirm_quantity: item.confirm_quantity ?? 0,
warehouse_quantity: stock.quantity ?? null,
warehouse_locked_quantity: stock.locked_quantity ?? null,
warehouse_is_batch_mgmt: stock.is_batch_mgmt ?? null,
warehouse_is_shelf_life_mgmt: stock.is_shelf_life_mgmt ?? null,
warehouse_image_url: imageUrls.length > 0 ? imageUrls[0] : '',
warehouse_is_images: stock.is_images ?? null,
barcodes,
direct_inbound_quantity: item.direct_inbound_quantity ?? 0,
remaining_quantity: item.remaining_quantity ?? ((item.planned ?? item.count ?? 0) - (item.completed ?? item.received_quantity ?? 0)),
pending_total: item.pending_total ?? 0,
bindings: item.bindings || [],
direct_logs: item.direct_logs || [],
entry_order_code: entryOrder.entry_order_code || '',
purchase_order_code: entryOrder.purchase_order_code || '',
store_name: entryOrder.store_remask || entryOrder.store_name || '',
}
})
tableData.value = items
directSummary.value = buildDirectSummary(items)
pagination.total = tableData.value.length
} else {

View File

@ -483,16 +483,20 @@ async function fetchEntryPrintData(row: any, _index: number): Promise<Record<str
}
const entryOrder = res.data.entryOrder as Record<string, unknown>
const result: Record<string, unknown> = { ...entryOrder }
// 表格渲染使用 details 字段,将 items 映射过去
if (Array.isArray(entryOrder.items)) {
result.details = (entryOrder.items as any[]).map((item: any, idx: number) => ({
// items 与 entryOrder 同级,在 res.data 下
const items: any[] = res.data.items || []
result.details = items.map((item: any, idx: number) => {
const stock = item.stock || {}
return {
...item,
...stock,
// 条码:取 barcodes 数组第一条的 barcode
barcode: item.barcode ?? item.barcodes?.[0]?.barcode ?? '',
barcode: item.barcode ?? stock.barcodes?.[0]?.barcode ?? '',
// 序号
seq_no: idx + 1,
}))
}
}
})
return result
}