mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	!565 vben代码生成模版
Merge pull request !565 from xingyu/feature/vben_codegen
This commit is contained in:
		@@ -15,7 +15,7 @@ export const columns: BasicColumn[] = [
 | 
			
		||||
    width: 180,
 | 
			
		||||
    customRender: ({ text }) => {
 | 
			
		||||
      return useRender.renderDate(text)
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
#elseif("" != $column.dictType)## 数据字典
 | 
			
		||||
  {
 | 
			
		||||
@@ -24,13 +24,13 @@ export const columns: BasicColumn[] = [
 | 
			
		||||
    width: 180,
 | 
			
		||||
    customRender: ({ text }) => {
 | 
			
		||||
      return useRender.renderDict(text, DICT_TYPE.$dictType.toUpperCase())
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
#else
 | 
			
		||||
  {
 | 
			
		||||
    title: '${comment}',
 | 
			
		||||
    dataIndex: '${javaField}',
 | 
			
		||||
    width: 160
 | 
			
		||||
    width: 160,
 | 
			
		||||
  },
 | 
			
		||||
#end
 | 
			
		||||
#end
 | 
			
		||||
@@ -53,15 +53,15 @@ export const searchFormSchema: FormSchema[] = [
 | 
			
		||||
    component: 'Select',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 设置了 dictType 数据字典的情况
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase())
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()),
 | 
			
		||||
      #else## 未设置 dictType 数据字典的情况
 | 
			
		||||
        options: []
 | 
			
		||||
        options: [],
 | 
			
		||||
      #end
 | 
			
		||||
    },
 | 
			
		||||
  #elseif($column.htmlType == "datetime")
 | 
			
		||||
    component: 'RangePicker',
 | 
			
		||||
    #end
 | 
			
		||||
    colProps: { span: 8 }
 | 
			
		||||
    colProps: { span: 8 },
 | 
			
		||||
  },
 | 
			
		||||
#end
 | 
			
		||||
#end
 | 
			
		||||
@@ -72,7 +72,7 @@ export const createFormSchema: FormSchema[] = [
 | 
			
		||||
    label: '编号',
 | 
			
		||||
    field: 'id',
 | 
			
		||||
    show: false,
 | 
			
		||||
    component: 'Input'
 | 
			
		||||
    component: 'Input',
 | 
			
		||||
  },
 | 
			
		||||
#foreach($column in $columns)
 | 
			
		||||
#if ($column.createOperation)
 | 
			
		||||
@@ -88,52 +88,52 @@ export const createFormSchema: FormSchema[] = [
 | 
			
		||||
    required: true,
 | 
			
		||||
    #end
 | 
			
		||||
  #if ($column.htmlType == "input")
 | 
			
		||||
    component: 'Input'
 | 
			
		||||
    component: 'Input',
 | 
			
		||||
  #elseif($column.htmlType == "imageUpload")## 图片上传
 | 
			
		||||
    component: 'FileUpload',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      fileType: 'file',
 | 
			
		||||
      maxCount: 1
 | 
			
		||||
    }
 | 
			
		||||
      maxCount: 1,
 | 
			
		||||
    },
 | 
			
		||||
  #elseif($column.htmlType == "fileUpload")## 文件上传
 | 
			
		||||
    component: 'FileUpload',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      fileType: 'image',
 | 
			
		||||
      maxCount: 1
 | 
			
		||||
    }
 | 
			
		||||
      maxCount: 1,
 | 
			
		||||
    },
 | 
			
		||||
  #elseif($column.htmlType == "editor")## 文本编辑器
 | 
			
		||||
    component: 'Editor'
 | 
			
		||||
    component: 'Editor',
 | 
			
		||||
  #elseif($column.htmlType == "select")## 下拉框
 | 
			
		||||
    component: 'Select',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 有数据字典
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number')
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
 | 
			
		||||
      #else##没数据字典
 | 
			
		||||
        options:[]
 | 
			
		||||
        options:[],
 | 
			
		||||
      #end
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  #elseif($column.htmlType == "checkbox")## 多选框
 | 
			
		||||
    component: 'Checkbox',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 有数据字典
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number')
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
 | 
			
		||||
      #else##没数据字典
 | 
			
		||||
        options:[]
 | 
			
		||||
        options:[],
 | 
			
		||||
      #end
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  #elseif($column.htmlType == "radio")## 单选框
 | 
			
		||||
    component: 'RadioButtonGroup',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 有数据字典
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number')
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
 | 
			
		||||
      #else##没数据字典
 | 
			
		||||
        options:[]
 | 
			
		||||
        options:[],
 | 
			
		||||
      #end
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  #elseif($column.htmlType == "datetime")## 时间框
 | 
			
		||||
    component: 'DatePicker'
 | 
			
		||||
    component: 'DatePicker',
 | 
			
		||||
  #elseif($column.htmlType == "textarea")## 文本域
 | 
			
		||||
    component: 'InputTextArea'
 | 
			
		||||
    component: 'InputTextArea',
 | 
			
		||||
  #end
 | 
			
		||||
  },
 | 
			
		||||
