优化
This commit is contained in:
@@ -61,6 +61,7 @@ const actionLoadingIds = ref(new Set<string>())
|
||||
const formRef = ref<FormInstance>()
|
||||
let warehouseLoadSequence = 0
|
||||
let locationLoadSequence = 0
|
||||
let drawerLoadSequence = 0
|
||||
|
||||
const filters = ref<LocationFilters>({ warehouseId: '', zoneCode: '', locationCode: '', locationType: '', status: '' })
|
||||
const appliedFilters = ref<AppliedLocationFilters>({ warehouseId: '', zoneCode: '', locationCode: '', locationType: '', status: '' })
|
||||
@@ -335,6 +336,7 @@ async function loadDetail(row: PlatformLocationResource, mode: 'view' | 'edit')
|
||||
ElMessage.warning('仅支持编辑国内仓库位')
|
||||
return
|
||||
}
|
||||
const sequence = ++drawerLoadSequence
|
||||
const scope = recordScope(row)
|
||||
drawerMode.value = mode
|
||||
drawerOpen.value = true
|
||||
@@ -343,6 +345,7 @@ async function loadDetail(row: PlatformLocationResource, mode: 'view' | 'edit')
|
||||
detail.value = null
|
||||
try {
|
||||
const result = await getPlatformLocation(scope.warehouseId, row.id)
|
||||
if (sequence !== drawerLoadSequence || !drawerOpen.value) return
|
||||
detail.value = result
|
||||
if (mode === 'edit') {
|
||||
assignForm(result.location)
|
||||
@@ -350,9 +353,10 @@ async function loadDetail(row: PlatformLocationResource, mode: 'view' | 'edit')
|
||||
void formRef.value?.clearValidate()
|
||||
}
|
||||
} catch (error) {
|
||||
if (sequence !== drawerLoadSequence) return
|
||||
drawerError.value = getApiErrorDetails(error, '库位详情加载失败,请稍后重试')
|
||||
} finally {
|
||||
drawerLoading.value = false
|
||||
if (sequence === drawerLoadSequence) drawerLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,6 +479,13 @@ watch(
|
||||
)
|
||||
|
||||
watch([page, pageSize], () => { void loadLocations() })
|
||||
watch(drawerOpen, (open) => {
|
||||
if (open) return
|
||||
drawerLoadSequence += 1
|
||||
drawerLoading.value = false
|
||||
drawerError.value = null
|
||||
detail.value = null
|
||||
})
|
||||
watch(() => form.warehouseId, (warehouseId) => {
|
||||
if (drawerMode.value !== 'create') return
|
||||
const warehouse = warehouses.value.find((item) => String(item.id) === warehouseId)
|
||||
|
||||
Reference in New Issue
Block a user