| | |
| | | <ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData"> |
| | | <template #left> |
| | | <ElSpace wrap> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>{{ t('pages.system.dictType.buttons.add') }}</ElButton> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>{{ |
| | | t('pages.system.dictType.buttons.add') |
| | | }}</ElButton> |
| | | <ElButton |
| | | v-auth="'delete'" |
| | | type="danger" |
| | |
| | | v-ripple |
| | | > |
| | | {{ t('common.actions.batchDelete') }} |
| | | </ElButton> |
| | | <ElButton |
| | | v-auth="'query'" |
| | | :loading="exportLoading" |
| | | :disabled="loading || exportLoading" |
| | | @click="handleExport" |
| | | v-ripple |
| | | > |
| | | {{ t('common.actions.export') }} |
| | | </ElButton> |
| | | </ElSpace> |
| | | </template> |
| | |
| | | :loading="detailLoading" |
| | | :detail-data="detailData" |
| | | /> |
| | | |
| | | <DictDataPanel |
| | | v-model:visible="dictDataPanelVisible" |
| | | :dict-type-data="currentManagedDictTypeData" |
| | | /> |
| | | </ElCard> |
| | | </div> |
| | | </template> |
| | |
| | | <script setup> |
| | | import { useI18n } from 'vue-i18n' |
| | | import { ElMessage } from 'element-plus' |
| | | import { useUserStore } from '@/store/modules/user' |
| | | import { useAuth } from '@/hooks/core/useAuth' |
| | | import { useTable } from '@/hooks/core/useTable' |
| | | import { useCrudPage } from '@/views/system/common/useCrudPage' |
| | | import { guardRequestWithMessage } from '@/utils/sys/requestGuard' |
| | | import { |
| | | fetchDeleteDictType, |
| | | fetchDictTypePage, |
| | | fetchExportDictTypeReport, |
| | | fetchGetDictTypeDetail, |
| | | fetchSaveDictType, |
| | | fetchUpdateDictType |
| | | } from '@/api/system-manage' |
| | | import DictDataPanel from './modules/dict-data-panel.vue' |
| | | import DictTypeDialog from './modules/dict-type-dialog.vue' |
| | | import DictTypeDetailDrawer from './modules/dict-type-detail-drawer.vue' |
| | | import { createDictTypeTableColumns } from './dictTypeTable.columns' |
| | |
| | | |
| | | const { t } = useI18n() |
| | | const { hasAuth } = useAuth() |
| | | const userStore = useUserStore() |
| | | const searchForm = ref(createDictTypeSearchState()) |
| | | const detailDrawerVisible = ref(false) |
| | | const detailLoading = ref(false) |
| | | const detailData = ref({}) |
| | | const dictDataPanelVisible = ref(false) |
| | | const currentManagedDictTypeData = ref(buildDictTypeDialogModel()) |
| | | const exportLoading = ref(false) |
| | | let handleDeleteAction = null |
| | | |
| | | const searchItems = computed(() => [ |
| | |
| | | } |
| | | }, |
| | | { |
| | | label: t('pages.system.dictType.table.description'), |
| | | key: 'description', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入字典描述' |
| | | } |
| | | }, |
| | | { |
| | | label: t('table.memo'), |
| | | key: 'memo', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入备注' |
| | | } |
| | | }, |
| | | { |
| | | label: t('table.status'), |
| | | key: 'status', |
| | | type: 'select', |
| | |
| | | { label: t('common.status.normal'), value: 1 }, |
| | | { label: t('common.status.frozen'), value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: '开始日期', |
| | | key: 'timeStart', |
| | | type: 'date', |
| | | props: { |
| | | clearable: true, |
| | | valueFormat: 'YYYY-MM-DD', |
| | | type: 'date' |
| | | } |
| | | }, |
| | | { |
| | | label: '结束日期', |
| | | key: 'timeEnd', |
| | | type: 'date', |
| | | props: { |
| | | clearable: true, |
| | | valueFormat: 'YYYY-MM-DD', |
| | | type: 'date' |
| | | } |
| | | } |
| | | ]) |
| | |
| | | } |
| | | } |
| | | |
| | | function openDictDataPanel(row) { |
| | | currentManagedDictTypeData.value = buildDictTypeDialogModel(row) |
| | | dictDataPanelVisible.value = true |
| | | } |
| | | |
| | | const { |
| | | columns, |
| | | columnChecks, |
| | |
| | | handleView: openDetail, |
| | | handleEdit: openEditDialog, |
| | | handleDelete: hasAuth('delete') ? (row) => handleDeleteAction?.(row) : null, |
| | | handleManageData: hasAuth('system:dictData:list') |
| | | ? (row) => openDictDataPanel(row) |
| | | : null, |
| | | t |
| | | }) |
| | | }, |
| | |
| | | }) |
| | | handleDeleteAction = handleDelete |
| | | |
| | | async function handleExport() { |
| | | exportLoading.value = true |
| | | try { |
| | | const response = await guardRequestWithMessage( |
| | | fetchExportDictTypeReport(buildDictTypeSearchParams(searchForm.value), { |
| | | headers: { |
| | | Authorization: userStore.accessToken || '' |
| | | } |
| | | }), |
| | | null, |
| | | { |
| | | timeoutMessage: '数据字典导出超时,已停止等待' |
| | | } |
| | | ) |
| | | if (!response) { |
| | | return |
| | | } |
| | | if (!response.ok) { |
| | | throw new Error(`导出失败,状态码:${response.status}`) |
| | | } |
| | | |
| | | const blob = await response.blob() |
| | | const downloadUrl = window.URL.createObjectURL(blob) |
| | | const link = document.createElement('a') |
| | | link.href = downloadUrl |
| | | link.download = 'dict-type.xlsx' |
| | | document.body.appendChild(link) |
| | | link.click() |
| | | link.remove() |
| | | window.URL.revokeObjectURL(downloadUrl) |
| | | ElMessage.success('导出成功') |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '导出失败') |
| | | } finally { |
| | | exportLoading.value = false |
| | | } |
| | | } |
| | | |
| | | function handleSearch(params) { |
| | | replaceSearchParams(buildDictTypeSearchParams(params)) |
| | | getData() |