Commit 80a588975781c78f36a61365b071cfca764f2040

Authored by 芋道源码
Committed by Gitee
2 parents 7870283b 282c15c7

!565 vben代码生成模版

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