This commit is contained in:
liufumingren 2026-06-11 09:01:58 +08:00
parent 2e68b59e60
commit a641265cf9

View File

@ -154,7 +154,7 @@
<el-dialog
v-model="weighingDialogVisible"
title="称重"
:title="weighingBeforeConfirm ? '称重(复核前)' : '称重'"
width="360px"
align-center
@closed="resetWeighingForm"
@ -1007,6 +1007,26 @@ const allItemsScanned = computed(() => {
})
})
/** 团购波次且所有商品一致(同款同码) */
const isAllSameProductInWave = computed(() => {
const order = selectedOrderRow.value as any
if (!order?._is_wave) return false
const stock = order?.stock || order?.stocks
if (!Array.isArray(stock) || stock.length <= 1) return false
const firstCode = String(stock[0]?.item_code || stock[0]?.barcode || '').trim()
if (!firstCode) return false
return stock.every((s: any) => String(s.item_code || s.barcode || '').trim() === firstCode)
})
// 团购同款全部扫完时自动弹出称重弹窗
watch(allItemsScanned, (scanned) => {
if (scanned && isAllSameProductInWave.value && !weighingDialogVisible.value && !confirmLoading.value) {
weighingBeforeConfirm.value = true
weighingForm.weight = null
weighingDialogVisible.value = true
}
})
/** 选中订单是否设置了拦截 */
const hasSelectedIntercept = computed(() => {
const order = selectedOrderRow.value as any
@ -1458,6 +1478,7 @@ async function handleConfirm() {
)
return
}
try {
await ElMessageBox.confirm(`确认对订单 ID ${id} 提交复核记录?`, '确认复核', {
type: 'warning'
@ -1465,6 +1486,13 @@ async function handleConfirm() {
} catch {
return
}
await doConfirm()
}
/** 执行复核确认(不含用户二次确认弹窗) */
async function doConfirm() {
const id = activeOrderId.value
if (id == null) return
confirmLoading.value = true
try {
// 团购波次:使用 wave_id;散单:使用 order_id
@ -1529,6 +1557,7 @@ onMounted(loadRecheckStationOptions)
// ─── 称重 ──────────────────────────────────────────────────────────────────
const weighingDialogVisible = ref(false)
const weighingSubmitting = ref(false)
const weighingBeforeConfirm = ref(false)
const weighingFormRef = ref<FormInstance>()
const weighingForm = reactive({ weight: null as number | null })
const weighingRules: FormRules = {
@ -1541,9 +1570,11 @@ const weighingRules: FormRules = {
function resetWeighingForm() {
weighingForm.weight = null
weighingFormRef.value?.clearValidate()
weighingBeforeConfirm.value = false
}
function openWeighingDialog() {
weighingBeforeConfirm.value = false
weighingForm.weight = null
weighingDialogVisible.value = true
}
@ -1567,6 +1598,20 @@ async function submitWeighing() {
if (ok) {
ElMessage.success(res?.message || '称重保存成功')
weighingDialogVisible.value = false
// 团购同款预称重模式:称重完成后继续复核确认
if (weighingBeforeConfirm.value) {
weighingBeforeConfirm.value = false
const id = activeOrderId.value
if (id == null || id <= 0) return
try {
await ElMessageBox.confirm(`称重已完成,确认对订单 ID ${id} 提交复核记录?`, '确认复核', {
type: 'warning'
})
} catch {
return
}
await doConfirm()
}
} else {
ElMessage.error(res?.message || '称重保存失败')
}