|
|
|
@@ -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) {
|
|
|
|
|