¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <BasicTable @register="registerTable"> |
| | | <template \#toolbar> |
| | | <a-button type="primary" v-auth="'${modelCode!}_add'" @click="handleCreate"> |
| | | æ°å¢ |
| | | </a-button> |
| | | </template> |
| | | <template \#bodyCell="{ column, record }"> |
| | | #for(x in prototypes) { |
| | | #if(isNotEmpty(x.dictCode)){ |
| | | <template v-if="column.dataIndex === '${x.propertyName!}'"> |
| | | {{ formatDictValue(options['${x.propertyName!}Data'], record.category) }} |
| | | </template> |
| | | #} |
| | | #} |
| | | <template v-if="column.dataIndex === 'action'"> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | auth: '${modelCode!}_view', |
| | | label: 'æ¥ç', |
| | | color: 'success', |
| | | icon: 'clarity:info-standard-line', |
| | | onClick: handleView.bind(null, record), |
| | | }, |
| | | { |
| | | auth: '${modelCode!}_edit', |
| | | label: 'ç¼è¾', |
| | | icon: 'clarity:note-edit-line', |
| | | onClick: handleEdit.bind(null, record), |
| | | }, |
| | | { |
| | | auth: '${modelCode!}_delete', |
| | | label: 'å é¤', |
| | | icon: 'ant-design:delete-outlined', |
| | | color: 'error', |
| | | popConfirm: { |
| | | title: 'æ¯å¦ç¡®è®¤å é¤', |
| | | confirm: handleDelete.bind(null, record), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | </template> |
| | | </BasicTable> |
| | | <${modelClass!}Modal @register="registerModal" @success="handleSuccess" /> |
| | | </div> |
| | | </template> |
| | | <script lang="ts" setup name="${modelClass!}"> |
| | | import { ref } from 'vue'; |
| | | import ${modelClass!}Modal from './${modelCode!}Modal.vue'; |
| | | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| | | import { getList, remove } from '/@/api/${serviceCode!}/${modelCode!}'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | import { columns, searchFormSchema } from './${modelCode!}.data'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | import { formatDictValue } from '/@/utils'; |
| | | import { getDictList } from '/@/api/system/system'; |
| | | //åå§ååå
¸ |
| | | let options = ref({}); |
| | | async function fetch() { |
| | | #for(x in prototypes) { |
| | | #if(isNotEmpty(x.dictCode)){ |
| | | options.value['${x.propertyName!}Data'] = await getDictList({ code: '${x.dictCode!}' }); |
| | | #} |
| | | #} |
| | | } |
| | | fetch(); |
| | | |
| | | const { createMessage } = useMessage(); |
| | | const [registerModal, { openModal }] = useModal(); |
| | | const [registerTable, { reload }] = useTable({ |
| | | api: getList, |
| | | rowKey: 'id', |
| | | columns, |
| | | formConfig: { |
| | | labelWidth: 120, |
| | | schemas: searchFormSchema, |
| | | baseColProps: { xl: 12, xxl: 8 }, |
| | | }, |
| | | useSearchForm: true, |
| | | actionColumn: { |
| | | width: 250, |
| | | title: 'æä½', |
| | | dataIndex: 'action', |
| | | }, |
| | | }); |
| | | |
| | | function handleCreate() { |
| | | openModal(true, { |
| | | isDetail: false, |
| | | isUpdate: false, |
| | | }); |
| | | } |
| | | |
| | | function handleView(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: false, |
| | | isDetail: true, |
| | | }); |
| | | } |
| | | |
| | | function handleEdit(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isDetail: false, |
| | | isUpdate: true, |
| | | }); |
| | | } |
| | | async function handleDelete(record: Recordable) { |
| | | await remove({ ids: record.id }); |
| | | createMessage.success('æä½æå'); |
| | | reload(); |
| | | } |
| | | |
| | | function handleSuccess() { |
| | | //æä½æåæç¤º |
| | | createMessage.success('æä½æå'); |
| | | reload(); |
| | | } |
| | | </script> |