Commit 80a588975781c78f36a61365b071cfca764f2040
Committed by
Gitee
!565 vben代码生成模版
Merge pull request !565 from xingyu/feature/vben_codegen
Showing
4 changed files
with
89 additions
and
89 deletions
yudao-dependencies/pom.xml
| ... | ... | @@ -23,8 +23,8 @@ |
| 23 | 23 | <servlet.versoin>2.5</servlet.versoin> |
| 24 | 24 | <!-- DB 相关 --> |
| 25 | 25 | <druid.version>1.2.18</druid.version> |
| 26 | - <mybatis-plus.version>3.5.3.1</mybatis-plus.version> | |
| 27 | - <mybatis-plus-generator.version>3.5.3.1</mybatis-plus-generator.version> | |
| 26 | + <mybatis-plus.version>3.5.3.2</mybatis-plus.version> | |
| 27 | + <mybatis-plus-generator.version>3.5.3.2</mybatis-plus-generator.version> | |
| 28 | 28 | <dynamic-datasource.version>3.6.1</dynamic-datasource.version> |
| 29 | 29 | <mybatis-plus-join-boot-starter.version>1.4.5</mybatis-plus-join-boot-starter.version> |
| 30 | 30 | <redisson.version>3.18.0</redisson.version> | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/data.ts.vm
| ... | ... | @@ -15,7 +15,7 @@ export const columns: BasicColumn[] = [ |
| 15 | 15 | width: 180, |
| 16 | 16 | customRender: ({ text }) => { |
| 17 | 17 | return useRender.renderDate(text) |
| 18 | - } | |
| 18 | + }, | |
| 19 | 19 | }, |
| 20 | 20 | #elseif("" != $column.dictType)## 数据字典 |
| 21 | 21 | { |
| ... | ... | @@ -24,13 +24,13 @@ export const columns: BasicColumn[] = [ |
| 24 | 24 | width: 180, |
| 25 | 25 | customRender: ({ text }) => { |
| 26 | 26 | return useRender.renderDict(text, DICT_TYPE.$dictType.toUpperCase()) |
| 27 | - } | |
| 27 | + }, | |
| 28 | 28 | }, |
| 29 | 29 | #else |
| 30 | 30 | { |
| 31 | 31 | title: '${comment}', |
| 32 | 32 | dataIndex: '${javaField}', |
| 33 | - width: 160 | |
| 33 | + width: 160, | |
| 34 | 34 | }, |
| 35 | 35 | #end |
| 36 | 36 | #end |
| ... | ... | @@ -53,15 +53,15 @@ export const searchFormSchema: FormSchema[] = [ |
| 53 | 53 | component: 'Select', |
| 54 | 54 | componentProps: { |
| 55 | 55 | #if ("" != $dictType)## 设置了 dictType 数据字典的情况 |
| 56 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()) | |
| 56 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()), | |
| 57 | 57 | #else## 未设置 dictType 数据字典的情况 |
| 58 | - options: [] | |
| 58 | + options: [], | |
| 59 | 59 | #end |
| 60 | 60 | }, |
| 61 | 61 | #elseif($column.htmlType == "datetime") |
| 62 | 62 | component: 'RangePicker', |
| 63 | 63 | #end |
| 64 | - colProps: { span: 8 } | |
| 64 | + colProps: { span: 8 }, | |
| 65 | 65 | }, |
| 66 | 66 | #end |
| 67 | 67 | #end |
| ... | ... | @@ -72,7 +72,7 @@ export const createFormSchema: FormSchema[] = [ |
| 72 | 72 | label: '编号', |
| 73 | 73 | field: 'id', |
| 74 | 74 | show: false, |
| 75 | - component: 'Input' | |
| 75 | + component: 'Input', | |
| 76 | 76 | }, |
| 77 | 77 | #foreach($column in $columns) |
| 78 | 78 | #if ($column.createOperation) |
| ... | ... | @@ -88,52 +88,52 @@ export const createFormSchema: FormSchema[] = [ |
| 88 | 88 | required: true, |
| 89 | 89 | #end |
| 90 | 90 | #if ($column.htmlType == "input") |
| 91 | - component: 'Input' | |
| 91 | + component: 'Input', | |
| 92 | 92 | #elseif($column.htmlType == "imageUpload")## 图片上传 |
| 93 | 93 | component: 'FileUpload', |
| 94 | 94 | componentProps: { |
| 95 | 95 | fileType: 'file', |
| 96 | - maxCount: 1 | |
| 97 | - } | |
| 96 | + maxCount: 1, | |
| 97 | + }, | |
| 98 | 98 | #elseif($column.htmlType == "fileUpload")## 文件上传 |
| 99 | 99 | component: 'FileUpload', |
| 100 | 100 | componentProps: { |
| 101 | 101 | fileType: 'image', |
| 102 | - maxCount: 1 | |
| 103 | - } | |
| 102 | + maxCount: 1, | |
| 103 | + }, | |
| 104 | 104 | #elseif($column.htmlType == "editor")## 文本编辑器 |
| 105 | - component: 'Editor' | |
| 105 | + component: 'Editor', | |
| 106 | 106 | #elseif($column.htmlType == "select")## 下拉框 |
| 107 | 107 | component: 'Select', |
| 108 | 108 | componentProps: { |
| 109 | 109 | #if ("" != $dictType)## 有数据字典 |
| 110 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') | |
| 110 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), | |
| 111 | 111 | #else##没数据字典 |
| 112 | - options:[] | |
| 112 | + options:[], | |
| 113 | 113 | #end |
| 114 | - } | |
| 114 | + }, | |
| 115 | 115 | #elseif($column.htmlType == "checkbox")## 多选框 |
| 116 | 116 | component: 'Checkbox', |
| 117 | 117 | componentProps: { |
| 118 | 118 | #if ("" != $dictType)## 有数据字典 |
| 119 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') | |
| 119 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), | |
| 120 | 120 | #else##没数据字典 |
| 121 | - options:[] | |
| 121 | + options:[], | |
| 122 | 122 | #end |
| 123 | - } | |
| 123 | + }, | |
| 124 | 124 | #elseif($column.htmlType == "radio")## 单选框 |
| 125 | 125 | component: 'RadioButtonGroup', |
| 126 | 126 | componentProps: { |
| 127 | 127 | #if ("" != $dictType)## 有数据字典 |
| 128 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') | |
| 128 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), | |
| 129 | 129 | #else##没数据字典 |
| 130 | - options:[] | |
| 130 | + options:[], | |
| 131 | 131 | #end |
| 132 | - } | |
| 132 | + }, | |
| 133 | 133 | #elseif($column.htmlType == "datetime")## 时间框 |
| 134 | - component: 'DatePicker' | |
| 134 | + component: 'DatePicker', | |
| 135 | 135 | #elseif($column.htmlType == "textarea")## 文本域 |
| 136 | - component: 'InputTextArea' | |
| 136 | + component: 'InputTextArea', | |
| 137 | 137 | #end |
| 138 | 138 | }, |
| 139 | 139 | #end |
| ... | ... | @@ -146,7 +146,7 @@ export const updateFormSchema: FormSchema[] = [ |
| 146 | 146 | label: '编号', |
| 147 | 147 | field: 'id', |
| 148 | 148 | show: false, |
| 149 | - component: 'Input' | |
| 149 | + component: 'Input', | |
| 150 | 150 | }, |
| 151 | 151 | #foreach($column in $columns) |
| 152 | 152 | #if ($column.updateOperation) |
| ... | ... | @@ -162,44 +162,44 @@ export const updateFormSchema: FormSchema[] = [ |
| 162 | 162 | required: true, |
| 163 | 163 | #end |
| 164 | 164 | #if ($column.htmlType == "input") |
| 165 | - component: 'Input' | |
| 165 | + component: 'Input', | |
| 166 | 166 | #elseif($column.htmlType == "imageUpload")## 图片上传 |
| 167 | - component: 'Upload' | |
| 167 | + component: 'Upload', | |
| 168 | 168 | #elseif($column.htmlType == "fileUpload")## 文件上传 |
| 169 | - component: 'Upload' | |
| 169 | + component: 'Upload', | |
| 170 | 170 | #elseif($column.htmlType == "editor")## 文本编辑器 |
| 171 | - component: 'Editor' | |
| 171 | + component: 'Editor', | |
| 172 | 172 | #elseif($column.htmlType == "select")## 下拉框 |
| 173 | 173 | component: 'Select', |
| 174 | 174 | componentProps: { |
| 175 | 175 | #if ("" != $dictType)## 有数据字典 |
| 176 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') | |
| 176 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), | |
| 177 | 177 | #else##没数据字典 |
| 178 | - options:[] | |
| 178 | + options:[], | |
| 179 | 179 | #end |
| 180 | - } | |
| 180 | + }, | |
| 181 | 181 | #elseif($column.htmlType == "checkbox")## 多选框 |
| 182 | 182 | component: 'Checkbox', |
| 183 | 183 | componentProps: { |
| 184 | 184 | #if ("" != $dictType)## 有数据字典 |
| 185 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') | |
| 185 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), | |
| 186 | 186 | #else##没数据字典 |
| 187 | - options:[] | |
| 187 | + options:[], | |
| 188 | 188 | #end |
| 189 | - } | |
| 189 | + }, | |
| 190 | 190 | #elseif($column.htmlType == "radio")## 单选框 |
| 191 | 191 | component: 'RadioButtonGroup', |
| 192 | 192 | componentProps: { |
| 193 | 193 | #if ("" != $dictType)## 有数据字典 |
| 194 | - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number') | |
| 194 | + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), | |
| 195 | 195 | #else##没数据字典 |
| 196 | - options:[] | |
| 196 | + options:[], | |
| 197 | 197 | #end |
| 198 | - } | |
| 198 | + }, | |
| 199 | 199 | #elseif($column.htmlType == "datetime")## 时间框 |
| 200 | - component: 'DatePicker' | |
| 200 | + component: 'DatePicker', | |
| 201 | 201 | #elseif($column.htmlType == "textarea")## 文本域 |
| 202 | - component: 'InputTextArea' | |
| 202 | + component: 'InputTextArea', | |
| 203 | 203 | #end |
| 204 | 204 | }, |
| 205 | 205 | #end | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm
| 1 | -<template> | |
| 2 | - <BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? t('action.edit') : t('action.create')" @ok="handleSubmit"> | |
| 3 | - <BasicForm @register="registerForm" /> | |
| 4 | - </BasicModal> | |
| 5 | -</template> | |
| 6 | 1 | <script lang="ts" setup> |
| 7 | 2 | import { ref, unref } from 'vue' |
| 3 | +import { createFormSchema, updateFormSchema } from './${classNameVar}.data' | |
| 8 | 4 | import { useI18n } from '@/hooks/web/useI18n' |
| 9 | 5 | import { useMessage } from '@/hooks/web/useMessage' |
| 10 | 6 | import { BasicForm, useForm } from '@/components/Form' |
| 11 | 7 | import { BasicModal, useModalInner } from '@/components/Modal' |
| 12 | -import { createFormSchema, updateFormSchema } from './${classNameVar}.data' | |
| 13 | 8 | import { create${simpleClassName}, get${simpleClassName}, update${simpleClassName} } from '@/api/${table.moduleName}/${classNameVar}' |
| 14 | 9 | |
| 15 | 10 | defineOptions({ name: '${table.className}Modal' }) |
| ... | ... | @@ -24,7 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, resetSchema, validate }] = u |
| 24 | 19 | baseColProps: { span: 24 }, |
| 25 | 20 | schemas: createFormSchema, |
| 26 | 21 | showActionButtonGroup: false, |
| 27 | - actionColOptions: { span: 23 } | |
| 22 | + actionColOptions: { span: 23 }, | |
| 28 | 23 | }) |
| 29 | 24 | |
| 30 | 25 | const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
| ... | ... | @@ -55,3 +50,8 @@ async function handleSubmit() { |
| 55 | 50 | } |
| 56 | 51 | } |
| 57 | 52 | </script> |
| 53 | +<template> | |
| 54 | + <BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? t('action.edit') : t('action.create')" @ok="handleSubmit"> | |
| 55 | + <BasicForm @register="registerForm" /> | |
| 56 | + </BasicModal> | |
| 57 | +</template> | |
| 58 | 58 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm
| 1 | -<template> | |
| 2 | - <div> | |
| 3 | - <BasicTable @register="registerTable"> | |
| 4 | - <template #toolbar> | |
| 5 | - <a-button type="primary" v-auth="['${permissionPrefix}:create']" :preIcon="IconEnum.ADD" @click="handleCreate"> | |
| 6 | - {{ t('action.create') }} | |
| 7 | - </a-button> | |
| 8 | - <a-button type="warning" v-auth="['${permissionPrefix}:export']" :preIcon="IconEnum.EXPORT" @click="handleExport"> | |
| 9 | - {{ t('action.export') }} | |
| 10 | - </a-button> | |
| 11 | - </template> | |
| 12 | - <template #bodyCell="{ column, record }"> | |
| 13 | - <template v-if="column.key === 'action'"> | |
| 14 | - <TableAction | |
| 15 | - :actions="[ | |
| 16 | - { icon: IconEnum.EDIT, label: t('action.edit'), auth: '${permissionPrefix}:update', onClick: handleEdit.bind(null, record) }, | |
| 17 | - { | |
| 18 | - icon: IconEnum.DELETE, | |
| 19 | - color: 'error', | |
| 20 | - label: t('action.delete'), | |
| 21 | - auth: '${permissionPrefix}:delete', | |
| 22 | - popConfirm: { | |
| 23 | - title: t('common.delMessage'), | |
| 24 | - placement: 'left', | |
| 25 | - confirm: handleDelete.bind(null, record) | |
| 26 | - } | |
| 27 | - } | |
| 28 | - ]" | |
| 29 | - /> | |
| 30 | - </template> | |
| 31 | - </template> | |
| 32 | - </BasicTable> | |
| 33 | - <${simpleClassName}Modal @register="registerModal" @success="reload()" /> | |
| 34 | - </div> | |
| 35 | -</template> | |
| 36 | 1 | <script lang="ts" setup> |
| 2 | +import ${simpleClassName}Modal from './${simpleClassName}Modal.vue' | |
| 3 | +import { columns, searchFormSchema } from './${classNameVar}.data' | |
| 37 | 4 | import { useI18n } from '@/hooks/web/useI18n' |
| 38 | 5 | import { useMessage } from '@/hooks/web/useMessage' |
| 39 | 6 | import { useModal } from '@/components/Modal' |
| 40 | -import ${simpleClassName}Modal from './${simpleClassName}Modal.vue' | |
| 41 | 7 | import { IconEnum } from '@/enums/appEnum' |
| 42 | 8 | import { BasicTable, useTable, TableAction } from '@/components/Table' |
| 43 | 9 | import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}' |
| 44 | -import { columns, searchFormSchema } from './${classNameVar}.data' | |
| 45 | 10 | |
| 46 | 11 | defineOptions({ name: '${table.className}' }) |
| 47 | 12 | |
| ... | ... | @@ -60,8 +25,8 @@ const [registerTable, { getForm, reload }] = useTable({ |
| 60 | 25 | width: 140, |
| 61 | 26 | title: t('common.action'), |
| 62 | 27 | dataIndex: 'action', |
| 63 | - fixed: 'right' | |
| 64 | - } | |
| 28 | + fixed: 'right', | |
| 29 | + }, | |
| 65 | 30 | }) |
| 66 | 31 | |
| 67 | 32 | function handleCreate() { |
| ... | ... | @@ -80,7 +45,7 @@ async function handleExport() { |
| 80 | 45 | async onOk() { |
| 81 | 46 | await export${simpleClassName}(getForm().getFieldsValue()) |
| 82 | 47 | createMessage.success(t('common.exportSuccessText')) |
| 83 | - } | |
| 48 | + }, | |
| 84 | 49 | }) |
| 85 | 50 | } |
| 86 | 51 | |
| ... | ... | @@ -90,3 +55,38 @@ async function handleDelete(record: Recordable) { |
| 90 | 55 | reload() |
| 91 | 56 | } |
| 92 | 57 | </script> |
| 58 | +<template> | |
| 59 | + <div> | |
| 60 | + <BasicTable @register="registerTable"> | |
| 61 | + <template #toolbar> | |
| 62 | + <a-button type="primary" v-auth="['${permissionPrefix}:create']" :preIcon="IconEnum.ADD" @click="handleCreate"> | |
| 63 | + {{ t('action.create') }} | |
| 64 | + </a-button> | |
| 65 | + <a-button type="warning" v-auth="['${permissionPrefix}:export']" :preIcon="IconEnum.EXPORT" @click="handleExport"> | |
| 66 | + {{ t('action.export') }} | |
| 67 | + </a-button> | |
| 68 | + </template> | |
| 69 | + <template #bodyCell="{ column, record }"> | |
| 70 | + <template v-if="column.key === 'action'"> | |
| 71 | + <TableAction | |
| 72 | + :actions="[ | |
| 73 | + { icon: IconEnum.EDIT, label: t('action.edit'), auth: '${permissionPrefix}:update', onClick: handleEdit.bind(null, record) }, | |
| 74 | + { | |
| 75 | + icon: IconEnum.DELETE, | |
| 76 | + danger: true, | |
| 77 | + label: t('action.delete'), | |
| 78 | + auth: '${permissionPrefix}:delete', | |
| 79 | + popConfirm: { | |
| 80 | + title: t('common.delMessage'), | |
| 81 | + placement: 'left', | |
| 82 | + confirm: handleDelete.bind(null, record), | |
| 83 | + }, | |
| 84 | + }, | |
| 85 | + ]" | |
| 86 | + /> | |
| 87 | + </template> | |
| 88 | + </template> | |
| 89 | + </BasicTable> | |
| 90 | + <${simpleClassName}Modal @register="registerModal" @success="reload()" /> | |
| 91 | + </div> | |
| 92 | +</template> | |
| 93 | 93 | \ No newline at end of file | ... | ... |