优化
This commit is contained in:
@@ -54,6 +54,8 @@ describe('CarrierRatesView price-book source contract', () => {
|
||||
expect(source).toContain('海外仓映射')
|
||||
expect(source).toContain('originWarehouseCode')
|
||||
expect(source).toContain('sourceDestinationName')
|
||||
expect(source).toContain('autoSelectExactWarehouseMappings')
|
||||
expect(source).toContain("'DUPLICATE_RATE'")
|
||||
expect(source).not.toContain('tenantId')
|
||||
expect(source).not.toContain('客户选择')
|
||||
})
|
||||
|
||||
@@ -166,6 +166,7 @@ const mappingBlockingIssueCodes = new Set([
|
||||
'UNUSED_ORIGIN_MAPPING',
|
||||
'UNUSED_OVERSEAS_MAPPING',
|
||||
'DUPLICATE_WAREHOUSE_MAPPING',
|
||||
'DUPLICATE_RATE',
|
||||
])
|
||||
const nonMappingBlockingIssues = computed(() => (detail.value?.issues || []).filter((issue) => (
|
||||
issue.severity === 'BLOCKING' && !mappingBlockingIssueCodes.has(issue.issueCode)
|
||||
@@ -373,11 +374,42 @@ function resetMappings(value: PlatformPriceBookDetail) {
|
||||
overseasSelections.value = overseas
|
||||
}
|
||||
|
||||
function autoSelectExactWarehouseMappings() {
|
||||
const origins = { ...originSelections.value }
|
||||
const overseas = { ...overseasSelections.value }
|
||||
const usedOrigins = new Set(Object.values(origins))
|
||||
const usedOverseas = new Set(Object.values(overseas))
|
||||
|
||||
for (const row of originMappingRows.value) {
|
||||
if (origins[row.key]) continue
|
||||
const matches = domesticWarehouses.value.filter((warehouse) => originWarehouseMatches(row, warehouse))
|
||||
if (matches.length !== 1) continue
|
||||
const warehouseId = String(matches[0].id)
|
||||
if (!usedOrigins.has(warehouseId)) {
|
||||
origins[row.key] = warehouseId
|
||||
usedOrigins.add(warehouseId)
|
||||
}
|
||||
}
|
||||
for (const row of overseasMappingRows.value) {
|
||||
if (overseas[row.key]) continue
|
||||
const matches = overseasWarehouses.value.filter((warehouse) => overseasWarehouseMatches(row, warehouse))
|
||||
if (matches.length !== 1) continue
|
||||
const warehouseId = String(matches[0].id)
|
||||
if (!usedOverseas.has(warehouseId)) {
|
||||
overseas[row.key] = warehouseId
|
||||
usedOverseas.add(warehouseId)
|
||||
}
|
||||
}
|
||||
originSelections.value = origins
|
||||
overseasSelections.value = overseas
|
||||
}
|
||||
|
||||
function applyDetail(value: PlatformPriceBookDetail) {
|
||||
detail.value = value
|
||||
selectedVersionId.value = value.version.id
|
||||
selectedChannelCode.value = value.channels[0]?.channelCode || ''
|
||||
resetMappings(value)
|
||||
if (mappingWarehousesLoaded.value) autoSelectExactWarehouseMappings()
|
||||
}
|
||||
|
||||
async function loadMappingWarehouses(force = false) {
|
||||
@@ -390,6 +422,7 @@ async function loadMappingWarehouses(force = false) {
|
||||
if (sequence !== warehouseSequence) return false
|
||||
mappingWarehouses.value = result
|
||||
mappingWarehousesLoaded.value = true
|
||||
autoSelectExactWarehouseMappings()
|
||||
return true
|
||||
} catch (error) {
|
||||
if (sequence === warehouseSequence) {
|
||||
|
||||
@@ -181,7 +181,8 @@ describe('InboundOrdersView', () => {
|
||||
const wrapper = mountPage()
|
||||
await flushPromises()
|
||||
|
||||
await wrapper.findAll('button').find((button) => button.text().includes('打印箱唛'))?.trigger('click')
|
||||
;[...document.querySelectorAll<HTMLButtonElement>('button')]
|
||||
.filter((button) => button.textContent?.trim() === '打印箱唛').at(-1)?.click()
|
||||
await flushPromises()
|
||||
|
||||
expect(downloadInboundCartonLabels).toHaveBeenCalledWith('10002', '19001')
|
||||
|
||||
Reference in New Issue
Block a user