优化
This commit is contained in:
@@ -652,7 +652,23 @@ async function exportCustomers() {
|
||||
if (openDownloadCenter) await router.push({ name: 'download-center' })
|
||||
}
|
||||
|
||||
async function openRouteEditor(editId: string) {
|
||||
if (!editId || !access.can('platform:customer:edit')) return
|
||||
const row = result.value.records.find((item) => String(item.id) === editId)
|
||||
try {
|
||||
await openEdit(row ?? await getPlatformTenant(editId))
|
||||
} catch (error) {
|
||||
ElMessage.error(getApiErrorMessage(error, '客户资料加载失败'))
|
||||
}
|
||||
if (route.query.edit === editId) void router.replace({ name: 'customers' })
|
||||
}
|
||||
|
||||
watch([page, pageSize], () => { void loadCustomers() })
|
||||
watch(
|
||||
() => typeof route.query.edit === 'string' ? route.query.edit : '',
|
||||
(editId) => { if (editId) void openRouteEditor(editId) },
|
||||
{ immediate: true },
|
||||
)
|
||||
watch(editorOpen, (open) => {
|
||||
if (!open) {
|
||||
editorLoadSequence += 1
|
||||
@@ -666,18 +682,7 @@ watch(
|
||||
},
|
||||
)
|
||||
onBeforeUnmount(clearQualificationPreviews)
|
||||
onMounted(async () => {
|
||||
await loadCustomers()
|
||||
const editId = typeof route.query.edit === 'string' ? route.query.edit : ''
|
||||
if (!editId || !access.can('platform:customer:edit')) return
|
||||
const row = result.value.records.find((item) => String(item.id) === editId)
|
||||
if (row) await openEdit(row)
|
||||
else {
|
||||
try { await openEdit(await getPlatformTenant(editId)) }
|
||||
catch (error) { ElMessage.error(getApiErrorMessage(error, '客户资料加载失败')) }
|
||||
}
|
||||
void router.replace({ name: 'customers' })
|
||||
})
|
||||
onMounted(() => { void loadCustomers() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user