#end
 | 
			
		||||
@@ -146,7 +146,7 @@ export const updateFormSchema: FormSchema[] = [
 | 
			
		||||
    label: '编号',
 | 
			
		||||
    field: 'id',
 | 
			
		||||
    show: false,
 | 
			
		||||
    component: 'Input'
 | 
			
		||||
    component: 'Input',
 | 
			
		||||
  },
 | 
			
		||||
#foreach($column in $columns)
 | 
			
		||||
#if ($column.updateOperation)
 | 
			
		||||
@@ -162,44 +162,44 @@ export const updateFormSchema: FormSchema[] = [
 | 
			
		||||
    required: true,
 | 
			
		||||
    #end
 | 
			
		||||
    #if ($column.htmlType == "input")
 | 
			
		||||
    component: 'Input'
 | 
			
		||||
    component: 'Input',
 | 
			
		||||
    #elseif($column.htmlType == "imageUpload")## 图片上传
 | 
			
		||||
    component: 'Upload'
 | 
			
		||||
    component: 'Upload',
 | 
			
		||||
    #elseif($column.htmlType == "fileUpload")## 文件上传
 | 
			
		||||
    component: 'Upload'
 | 
			
		||||
    component: 'Upload',
 | 
			
		||||
    #elseif($column.htmlType == "editor")## 文本编辑器
 | 
			
		||||
    component: 'Editor'
 | 
			
		||||
    component: 'Editor',
 | 
			
		||||
    #elseif($column.htmlType == "select")## 下拉框
 | 
			
		||||
    component: 'Select',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 有数据字典
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number')
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
 | 
			
		||||
      #else##没数据字典
 | 
			
		||||
        options:[]
 | 
			
		||||
        options:[],
 | 
			
		||||
      #end
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
    #elseif($column.htmlType == "checkbox")## 多选框
 | 
			
		||||
    component: 'Checkbox',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 有数据字典
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number')
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
 | 
			
		||||
      #else##没数据字典
 | 
			
		||||
        options:[]
 | 
			
		||||
        options:[],
 | 
			
		||||
      #end
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
    #elseif($column.htmlType == "radio")## 单选框
 | 
			
		||||
    component: 'RadioButtonGroup',
 | 
			
		||||
    componentProps: {
 | 
			
		||||
      #if ("" != $dictType)## 有数据字典
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number')
 | 
			
		||||
        options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
 | 
			
		||||
      #else##没数据字典
 | 
			
		||||
        options:[]
 | 
			
		||||
        options:[],
 | 
			
		||||
      #end
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
    #elseif($column.htmlType == "datetime")## 时间框
 | 
			
		||||
    component: 'DatePicker'
 | 
			
		||||
    component: 'DatePicker',
 | 
			
		||||
    #elseif($column.htmlType == "textarea")## 文本域
 | 
			
		||||
    component: 'InputTextArea'
 | 
			
		||||
    component: 'InputTextArea',
 | 
			
		||||
    #end
 | 
			
		||||
  },
 | 
			
		||||
#end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,10 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? t('action.edit') : t('action.create')" @ok="handleSubmit">
 | 
			
		||||
    <BasicForm @register="registerForm" />
 | 
			
		||||
  </BasicModal>
 | 
			
		||||
</template>
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { ref, unref } from 'vue'
 | 
			
		||||
import { createFormSchema, updateFormSchema } from './${classNameVar}.data'
 | 
			
		||||
import { useI18n } from '@/hooks/web/useI18n'
 | 
			
		||||
import { useMessage } from '@/hooks/web/useMessage'
 | 
			
		||||
import { BasicForm, useForm } from '@/components/Form'
 | 
			
		||||
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' })
 | 
			
		||||
@@ -24,7 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, resetSchema, validate }] = u
 | 
			
		||||
  baseColProps: { span: 24 },
 | 
			
		||||
  schemas: createFormSchema,
 | 
			
		||||
  showActionButtonGroup: false,
 | 
			
		||||
  actionColOptions: { span: 23 }
 | 
			
		||||
  actionColOptions: { span: 23 },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
 | 
			
		||||
