| | |
| | | createConfigSearchState, |
| | | getConfigPaginationKey, |
| | | getConfigTypeOptions, |
| | | normalizeConfigListRow |
| | | normalizeConfigListRow, |
| | | PROJECT_COPYRIGHT_FLAG, |
| | | PROJECT_LOGO_FLAG |
| | | } from './configPage.helpers' |
| | | |
| | | defineOptions({ name: 'Config' }) |
| | |
| | | selectedRows, |
| | | handleSelectionChange, |
| | | showDialog, |
| | | handleDialogSubmit, |
| | | closeDialog, |
| | | handleDelete, |
| | | handleBatchDelete |
| | | } = useCrudPage({ |
| | |
| | | }) |
| | | handleDeleteAction = handleDelete |
| | | |
| | | function notifyProjectLogoUpdated(payload) { |
| | | if (payload?.flag !== PROJECT_LOGO_FLAG) { |
| | | return |
| | | } |
| | | window.dispatchEvent(new CustomEvent('project-logo-updated', { detail: { url: payload.val } })) |
| | | } |
| | | |
| | | function notifyProjectCopyrightUpdated(payload) { |
| | | if (payload?.flag !== PROJECT_COPYRIGHT_FLAG) { |
| | | return |
| | | } |
| | | window.dispatchEvent( |
| | | new CustomEvent('project-copyright-updated', { detail: { text: payload.val } }) |
| | | ) |
| | | } |
| | | |
| | | async function handleDialogSubmit(formData) { |
| | | const payload = buildConfigSavePayload(formData) |
| | | try { |
| | | if (dialogType.value === 'edit') { |
| | | await fetchUpdateConfig(payload) |
| | | ElMessage.success(t('crud.messages.updateSuccess')) |
| | | closeDialog() |
| | | notifyProjectLogoUpdated(payload) |
| | | notifyProjectCopyrightUpdated(payload) |
| | | await refreshUpdate?.() |
| | | return |
| | | } |
| | | |
| | | await fetchSaveConfig(payload) |
| | | ElMessage.success(t('crud.messages.createSuccess')) |
| | | closeDialog() |
| | | notifyProjectLogoUpdated(payload) |
| | | notifyProjectCopyrightUpdated(payload) |
| | | await refreshCreate?.() |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || t('crud.messages.submitFailed')) |
| | | } |
| | | } |
| | | |
| | | function handleSearch(params) { |
| | | replaceSearchParams(buildConfigSearchParams(params)) |
| | | getData() |