mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	feat: 适配vue3.3 defineOptions
This commit is contained in:
		@@ -3,7 +3,7 @@
 | 
			
		||||
    <BasicForm @register="registerForm" />
 | 
			
		||||
  </BasicModal>
 | 
			
		||||
</template>
 | 
			
		||||
<script lang="ts" setup name="${table.className}Modal">
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { ref, unref } from 'vue'
 | 
			
		||||
import { useI18n } from '@/hooks/web/useI18n'
 | 
			
		||||
import { useMessage } from '@/hooks/web/useMessage'
 | 
			
		||||
@@ -12,6 +12,8 @@ import { BasicModal, useModalInner } from '@/components/Modal'
 | 
			
		||||
import { createFormSchema, updateFormSchema } from './${classNameVar}.data'
 | 
			
		||||
import { create${simpleClassName}, get${simpleClassName}, update${simpleClassName} } from '@/api/${table.moduleName}/${classNameVar}'
 | 
			
		||||
 | 
			
		||||
defineOptions({ name: '${table.className}Modal' })
 | 
			
		||||
 | 
			
		||||
const { t } = useI18n()
 | 
			
		||||
const { createMessage } = useMessage()
 | 
			
		||||
const emit = defineEmits(['success', 'register'])
 | 
			
		||||
 
 | 
			
		||||
@@ -33,58 +33,60 @@
 | 
			
		||||
    <${simpleClassName}Modal @register="registerModal" @success="reload()" />
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script lang="ts" setup name="${table.className}">
 | 
			
		||||
  import { useI18n } from '@/hooks/web/useI18n'
 | 
			
		||||
  import { useMessage } from '@/hooks/web/useMessage'
 | 
			
		||||
  import { useModal } from '@/components/Modal'
 | 
			
		||||
  import ${simpleClassName}Modal from './${simpleClassName}Modal.vue'
 | 
			
		||||
  import { IconEnum } from '@/enums/appEnum'
 | 
			
		||||
  import { BasicTable, useTable, TableAction } from '@/components/Table'
 | 
			
		||||
  import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}'
 | 
			
		||||
  import { columns, searchFormSchema } from './${classNameVar}.data'
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { useI18n } from '@/hooks/web/useI18n'
 | 
			
		||||
import { useMessage } from '@/hooks/web/useMessage'
 | 
			
		||||
import { useModal } from '@/components/Modal'
 | 
			
		||||
import ${simpleClassName}Modal from './${simpleClassName}Modal.vue'
 | 
			
		||||
import { IconEnum } from '@/enums/appEnum'
 | 
			
		||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
 | 
			
		||||
import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}'
 | 
			
		||||
import { columns, searchFormSchema } from './${classNameVar}.data'
 | 
			
		||||
 | 
			
		||||
  const { t } = useI18n()
 | 
			
		||||
  const { createConfirm, createMessage } = useMessage()
 | 
			
		||||
  const [registerModal, { openModal }] = useModal()
 | 
			
		||||
defineOptions({ name: '${table.className}' })
 | 
			
		||||
 | 
			
		||||
  const [registerTable, { getForm, reload }] = useTable({
 | 
			
		||||
    title: '${table.classComment}列表',
 | 
			
		||||
    api: get${simpleClassName}Page,
 | 
			
		||||
    columns,
 | 
			
		||||
    formConfig: { labelWidth: 120, schemas: searchFormSchema },
 | 
			
		||||
    useSearchForm: true,
 | 
			
		||||
    showTableSetting: true,
 | 
			
		||||
    actionColumn: {
 | 
			
		||||
      width: 140,
 | 
			
		||||
      title: t('common.action'),
 | 
			
		||||
      dataIndex: 'action',
 | 
			
		||||
      fixed: 'right'
 | 
			
		||||
const { t } = useI18n()
 | 
			
		||||
const { createConfirm, createMessage } = useMessage()
 | 
			
		||||
const [registerModal, { openModal }] = useModal()
 | 
			
		||||
 | 
			
		||||
const [registerTable, { getForm, reload }] = useTable({
 | 
			
		||||
  title: '${table.classComment}列表',
 | 
			
		||||
  api: get${simpleClassName}Page,
 | 
			
		||||
  columns,
 | 
			
		||||
  formConfig: { labelWidth: 120, schemas: searchFormSchema },
 | 
			
		||||
  useSearchForm: true,
 | 
			
		||||
  showTableSetting: true,
 | 
			
		||||
  actionColumn: {
 | 
			
		||||
    width: 140,
 | 
			
		||||
    title: t('common.action'),
 | 
			
		||||
    dataIndex: 'action',
 | 
			
		||||
    fixed: 'right'
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
function handleCreate() {
 | 
			
		||||
  openModal(true, { isUpdate: false })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function handleEdit(record: Recordable) {
 | 
			
		||||
  openModal(true, { record, isUpdate: true })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function handleExport() {
 | 
			
		||||
  createConfirm({
 | 
			
		||||
    title: t('common.exportTitle'),
 | 
			
		||||
    iconType: 'warning',
 | 
			
		||||
    content: t('common.exportMessage'),
 | 
			
		||||
    async onOk() {
 | 
			
		||||
      await export${simpleClassName}(getForm().getFieldsValue())
 | 
			
		||||
      createMessage.success(t('common.exportSuccessText'))
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  function handleCreate() {
 | 
			
		||||
    openModal(true, { isUpdate: false })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function handleEdit(record: Recordable) {
 | 
			
		||||
    openModal(true, { record, isUpdate: true })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async function handleExport() {
 | 
			
		||||
    createConfirm({
 | 
			
		||||
      title: t('common.exportTitle'),
 | 
			
		||||
      iconType: 'warning',
 | 
			
		||||
      content: t('common.exportMessage'),
 | 
			
		||||
      async onOk() {
 | 
			
		||||
        await export${simpleClassName}(getForm().getFieldsValue())
 | 
			
		||||
        createMessage.success(t('common.exportSuccessText'))
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async function handleDelete(record: Recordable) {
 | 
			
		||||
    await delete${simpleClassName}(record.id)
 | 
			
		||||
    createMessage.success(t('common.delSuccessText'))
 | 
			
		||||
    reload()
 | 
			
		||||
  }
 | 
			
		||||
async function handleDelete(record: Recordable) {
 | 
			
		||||
  await delete${simpleClassName}(record.id)
 | 
			
		||||
  createMessage.success(t('common.delSuccessText'))
 | 
			
		||||
  reload()
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user