Commit ed920f3fd3df8c5d11dd5880cffb99a528de4559

Authored by puhui999
1 parent 380cc87e

【代码优化】INFRA:代码生成 vben5 antd 模版

yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
... ... @@ -164,8 +164,6 @@ public class CodegenEngine {
164 164 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑
165 165 vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
166 166 // VUE3_VBEN5_ANTD
167   - .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/data.ts"),
168   - vue3FilePath("views/${table.moduleName}/${table.businessName}/data.ts"))
169 167 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/index.vue"),
170 168 vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
171 169 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/form.vue"),
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/api/api.ts.vm
1 1 import type { PageParam, PageResult } from '@vben/request';
  2 +import type { Dayjs } from 'dayjs';
2 3  
3 4 import { requestClient } from '#/api/request';
4 5 #set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
... ... @@ -16,7 +17,7 @@ export namespace ${simpleClassName}Api {
16 17 #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
17 18 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
18 19 #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
19   - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
  20 + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
20 21 #else
21 22 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
22 23 #end
... ... @@ -32,7 +33,7 @@ export namespace ${simpleClassName}Api {
32 33 #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
33 34 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
34 35 #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
35   - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
  36 + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
36 37 #else
37 38 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
38 39 #end
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/data.ts.vm deleted
1   -import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
2   -import type { VbenFormSchema } from '#/adapter/form';
3   -import type { OnActionClickFn } from '#/adapter/vxe-table';
4   -import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
5   -
6   -import { z } from '#/adapter/form';
7   -#if(${table.templateType} == 2)## 树表需要导入这些
8   -import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
9   -import { handleTree } from '#/utils/tree';
10   -#end
11   -import { DICT_TYPE, getDictOptions } from '#/utils/dict';
12   -import { getRangePickerDefaultProps } from '#/utils/date';
13   -import { useAccess } from '@vben/access';
14   -
15   -const { hasAccessByCodes } = useAccess();
16   -
17   -/** 列表的搜索表单 */
18   -export function useGridFormSchema(): VbenFormSchema[] {
19   - return [
20   -#foreach($column in $columns)
21   -#if ($column.listOperation)
22   - #set ($dictType = $column.dictType)
23   - #set ($javaType = $column.javaType)
24   - #set ($javaField = $column.javaField)
25   - #set ($comment = $column.columnComment)
26   - #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
27   - #set ($dictMethod = "number")
28   - #elseif ($javaType == "String")
29   - #set ($dictMethod = "string")
30   - #elseif ($javaType == "Boolean")
31   - #set ($dictMethod = "boolean")
32   - #end
33   - {
34   - fieldName: '${javaField}',
35   - label: '${comment}',
36   - #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor")
37   - component: 'Input',
38   - componentProps: {
39   - allowClear: true,
40   - placeholder: '请输入${comment}',
41   - },
42   - #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
43   - component: 'Select',
44   - componentProps: {
45   - allowClear: true,
46   - #if ("" != $dictType)## 设置了 dictType 数据字典的情况
47   - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
48   - #else## 未设置 dictType 数据字典的情况
49   - options: [],
50   - #end
51   - placeholder: '请选择${comment}',
52   - },
53   - #elseif($column.htmlType == "datetime")
54   - component: 'RangePicker',
55   - componentProps: {
56   - ...getRangePickerDefaultProps(),
57   - allowClear: true,
58   - },
59   - #end
60   - },
61   -#end
62   -#end
63   - ];
64   -}
65   -
66   -/** 列表的字段 */
67   -export function useGridColumns(
68   - onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>,
69   -): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
70   - return [
71   -#if ($table.templateType == 12) ## 内嵌情况
72   - { type: 'expand', width: 80, slots: { content: 'expand_content' } },
73   -#end
74   -#foreach($column in $columns)
75   -#if ($column.listOperationResult)
76   - #set ($dictType = $column.dictType)
77   - #set ($javaField = $column.javaField)
78   - #set ($comment = $column.columnComment)
79   - {
80   - field: '${javaField}',
81   - title: '${comment}',
82   - minWidth: 120,
83   - #if ($column.javaType == "LocalDateTime")## 时间类型
84   - formatter: 'formatDateTime',
85   - #elseif("" != $dictType)## 数据字典
86   - cellRender: {
87   - name: 'CellDict',
88   - props: { type: DICT_TYPE.$dictType.toUpperCase() },
89   - },
90   - #end
91   - #if (${table.templateType} == 2 && $column.id == $treeNameColumn.id)## 树表特有:标记树节点列
92   - treeNode: true,
93   - #end
94   - },
95   -#end
96   -#end
97   - {
98   - field: 'operation',
99   - title: '操作',
100   - minWidth: 200,
101   - align: 'center',
102   - fixed: 'right',
103   - headerAlign: 'center',
104   - showOverflow: false,
105   - cellRender: {
106   - attrs: {
107   - nameField: '${columns[0].javaField}',
108   - nameTitle: '${table.classComment}',
109   - onClick: onActionClick,
110   - },
111   - name: 'CellOperation',
112   - options: [
113   -#if (${table.templateType} == 2)## 树表特有操作
114   - {
115   - code: 'append',
116   - text: '新增下级',
117   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:create']),
118   - },
119   -#end
120   - {
121   - code: 'edit',
122   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
123   - },
124   - {
125   - code: 'delete',
126   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
127   -#if (${table.templateType} == 2)## 树表禁止删除带有子节点的数据
128   - disabled: (row: ${simpleClassName}Api.${simpleClassName}) => {
129   - return !!(row.children && row.children.length > 0);
130   - },
131   -#end
132   - },
133   - ],
134   - },
135   - },
136   - ];
137   -}
138   -
139   -## 标准模式和内嵌模式时,主子关系一对一则生成表单schema,一对多则生成列表schema(内嵌模式时表单schema也要生成)。erp 模式时都生成
140   -## 特殊:主子表专属逻辑
141   -#foreach ($subTable in $subTables)
142   - #set ($index = $foreach.count - 1)
143   - #set ($subColumns = $subColumnsList.get($index))##当前字段数组
144   - #set ($subSimpleClassName = $subSimpleClassNames.get($index))
145   - #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
146   - #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
147   -// ==================== 子表($subTable.classComment) ====================
148   -
149   -#if ($table.templateType == 11) ## erp 情况
150   -/** 列表的搜索表单 */
151   -export function use${subSimpleClassName}GridFormSchema(): VbenFormSchema[] {
152   - return [
153   - #foreach($column in $subColumns)
154   - #if ($column.listOperation)
155   - #set ($dictType = $column.dictType)
156   - #set ($javaType = $column.javaType)
157   - #set ($javaField = $column.javaField)
158   - #set ($comment = $column.columnComment)
159   - #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
160   - #set ($dictMethod = "number")
161   - #elseif ($javaType == "String")
162   - #set ($dictMethod = "string")
163   - #elseif ($javaType == "Boolean")
164   - #set ($dictMethod = "boolean")
165   - #end
166   - {
167   - fieldName: '${javaField}',
168   - label: '${comment}',
169   - #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor")
170   - component: 'Input',
171   - componentProps: {
172   - allowClear: true,
173   - placeholder: '请输入${comment}',
174   - },
175   - #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
176   - component: 'Select',
177   - componentProps: {
178   - allowClear: true,
179   - #if ("" != $dictType)## 设置了 dictType 数据字典的情况
180   - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
181   - #else## 未设置 dictType 数据字典的情况
182   - options: [],
183   - #end
184   - placeholder: '请选择${comment}',
185   - },
186   - #elseif($column.htmlType == "datetime")
187   - component: 'RangePicker',
188   - componentProps: {
189   - ...getRangePickerDefaultProps(),
190   - allowClear: true,
191   - },
192   - #end
193   - },
194   - #end
195   - #end
196   - ];
197   -}
198   -
199   -/** 列表的字段 */
200   -export function use${subSimpleClassName}GridColumns(
201   - onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
202   -): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
203   - return [
204   - #foreach($column in $subColumns)
205   - #if ($column.listOperationResult)
206   - #set ($dictType = $column.dictType)
207   - #set ($javaField = $column.javaField)
208   - #set ($comment = $column.columnComment)
209   - {
210   - field: '${javaField}',
211   - title: '${comment}',
212   - minWidth: 120,
213   - #if ($column.javaType == "LocalDateTime")## 时间类型
214   - formatter: 'formatDateTime',
215   - #elseif("" != $dictType)## 数据字典
216   - cellRender: {
217   - name: 'CellDict',
218   - props: { type: DICT_TYPE.$dictType.toUpperCase() },
219   - },
220   - #end
221   - },
222   - #end
223   - #end
224   - {
225   - field: 'operation',
226   - title: '操作',
227   - minWidth: 200,
228   - align: 'center',
229   - fixed: 'right',
230   - headerAlign: 'center',
231   - showOverflow: false,
232   - cellRender: {
233   - attrs: {
234   - nameField: '${columns[0].javaField}',
235   - nameTitle: '${subTable.classComment}',
236   - onClick: onActionClick,
237   - },
238   - name: 'CellOperation',
239   - options: [
240   - {
241   - code: 'edit',
242   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
243   - },
244   - {
245   - code: 'delete',
246   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
247   - },
248   - ],
249   - },
250   - },
251   - ];
252   -}
253   -
254   -#else
255   - #if ($subTable.subJoinMany) ## 一对多
256   - /** 新增/修改列表的字段 */
257   - export function use${subSimpleClassName}GridEditColumns(
258   - onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
259   - ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
260   - return [
261   - #foreach($column in $subColumns)
262   - #if ($column.createOperation || $column.updateOperation)
263   - #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
264   - #set ($dictType = $column.dictType)
265   - #set ($javaField = $column.javaField)
266   - #set ($comment = $column.columnComment)
267   - #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
268   - #set ($dictMethod = "number")
269   - #elseif ($javaType == "String")
270   - #set ($dictMethod = "string")
271   - #elseif ($javaType == "Boolean")
272   - #set ($dictMethod = "boolean")
273   - #end
274   - {
275   - field: '${javaField}',
276   - title: '${comment}',
277   - minWidth: 120,
278   - slots: { default: '${javaField}' },
279   - #if ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio")
280   - #if ("" != $dictType)## 有数据字典
281   - params: {
282   - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
283   - },
284   - #else
285   - params: {
286   - options: [],
287   - },
288   - #end
289   - #end
290   - },
291   - #end
292   - #end
293   - #end
294   - {
295   - field: 'operation',
296   - title: '操作',
297   - minWidth: 60,
298   - align: 'center',
299   - fixed: 'right',
300   - headerAlign: 'center',
301   - showOverflow: false,
302   - cellRender: {
303   - attrs: {
304   - nameField: '${columns[0].javaField}',
305   - nameTitle: '${table.classComment}',
306   - onClick: onActionClick,
307   - },
308   - name: 'CellOperation',
309   - options: [
310   - {
311   - code: 'delete',
312   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
313   - },
314   - ],
315   - },
316   - },
317   - ];
318   - }
319   - #end
320   - #if ($table.templateType == 12) ## 内嵌情况
321   - /** 列表的字段 */
322   - export function use${subSimpleClassName}GridColumns(): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
323   - return [
324   - #foreach($column in $subColumns)
325   - #if ($column.listOperationResult)
326   - #set ($dictType = $column.dictType)
327   - #set ($javaField = $column.javaField)
328   - #set ($comment = $column.columnComment)
329   - {
330   - field: '${javaField}',
331   - title: '${comment}',
332   - minWidth: 120,
333   - #if ($column.javaType == "LocalDateTime")## 时间类型
334   - formatter: 'formatDateTime',
335   - #elseif("" != $dictType)## 数据字典
336   - cellRender: {
337   - name: 'CellDict',
338   - props: { type: DICT_TYPE.$dictType.toUpperCase() },
339   - },
340   - #end
341   - },
342   - #end
343   - #end
344   - ];
345   - }
346   -
347   - #end
348   -#end
349   -#end
350 0 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/form.vue.vm
... ... @@ -25,9 +25,8 @@ import { $t } from &#39;#/locales&#39;;
25 25 import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
26 26  
27 27 const emit = defineEmits(['success']);
  28 +
