This commit is contained in:
2026-10-20 14:52:22 +08:00
parent 64697276ec
commit 9b1dec75dd
18 changed files with 78 additions and 175 deletions
@@ -1,25 +0,0 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import { apiRequest } from '@/api/http'
interface Statistics { orderCount: number; skuCount: number; requestedPackages: number; actualPackages: number | null; requestedPieces: number | null; actualPieces: number | null; palletCount: number | null }
const props = defineProps<{ query: Record<string, unknown>; revision: number }>()
const statistics = ref<Statistics | null>(null)
const error = ref(false)
let generation = 0
/** 仅消费与列表已提交查询一致的全筛选统计,旧响应不得覆盖新查询。 */
watch(() => [props.query, props.revision], async () => {
const request = ++generation
statistics.value = null; error.value = false
try {
const result = await apiRequest<Statistics>({ method: 'GET', url: '/merchant/v1/last-leg/cargo-discards/statistics', params: props.query })
if (request === generation) statistics.value = result
} catch { if (request === generation) error.value = true }
}, { immediate: true })
/** 缺少商品或托盘事实时保留空值含义。 */
function quantity(value: number | null, unit: string) { return value == null ? '未记录 / 不适用' : `${value} ${unit}` }
</script>
<template>
<p aria-live="polite" class="discard-statistics" v-if="statistics">全筛选:{{ statistics.orderCount }} 票 · {{ statistics.skuCount }} 种 SKU · 申请 {{ statistics.requestedPackages }} 箱 · 已确认实际 {{ quantity(statistics.actualPackages, '箱') }} · 商品 {{ quantity(statistics.requestedPieces, '个') }} · 托盘 {{ quantity(statistics.palletCount, '托盘') }}</p>
<p v-else class="discard-statistics">{{ error ? '数量汇总加载失败,请重新查询' : '数量汇总加载中…' }}</p>
</template>
<style scoped>.discard-statistics{margin:10px 0;color:var(--muted);font-size:13px;line-height:1.6}</style>
@@ -1,30 +0,0 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import { getTransferQuantities, type TransferQuantityTotals } from '../api/transferQuantities'
const props = defineProps<{ query: Record<string, unknown> }>()
const data = ref<TransferQuantityTotals>()
const error = ref('')
let generation = 0
watch(() => JSON.stringify(props.query), async () => {
const current = ++generation
data.value = undefined; error.value = ''
try { const result = await getTransferQuantities(props.query); if (current === generation) data.value = result }
catch { if (current === generation) error.value = '转运数量汇总加载失败,请重新查询' }
}, { immediate: true })
</script>
<template>
<section class="transfer-quantity-panel" aria-label="仓储转运全筛选汇总">
<p v-if="error" role="alert">{{ error }}</p>
<template v-else-if="data">
<strong>全部筛选结果 · {{ data.orderCount }} 票</strong>
<span>预报:{{ data.declaredPieceCount ?? `未记录(已知 ${data.knownDeclaredPieceCount} 件,${data.unknownDeclaredOrderCount} 票未知)` }}{{ data.declaredPieceCount == null ? '' : ' 件' }} / {{ data.declaredCartonCount }} 箱</span>
<span>历史实收:{{ data.receivedPieceCount ?? `未记录(已知 ${data.knownReceivedPieceCount} 件,${data.unknownReceivedOrderCount} 票未知)` }}{{ data.receivedPieceCount == null ? '' : ' 件' }} / {{ data.receivedCartonCount }} 箱 / {{ data.receivedPalletCount }} 托</span>
<span>当前已清点 {{ data.availableCartonCount }} 箱 · 剩余 {{ data.remainingPalletCount }} 托 · 已出库 {{ data.shippedCartonCount }} 箱 / {{ data.shippedPalletCount }} 托(托盘可重叠)</span>
</template>
<span v-else>转运数量加载中…</span>
</section>
</template>
<style scoped>
.transfer-quantity-panel { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 16px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface, white); }
.transfer-quantity-panel p { margin: 0; }
</style>