Commit 69ebfbe1053f392f0c066b0f3f8d5d1a30e7aa7c
1 parent
9d68c621
feat: 适配vue3.3 defineOptions
Showing
2 changed files
with
52 additions
and
48 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | <BasicForm @register="registerForm" /> | 3 | <BasicForm @register="registerForm" /> |
| 4 | </BasicModal> | 4 | </BasicModal> |
| 5 | </template> | 5 | </template> |
| 6 | -<script lang="ts" setup name="${table.className}Modal"> | 6 | +<script lang="ts" setup> |
| 7 | import { ref, unref } from 'vue' | 7 | import { ref, unref } from 'vue' |
| 8 | import { useI18n } from '@/hooks/web/useI18n' | 8 | import { useI18n } from '@/hooks/web/useI18n' |
| 9 | import { useMessage } from '@/hooks/web/useMessage' | 9 | import { useMessage } from '@/hooks/web/useMessage' |
| @@ -12,6 +12,8 @@ import { BasicModal, useModalInner } from '@/components/Modal' | @@ -12,6 +12,8 @@ import { BasicModal, useModalInner } from '@/components/Modal' | ||
| 12 | import { createFormSchema, updateFormSchema } from './${classNameVar}.data' | 12 | import { createFormSchema, updateFormSchema } from './${classNameVar}.data' |
| 13 | import { create${simpleClassName}, get${simpleClassName}, update${simpleClassName} } from '@/api/${table.moduleName}/${classNameVar}' | 13 | import { create${simpleClassName}, get${simpleClassName}, update${simpleClassName} } from '@/api/${table.moduleName}/${classNameVar}' |
| 14 | 14 | ||
| 15 | +defineOptions({ name: '${table.className}Modal' }) | ||
| 16 | + | ||
| 15 | const { t } = useI18n() | 17 | const { t } = useI18n() |
| 16 | const { createMessage } = useMessage() | 18 | const { createMessage } = useMessage() |
| 17 | const emit = defineEmits(['success', 'register']) | 19 | const emit = defineEmits(['success', 'register']) |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm
| @@ -33,58 +33,60 @@ | @@ -33,58 +33,60 @@ | ||
| 33 | <${simpleClassName}Modal @register="registerModal" @success="reload()" /> | 33 | <${simpleClassName}Modal @register="registerModal" @success="reload()" /> |
| 34 | </div> | 34 | </div> |
| 35 | </template> | 35 | </template> |
| 36 | -<script lang="ts" setup name="${table.className}"> | ||
| 37 | - import { useI18n } from '@/hooks/web/useI18n' | ||
| 38 | - import { useMessage } from '@/hooks/web/useMessage' | ||
| 39 | - import { useModal } from '@/components/Modal' | ||
| 40 | - import ${simpleClassName}Modal from './${simpleClassName}Modal.vue' | ||
| 41 | - import { IconEnum } from '@/enums/appEnum' | ||
| 42 | - import { BasicTable, useTable, TableAction } from '@/components/Table' | ||
| 43 | - import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}' | ||
| 44 | - import { columns, searchFormSchema } from './${classNameVar}.data' | 36 | +<script lang="ts" setup> |
| 37 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 38 | +import { useMessage } from '@/hooks/web/useMessage' | ||
| 39 | +import { useModal } from '@/components/Modal' | ||
| 40 | +import ${simpleClassName}Modal from './${simpleClassName}Modal.vue' | ||
| 41 | +import { IconEnum } from '@/enums/appEnum' | ||
| 42 | +import { BasicTable, useTable, TableAction } from '@/components/Table' | ||
| 43 | +import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}' | ||
| 44 | +import { columns, searchFormSchema } from './${classNameVar}.data' | ||
| 45 | 45 | ||
| 46 | - const { t } = useI18n() | ||
| 47 | - const { createConfirm, createMessage } = useMessage() | ||
| 48 | - const [registerModal, { openModal }] = useModal() | 46 | +defineOptions({ name: '${table.className}' }) |
| 49 | 47 | ||
| 50 | - const [registerTable, { getForm, reload }] = useTable({ | ||
| 51 | - title: '${table.classComment}列表', | ||
| 52 | - api: get${simpleClassName}Page, | ||
| 53 | - columns, | ||
| 54 | - formConfig: { labelWidth: 120, schemas: searchFormSchema }, | ||
| 55 | - useSearchForm: true, | ||
| 56 | - showTableSetting: true, | ||
| 57 | - actionColumn: { | ||
| 58 | - width: 140, | ||
| 59 | - title: t('common.action'), | ||
| 60 | - dataIndex: 'action', | ||
| 61 | - fixed: 'right' | ||
| 62 | - } | ||
| 63 | - }) | 48 | +const { t } = useI18n() |
| 49 | +const { createConfirm, createMessage } = useMessage() | ||
| 50 | +const [registerModal, { openModal }] = useModal() | ||
| 64 | 51 | ||
| 65 | - function handleCreate() { | ||
| 66 | - openModal(true, { isUpdate: false }) | 52 | +const [registerTable, { getForm, reload }] = useTable({ |
| 53 | + title: '${table.classComment}列表', | ||
| 54 | + api: get${simpleClassName}Page, | ||
| 55 | + columns, | ||
| 56 | + formConfig: { labelWidth: 120, schemas: searchFormSchema }, | ||
| 57 | + useSearchForm: true, | ||
| 58 | + showTableSetting: true, | ||
| 59 | + actionColumn: { | ||
| 60 | + width: 140, | ||
| 61 | + title: t('common.action'), | ||
| 62 | + dataIndex: 'action', | ||
| 63 | + fixed: 'right' | ||
| 67 | } | 64 | } |
| 65 | +}) | ||
| 68 | 66 | ||
| 69 | - function handleEdit(record: Recordable) { | ||
| 70 | - openModal(true, { record, isUpdate: true }) | ||
| 71 | - } | 67 | +function handleCreate() { |
| 68 | + openModal(true, { isUpdate: false }) | ||
| 69 | +} | ||
| 72 | 70 | ||
| 73 | - async function handleExport() { | ||
| 74 | - createConfirm({ | ||
| 75 | - title: t('common.exportTitle'), | ||
| 76 | - iconType: 'warning', | ||
| 77 | - content: t('common.exportMessage'), | ||
| 78 | - async onOk() { | ||
| 79 | - await export${simpleClassName}(getForm().getFieldsValue()) | ||
| 80 | - createMessage.success(t('common.exportSuccessText')) | ||
| 81 | - } | ||
| 82 | - }) | ||
| 83 | - } | 71 | +function handleEdit(record: Recordable) { |
| 72 | + openModal(true, { record, isUpdate: true }) | ||
| 73 | +} | ||
| 84 | 74 | ||
| 85 | - async function handleDelete(record: Recordable) { | ||
| 86 | - await delete${simpleClassName}(record.id) | ||
| 87 | - createMessage.success(t('common.delSuccessText')) | ||
| 88 | - reload() | ||
| 89 | - } | 75 | +async function handleExport() { |
| 76 | + createConfirm({ | ||
| 77 | + title: t('common.exportTitle'), | ||
| 78 | + iconType: 'warning', | ||
| 79 | + content: t('common.exportMessage'), | ||
| 80 | + async onOk() { | ||
| 81 | + await export${simpleClassName}(getForm().getFieldsValue()) | ||
| 82 | + createMessage.success(t('common.exportSuccessText')) | ||
| 83 | + } | ||
| 84 | + }) | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +async function handleDelete(record: Recordable) { | ||
| 88 | + await delete${simpleClassName}(record.id) | ||
| 89 | + createMessage.success(t('common.delSuccessText')) | ||
| 90 | + reload() | ||
| 91 | +} | ||
| 90 | </script> | 92 | </script> |