28 29 const formRef = ref();
29   -const labelCol = { span: 5 };
30   -const wrapperCol = { span: 13 };
31 30 const formData = ref<Partial<${simpleClassName}Api.${simpleClassName}>>({
32 31 #foreach ($column in $columns)
33 32 #if ($column.createOperation || $column.updateOperation)
... ... @@ -156,7 +155,6 @@ const [Modal, modalApi] = useVbenModal({
156 155 resetForm()
157 156 return;
158 157 }
159   -
160 158 // 加载数据
161 159 let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
162 160 if (!data) {
... ... @@ -185,8 +183,8 @@ const [Modal, modalApi] = useVbenModal({
185 183 ref="formRef"
186 184 :model="formData"
187 185 :rules="rules"
188   - :label-col="labelCol"
189   - :wrapper-col="wrapperCol"
  186 + :label-col="{ span: 5 }"
  187 + :wrapper-col="{ span: 18 }"
190 188 >
191 189 #foreach($column in $columns)
192 190 #if ($column.createOperation || $column.updateOperation)
... ... @@ -239,9 +237,10 @@ const [Modal, modalApi] = useVbenModal({
239 237 <Select.Option
240 238 v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
241 239 :key="dict.value"
242   - :label="dict.label"
243 240 :value="dict.value"
244   - />
  241 + >
  242 + {{ dict.label }}
  243 + </Select.Option>
245 244 #else##没数据字典
246 245 <Select.Option label="请选择字典生成" value="" />
247 246 #end
... ... @@ -254,9 +253,10 @@ const [Modal, modalApi] = useVbenModal({
254 253 <Checkbox
255 254 v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
256 255 :key="dict.value"
257   - :label="dict.label"
258 256 :value="dict.value"
259   - />
  257 + >
  258 + {{ dict.label }}
  259 + </Checkbox>
260 260 #else##没数据字典
261 261 <Checkbox label="请选择字典生成" />
262 262 #end
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/index.vue.vm
1 1 <script lang="ts" setup>
2 2 import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
  3 +import type { VxeTableInstance } from 'vxe-table';
3 4  
4 5 import { Page, useVbenModal } from '@vben/common-ui';
5   -import { formatDateTime } from '@vben/utils';
  6 +import { cloneDeep, formatDateTime } from '@vben/utils';
6 7 import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
7 8 import { DictTag } from '#/components/dict-tag';
8 9 import { DICT_TYPE, getDictOptions } from '#/utils/dict';
... ... @@ -10,6 +11,7 @@ import ${simpleClassName}Form from &#39;./modules/form.vue&#39;;
10 11 import { Download, Plus, RefreshCw, Search } from '@vben/icons';
11 12 import { ContentWrap } from "#/components/content-wrap";
12 13 import { VxeColumn, VxeTable } from 'vxe-table';
  14 +import { TableToolbar } from '#/components/table-toolbar';
13 15 import { getRangePickerDefaultProps } from '#/utils/date';
14 16  
15 17 ## 特殊:主子表专属逻辑
... ... @@ -21,7 +23,7 @@ import { getRangePickerDefaultProps } from &#39;#/utils/date&#39;;
21 23 #end
22 24 #end
23 25  
24   -import { ref, h, reactive,onMounted } from 'vue';
  26 +import { ref, h, reactive,onMounted,nextTick } from 'vue';
25 27 import { $t } from '#/locales';
26 28 #if (${table.templateType} == 2)## 树表接口
27 29 import { handleTree } from '@/utils/tree'
... ... @@ -69,12 +71,22 @@ const exportLoading = ref(false) // 导出的加载中
69 71 const getList = async () => {
70 72 loading.value = true
71 73 try {
  74 + const params = cloneDeep(queryParams) as any;
  75 + #foreach ($column in $columns)
  76 + #if ($column.listOperation)
  77 + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
  78 + if (params.${column.javaField} && Array.isArray(params.${column.javaField})) {
  79 + params.${column.javaField} = (params.${column.javaField} as string[]).join(',');
  80 + }
  81 + #end
  82 + #end
  83 + #end
72 84 ## 特殊:树表专属逻辑(树不需要分页接口)
73 85 #if ( $table.templateType == 2 )
74   - const data = await get${simpleClassName}List(queryParams)
  86 + const data = await get${simpleClassName}List(params)
75 87 list.value = handleTree(data, 'id', '${treeParentColumn.javaField}')
76 88 #else
77   - const data = await get${simpleClassName}Page(queryParams)
  89 + const data = await get${simpleClassName}Page(params)
78 90 list.value = data.list
79 91 total.value = data.total
80 92 #end
... ... @@ -147,20 +159,30 @@ try {
147 159 }
148 160 }
149 161  
150   -/** 初始化 **/
151   -onMounted(() => {
152   - getList()
153   -})
  162 +/** 隐藏搜索栏 */
  163 +const hiddenSearchBar = ref(false);
  164 +const tableToolbarRef = ref<InstanceType<typeof TableToolbar>>();
  165 +const tableRef = ref<VxeTableInstance>();
  166 +/** 初始化 */
  167 +onMounted(async () => {
  168 + await getList();
  169 + await nextTick();
  170 + // 挂载 toolbar 工具栏
  171 + const table = tableRef.value;
  172 + const tableToolbar = tableToolbarRef.value;
  173 + if (table && tableToolbar) {
  174 + await table.connect(tableToolbar.getToolbarRef()!);
  175 + }
  176 +});
154 177 </script>
155 178  
156 179 <template>
157 180 <Page auto-content-height>
158 181 <FormModal @success="getList" />
159 182  
160   - <ContentWrap>
  183 + <ContentWrap v-if="!hiddenSearchBar">
161 184 <!-- 搜索工作栏 -->
162 185 <Form
163   - class="-mb-15px"
164 186 :model="queryParams"
165 187 ref="queryFormRef"
166 188 layout="inline"
... ... @@ -185,7 +207,7 @@ onMounted(() =&gt; {
185 207 placeholder="请输入${comment}"
186 208 allowClear
187 209 @pressEnter="handleQuery"
188   - class="!w-240px"
  210 + class="w-full"
189 211 />
190 212 </Form.Item>
191 213 #elseif ($column.htmlType == "select" || $column.htmlType == "radio" || $column.htmlType == "checkbox")
... ... @@ -194,15 +216,16 @@ onMounted(() =&gt; {
194 216 v-model:value="queryParams.${javaField}"
195 217 placeholder="请选择${comment}"
196 218 allowClear
197   - class="!w-240px"
  219 + class="w-full"
198 220 >
199 221 #if ("" != $dictType)## 设置了 dictType 数据字典的情况
200 222 <Select.Option
201 223 v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
202 224 :key="dict.value"
203   - :label="dict.label"
204 225 :value="dict.value"
205   - />
  226 + >
  227 + {{ dict.label }}
  228 + </Select.Option>
206 229 #else## 未设置 dictType 数据字典的情况
207 230 <Select.Option label="请选择字典生成" value="" />
208 231 #end
... ... @@ -216,7 +239,7 @@ onMounted(() =&gt; {
216 239 valueFormat="YYYY-MM-DD"
217 240 placeholder="选择${comment}"
218 241 allowClear
219   - class="!w-240px"
  242 + class="w-full"
220 243 />
221 244 </Form.Item>
222 245 #else## 范围
... ... @@ -224,7 +247,7 @@ onMounted(() =&gt; {
224 247 <RangePicker
225 248 v-model:value="queryParams.${javaField}"
226 249 v-bind="getRangePickerDefaultProps()"
227   - class="!w-220px"
  250 + class="w-full"
228 251 />
229 252 </Form.Item>
230 253 #end
... ... @@ -232,8 +255,21 @@ onMounted(() =&gt; {
232 255 #end
233 256 #end
234 257 <Form.Item>
235   - <Button class="ml-2" @click="handleQuery" :icon="h(Search)">搜索</Button>
236   - <Button class="ml-2" @click="resetQuery" :icon="h(RefreshCw)">重置</Button>
  258 + <Button class="ml-2" @click="resetQuery"> 重置 </Button>
  259 + <Button class="ml-2" @click="handleQuery" type="primary">
  260 + 搜索
  261 + </Button>
  262 + </Form.Item>
  263 + </Form>
  264 + </ContentWrap>
  265 +
  266 + <!-- 列表 -->
  267 + <ContentWrap title="${table.classComment}">
  268 + <template #extra>
  269 + <TableToolbar
  270 + ref="tableToolbarRef"
  271 + v-model:hidden-search="hiddenSearchBar"
  272 + >
237 273 <Button
238 274 class="ml-2"
239 275 :icon="h(Plus)"
... ... @@ -253,13 +289,9 @@ onMounted(() =&gt; {
253 289 >
254 290 {{ $t('ui.actionTitle.export') }}
255 291 </Button>
256   - </Form.Item>
257   - </Form>
258   - </ContentWrap>
259   -
260   - <!-- 列表 -->
261   - <ContentWrap>
262   - <vxe-table :data="list" show-overflow :loading="loading">
  292 + </TableToolbar>
  293 + </template>
  294 + <vxe-table ref="tableRef" :data="list" show-overflow :loading="loading">
263 295 ## 特殊:主子表专属逻辑
264 296 #if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
265 297 <!-- 子表的列表 -->
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm
1 1 import type { PageParam, PageResult } from '@vben/request';
  2 +import type { Dayjs } from 'dayjs';
2 3  
3 4 import { requestClient } from '#/api/request';
4 5 #set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
... ... @@ -16,7 +17,7 @@ export namespace ${simpleClassName}Api {
16 17 #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
17 18 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
18 19 #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
19   - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
  20 + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
20 21 #else
21 22 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
22 23 #end
... ... @@ -32,7 +33,7 @@ export namespace ${simpleClassName}Api {
32 33 #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
33 34 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
34 35 #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
35   - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
  36 + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
36 37 #else
37 38 ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
38 39 #end
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/form.vue.vm
... ... @@ -21,24 +21,11 @@ import { useFormSchema } from &#39;../data&#39;;
21 21  
22 22 const emit = defineEmits(['success']);
23 23 const formData = ref<${simpleClassName}Api.${simpleClassName}>();
24   -#if (${table.templateType} == 2)## 树表特有:父ID处理
25   -const parentId = ref<number>(); // 新增下级时的父级 ID
26   -
27   -const getTitle = computed(() => {
28   - if (formData.value?.id) {
29   - return $t('ui.actionTitle.edit', ['${table.classComment}']);
30   - }
31   - return parentId.value
32   - ? $t('ui.actionTitle.create', ['下级${table.classComment}'])
33   - : $t('ui.actionTitle.create', ['${table.classComment}']);
34   -});
35   -#else## 标准表标题
36 24 const getTitle = computed(() => {
37 25 return formData.value?.id
38 26 ? $t('ui.actionTitle.edit', ['${table.classComment}'])
39 27 : $t('ui.actionTitle.create', ['${table.classComment}']);
40 28 });
41   -#end
42 29  
43 30 ## 特殊:主子表专属逻辑
44 31 #if ( $table.templateType == 10 || $table.templateType == 12 )
... ... @@ -121,7 +108,6 @@ const [Modal, modalApi] = useVbenModal({
121 108 formData.value = undefined;
122 109 return;
123 110 }
124   -
125 111 // 加载数据
126 112 let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
127 113 if (!data) {
... ...