| | |
| | | <ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData"> |
| | | <template #left> |
| | | <ElSpace wrap> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>新增数据字典</ElButton> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>{{ t('pages.system.dictType.buttons.add') }}</ElButton> |
| | | <ElButton |
| | | v-auth="'delete'" |
| | | type="danger" |
| | |
| | | @click="handleBatchDelete" |
| | | v-ripple |
| | | > |
| | | 批量删除 |
| | | {{ t('common.actions.batchDelete') }} |
| | | </ElButton> |
| | | </ElSpace> |
| | | </template> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { useI18n } from 'vue-i18n' |
| | | import { ElMessage } from 'element-plus' |
| | | import { useAuth } from '@/hooks/core/useAuth' |
| | | import { useTable } from '@/hooks/core/useTable' |
| | |
| | | |
| | | defineOptions({ name: 'DictType' }) |
| | | |
| | | const { t } = useI18n() |
| | | const { hasAuth } = useAuth() |
| | | const searchForm = ref(createDictTypeSearchState()) |
| | | const detailDrawerVisible = ref(false) |
| | |
| | | |
| | | const searchItems = computed(() => [ |
| | | { |
| | | label: '关键字', |
| | | label: t('table.keyword'), |
| | | key: 'condition', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入编码或名称' |
| | | placeholder: t('pages.system.dictType.search.conditionPlaceholder') |
| | | } |
| | | }, |
| | | { |
| | | label: '编码', |
| | | label: t('table.code'), |
| | | key: 'code', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入字典编码' |
| | | placeholder: t('pages.system.dictType.search.codePlaceholder') |
| | | } |
| | | }, |
| | | { |
| | | label: '名称', |
| | | label: t('table.name'), |
| | | key: 'name', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入字典名称' |
| | | placeholder: t('pages.system.dictType.search.namePlaceholder') |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | label: t('table.status'), |
| | | key: 'status', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | options: [ |
| | | { label: '正常', value: 1 }, |
| | | { label: '冻结', value: 0 } |
| | | { label: t('common.status.normal'), value: 1 }, |
| | | { label: t('common.status.frozen'), value: 0 } |
| | | ] |
| | | } |
| | | } |
| | |
| | | detailDrawerVisible.value = true |
| | | detailLoading.value = true |
| | | try { |
| | | detailData.value = normalizeDictTypeListRow(await fetchGetDictTypeDetail(row.id)) |
| | | detailData.value = normalizeDictTypeListRow(await fetchGetDictTypeDetail(row.id), t) |
| | | } catch (error) { |
| | | detailDrawerVisible.value = false |
| | | detailData.value = {} |
| | | ElMessage.error(error?.message || '获取数据字典详情失败') |
| | | ElMessage.error(error?.message || t('pages.system.dictType.messages.detailFailed')) |
| | | } finally { |
| | | detailLoading.value = false |
| | | } |
| | |
| | | dialogVisible.value = true |
| | | dialogType.value = 'edit' |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '获取数据字典详情失败') |
| | | ElMessage.error(error?.message || t('pages.system.dictType.messages.detailFailed')) |
| | | } |
| | | } |
| | | |
| | |
| | | createDictTypeTableColumns({ |
| | | handleView: openDetail, |
| | | handleEdit: openEditDialog, |
| | | handleDelete: hasAuth('delete') ? (row) => handleDeleteAction?.(row) : null |
| | | handleDelete: hasAuth('delete') ? (row) => handleDeleteAction?.(row) : null, |
| | | t |
| | | }) |
| | | }, |
| | | transform: { |
| | |
| | | if (!Array.isArray(records)) { |
| | | return [] |
| | | } |
| | | return records.map((item) => normalizeDictTypeListRow(item)) |
| | | return records.map((item) => normalizeDictTypeListRow(item, t)) |
| | | } |
| | | } |
| | | }) |
| | |
| | | saveRequest: fetchSaveDictType, |
| | | updateRequest: fetchUpdateDictType, |
| | | deleteRequest: fetchDeleteDictType, |
| | | entityName: '数据字典', |
| | | entityName: t('pages.system.dictType.entity'), |
| | | resolveRecordLabel: (record) => record?.name || record?.code || record?.id, |
| | | refreshCreate, |
| | | refreshUpdate, |