diff --git a/src/api/storage.entry/entry.ts b/src/api/storage.entry/entry.ts index 0a1a45b4..d5256038 100644 --- a/src/api/storage.entry/entry.ts +++ b/src/api/storage.entry/entry.ts @@ -704,6 +704,28 @@ export type ReceivingCompareRow = { [key: string]: unknown } +/** storage.entry.queryEntryLogs 参数 */ +export type QueryEntryLogsParams = { + id?: number | string + page?: number + pageSize?: number +} + +/** 查询入库单操作日志 */ +export function queryEntryLogs(data: QueryEntryLogsParams = {}): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.entry.queryEntryLogs', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + /** 汇总统计(summary 对象) */ export type ReceivingCompareSummary = { total_rows?: number @@ -780,3 +802,34 @@ export function receivingCompare( data }) } + +/** storage.entry.reviewEntry 参数 */ +export type ReviewEntryParams = { + /** 入库单ID */ + id: number +} + +/** storage.entry.reviewEntry 响应 */ +export type ReviewEntryResponse = { + flag?: string + code?: number + message?: string + data?: { + id?: number + order_status?: string + } +} + +/** 审核入库单(CREATED → PENDING),仅允许已绑定收货单的入库单推进状态 */ +export function reviewEntry(data: ReviewEntryParams): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.entry.reviewEntry', + v, + timestamp: new Date().getTime() + }, + data + }) +} diff --git a/src/views/order/orderManagement/config/order-common-config.ts b/src/views/order/orderManagement/config/order-common-config.ts index bb0b0274..1614b0b6 100644 --- a/src/views/order/orderManagement/config/order-common-config.ts +++ b/src/views/order/orderManagement/config/order-common-config.ts @@ -694,9 +694,9 @@ export const pendingOrderDetailSections: OrderDetailSectionConfig[] = [ { prop: 'delivery_order_code', label: '发货单号' }, { prop: 'pre_delivery_order_code', label: '前置单号' }, { prop: 'order_type', label: '订单类型' }, - { prop: 'create_channel', label: '创建渠道' }, + { prop: 'create_channel', label: '来源' }, { prop: 'order_flag', label: '订单标记', span: 4 }, - { prop: 'sys_platform_name', label: '来源' }, + { prop: 'sys_platform_name', label: '平台' }, { prop: 'sys_platform_code', label: '平台编码', tag: true }, { prop: 'source_platform_name', label: '来源平台名' }, { prop: 'source_order_codes', label: '平台交易单号' }, @@ -795,7 +795,8 @@ export const orderDetailCompactSections: OrderDetailSectionConfig[] = [ fields: [ { prop: 'delivery_order_code', label: '发货单号' }, { prop: 'order_type', label: '订单类型' }, - { prop: 'sys_platform_name', label: '来源' }, + { prop: 'sys_platform_name', label: '平台' }, + { prop: 'create_channel', label: '来源' }, { prop: 'shop_nick', label: '店铺名称' }, { prop: 'buyer_nick', label: '买家昵称' }, { prop: 'status', label: '订单状态', tag: true }, @@ -1098,7 +1099,7 @@ export const sourceOrderCodesScanField = scanBasicField({ label: '平台交易 export const pendingOrderCodeScanField = scanBasicField({ label: '发货单号', value: 'order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' }) export const exceptionOrderCodeScanField = scanBasicField({ label: '发货单号', value: 'order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' }) export const shopNickScanField = scanBasicField({ label: '店铺名称', value: 'shop_nick', type: 'text' }) -export const sysPlatformNameScanField = scanBasicField({ label: '来源', value: 'sys_platform_name', type: 'select', options: [] }) +export const sysPlatformNameScanField = scanBasicField({ label: '平台', value: 'sys_platform_name', type: 'select', options: [] }) export const sysPlatformCodeScanField = scanBasicField({ label: '平台编码', value: 'sys_platform_code', type: 'select', options: [] }) export const buyerNickScanField = scanBasicField({ label: '买家昵称', value: 'buyer_nick', type: 'text' }) export const receiverNameScanField = scanBasicField({ label: '收件人', value: 'name', type: 'text' }) @@ -1290,7 +1291,8 @@ export const deliveryColumns = applyOrderListCopyActions([ { prop: 'wave_no', label: '波次号', width: '150' }, { prop: 'wave_id', label: '波次ID', width: '90' }, { prop: 'order_flag', label: '订单标记', minWidth: '220' }, - { prop: 'sys_platform_name', label: '来源', width: '110' }, + { prop: 'sys_platform_name', label: '平台', width: '110' }, + { prop: 'create_channel', label: '来源', width: '120' }, { prop: 'sys_platform_code', label: '平台编码', width: '100' }, { prop: 'order_type', label: '订单类型', width: '90', formatter: orderTypeFormatter }, { prop: 'buyer_nick', label: '买家昵称', width: '120' }, @@ -1488,7 +1490,8 @@ export const reviewOrderDetail = [ { prop: 'pre_delivery_order_code', label: '前置单号' }, { prop: 'order_type', label: '订单类型' }, { prop: 'order_flag', label: '订单标记' }, - { prop: 'sys_platform_name', label: '来源' }, + { prop: 'sys_platform_name', label: '平台' }, + { prop: 'create_channel', label: '来源' }, { prop: 'sys_platform_code', label: '平台编码' }, { prop: 'shop_nick', label: '店铺名称' }, { prop: 'buyer_nick', label: '买家昵称' }, @@ -1641,7 +1644,8 @@ export const pendingCloums = [ { prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter }, { prop: 'pay_time', label: '支付时间', width: '160', formatter: orderTimeFormatter }, { prop: 'place_order_time', label: '时效', width: '165', formatter: orderTimeFormatter }, - { prop: 'sys_platform_name', label: '来源', width: '120' }, + { prop: 'sys_platform_name', label: '平台', width: '120' }, + { prop: 'create_channel', label: '来源', width: '120' }, { prop: 'source_order_codes', label: '平台交易单号', width: '140' }, { prop: 'logistics_name', label: '快递', width: '120' }, { prop: 'remark', label: '留言', width: '160' }, @@ -1705,7 +1709,8 @@ export const pendingOrderDetail = [ { prop: 'pre_delivery_order_code', label: '前置单号' }, { prop: 'order_type', label: '订单类型' }, { prop: 'order_flag', label: '订单标记' }, - { prop: 'sys_platform_name', label: '来源' }, + { prop: 'sys_platform_name', label: '平台' }, + { prop: 'create_channel', label: '来源' }, { prop: 'sys_platform_code', label: '平台编码' }, { prop: 'shop_nick', label: '店铺名称' }, { prop: 'buyer_nick', label: '买家昵称' }, @@ -1865,7 +1870,8 @@ export const workbenchColumns = applyOrderListCopyActions([ { prop: 'delivery_order_code', label: '发货单号', minWidth: 160 }, { prop: 'wave_no', label: '波次号', minWidth: 160 }, { prop: 'order_flag', label: '订单标记', minWidth: 260 }, - { prop: 'sys_platform_name', label: '来源', minWidth: 120 }, + { prop: 'sys_platform_name', label: '平台', minWidth: 120 }, + { prop: 'create_channel', label: '来源', minWidth: 120 }, { prop: 'shop_nick', label: '店铺名称', minWidth: 140 }, { prop: 'buyer_nick', label: '买家昵称', minWidth: 140 }, { prop: 'name', label: '收件人', minWidth: 100 }, @@ -1936,7 +1942,8 @@ export const expectionColumns = [ { prop: 'id', label: '订单ID', width: '80' }, { prop: 'delivery_order_code', label: '发货单号', width: '170' }, { prop: 'wave_no', label: '波次号', width: '170' }, - { prop: 'sys_platform_name', label: '来源', width: '120' }, + { prop: 'sys_platform_name', label: '平台', width: '120' }, + { prop: 'create_channel', label: '来源', width: '120' }, { prop: 'shop_nick', label: '店铺名称', width: '140' }, { prop: 'is_urgency', label: '是否紧急', width: '100' }, { prop: 'status', label: '订单状态', width: '100' }, @@ -1966,7 +1973,8 @@ export const expectionOrderDetail = [ { prop: 'order_code', label: '发货单号' }, { prop: 'order_type', label: '订单类型' }, { prop: 'shop_nick', label: '店铺名称' }, - { prop: 'sys_platform_name', label: '来源' }, + { prop: 'sys_platform_name', label: '平台' }, + { prop: 'create_channel', label: '来源' }, { prop: 'status', label: '订单状态' }, { prop: 'intercept_status', label: '拦截状态' }, @@ -2044,6 +2052,7 @@ export const archiveColumns = applyOrderListCopyActions([ { prop: 'wave_no', label: '波次号', width: '160' }, { prop: 'order_flag', label: '订单标记', minWidth: '260' }, { prop: 'shop_nick', label: '店铺名称', width: '140' }, + { prop: 'create_channel', label: '来源', width: '120' }, { prop: 'name', label: '收件人', width: '120' }, { prop: 'mobile', label: '电话', width: '120' }, { prop: 'buyer_message', label: '买家留言', minWidth: '180' }, @@ -2060,7 +2069,8 @@ export const archiveOrderDetail = [ { prop: 'order_code', label: '发货单号' }, { prop: 'order_type', label: '订单类型' }, { prop: 'shop_nick', label: '店铺名称' }, - { prop: 'sys_platform_name', label: '来源' }, + { prop: 'sys_platform_name', label: '平台' }, + { prop: 'create_channel', label: '来源' }, { prop: 'status', label: '订单状态' }, // 收货信息 diff --git a/src/views/storage/entry/component/BindReceivingToEntryDialog.vue b/src/views/storage/entry/component/BindReceivingToEntryDialog.vue index 1b870030..7b0c8645 100644 --- a/src/views/storage/entry/component/BindReceivingToEntryDialog.vue +++ b/src/views/storage/entry/component/BindReceivingToEntryDialog.vue @@ -333,8 +333,7 @@ const canSubmitBind = computed( selectedReceivingRows.value.length > 0 && !bindSubmitting.value && !compareLoading.value && - !receivingListLoading.value && - isEntryFullyCovered.value + !receivingListLoading.value ) function isApiSuccess(res: { code?: number; flag?: string } | null | undefined): boolean { diff --git a/src/views/storage/entry/component/entrydetail.vue b/src/views/storage/entry/component/entrydetail.vue index a8978d48..6697eacb 100644 --- a/src/views/storage/entry/component/entrydetail.vue +++ b/src/views/storage/entry/component/entrydetail.vue @@ -21,7 +21,6 @@
- 待入库,可绑定收货明细 可导入/PDA 入库 已导入 {{ directSummary.total_direct_inbound ?? 0 }} / 计划 {{ directSummary.total_planned ?? '—' }} @@ -40,28 +39,7 @@ @page-size-change="handlePageSizeChange" @page-change="handlePageChange" > - - @@ -232,6 +309,7 @@ import { isPendingEntryOrderStatus, canQuickInbound, canBindEntryOrder, + canStartReceiving, finalizeEntryListWhere, formatEntryHasReceiving, formatReceivingBindingsSummary, @@ -343,6 +421,12 @@ const selectedRow = computed(() => { const bindDialogVisible = ref(false) const bindTargetRow = ref(null) +const reviewDialogVisible = ref(false) +const reviewTargetRow = ref(null) +const reviewSubmitting = ref(false) +const reviewCompareLoading = ref(false) +const reviewCompareRows = ref([]) + function openBindDialog(row: any) { if (!canBindEntryOrder(row?.order_status)) return bindTargetRow.value = row @@ -761,6 +845,104 @@ async function handleRowQuickInbound(row: any) { } } +/** 构建收货对照预览行 */ +function buildReviewCompareRow(record: any, index: number) { + const raw = record as Record + const status = String(raw.match_status ?? '').toLowerCase() + const entryName = raw.warehouse_item_name as string || raw.receiving_product_name as string || '—' + const receivingName = raw.receiving_product_name as string || raw.warehouse_item_name as string || '—' + const entryQty = raw.entry_count ?? raw.entry_received ?? '—' + const receivingAvailable = raw.receiving_available ?? raw.receiving_actual_quantity ?? raw.receiving_allocated ?? '—' + + const tagMap: Record = { + matched: 'success', + entry_only: 'warning', + receiving_only: 'primary', + } + const labelMap: Record = { + matched: '已匹配', + entry_only: '仅入库', + receiving_only: '仅收货', + } + + return { + rowKey: `review-compare-${index}`, + matchStatus: status, + matchTagType: tagMap[status] || 'info', + matchStatusLabel: labelMap[status] || status, + entryName, + receivingName, + entryQty: entryQty === '—' ? '—' : String(entryQty), + receivingAvailable: receivingAvailable === '—' ? '—' : String(receivingAvailable), + } +} + +/** 开始入库(打开确认弹窗,拉取收货对照数据) */ +async function handleReviewEntry(row: any) { + reviewTargetRow.value = row + reviewDialogVisible.value = true + reviewCompareLoading.value = true + reviewCompareRows.value = [] + + try { + // 从 row 的 receivingBindings 中提取收货单 ID + const bindings = row.receivingBindings || [] + const receivingIds = bindings + .map((item: any) => Number(item.receiving_id)) + .filter((id: number) => Number.isFinite(id) && id > 0) + + if (receivingIds.length > 0 && row.id) { + const res = await entryApi.receivingCompare({ + entry_order_id: Number(row.id), + receiving_ids: receivingIds, + }) + const payload = (res.data && typeof res.data === 'object' ? { ...res, ...res.data } : res) as any + const allRecords: any[] = [] + for (const item of (payload.comparisons ?? [])) { + const records = [ + ...(Array.isArray(item.comparison) ? item.comparison : []), + ...(Array.isArray(item.receiving_only) ? item.receiving_only : []), + ] + allRecords.push(...records) + } + reviewCompareRows.value = allRecords.map(buildReviewCompareRow) + } + } catch (e) { + console.warn('拉取收货对照数据失败', e) + reviewCompareRows.value = [] + } finally { + reviewCompareLoading.value = false + } +} + +function handleReviewDialogClosed() { + reviewTargetRow.value = null + reviewCompareRows.value = [] + reviewCompareLoading.value = false + reviewSubmitting.value = false +} + +/** 确定开始入库(审核入库单,CREATED → PENDING) */ +async function handleReviewConfirm() { + if (!reviewTargetRow.value) return + reviewSubmitting.value = true + try { + const res = await entryApi.reviewEntry({ id: Number(reviewTargetRow.value.id) }) + if (res && (res.code === 200)) { + ElMessage.success('开始入库成功') + reviewDialogVisible.value = false + await loadData() + entryDetailRefreshTick.value += 1 + } else { + ElMessage.error(res?.message || '开始入库失败') + } + } catch (e: any) { + ElMessage.error(e?.message || '开始入库失败') + } finally { + reviewSubmitting.value = false + } +} + async function handleCompleteEntry() { const targets = getActionTargetRows() if (!targets.length) {