装柜优化

This commit is contained in:
2026-08-11 14:23:46 +08:00
parent 8a8c5a3faa
commit ef35a1be2e
7 changed files with 38 additions and 16 deletions
@@ -102,7 +102,7 @@ function formatNumber(value?: number | null, digits = 3) {
</section>
</template>
<div v-if="mode === 'preload' && canEdit && summary.status === 'LOADING'" class="detail-actions">
<div v-if="mode === 'preload' && canEdit && ['EDITING', 'LOADING'].includes(summary.status)" class="detail-actions">
<el-button type="primary" @click="emit('edit')"><Pencil :size="16" />编辑运输信息</el-button>
</div>
<el-alert v-else-if="mode === 'confirmed'" type="info" :closable="false" show-icon title="装柜完成后清单、明细和运输信息永久只读" />
@@ -34,7 +34,7 @@ describe('LoadingListsView', () => {
})
it('only exposes transport editing for LOADING preload details', () => {
expect(detailSource).toContain("mode === 'preload' && canEdit && summary.status === 'LOADING'")
expect(detailSource).toContain("mode === 'preload' && canEdit && ['EDITING', 'LOADING'].includes(summary.status)")
expect(detailSource).toContain('装柜完成后清单、明细和运输信息永久只读')
expect(source).toContain('expectedVersion: detail.value.summary.version')
})
@@ -50,7 +50,7 @@ describe('LoadingListsView', () => {
})
it('exposes a row edit action only for loading preload plans', () => {
expect(source).toContain("isPreload && canEdit && row.status === 'LOADING'")
expect(source).toContain("isPreload && canEdit && ['EDITING', 'LOADING'].includes(row.status)")
expect(source).toContain('openEditFromRow(row)')
expect(source).toContain('await loadDetail()')
})
@@ -65,7 +65,7 @@ describe('LoadingListsView', () => {
expect(source).toContain('useRoute()')
expect(source).toContain('route.query.planId')
expect(source).toContain('route.query.warehouseId')
expect(source).toContain("const expectedStatus = isPreload.value ? 'LOADING' : 'COMPLETED'")
expect(source).toContain("const expectedStatuses = isPreload.value ? ['EDITING', 'LOADING'] : ['COMPLETED']")
expect(source).toContain('MODE_STATUS_MISMATCH')
})
@@ -159,9 +159,9 @@ async function openDeepLinkedDetail() {
detailError.value = null
detailOpen.value = true
await loadDetail()
const expectedStatus = isPreload.value ? 'LOADING' : 'COMPLETED'
const expectedStatuses = isPreload.value ? ['EDITING', 'LOADING'] : ['COMPLETED']
const loadedDetail = detail.value as LoadingDetail | null
if (loadedDetail && loadedDetail.summary.status !== expectedStatus) {
if (loadedDetail && !expectedStatuses.includes(loadedDetail.summary.status)) {
detail.value = null
detailError.value = {
code: 'MODE_STATUS_MISMATCH',
@@ -211,7 +211,7 @@ function openDetail(rowValue: object) {
async function openEditFromRow(rowValue: object) {
const row = rowValue as LoadingListSummary
if (!isPreload.value || !canEdit.value || row.status !== 'LOADING') return
if (!isPreload.value || !canEdit.value || !['EDITING', 'LOADING'].includes(row.status)) return
selectedPlanId.value = String(row.planId)
selectedWarehouseId.value = String(row.warehouseId || '')
detail.value = null
@@ -219,11 +219,11 @@ async function openEditFromRow(rowValue: object) {
detailOpen.value = true
await loadDetail()
const loadedDetail = detail.value as LoadingDetail | null
if (loadedDetail && loadedDetail.summary.status === 'LOADING') openEdit()
if (loadedDetail && ['EDITING', 'LOADING'].includes(loadedDetail.summary.status)) openEdit()
}
function openEdit() {
if (!detail.value || !('preloadNo' in detail.value.summary) || detail.value.summary.status !== 'LOADING') return
if (!detail.value || !('preloadNo' in detail.value.summary) || !['EDITING', 'LOADING'].includes(detail.value.summary.status)) return
editForm.containerNo = detail.value.summary.containerNo || ''
editForm.voyageNo = detail.value.summary.voyageNo || ''
editForm.operationReason = ''
@@ -306,7 +306,7 @@ onMounted(() => {
>
<template #actions="{ row }">
<el-button v-if="canView" link type="primary" @click="openDetail(row)"><Eye :size="15" />查看</el-button>
<el-button v-if="isPreload && canEdit && row.status === 'LOADING'" link type="primary" @click="openEditFromRow(row)"><Pencil :size="15" />编辑</el-button>
<el-button v-if="isPreload && canEdit && ['EDITING', 'LOADING'].includes(row.status)" link type="primary" @click="openEditFromRow(row)"><Pencil :size="15" />编辑</el-button>
</template>
<template #customers="{ row }">{{ (row as PreloadSummary).customers.map((item) => item.customerName || item.accountId).join('、') || '—' }}</template>
<template #vesselVoyage="{ row }">{{ (row as PreloadSummary).vesselName || '—' }} / {{ (row as PreloadSummary).voyageNo || '—' }}</template>