This commit is contained in:
2026-08-17 18:32:41 +08:00
parent d14d0dcb61
commit 822b285312
17 changed files with 133 additions and 53 deletions
@@ -160,6 +160,7 @@ describe('WeightOcrPanel confirmation behavior', () => {
const wrapper = mountPanel()
await flushPromises()
await wrapper.find('.pallet-picker .el-select').trigger('click')
expect(document.body.textContent).toContain('木托盘 · 皮重 12.000 KG · 容量 1.2 m³')
await new DOMWrapper(document.body).find('.el-select-dropdown__item').trigger('click')
const input = wrapper.get('input[type="file"]')
const file = new File(['image'], 'weight.jpg', { type: 'image/jpeg' })
@@ -53,6 +53,13 @@ describe('WeightOcrPanel contract', () => {
expect(source).toContain("option.palletType || '未记录类型'")
})
it('keeps pallet type, tare weight, and capacity in one select line', () => {
expect(source).toContain(':label="palletOptionLabel(option)"')
expect(source).toContain("`${option.palletType || '未记录类型'} · 皮重 ${formatWeight(option.tareWeightKg)} · 容量 ${option.capacityCbm} m³`")
expect(source).not.toContain('<small v-if="selectedPallet">')
expect(source).toContain('width: clamp(360px, 36vw, 520px)')
})
it('gates every action with the implemented permissions and editable statuses', () => {
expect(source).toContain("platform:firstleg:inbound:measure:view")
expect(source).toContain("platform:firstleg:inbound:weight:edit")
@@ -61,7 +61,6 @@ const canConfirm = computed(() => access.can('platform:firstleg:inbound:weight:c
const canView = computed(() => access.can('platform:firstleg:inbound:measure:view'))
const editable = computed(() => Boolean(workspace.value && editableStatuses.has(workspace.value.processStatus)))
const rows = computed(() => workspace.value?.weightResults ?? [])
const selectedPallet = computed(() => palletOptions.value.find((option) => option.palletId === selectedPalletId.value) ?? null)
const previewResult = computed(() => rows.value.find((row) => row.id === previewResultId.value)
|| previewSnapshot.value)
const previewConfirmDisabled = computed(() => {
@@ -75,6 +74,10 @@ function formatWeight(value: number | null, unit = 'KG') {
return value == null ? '—' : `${Number(value).toFixed(3)} ${unit}`
}
function palletOptionLabel(option: WeightPalletOption) {
return `${option.palletType || '未记录类型'} · 皮重 ${formatWeight(option.tareWeightKg)} · 容量 ${option.capacityCbm} m³`
}
function actionKey(action: string, id: string) {
return `${action}:${id}`
}
@@ -400,11 +403,10 @@ defineExpose({ reload: loadWorkspace })
<el-option
v-for="option in palletOptions"
:key="option.palletId"
:label="option.palletType || '未记录类型'"
:label="palletOptionLabel(option)"
:value="option.palletId"
/>
</el-select>
<small v-if="selectedPallet">皮重 {{ formatWeight(selectedPallet.tareWeightKg) }} · 容量 {{ selectedPallet.capacityCbm }} m³</small>
</div>
<input
ref="fileInput"
@@ -570,15 +572,15 @@ defineExpose({ reload: loadWorkspace })
.weight-heading h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.weight-heading h3 svg { color: var(--cc-primary); }
.weight-heading__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 16px; }
.pallet-picker { display: grid; min-width: 260px; gap: 4px; }
.pallet-picker small { color: var(--cc-muted); font-size: 11px; line-height: 1.4; }
.pallet-picker { width: clamp(360px, 36vw, 520px); min-width: 0; }
.pallet-picker :deep(.el-select) { width: 100%; }
.weight-summary { display: grid; gap: 2px; text-align: right; }
.weight-summary span { color: var(--cc-muted); font-size: 12px; }
.weight-summary strong { color: #067647; font-size: 18px; }
.visually-hidden-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.weight-state-note, .weight-action-error { margin-bottom: 14px; }
.weight-list { min-height: 0; margin-top: 14px; }
.weight-empty { display: flex; min-height: 0; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 4px; background: var(--cc-surface-muted); color: var(--cc-muted); }
.weight-empty { display: flex; min-height: 0; align-items: center; gap: 10px; padding: 4px 0 0; color: var(--cc-muted); }
.weight-empty strong { color: #344054; font-size: 14px; }
.weight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.weight-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--cc-border); border-radius: 6px; background: #fff; }