This commit is contained in:
liufumingren 2026-06-12 12:17:23 +08:00
parent f8de12ab8b
commit 401a282186
5 changed files with 507 additions and 195 deletions

View File

@ -89,6 +89,17 @@
<el-option label="先打印后复核" value="print_first" /> <el-option label="先打印后复核" value="print_first" />
<el-option label="先复核后打印" value="recheck_first" /> <el-option label="先复核后打印" value="recheck_first" />
</el-select> </el-select>
<el-select
v-model="recheckWeighingMode"
placeholder="数据一致后称重"
size="small"
style="width: 150px"
clearable
@change="handleWeighingModeChange"
>
<el-option label="不称重" value="off" />
<el-option label="称重" value="on" />
</el-select>
</div> </div>
<div v-if="scanPayload" class="toolbar-right"> <div v-if="scanPayload" class="toolbar-right">
<el-tag v-if="scanPayloadPickerName" size="small" type="primary">拣货人:{{ scanPayloadPickerName }}</el-tag> <el-tag v-if="scanPayloadPickerName" size="small" type="primary">拣货人:{{ scanPayloadPickerName }}</el-tag>
@ -157,18 +168,21 @@
:title="weighingBeforeConfirm ? '称重(复核前)' : '称重'" :title="weighingBeforeConfirm ? '称重(复核前)' : '称重'"
width="360px" width="360px"
align-center align-center
@opened="focusWeighingInput"
@closed="resetWeighingForm" @closed="resetWeighingForm"
> >
<el-form ref="weighingFormRef" :model="weighingForm" :rules="weighingRules" label-width="80px"> <el-form ref="weighingFormRef" :model="weighingForm" :rules="weighingRules" label-width="80px" @submit.prevent>
<el-form-item label="重量" prop="weight"> <el-form-item label="重量" prop="weight">
<el-input-number <el-input-number
ref="weighingInputRef"
v-model="weighingForm.weight" v-model="weighingForm.weight"
:min="0.001" :min="0.001"
:max="9999" :max="9999"
:precision="3" :precision="3"
:step="0.1" :step="0.001"
style="width: 100%" style="width: 100%"
placeholder="请输入重量(kg)" placeholder="请输入重量(kg)"
@keyup.enter.prevent="submitWeighing"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -181,7 +195,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, h, onMounted, reactive, ref, watch } from 'vue' import { computed, h, nextTick, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus' import type { FormInstance, FormRules } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue' import ScanBox from '@/components/ScanBox/index.vue'
@ -380,6 +394,31 @@ function handleWorkflowModeChange(val: string | undefined) {
} }
} }
// ─── 数据一致后称重配置 ─────────────────────────────────────────────────────
const RECHECK_WEIGHING_KEY = 'order_recheck_weighing_mode'
const recheckWeighingMode = ref(loadWeighingMode())
function loadWeighingMode(): string {
try {
return localStorage.getItem(RECHECK_WEIGHING_KEY) || 'off'
} catch {
return 'off'
}
}
function handleWeighingModeChange(val: string | undefined) {
const mode = String(val ?? 'off').trim()
try {
if (mode === 'on') {
localStorage.setItem(RECHECK_WEIGHING_KEY, mode)
} else {
localStorage.removeItem(RECHECK_WEIGHING_KEY)
}
} catch {
// ignore
}
}
// ─── RecheckOrderPanel 状态 ───────────────────────────────────────────────── // ─── RecheckOrderPanel 状态 ─────────────────────────────────────────────────
const panelOrders = ref<any[]>([]) const panelOrders = ref<any[]>([])
const panelTotalCount = ref(0) const panelTotalCount = ref(0)
@ -394,6 +433,17 @@ function handlePanelSearch(keyword: string) {
void executeScan({ keyword }) void executeScan({ keyword })
} }
/** 判断订单是否已打印面单(兼容 print_status 与 is_printed 两种字段) */
function isOrderAlreadyPrinted(order: any): boolean {
if (!order) return false
// 优先检查 print_status
if (String(order.print_status ?? '').trim() === 'fin') return true
// 其次检查 is_printed 布尔/数字字段
const printed = order.is_printed
if (printed === true || printed === 1 || printed === 'true' || printed === '1') return true
return false
}
async function handlePanelSelect(order: any) { async function handlePanelSelect(order: any) {
const waybill = String(order?.waybill_no || '').trim() const waybill = String(order?.waybill_no || '').trim()
if (waybill) panelActiveWaybill.value = waybill if (waybill) panelActiveWaybill.value = waybill
@ -439,8 +489,8 @@ async function handlePanelSelect(order: any) {
// 先打印后复核模式(默认):散单/团购波次未打印时自动拉取打印数据并发送 // 先打印后复核模式(默认):散单/团购波次未打印时自动拉取打印数据并发送
const isPrintFirst = !recheckWorkflowMode.value || recheckWorkflowMode.value === 'print_first' const isPrintFirst = !recheckWorkflowMode.value || recheckWorkflowMode.value === 'print_first'
if (isPrintFirst && !isReviewed && !isIntercept && Number.isFinite(orderId) && orderId > 0) { if (isPrintFirst && !isReviewed && !isIntercept && Number.isFinite(orderId) && orderId > 0) {
const printStatus = String((order as any)?.print_status ?? '').trim() const alreadyPrinted = isOrderAlreadyPrinted(order as any)
if (printStatus !== 'fin') { if (!alreadyPrinted) {
const waveIds = isWave ? ((order as any)?.order_ids as Array<number | string> | undefined) : undefined const waveIds = isWave ? ((order as any)?.order_ids as Array<number | string> | undefined) : undefined
await autoPrintForOrder(orderId, waveIds) await autoPrintForOrder(orderId, waveIds)
} }
@ -1470,6 +1520,14 @@ async function handleConfirm() {
return return
} }
// 数据一致后称重模式:数据一致后先弹出称重弹窗,称重完成时并发确认复核
if (recheckWeighingMode.value === 'on' && allItemsScanned.value) {
weighingBeforeConfirm.value = true
weighingForm.weight = null
weighingDialogVisible.value = true
return
}
// 团购波次且所有商品一致:先弹出称重弹窗,称重完成后再确认复核 // 团购波次且所有商品一致:先弹出称重弹窗,称重完成后再确认复核
if (isAllSameProductInWave.value) { if (isAllSameProductInWave.value) {
weighingBeforeConfirm.value = true weighingBeforeConfirm.value = true
@ -1488,6 +1546,67 @@ async function handleConfirm() {
await doConfirm() await doConfirm()
} }
/** 复核完成后更新面板并跳转下一个未复核订单 */
async function finishConfirmAndAdvance() {
const id = activeOrderId.value
if (id == null) return
// 先复核后打印模式:复核成功后先拉取打印数据并发送
if (recheckWorkflowMode.value === 'recheck_first') {
const selectedRow = selectedOrderRow.value as any
const waveIds = selectedRow?._is_wave ? (selectedRow?.order_ids as Array<number | string> | undefined) : undefined
await autoPrintForOrder(id, waveIds)
}
// 更新面板:将该订单标记为已复核
const confirmedWaybill = panelActiveWaybill.value
panelOrders.value = panelOrders.value.map((o: any) => {
if (String(o.waybill_no ?? '').trim() === confirmedWaybill) {
return { ...o, recheck_status: 'fin' }
}
return o
})
panelRemainingCount.value = panelOrders.value.filter((o: any) => {
const status = String(o.recheck_status ?? '').trim()
return status !== 'fin'
}).length
// 自动选中下一个未复核订单:先找当前之后的下一个,找不到再从头找第一个
const confirmedIndex = panelOrders.value.findIndex((o: any) =>
String(o.waybill_no ?? '').trim() === confirmedWaybill
)
let nextUnreviewed: any = null
if (confirmedIndex >= 0) {
for (let i = confirmedIndex + 1; i < panelOrders.value.length; i++) {
const status = String(panelOrders.value[i].recheck_status ?? '').trim()
if (status !== 'fin') {
nextUnreviewed = panelOrders.value[i]
break
}
}
}
// 当前之后没有未复核的,再从头找第一个未复核的(兜底)
if (!nextUnreviewed) {
nextUnreviewed = panelOrders.value.find((o: any) => {
const status = String(o.recheck_status ?? '').trim()
return status !== 'fin'
})
}
if (nextUnreviewed) {
handlePanelSelect(nextUnreviewed)
} else {
// 清除当前订单的扫描状态
const curOrder = selectedOrderRow.value as any
if (curOrder?.stock) {
for (const s of curOrder.stock) delete s._scanned_qty
}
scanHint.value = '全部订单已复核完成!'
scanHintType.value = 'success'
panelActiveWaybill.value = ''
panelScanMode.value = 'search'
}
}
/** 执行复核确认(不含用户二次确认弹窗) */ /** 执行复核确认(不含用户二次确认弹窗) */
async function doConfirm() { async function doConfirm() {
const id = activeOrderId.value const id = activeOrderId.value
@ -1510,42 +1629,7 @@ async function doConfirm() {
].filter((x) => x != null && String(x) !== '') ].filter((x) => x != null && String(x) !== '')
ElMessage.success(parts.length ? `复核成功:${parts.join(' / ')}` : '复核已记录') ElMessage.success(parts.length ? `复核成功:${parts.join(' / ')}` : '复核已记录')
// 先复核后打印模式:复核成功后先拉取打印数据并缓存,再更新面板 await finishConfirmAndAdvance()
if (recheckWorkflowMode.value === 'recheck_first') {
const waveIds = selectedRow?._is_wave ? (selectedRow?.order_ids as Array<number | string> | undefined) : undefined
await autoPrintForOrder(id, waveIds)
}
// 更新面板:将该订单标记为已复核
const confirmedWaybill = panelActiveWaybill.value
panelOrders.value = panelOrders.value.map((o: any) => {
if (String(o.waybill_no ?? '').trim() === confirmedWaybill) {
return { ...o, recheck_status: 'fin' }
}
return o
})
panelRemainingCount.value = panelOrders.value.filter((o: any) => {
const status = String(o.recheck_status ?? '').trim()
return status !== 'fin'
}).length
// 自动选中下一个未复核订单(跳过自动打印,保留当前波次的打印缓存)
const nextUnreviewed = panelOrders.value.find((o: any) => {
const status = String(o.recheck_status ?? '').trim()
return status !== 'fin'
})
if (nextUnreviewed) {
handlePanelSelect(nextUnreviewed)
} else {
// 清除当前订单的扫描状态
const curOrder = selectedOrderRow.value as any
if (curOrder?.stock) {
for (const s of curOrder.stock) delete s._scanned_qty
}
scanHint.value = '全部订单已复核完成!'
scanHintType.value = 'success'
panelActiveWaybill.value = ''
panelScanMode.value = 'search'
}
} finally { } finally {
confirmLoading.value = false confirmLoading.value = false
} }
@ -1558,6 +1642,7 @@ const weighingDialogVisible = ref(false)
const weighingSubmitting = ref(false) const weighingSubmitting = ref(false)
const weighingBeforeConfirm = ref(false) const weighingBeforeConfirm = ref(false)
const weighingFormRef = ref<FormInstance>() const weighingFormRef = ref<FormInstance>()
const weighingInputRef = ref<any>(null)
const weighingForm = reactive({ weight: null as number | null }) const weighingForm = reactive({ weight: null as number | null })
const weighingRules: FormRules = { const weighingRules: FormRules = {
weight: [ weight: [
@ -1566,12 +1651,31 @@ const weighingRules: FormRules = {
] ]
} }
// 数据一致后自动弹出称重窗口
watch(allItemsScanned, (val) => {
if (!val) return
if (recheckWeighingMode.value !== 'on') return
if (weighingDialogVisible.value) return
if (hasSelectedIntercept.value) return
const id = activeOrderId.value
if (id == null || id <= 0) return
weighingBeforeConfirm.value = true
weighingForm.weight = null
weighingDialogVisible.value = true
})
function resetWeighingForm() { function resetWeighingForm() {
weighingForm.weight = null weighingForm.weight = null
weighingFormRef.value?.clearValidate() weighingFormRef.value?.clearValidate()
weighingBeforeConfirm.value = false weighingBeforeConfirm.value = false
} }
function focusWeighingInput() {
nextTick(() => {
weighingInputRef.value?.focus?.()
})
}
function openWeighingDialog() { function openWeighingDialog() {
weighingBeforeConfirm.value = false weighingBeforeConfirm.value = false
weighingForm.weight = null weighingForm.weight = null
@ -1588,6 +1692,60 @@ async function submitWeighing() {
return return
} }
weighingSubmitting.value = true weighingSubmitting.value = true
// 数据一致后称重模式:并发提交确认复核 + 保存重量
if (weighingBeforeConfirm.value && recheckWeighingMode.value === 'on') {
const selectedRow = selectedOrderRow.value as any
const confirmParams: any = { order_id: id }
if (selectedRow?._is_wave && selectedRow?.wave_id) {
confirmParams.wave_id = selectedRow.wave_id
delete confirmParams.order_id
}
const weight = Number(weighingForm.weight)
const [confirmResult, weighResult] = await Promise.allSettled([
confirmRecheck(confirmParams),
orderUpdateExpressWeighingWeight({ order_id: id, weighing_weight: weight })
])
const confirmOk = confirmResult.status === 'fulfilled' && (() => {
const r: any = confirmResult.value
return r && (r.code === 1 || r.code === 200 || r.flag === 'success')
})()
const weighOk = weighResult.status === 'fulfilled' && isOrderIndexApiSuccess(weighResult.value)
if (confirmOk && weighOk) {
const payload = unwrapResponse(confirmResult.value) as ConfirmRecheckResultShape
const parts = [
payload.review_no ?? payload.reviewNo,
payload.recheck_status,
payload.recheck_time
].filter((x) => x != null && String(x) !== '')
ElMessage.success(parts.length ? `复核成功:${parts.join(' / ')},称重 ${weight} kg` : `复核已记录,称重 ${weight} kg`)
weighingDialogVisible.value = false
weighingBeforeConfirm.value = false
await finishConfirmAndAdvance()
} else {
const msgs: string[] = []
if (!confirmOk) {
const errMsg = confirmResult.status === 'fulfilled'
? ((confirmResult.value as any)?.message || '确认复核失败')
: '确认复核请求失败'
msgs.push(errMsg)
}
if (!weighOk) {
const errMsg = weighResult.status === 'fulfilled'
? ((weighResult.value as any)?.message || '称重保存失败')
: '称重保存请求失败'
msgs.push(errMsg)
}
ElMessage.error(msgs.join(';'))
}
weighingSubmitting.value = false
return
}
// 原有逻辑:仅称重 或 团购同款预称重
try { try {
const res: any = await orderUpdateExpressWeighingWeight({ const res: any = await orderUpdateExpressWeighingWeight({
order_id: id, order_id: id,

View File

@ -2,12 +2,9 @@ export const availableFields = [
{ label:'', value: '', type: 'input' }, { label:'', value: '', type: 'input' },
{ label: '货主', value: 'store_id', type: 'select', multiple: true, options: [] }, { label: '货主', value: 'store_id', type: 'select', multiple: true, options: [] },
{ label: '状态', value: 'order_status', type: 'select', options: [ { label: '状态', value: 'order_status', type: 'select', options: [
{ label: '已创建', value: 'CREATED' },
{ label: '待入库', value: 'PENDING' }, { label: '待入库', value: 'PENDING' },
{ label: '入库中', value: 'PARTIAL' }, { label: '入库中', value: 'PARTIAL' },
{ label: '部分收货', value: 'PARTIAL_RECEIVED' }, { label: '部分收货', value: 'PARTIAL_RECEIVED' },
{ label: '已完成', value: 'COMPLETED' },
{ label: '已取消', value: 'CANCELLED' },
]}, ]},
{ label: '入库单类型', value: 'order_type', type: 'select', options: [ { label: '入库单类型', value: 'order_type', type: 'select', options: [
{ label: '采购入库', value: 'CGRK' }, { label: '采购入库', value: 'CGRK' },
@ -27,6 +24,11 @@ export const availableFields = [
{ label: '成功', value: 'SUCCESS' }, { label: '成功', value: 'SUCCESS' },
{ label: '失败', value: 'FAIL' }, { label: '失败', value: 'FAIL' },
]}, ]},
{ label: '数据来源', value: 'source_type', type: 'select', options: [
{ label: '奇门', value: 'QM' },
{ label: '接口', value: 'API' },
{ label: '系统', value: 'WMS' },
]},
{ label: '费用是否记录',value: 'expense_record', type: 'select', options: [ { label: '费用是否记录',value: 'expense_record', type: 'select', options: [
{ label: '是', value: true }, { label: '是', value: true },
{ label: '否', value: false }, { label: '否', value: false },
@ -67,6 +69,7 @@ export const entryColums = [
{ prop: 'expect_end_time',label:'预计结束时间',width:'160' }, { prop: 'expect_end_time',label:'预计结束时间',width:'160' },
{ prop: '',label:'',width:'160',fixed: 'left' }, { prop: '',label:'',width:'160',fixed: 'left' },
{ prop: 'source_type',label:'数据来源',width:'160' }, { prop: 'source_type',label:'数据来源',width:'160' },
{ prop: 'remark',label:'备注',width:'160' },
{ prop: '',label:'',width:'160',fixed: 'left' }, { prop: '',label:'',width:'160',fixed: 'left' },
{ prop: '',label:'',width:'160',fixed: 'left' }, { prop: '',label:'',width:'160',fixed: 'left' },
] ]

View File

@ -82,6 +82,12 @@
{{ formatTime(row.expect_end_time) }} {{ formatTime(row.expect_end_time) }}
</template> </template>
<template #column-source_type="{ row }">
<el-tag size="small" :type="row.source_type === 'WMS' ? '' : row.source_type === 'QM' ? 'primary' : 'success'">
{{ translateField('source_type', row.source_type) }}
</el-tag>
</template>
<template #empty> <template #empty>
<div class="empty-tip">暂无入库单</div> <div class="empty-tip">暂无入库单</div>
</template> </template>
@ -384,6 +390,10 @@ async function loadData() {
try { try {
// 优先使用由 ScanBox 提交并经过规范化的条件(包含 operator 等信息) // 优先使用由 ScanBox 提交并经过规范化的条件(包含 operator 等信息)
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {}) const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
// 固定条件:订单状态只显示待入库或部分入库(始终强制)
where.order_status = { operator: 'in', value: ['PENDING', 'PARTIAL', 'PARTIAL_RECEIVED'], type: 'select' }
const params: StorageEntryListParams = { const params: StorageEntryListParams = {
pagination: { pagination: {
page: pagination.currentPage, page: pagination.currentPage,
@ -451,7 +461,7 @@ async function loadData() {
express_code: '', express_code: '',
supplier_code: '', supplier_code: '',
supplier_name: '', supplier_name: '',
source_type: 'QM', source_type: 'API',
order_status: 'COMPLETED', order_status: 'COMPLETED',
sync_status: 'SUCCESS', sync_status: 'SUCCESS',
warehouse_id: 100000, warehouse_id: 100000,
@ -474,7 +484,7 @@ async function loadData() {
express_code: '', express_code: '',
supplier_code: '0004', supplier_code: '0004',
supplier_name: 'NBBT30', supplier_name: 'NBBT30',
source_type: 'QM', source_type: 'WMS',
order_status: 'COMPLETED', order_status: 'COMPLETED',
sync_status: 'SUCCESS', sync_status: 'SUCCESS',
warehouse_id: 100000, warehouse_id: 100000,

View File

@ -95,6 +95,7 @@
<template #column-actions="{ row }"> <template #column-actions="{ row }">
<el-button <el-button
v-if="row.status === 'completed' && row.detail_status === 'all_matched' && (row.is_review === 1 || row.is_review === true) && row.storage_status !== 'all'"
type="success" type="success"
link link
size="small" size="small"
@ -205,110 +206,101 @@
</template> </template>
</el-dialog> </el-dialog>
<!-- 匹配入库:选择入库单后与当前行收货单执行 storage.inventory.matchPutaway --> <!-- 匹配入库:左右结构,左选收货单,右对比明细 -->
<el-dialog <el-dialog
v-model="matchPutawayDialogVisible" v-model="matchPutawayDialogVisible"
title="匹配入库 — 选择入库单" title="匹配入库"
width="780px" width="92vw"
align-center align-center
append-to-body append-to-body
destroy-on-close destroy-on-close
@closed="resetMatchPutawayDialog" @closed="resetMatchPutawayDialog"
> >
<div class="match-putaway-dialog"> <div class="match-putaway-dialog">
<p v-if="matchPutawayContextHint" class="match-hint">{{ matchPutawayContextHint }}</p> <div class="match-left-panel">
<p class="match-desc"> <div class="match-panel-title">入库单列表</div>
请选择与当前收货单对应的入库单(可多选)。接口将按商品维度匹配数量;收货单需已完成且已审核。 <el-table
</p> ref="matchEntryTableRef"
<el-form :inline="true" size="small" class="match-entry-filters"> :data="matchEntryList"
<el-form-item label="货主"> v-loading="matchEntryListLoading"
<el-select highlight-current-row
v-model="matchEntryFilterStoreId" border
placeholder="全部" size="small"
clearable height="100%"
filterable @current-change="onMatchEntrySelect"
style="width: 200px" >
@change="onMatchEntryFilterChange" <el-table-column prop="entry_order_code" label="入库单号" min-width="160" show-overflow-tooltip />
<el-table-column label="来源" width="80" align="center">
<template #default="{ row: e }">{{ entrySourceLabel(e.source_type) }}</template>
</el-table-column>
<el-table-column label="入库状态" width="90" align="center">
<template #default="{ row: e }">
<el-tag size="small" :type="entryOrderStatusTag(e.order_status)">
{{ entryOrderStatusLabel(e.order_status) }}
</el-tag>
</template>
</el-table-column>
</el-table>
</div>
<div class="match-right-panel">
<div class="match-panel-title">
明细对比
<span style="font-weight:400;color:#909399;margin-left:8px;font-size:12px">
收货单 {{ matchPutawayReceivingRow?.receiving_number || '—' }}
<template v-if="matchSelectedEntryOrder"> ← → 入库单 {{ matchSelectedEntryOrder.entry_order_code }}</template>
</span>
<el-tag
v-if="matchSelectedEntryOrder && matchComparisonRows.length"
size="small"
:type="matchComparisonSummary.type"
style="margin-left:10px"
> >
<el-option {{ matchComparisonSummary.text }}
v-for="s in matchEntryStoreOptions" </el-tag>
:key="String(s.value)" </div>
:label="s.label" <el-table
:value="s.value" :data="matchComparisonRows"
/> v-loading="matchReceivingDetailsLoading || matchEntryDetailsLoading"
</el-select> border
</el-form-item> size="small"
<el-form-item label="入库状态"> height="100%"
<el-select row-key="stockId"
v-model="matchEntryFilterOrderStatus" >
placeholder="全部" <el-table-column prop="productName" label="商品名称" min-width="150" show-overflow-tooltip />
clearable <el-table-column prop="barcode" label="条码" width="130" show-overflow-tooltip />
style="width: 170px" <el-table-column prop="itemCode" label="商品编码" width="130" show-overflow-tooltip />
@change="onMatchEntryFilterChange" <el-table-column label="收货数量" width="90" align="center">
> <template #default="{ row: r }">{{ r.receivingQty ?? '--' }}</template>
<el-option </el-table-column>
v-for="o in ENTRY_ORDER_STATUS_OPTIONS" <el-table-column label="收货箱数" width="80" align="center">
:key="o.value" <template #default="{ row: r }">{{ r.receivingBoxes ?? '--' }}</template>
:label="o.label" </el-table-column>
:value="o.value" <el-table-column label="入库应收" width="90" align="center">
/> <template #default="{ row: r }">{{ r.entryPlanQty ?? '--' }}</template>
</el-select> </el-table-column>
</el-form-item> <el-table-column label="入库实收" width="90" align="center">
<el-form-item> <template #default="{ row: r }">{{ r.entryReceivedQty ?? '--' }}</template>
<el-button type="primary" :loading="matchEntryListLoading" @click="fetchMatchEntryList">查询</el-button> </el-table-column>
</el-form-item> <el-table-column label="匹配" width="70" align="center">
</el-form> <template #default="{ row: r }">
<el-tag size="small" :type="r.matched ? 'success' : 'info'">
<el-table {{ r.matched ? '已匹配' : '未匹配' }}
ref="matchEntryTableRef" </el-tag>
:data="matchEntryList" </template>
v-loading="matchEntryListLoading" </el-table-column>
max-height="380" </el-table>
border
size="small"
row-key="id"
@selection-change="onMatchEntrySelectionChange"
>
<el-table-column type="selection" width="48" />
<el-table-column prop="entry_order_code" label="入库单号" min-width="170" show-overflow-tooltip />
<el-table-column label="货主" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
{{ row.store_name || row.store?.store_remask || row.store?.name || '--' }}
</template>
</el-table-column>
<el-table-column label="入库状态" width="120" align="center">
<template #default="{ row }">
<el-tag size="small" :type="entryOrderStatusTag(row.order_status)">
{{ entryOrderStatusLabel(row.order_status) }}
</el-tag>
</template>
</el-table-column>
</el-table>
<div class="match-entry-pager">
<el-pagination
:current-page="matchEntryPagination.page"
:page-size="matchEntryPagination.pageSize"
:total="matchEntryPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
small
background
@current-change="handleMatchEntryPageChange"
@size-change="handleMatchEntryPageSizeChange"
/>
</div> </div>
</div> </div>
<template #footer> <template #footer>
<div class="match-putaway-footer"> <div class="match-putaway-footer">
<span class="match-selection-tip">已选 {{ matchEntrySelectedRows.length }} 条入库单</span> <span class="match-selection-tip">{{ matchSelectedEntryOrder ? '已选:' + matchSelectedEntryOrder.entry_order_code : '未选择入库单' }}</span>
<div> <div>
<el-button size="small" @click="matchPutawayDialogVisible = false">取消</el-button> <el-button size="small" @click="matchPutawayDialogVisible = false">取消</el-button>
<el-button <el-button
size="small" size="small"
type="primary" type="primary"
:loading="matchPutawaySubmitLoading" :loading="matchPutawaySubmitLoading"
:disabled="!matchEntrySelectedRows.length" :disabled="!matchSelectedEntryOrder"
@click="submitMatchPutaway" @click="submitMatchPutaway"
> >
确认匹配入库 确认匹配入库
@ -451,6 +443,9 @@ async function loadData() {
const where = currentCondition.value || {} const where = currentCondition.value || {}
// console.log('当前筛选条件:', where) // console.log('当前筛选条件:', where)
// 固定条件:入库状态只显示待入库或部分入库(始终强制,不受预设或用户筛选覆盖)
where.storage_status = { operator: 'in', value: ['none', 'partial'], type: 'select' }
const params: any = { const params: any = {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize }, pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where, where,
@ -964,12 +959,9 @@ async function submitRejectReceiving() {
/** 入库单列表 order_status,与 storage.entry.list 一致 */ /** 入库单列表 order_status,与 storage.entry.list 一致 */
const ENTRY_ORDER_STATUS_OPTIONS = [ const ENTRY_ORDER_STATUS_OPTIONS = [
{ label: '已创建', value: 'CREATED' },
{ label: '待入库', value: 'PENDING' }, { label: '待入库', value: 'PENDING' },
{ label: '入库中', value: 'PARTIAL' }, { label: '入库中', value: 'PARTIAL' },
{ label: '部分收货', value: 'PARTIAL_RECEIVED' }, { label: '部分收货', value: 'PARTIAL_RECEIVED' }
{ label: '已完成', value: 'COMPLETED' },
{ label: '已取消', value: 'CANCELLED' }
] ]
const matchPutawayDialogVisible = ref(false) const matchPutawayDialogVisible = ref(false)
@ -978,14 +970,129 @@ const matchPutawayContextHint = ref('')
const matchEntryList = ref<any[]>([]) const matchEntryList = ref<any[]>([])
const matchEntryListLoading = ref(false) const matchEntryListLoading = ref(false)
const matchEntryStoreOptions = ref<any[]>([]) const matchEntryStoreOptions = ref<any[]>([])
/** 货主筛选值,与选项 value 同类型(一般为 number) */
const matchEntryFilterStoreId = ref<number | string | undefined>(undefined)
const matchEntryFilterOrderStatus = ref('') const matchEntryFilterOrderStatus = ref('')
/** 货主筛选值(在 fetchMatchEntryList 中作为后端查询条件使用) */
const matchEntryFilterStoreId = ref<number | string | undefined>(undefined)
const matchEntryPagination = reactive({ page: 1, pageSize: 10, total: 0 }) const matchEntryPagination = reactive({ page: 1, pageSize: 10, total: 0 })
const matchEntrySelectedRows = ref<any[]>([])
const matchEntryTableRef = ref<any>(null) const matchEntryTableRef = ref<any>(null)
const matchPutawaySubmitLoading = ref(false) const matchPutawaySubmitLoading = ref(false)
// 对比视图相关
const matchReceivingDetails = ref<any[]>([])
const matchReceivingDetailsLoading = ref(false)
const matchSelectedEntryOrder = ref<any>(null)
const matchEntryDetails = ref<any[]>([])
const matchEntryDetailsLoading = ref(false)
type ComparisonRow = {
stockId: string
productName: string
barcode: string
itemCode: string
receivingQty: string | number
receivingBoxes: string | number
entryPlanQty: string | number
entryReceivedQty: string | number
matched: boolean
}
const matchComparisonRows = computed<ComparisonRow[]>(() => {
const receiving = matchReceivingDetails.value
const entries = matchEntryDetails.value
const stockMap = new Map<string, any>()
// 以入库单明细为主,建立 stock_id 索引
for (const e of entries) {
const sid = String(e.stock_id || e.item_id || e.item_code || '')
if (!sid) continue
stockMap.set(sid, { receiving: null, entry: e })
}
// 收货明细匹配到对应入库单明细
for (const r of receiving) {
const sid = String(r.system_product_id || r.stock_id || r.item_code || '')
if (!sid) continue
const existing = stockMap.get(sid)
if (existing) {
existing.receiving = r
} else {
stockMap.set(sid, { receiving: r, entry: null })
}
}
// 生成对比行:以入库单为主,确保所有入库单商品都显示
const rows: ComparisonRow[] = []
for (const e of entries) {
const sid = String(e.stock_id || e.item_id || e.item_code || '')
const pair = sid ? stockMap.get(sid) : null
const recv = pair?.receiving || null
rows.push({
stockId: sid || `e_${rows.length}`,
productName: e.item_name || recv?.product_name || '—',
barcode: recv?.barcode || '—',
itemCode: e.item_code || recv?.item_code || '—',
receivingQty: recv?.actual_quantity ?? '—',
receivingBoxes: recv?.box_quantity ?? '—',
entryPlanQty: e.count ?? e.plan_qty ?? '—',
entryReceivedQty: e.received_quantity ?? '—',
matched: !!recv
})
}
// 追加仅在收货明细中存在、入库单中没有的商品
for (const r of receiving) {
const sid = String(r.system_product_id || r.stock_id || r.item_code || '')
if (!sid) continue
const pair = stockMap.get(sid)
if (pair?.entry) continue // 已在上面处理
rows.push({
stockId: sid,
productName: r.product_name || r.item_name || '—',
barcode: r.barcode || '—',
itemCode: r.item_code || '—',
receivingQty: r.actual_quantity ?? '—',
receivingBoxes: r.box_quantity ?? '—',
entryPlanQty: '—',
entryReceivedQty: '—',
matched: false
})
}
return rows
})
const matchComparisonSummary = computed(() => {
const rows = matchComparisonRows.value
if (!rows.length) return { text: '无匹配商品', type: 'info' as const }
const matched = rows.filter(r => r.matched).length
if (matched === 0) return { text: '无匹配商品', type: 'danger' as const }
if (matched === rows.length) return { text: '全部一致', type: 'success' as const }
return { text: '部分一致', type: 'warning' as const }
})
async function onMatchEntrySelect(row: any) {
matchSelectedEntryOrder.value = row
matchEntryDetails.value = []
if (!row?.id) return
matchEntryDetailsLoading.value = true
try {
const res: any = await entryApi.getEntryDetail({ id: row.id })
if (res && res.code === 200 && res.data?.entryOrder) {
const entryOrder = res.data.entryOrder
const items = entryOrder.items || []
matchEntryDetails.value = items.map((item: any) => ({
...item,
item_name: item.stock?.item_name || item.item_name || '',
item_code: item.item_code || item.stock?.item_code || '',
stock_id: item.stock_id || item.stock?.id || '',
count: item.count ?? item.plan_qty ?? 0,
received_quantity: item.received_quantity ?? item.confirm_quantity ?? 0
}))
} else {
matchEntryDetails.value = []
}
} catch {
matchEntryDetails.value = []
} finally {
matchEntryDetailsLoading.value = false
}
}
function entryOrderStatusLabel(status: string) { function entryOrderStatusLabel(status: string) {
const o = ENTRY_ORDER_STATUS_OPTIONS.find(i => i.value === status) const o = ENTRY_ORDER_STATUS_OPTIONS.find(i => i.value === status)
return o?.label || status || '--' return o?.label || status || '--'
@ -1003,6 +1110,11 @@ function entryOrderStatusTag(status: string) {
return map[status] || 'info' return map[status] || 'info'
} }
function entrySourceLabel(sourceType: string) {
const map: Record<string, string> = { QM: '奇门', API: '接口', WMS: '系统' }
return map[sourceType] || sourceType || '—'
}
/** /**
* 将 index.loadStores / ScanBox 等处的货主项统一为下拉可用的 { value, label }。 * 将 index.loadStores / ScanBox 等处的货主项统一为下拉可用的 { value, label }。
* 兼容 { value, label }、{ id, store_remask }、{ store_id, store_name } 等形态。 * 兼容 { value, label }、{ id, store_remask }、{ store_id, store_name } 等形态。
@ -1049,11 +1161,13 @@ function resetMatchPutawayDialog() {
matchPutawayReceivingRow.value = null matchPutawayReceivingRow.value = null
matchPutawayContextHint.value = '' matchPutawayContextHint.value = ''
matchEntryList.value = [] matchEntryList.value = []
matchEntrySelectedRows.value = []
matchEntryFilterStoreId.value = undefined matchEntryFilterStoreId.value = undefined
matchEntryFilterOrderStatus.value = '' matchEntryFilterOrderStatus.value = ''
matchEntryPagination.page = 1 matchEntryPagination.page = 1
matchEntryPagination.total = 0 matchEntryPagination.total = 0
matchReceivingDetails.value = []
matchSelectedEntryOrder.value = null
matchEntryDetails.value = []
} }
async function openMatchPutawayDialog(row: any) { async function openMatchPutawayDialog(row: any) {
@ -1061,43 +1175,43 @@ async function openMatchPutawayDialog(row: any) {
ElMessage.warning('缺少收货单信息') ElMessage.warning('缺少收货单信息')
return return
} }
const sid = row.store_id
if (sid == null || sid === '' || !Number.isFinite(Number(sid))) {
ElMessage.warning('该收货单未设置货主,请先在详情中设置货主后再匹配入库')
return
}
matchPutawayReceivingRow.value = row matchPutawayReceivingRow.value = row
matchPutawayContextHint.value = `收货单:${row.receiving_number || row.id}` matchPutawayContextHint.value = `收货单:${row.receiving_number || row.id}`
matchPutawayDialogVisible.value = true matchPutawayDialogVisible.value = true
await ensureMatchEntryStores() matchEntryList.value = []
const sid = row.store_id matchEntryFilterStoreId.value = Number(sid)
if (sid != null && sid !== '') {
const n = Number(sid)
matchEntryFilterStoreId.value = Number.isFinite(n) ? n : sid
} else {
matchEntryFilterStoreId.value = undefined
}
matchEntryFilterOrderStatus.value = '' matchEntryFilterOrderStatus.value = ''
matchEntryPagination.page = 1 matchEntryPagination.page = 1
matchEntrySelectedRows.value = [] matchSelectedEntryOrder.value = null
matchEntryDetails.value = []
// 加载收货明细
matchReceivingDetailsLoading.value = true
try {
const res: any = await receivingApi.getReceivingDetail({
id: row.id,
pagination: { page: 1, pageSize: 1000 }
})
if (res && res.code === 200 && res.data) {
const d = res.data.receiving || {}
matchReceivingDetails.value = Array.isArray(d.details) ? d.details
: Array.isArray(res.data.list) ? res.data.list
: Array.isArray(res.data.details) ? res.data.details : []
} else {
matchReceivingDetails.value = []
}
} catch {
matchReceivingDetails.value = []
} finally {
matchReceivingDetailsLoading.value = false
}
await fetchMatchEntryList() await fetchMatchEntryList()
} }
function onMatchEntryFilterChange() {
matchEntryPagination.page = 1
fetchMatchEntryList()
}
function handleMatchEntryPageChange(page: number) {
matchEntryPagination.page = page
fetchMatchEntryList()
}
function handleMatchEntryPageSizeChange(size: number) {
matchEntryPagination.pageSize = size
matchEntryPagination.page = 1
fetchMatchEntryList()
}
function onMatchEntrySelectionChange(rows: any[]) {
matchEntrySelectedRows.value = rows || []
}
async function fetchMatchEntryList() { async function fetchMatchEntryList() {
matchEntryListLoading.value = true matchEntryListLoading.value = true
try { try {
@ -1118,6 +1232,13 @@ async function fetchMatchEntryList() {
value: matchEntryFilterOrderStatus.value, value: matchEntryFilterOrderStatus.value,
type: 'text' type: 'text'
} }
} else {
// 未选择时固定过滤:只显示待入库/入库中/部分收货
where.order_status = {
operator: 'in',
value: ['PENDING', 'PARTIAL', 'PARTIAL_RECEIVED'],
type: 'select'
}
} }
const res: any = await entryApi.getEntryList({ const res: any = await entryApi.getEntryList({
pagination: { pagination: {
@ -1142,8 +1263,7 @@ async function fetchMatchEntryList() {
} finally { } finally {
matchEntryListLoading.value = false matchEntryListLoading.value = false
await nextTick() await nextTick()
matchEntryTableRef.value?.clearSelection?.() matchEntryTableRef.value?.setCurrentRow?.(undefined)
matchEntrySelectedRows.value = []
} }
} }
@ -1154,16 +1274,16 @@ async function submitMatchPutaway() {
ElMessage.warning('缺少收货单ID') ElMessage.warning('缺少收货单ID')
return return
} }
const ids = matchEntrySelectedRows.value const entry = matchSelectedEntryOrder.value
.map((r: any) => Number(r.id)) if (!entry?.id) {
.filter((id: number) => Number.isFinite(id) && id > 0) ElMessage.warning('请选择一条入库单')
if (!ids.length) {
ElMessage.warning('请至少选择一条入库单')
return return
} }
const entryId = Number(entry.id)
if (!Number.isFinite(entryId) || entryId <= 0) return
try { try {
await ElMessageBox.confirm( await ElMessageBox.confirm(
`将对收货单「${row?.receiving_number || receivingId}」与已选的 ${ids.length} 条入库单执行匹配入库(按 SKU 数量匹配)。确定继续?`, `将对收货单「${row?.receiving_number || receivingId}」与入库单「${entry.entry_order_code || entryId}」执行匹配入库(按 SKU 数量匹配)。确定继续?`,
'确认匹配入库', '确认匹配入库',
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
) )
@ -1174,7 +1294,7 @@ async function submitMatchPutaway() {
try { try {
const res: any = await inventoryApi.matchPutaway({ const res: any = await inventoryApi.matchPutaway({
receiving_ids: [receivingId], receiving_ids: [receivingId],
entry_order_ids: ids entry_order_ids: [entryId]
}) })
if (res && (res.code === 200 || res.flag === 'success' || res.status === 'success')) { if (res && (res.code === 200 || res.flag === 'success' || res.status === 'success')) {
ElMessage.success(res.message || '匹配入库已提交') ElMessage.success(res.message || '匹配入库已提交')
@ -1519,29 +1639,47 @@ async function handleExport() {
} }
.match-putaway-dialog {
display: flex;
height: 65vh;
gap: 12px;
}
.match-left-panel {
width: 300px;
flex-shrink: 0;
display: flex;
flex-direction: column;
min-height: 0;
:deep(.el-table) { height: 100%; }
}
.match-right-panel {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
}
.match-right-panel > .el-table {
flex: 1;
}
.match-panel-title {
font-size: 13px;
font-weight: 600;
color: #303133;
margin-bottom: 6px;
flex-shrink: 0;
}
.match-putaway-dialog .match-hint { .match-putaway-dialog .match-hint {
margin: 0 0 8px; margin: 0 0 8px;
font-size: 13px; font-size: 13px;
color: #606266; color: #606266;
} }
.match-putaway-dialog .match-desc {
margin: 0 0 12px;
font-size: 12px;
color: #909399;
line-height: 1.5;
}
.match-entry-filters {
margin-bottom: 12px;
}
.match-entry-pager {
margin-top: 12px;
display: flex;
justify-content: flex-end;
}
.match-putaway-footer { .match-putaway-footer {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -136,7 +136,10 @@ export const availableFields = [
}, },
{ value: 'status', label: '收货状态', type: 'select', options: Object.entries(statusConfig).map(([v, c]) => ({ value: v, label: c.text })) }, { value: 'status', label: '收货状态', type: 'select', options: Object.entries(statusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
{ value: 'detail_status', label: '匹配状态', type: 'select', options: Object.entries(detailStatusConfig).map(([v, c]) => ({ value: v, label: c.text })) }, { value: 'detail_status', label: '匹配状态', type: 'select', options: Object.entries(detailStatusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
{ value: 'storage_status', label: '入库状态', type: 'select', options: Object.entries(storageStatusConfig).map(([v, c]) => ({ value: v, label: c.text })) }, { value: 'storage_status', label: '入库状态', type: 'select', options: [
{ value: 'none', label: '待入库' },
{ value: 'partial', label: '部分入库' }
] },
{ {
value: 'is_review', value: 'is_review',
label: '审核状态', label: '审核状态',