优化
This commit is contained in:
@@ -56,6 +56,7 @@ const queryFields = computed<QueryField[]>(() => [
|
||||
},
|
||||
])
|
||||
let loadSequence = 0
|
||||
let editorLoadSequence = 0
|
||||
|
||||
const emptyForm = (): SavePlatformExpressCompanyRequest & { id: string } => ({
|
||||
id: '',
|
||||
@@ -161,6 +162,7 @@ function applyFilters(model: QueryModel) {
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
editorLoadSequence += 1
|
||||
Object.assign(form, emptyForm())
|
||||
captureBaseline()
|
||||
editorOpen.value = true
|
||||
@@ -184,13 +186,17 @@ function assignEditor(row: PlatformExpressCompanyResource) {
|
||||
}
|
||||
|
||||
async function openEdit(row: PlatformExpressCompanyResource) {
|
||||
const sequence = ++editorLoadSequence
|
||||
const id = String(row.id)
|
||||
const pending = new Set(editLoadingIds.value)
|
||||
pending.add(id)
|
||||
editLoadingIds.value = pending
|
||||
try {
|
||||
assignEditor(await getPlatformExpressCompany(row.id))
|
||||
const result = await getPlatformExpressCompany(row.id)
|
||||
if (sequence !== editorLoadSequence) return
|
||||
assignEditor(result)
|
||||
} catch (error) {
|
||||
if (sequence !== editorLoadSequence) return
|
||||
const details = getApiErrorDetails(error, '快递公司详情加载失败,请稍后重试')
|
||||
ElMessage.error(details.requestId ? `${details.message}(requestId: ${details.requestId})` : details.message)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user