@@ -55,3 +50,8 @@ async function handleSubmit() {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<template>
 | 
			
		||||
  <BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? t('action.edit') : t('action.create')" @ok="handleSubmit">
 | 
			
		||||
    <BasicForm @register="registerForm" />
 | 
			
		||||
  </BasicModal>
 | 
			
		||||
</template>
 | 
			
		||||
@@ -1,47 +1,12 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <BasicTable @register="registerTable">
 | 
			
		||||
      <template #toolbar>
 | 
			
		||||
        <a-button type="primary" v-auth="['${permissionPrefix}:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
 | 
			
		||||
          {{ t('action.create') }}
 | 
			
		||||
        </a-button>
 | 
			
		||||
        <a-button type="warning" v-auth="['${permissionPrefix}:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
 | 
			
		||||
          {{ t('action.export') }}
 | 
			
		||||
        </a-button>
 | 
			
		||||
      </template>
 | 
			
		||||
      <template #bodyCell="{ column, record }">
 | 
			
		||||
        <template v-if="column.key === 'action'">
 | 
			
		||||
          <TableAction
 | 
			
		||||
             :actions="[
 | 
			
		||||
               { icon: IconEnum.EDIT, label: t('action.edit'), auth: '${permissionPrefix}:update', onClick: handleEdit.bind(null, record) },
 | 
			
		||||
               {
 | 
			
		||||
                  icon: IconEnum.DELETE,
 | 
			
		||||
                  color: 'error',
 | 
			
		||||
                  label: t('action.delete'),
 | 
			
		||||
                  auth: '${permissionPrefix}:delete',
 | 
			
		||||
                  popConfirm: {
 | 
			
		||||
                    title: t('common.delMessage'),
 | 
			
		||||
                    placement: 'left',
 | 
			
		||||
                    confirm: handleDelete.bind(null, record)
 | 
			
		||||
                  }
 | 
			
		||||
              }
 | 
			
		||||
            ]"
 | 
			
		||||
          />
 | 
			
		||||
        </template>
 | 
			
		||||
      </template>
 | 
			
		||||
    </BasicTable>
 | 
			
		||||
    <${simpleClassName}Modal @register="registerModal" @success="reload()" />
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import ${simpleClassName}Modal from './${simpleClassName}Modal.vue'
 | 
			
		||||
import { columns, searchFormSchema } from './${classNameVar}.data'
 | 
			
		||||
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'
 | 
			
		||||
 | 
			
		||||
defineOptions({ name: '${table.className}' })
 | 
			
		||||
 | 
			
		||||
@@ -60,8 +25,8 @@ const [registerTable, { getForm, reload }] = useTable({
 | 
			
		||||
    width: 140,
 | 
			
		||||
    title: t('common.action'),
 | 
			
		||||
    dataIndex: 'action',
 | 
			
		||||
    fixed: 'right'
 | 
			
		||||
  }
 | 
			
		||||
    fixed: 'right',
 | 
			
		||||
  },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
function handleCreate() {
 | 
			
		||||
@@ -80,7 +45,7 @@ async function handleExport() {
 | 
			
		||||
    async onOk() {
 | 
			
		||||
      await export${simpleClassName}(getForm().getFieldsValue())
 | 
			
		||||
      createMessage.success(t('common.exportSuccessText'))
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -90,3 +55,38 @@ async function handleDelete(record: Recordable) {
 | 
			
		||||
  reload()
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <BasicTable @register="registerTable">
 | 
			
		||||
      <template #toolbar>
 | 
			
		||||
        <a-button type="primary" v-auth="['${permissionPrefix}:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
 | 
			
		||||
          {{ t('action.create') }}
 | 
			
		||||
        </a-button>
 | 
			
		||||
        <a-button type="warning" v-auth="['${permissionPrefix}:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
 | 
			
		||||
          {{ t('action.export') }}
 | 
			
		||||
        </a-button>
 | 
			
		||||
      </template>
 | 
			
		||||
      <template #bodyCell="{ column, record }">
 | 
			
		||||
        <template v-if="column.key === 'action'">
 | 
			
		||||
          <TableAction
 | 
			
		||||
            :actions="[
 | 
			
		||||
              { icon: IconEnum.EDIT, label: t('action.edit'), auth: '${permissionPrefix}:update', onClick: handleEdit.bind(null, record) },
 | 
			
		||||
              {
 | 
			
		||||
                icon: IconEnum.DELETE,
 | 
			
		||||
                danger: true,
 | 
			
		||||
                label: t('action.delete'),
 | 
			
		||||
                auth: '${permissionPrefix}:delete',
 | 
			
		||||
                popConfirm: {
 | 
			
		||||
                  title: t('common.delMessage'),
 | 
			
		||||
                  placement: 'left',
 | 
			
		||||
                  confirm: handleDelete.bind(null, record),
 | 
			
		||||
                },
 | 
			
		||||
              },
 | 
			
		||||
            ]"
 | 
			
		||||
          />
 | 
			
		||||
        </template>
 | 
			
		||||
      </template>
 | 
			
		||||
    </BasicTable>
 | 
			
		||||
    <${simpleClassName}Modal @register="registerModal" @success="reload()" />
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
		Reference in New Issue
	
	Block a user