fix(admin): align loading history and pallet lookup

This commit is contained in:
2026-09-01 11:10:22 +08:00
parent 4711bcc4e6
commit e3ecba7133
8 changed files with 136 additions and 20 deletions
@@ -45,6 +45,7 @@ const fileInput = ref<HTMLInputElement>()
const workspace = ref<WeightWorkspaceResource | null>(null)
const palletOptions = ref<WeightPalletOption[]>([])
const selectedPalletId = ref('')
const palletKeyword = ref('')
const palletLoading = ref(false)
const palletError = ref<ApiErrorDetails | null>(null)
const loading = ref(false)
@@ -61,6 +62,7 @@ const weightDrafts = ref<Record<string, { value: number | null; unit: 'KG' | 'LB
let loadSequence = 0
let palletLoadSequence = 0
let palletAbortController: AbortController | null = null
const PALLET_OPTION_PAGE_SIZE = 50
const editableStatuses = new Set(['WAIT_MEASURE', 'MEASURING', 'MEASURE_REJECTED'])
const minimumWeight = { KG: 0.001, LB: 0.002 } as const
@@ -225,7 +227,7 @@ async function loadWorkspace() {
}
}
async function loadPalletOptions() {
async function loadPalletOptions(keyword = palletKeyword.value) {
if (!canLoadPalletOptions.value) {
cancelPalletOptionsLoad()
palletOptions.value = []
@@ -237,10 +239,16 @@ async function loadPalletOptions() {
const sequence = ++palletLoadSequence
const controller = new AbortController()
palletAbortController = controller
palletKeyword.value = keyword.trim()
palletLoading.value = true
palletError.value = null
try {
const result = await getWeightPalletOptions(customerId.value, props.inboundId, controller.signal)
const result = await getWeightPalletOptions(customerId.value, props.inboundId, {
page: 1,
size: PALLET_OPTION_PAGE_SIZE,
keyword: palletKeyword.value || undefined,
signal: controller.signal,
})
if (sequence !== palletLoadSequence || controller.signal.aborted) return
palletOptions.value = result.records
if (!result.records.some((option) => option.palletId === selectedPalletId.value)) selectedPalletId.value = ''
@@ -257,6 +265,14 @@ async function loadPalletOptions() {
}
}
function searchPalletOptions(keyword: string) {
void loadPalletOptions(keyword)
}
function reloadPalletOptions() {
void loadPalletOptions()
}
function cancelPalletOptionsLoad() {
++palletLoadSequence
palletAbortController?.abort()
@@ -417,6 +433,7 @@ watch(
workspace.value = null
palletOptions.value = []
selectedPalletId.value = ''
palletKeyword.value = ''
palletError.value = null
weightDrafts.value = {}
loadError.value = null
@@ -433,6 +450,7 @@ watch(
cancelPalletOptionsLoad()
palletOptions.value = []
selectedPalletId.value = ''
palletKeyword.value = ''
palletError.value = null
if (canLoadPalletOptions.value) void loadPalletOptions()
},
@@ -472,6 +490,8 @@ defineExpose({ reload: loadWorkspace })
aria-label="选择称重托盘"
placeholder="选择称重托盘"
filterable
remote
:remote-method="searchPalletOptions"
:loading="palletLoading"
:disabled="loading || uploading || !editable || !canEdit || Boolean(palletError)"
/>
@@ -519,7 +539,7 @@ defineExpose({ reload: loadWorkspace })
:loading="palletLoading"
compact
class="weight-action-error"
@retry="loadPalletOptions"
@retry="reloadPalletOptions"
>
<template #details><ApiErrorMeta :details="palletError" /></template>
</LoadErrorState>
@@ -531,7 +551,7 @@ defineExpose({ reload: loadWorkspace })
class="weight-action-error"
title="当前仓库暂无可选托盘,暂时不能上传称重图片。"
>
<el-button size="small" @click="loadPalletOptions"><RefreshCw :size="14" />重新加载</el-button>
<el-button size="small" @click="reloadPalletOptions"><RefreshCw :size="14" />重新加载</el-button>
</el-alert>
<div v-loading="loading" class="weight-list" aria-live="polite">
<div v-if="!loading && rows.length === 0" class="weight-empty">
@@ -566,6 +586,7 @@ defineExpose({ reload: loadWorkspace })
@click="openPreview(row)"
><strong>{{ cardWeight(row) }}</strong></button>
<dl class="weight-card__facts">
<div><dt>托盘编码</dt><dd :title="row.palletCode">{{ row.palletCode || '未记录编码' }}</dd></div>
<div><dt>托盘类型</dt><dd>{{ row.palletType || '未记录类型' }}</dd></div>
<div><dt>服务端确认毛重</dt><dd>{{ formatWeight(row.grossWeightKg) }}</dd></div>
<div><dt>托盘皮重</dt><dd>{{ formatWeight(row.palletTareWeightKg) }}</dd></div>