fix(frontend): 出库单审核/推送后提示并刷新整单
- audit / push 走服务后按动作给出对应提示(审核成功进入推送队列、已推送仓库) - 状态流转后重新拉取单据详情,刷新 pushed_at 与 wms_push_result 展示
This commit is contained in:
parent
5329aa8003
commit
09a5d31220
@ -215,14 +215,22 @@ async function transit(action: 'audit' | 'push' | 'complete' | 'cancel' | 'resto
|
||||
transiting.value = true
|
||||
try {
|
||||
const id = currentOrder.value.id
|
||||
if (action === 'audit') await outboundOrderApi.audit(id)
|
||||
else if (action === 'push') await outboundOrderApi.push(id)
|
||||
else if (action === 'complete') await outboundOrderApi.complete(id)
|
||||
if (action === 'audit') {
|
||||
await outboundOrderApi.audit(id)
|
||||
ElMessage.success('审核成功,已进入推送队列,稍后自动推送仓库')
|
||||
} else if (action === 'push') {
|
||||
await outboundOrderApi.push(id)
|
||||
ElMessage.success('已推送仓库')
|
||||
} else if (action === 'complete') await outboundOrderApi.complete(id)
|
||||
else if (action === 'cancel') await outboundOrderApi.cancel(id)
|
||||
else if (action === 'restore') await outboundOrderApi.restore(id)
|
||||
ElMessage.success('操作成功')
|
||||
if (action !== 'audit' && action !== 'push') ElMessage.success('操作成功')
|
||||
const map: Record<string, number> = { audit: 2, push: 3, complete: 4, cancel: 9, restore: 1 }
|
||||
if (currentOrder.value) currentOrder.value.status = map[action]
|
||||
// 重新拉取整单:自动/手动推送会写 pushed_at 与 wms_push_result,需刷新推送结果面板
|
||||
if (currentOrder.value) {
|
||||
await outboundOrderApi.get(id).then(r => { currentOrder.value = r }).catch(() => {})
|
||||
}
|
||||
await fetchItems()
|
||||
await fetchList()
|
||||
} catch {
|
||||
@ -337,6 +345,21 @@ const editTotal = computed(() =>
|
||||
)
|
||||
/** 明细锁定:仅「待出库(1)」可增删改明细,已审核及之后锁定(需先驳回) */
|
||||
const itemsLocked = computed(() => !!currentOrder.value && currentOrder.value.status !== 1)
|
||||
/** 推送失败原因(自动推送失败会退回「待出库」,列表上用感叹号提示,鼠标悬浮看原因) */
|
||||
function pushFailTip(row: OutboundOrder) {
|
||||
const result = row.wms_push_result
|
||||
if (!result || result.success !== false) return ''
|
||||
const kindMap: Record<string, string> = {
|
||||
timeout: `连续 ${result.attempts || 1} 次无响应/超时`,
|
||||
business: '仓库明确拒绝',
|
||||
insufficient_stock: '库存不足',
|
||||
lock_failed: '库存锁定失败',
|
||||
empty_items: '单据无明细',
|
||||
}
|
||||
const kind = kindMap[String(result.failureKind)] || '推送异常'
|
||||
const detail = result.message || result.error || ''
|
||||
return `推送失败(${kind}):${detail}`
|
||||
}
|
||||
// 始终保留一行空行在末尾,选商品填充后可继续往下添加
|
||||
function ensureTrailingEmptyRow() {
|
||||
const arr = editItems.value
|
||||
@ -497,9 +520,12 @@ onMounted(async () => {
|
||||
<el-table-column label="类型" width="110">
|
||||
<template #default="{ row }">{{ typeLabel(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90">
|
||||
<el-table-column label="状态" width="130">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="STATUS_TAGS[row.status]">{{ STATUS_LABELS[row.status] || row.status }}</el-tag>
|
||||
<el-tooltip v-if="pushFailTip(row)" :content="pushFailTip(row)" placement="top">
|
||||
<span class="push-fail">推送失败</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户" width="140">
|
||||
@ -535,7 +561,7 @@ onMounted(async () => {
|
||||
<el-table-column label="操作" width="300" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === 1" link type="primary" size="small" :disabled="transiting || !hasItems(row)" @click="transitRow('audit', row)">审核</el-button>
|
||||
<el-button v-if="row.status === 2" link type="primary" size="small" :disabled="transiting" @click="transitRow('push', row)">推送</el-button>
|
||||
<el-button v-if="row.status === 2" link type="primary" size="small" :disabled="transiting" @click="transitRow('push', row)">立即推送</el-button>
|
||||
<el-button v-if="row.status === 3" link type="primary" size="small" :disabled="transiting" @click="transitRow('complete', row)">完成</el-button>
|
||||
<el-button v-if="row.status === 9" link type="primary" size="small" :disabled="transiting" @click="transitRow('restore', row)">恢复</el-button>
|
||||
<el-button v-if="row.status === 2 || row.status === 3" link type="warning" size="small" :disabled="transiting" @click="handleReject(row)">驳回</el-button>
|
||||
@ -588,10 +614,10 @@ onMounted(async () => {
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废原因">{{ currentOrder.void_reason || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="status-actions">
|
||||
<el-tooltip :content="currentOrder.status !== 1 ? '仅「待出库」状态可以审核' : (!hasItems(currentOrder) ? '单据无明细,请先录入明细' : '')" :disabled="currentOrder.status === 1 && hasItems(currentOrder)">
|
||||
<el-tooltip :content="currentOrder.status !== 1 ? '仅「待出库」状态可以审核' : (!hasItems(currentOrder) ? '单据无明细,请先录入明细' : '审核后自动进入推送队列')" :disabled="currentOrder.status === 1 && hasItems(currentOrder)">
|
||||
<el-button size="small" :disabled="transiting || currentOrder.status !== 1 || !hasItems(currentOrder)" @click="transit('audit')">审核</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="currentOrder.status === 2 ? '' : '请先审核,仅「已审核」状态可推送到外部仓库'" :disabled="currentOrder.status === 2">
|
||||
<el-tooltip :content="currentOrder.status === 2 ? '审核后会自动推送,此处可立即推送一次' : '请先审核,仅「已审核」状态可推送到外部仓库'" :disabled="currentOrder.status === 2">
|
||||
<el-button size="small" type="primary" :disabled="transiting || currentOrder.status !== 2" @click="transit('push')">推送到外部仓库</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="currentOrder.status === 3 ? '' : '仅「已推送」状态可完成出库'" :disabled="currentOrder.status === 3">
|
||||
@ -922,6 +948,14 @@ onMounted(async () => {
|
||||
.lock-hint {
|
||||
color: #e6a23c;
|
||||
}
|
||||
/* 推送失败标记(自动推送失败会退回「待出库」,鼠标悬浮看原因) */
|
||||
.push-fail {
|
||||
margin-left: 4px;
|
||||
color: #f56c6c;
|
||||
font-size: 12px;
|
||||
cursor: help;
|
||||
border-bottom: 1px dashed #f56c6c;
|
||||
}
|
||||
.bottom-table-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user