This commit is contained in:
2026-09-04 14:38:08 +08:00
parent 01925fc134
commit 7db1d12aed
2 changed files with 3 additions and 20 deletions
@@ -367,12 +367,11 @@ describe('UnifiedOrdersView contract', () => {
expect(source).toContain("updateMeasurementSectionMode('actual', $event)")
expect(source).not.toContain("updateMeasurementSectionMode('outer', $event)")
expect(source.match(/@change="selectAndSaveOuterMeasurementMode\(\$event\)"/g)).toHaveLength(2)
expect(source).toContain('@visible-change="handleOuterModeDropdownVisibleChange($event)"')
expect(source).not.toContain('@visible-change="handleOuterModeDropdownVisibleChange($event)"')
expect(source.match(/:disabled="Boolean\(measurementStrategySavingId\) \|\| !can\('platform:firstleg:inbound:measure:edit'\)"/g)).toHaveLength(2)
expect(source).toContain('const previousMode = measurementSectionModes.outer')
expect(source).toContain('if (!saved) measurementSectionModes.outer = previousMode')
expect(source).toContain('const selectedSameMode = outerModeAtDropdownOpen.value === measurementSectionModes.outer')
expect(source).toContain('await nextTick()')
expect(source).not.toContain('handleOuterModeDropdownVisibleChange')
expect(source).toContain('const saved = await updateMeasurementCalculationMode(null, mode, ruleId)')
expect(source).toContain('calculatedMeasurementRow(row, measurementSectionModes.customer, true)')
expect(source).toContain('calculatedMeasurementRow(source, measurementSectionModes.outer)')
@@ -188,7 +188,6 @@ type MeasurementCalculationMode = 'ACTUAL' | 'ADD' | 'MULTIPLY'
const measurementSectionModes = reactive<Record<MeasurementSection, MeasurementCalculationMode>>({
customer: 'ACTUAL', outer: 'ACTUAL', actual: 'ACTUAL',
})
const outerModeAtDropdownOpen = ref<MeasurementCalculationMode | null>(null)
const cargoImagePreviewUrls = new Set<string>()
const measurementDialogOpen = ref(false)
const openWarehouseSuggestionOnMeasurementLoad = ref(false)
@@ -463,21 +462,6 @@ async function selectAndSaveOuterMeasurementMode(mode: MeasurementCalculationMod
if (!saved) measurementSectionModes.outer = previousMode
}
async function handleOuterModeDropdownVisibleChange(visible: boolean) {
if (visible) {
outerModeAtDropdownOpen.value = measurementSectionModes.outer
return
}
// Element Plus may emit dropdown-close before change. Wait until the change handler has
// updated the mode/saving state, otherwise one click can submit both the old and new mode.
await nextTick()
const selectedSameMode = outerModeAtDropdownOpen.value === measurementSectionModes.outer
outerModeAtDropdownOpen.value = null
if (selectedSameMode && !measurementStrategySavingId.value) {
void selectAndSaveOuterMeasurementMode(measurementSectionModes.outer)
}
}
async function waitForSavedMeasurementVersion(tenantId: string, inboundId: string, savedVersion: number) {
for (let attempt = 0; attempt < 6; attempt += 1) {
try {
@@ -2143,7 +2127,7 @@ onBeforeUnmount(() => {
</section>
<div class="measurement-rule-selector">
<span class="measurement-rule-selector__label">箱规计算规则选择</span>
<el-select class="measurement-rule-selector__control" :model-value="measurementSectionModes.outer" aria-label="外箱规数据计算方式" :loading="Boolean(measurementStrategySavingId)" :disabled="Boolean(measurementStrategySavingId) || !can('platform:firstleg:inbound:measure:edit')" @change="selectAndSaveOuterMeasurementMode($event)" @visible-change="handleOuterModeDropdownVisibleChange($event)">
<el-select class="measurement-rule-selector__control" :model-value="measurementSectionModes.outer" aria-label="外箱规数据计算方式" :loading="Boolean(measurementStrategySavingId)" :disabled="Boolean(measurementStrategySavingId) || !can('platform:firstleg:inbound:measure:edit')" @change="selectAndSaveOuterMeasurementMode($event)">
<el-option label="实测原尺寸(不调整)" value="ACTUAL" />
<el-option label="箱规尺寸" value="ADD" />
<el-option label="箱规系数" value="MULTIPLY" :disabled="multiplyModeDisabled" />