diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java index 15b5ef5d3..a77502f5f 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java @@ -187,6 +187,8 @@ public class CodegenEngine { templates.forEach((vmPath, filePath) -> { filePath = formatFilePath(filePath, bindingMap); String content = templateEngine.getTemplate(vmPath).render(bindingMap); + // 去除字段后面多余的 , 逗号 + content = content.replaceAll(",\n}", "\n}").replaceAll(",\n }", "\n }"); result.put(filePath, content); }); return result; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm index 9cce26fd2..f396dde32 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -182,7 +182,12 @@ #if ($dictMethods.size() > 0) import { DICT_TYPE#foreach ($dictMethod in $dictMethods), ${dictMethod}#end } from '@/utils/dict' #end +#foreach ($column in $columns) + #if ($column.listOperationResult && $column.htmlType == "datetime") import { dateFormatter } from '@/utils/formatTime' + #break + #end +#end import download from '@/utils/download' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' import ${simpleClassName}Form from './${simpleClassName}Form.vue' diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm index 0cb639901..dd5b022cb 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm @@ -1,6 +1,10 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas' +#foreach ($column in $columns) + #if ($column.listOperationResult && $column.htmlType == "datetime") import { dateFormatter } from '@/utils/formatTime' -const { t } = useI18n() // 国际化 + #break + #end +#end // 表单校验 export const rules = reactive({ @@ -12,7 +16,7 @@ export const rules = reactive({ #end }) -// CrudSchema +// CrudSchema https://kailong110120130.gitee.io/vue-element-plus-admin-doc/hooks/useCrudSchemas.html const crudSchemas = reactive([ #foreach($column in $columns) #if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation) @@ -20,7 +24,7 @@ const crudSchemas = reactive([ #set ($javaField = $column.javaField) #set ($javaType = $column.javaType) { - title: '${column.columnComment}', + label: '${column.columnComment}', field: '${column.javaField}', ## ========= 字典部分 ========= #if ("" != $dictType)## 有数据字典 @@ -36,6 +40,7 @@ const crudSchemas = reactive([ ## ========= Table 表格部分 ========= #if (!$column.listOperationResult) isTable: false, + #else #if ($column.htmlType == "datetime") formatter: dateFormatter, #end @@ -51,7 +56,7 @@ const crudSchemas = reactive([ type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } - } + }, #end #end ## ========= Form 表单部分 ========= @@ -82,7 +87,7 @@ const crudSchemas = reactive([ form: { component: 'Checkbox' }, - #elseif($column.htmlType == "checkbox")## 单选框 + #elseif($column.htmlType == "radio")## 单选框 form: { component: 'Radio' },