对比新文件 |
| | |
| | | <template> |
| | | <BasicDrawer |
| | | v-bind="$attrs" |
| | | @register="registerDrawer" |
| | | :title="`[\${${model.modelCode!}Name}] 閰嶇疆`" |
| | | width="1000px" |
| | | > |
| | | <BasicTable @register="registerTable"> |
| | | <template \#toolbar> |
| | | <a-button type="primary" @click="handleCreate">鏂板</a-button> |
| | | </template> |
| | | <template \#bodyCell="{ column, record }"> |
| | | <template v-if="column.dataIndex === 'action'"> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: '鏌ョ湅', |
| | | color: 'success', |
| | | icon: 'clarity:info-standard-line', |
| | | onClick: handleView.bind(null, record), |
| | | }, |
| | | { |
| | | label: '缂栬緫', |
| | | icon: 'clarity:note-edit-line', |
| | | onClick: handleEdit.bind(null, record), |
| | | }, |
| | | { |
| | | label: '鍒犻櫎', |
| | | icon: 'ant-design:delete-outlined', |
| | | color: 'error', |
| | | popConfirm: { |
| | | title: '鏄惁纭鍒犻櫎', |
| | | confirm: handleDelete.bind(null, record), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | </template> |
| | | </BasicTable> |
| | | <${modelClass!}Modal @register="registerModal" @success="handleSuccess" /> |
| | | </BasicDrawer> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| | | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| | | import { getList, remove } from '/@/api/${serviceCode!}/${modelCode!}'; |
| | | import { columns, searchFormSchema } from './${modelCode!}.data'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | import ${modelClass!}Modal from './${modelClass!}Modal.vue'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | const { createMessage } = useMessage(); |
| | | const { success } = createMessage; |
| | | const [registerModal, { openModal }] = useModal(); |
| | | const [registerTable, { reload, setProps }] = useTable({ |
| | | api: getList, |
| | | rowKey: 'id', |
| | | columns, |
| | | formConfig: { |
| | | labelWidth: 120, |
| | | schemas: searchFormSchema, |
| | | baseColProps: { xl: 12, xxl: 6 }, |
| | | }, |
| | | useSearchForm: true, |
| | | immediate: false, |
| | | actionColumn: { |
| | | width: 250, |
| | | title: '鎿嶄綔', |
| | | dataIndex: 'action', |
| | | }, |
| | | }); |
| | | const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { |
| | | setProps({ |
| | | searchInfo: {${subFkIdHump!}: data.mainId}, |
| | | }); |
| | | reload(); |
| | | }); |
| | | |
| | | function handleCreate() { |
| | | openModal(true, { |
| | | isUpdate: false, |
| | | isDetail: false, |
| | | }); |
| | | } |
| | | |
| | | function handleEdit(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: true, |
| | | isDetail: false, |
| | | }); |
| | | } |
| | | |
| | | function handleView(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: false, |
| | | isDetail: true, |
| | | }); |
| | | } |
| | | |
| | | async function handleDelete(record: Recordable) { |
| | | await remove({ ids: record.id }); |
| | | success('鎿嶄綔鎴愬姛'); |
| | | reload(); |
| | | } |
| | | |
| | | function handleSuccess() { |
| | | //鎿嶄綔鎴愬姛鎻愮ず |
| | | success('鎿嶄綔鎴愬姛'); |
| | | reload(); |
| | | } |
| | | </script> |