You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.7 KiB

<script lang="ts" setup>
import { reactive } from 'vue'
import DictData from './DictData.vue'
import DictTypeModal from './DictTypeModal.vue'
import { typeColumns, typeSearchFormSchema } from './dict.type'
2 years ago
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
2 years ago
import { useModal } from '@/components/Modal'
2 years ago
import { IconEnum } from '@/enums/appEnum'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteDictType, getDictTypePage } from '@/api/system/dict/type'
2 years ago
defineOptions({ name: 'SystemDict' })
2 years ago
const { t } = useI18n()
const { createMessage } = useMessage()
2 years ago
const [registerModal, { openModal }] = useModal()
const searchInfo = reactive<Recordable>({})
2 years ago
const [registerTable, { reload }] = useTable({
title: '字典分类列表',
api: getDictTypePage,
2 years ago
columns: typeColumns,
formConfig: {
labelWidth: 120,
schemas: typeSearchFormSchema,
2 years ago
},
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 140,
2 years ago
title: t('common.action'),
2 years ago
dataIndex: 'action',
fixed: 'right',
},
2 years ago
})
function handleRowClick(record) {
searchInfo.dictType = record.type
}
2 years ago
function handleCreate() {
2 years ago
openModal(true, { isUpdate: false })
2 years ago
}
function handleEdit(record: Recordable) {
2 years ago
openModal(true, { record, isUpdate: true })
2 years ago
}
async function handleDelete(record: Recordable) {
await deleteDictType(record.id)
2 years ago
createMessage.success(t('common.delSuccessText'))
reload()
2 years ago
}
</script>
<template>
<div class="flex">
<BasicTable class="w-1/2" @register="registerTable" @row-click="handleRowClick">
<template #toolbar>
<a-button v-auth="['system:dict:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:dict:update', onClick: handleEdit.bind(null, record) },
{
icon: IconEnum.DELETE,
danger: true,
label: t('action.delete'),
auth: 'system:dict:delete',
popConfirm: {
title: t('common.delMessage'),
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</template>
</BasicTable>
<DictData class="w-1/2" :search-info="searchInfo" />
<DictTypeModal @register="registerModal" @success="reload()" />
</div>
</template>