Commit 9d272e79410423b8099b5d7f4aabdb3cdc03f1c5

Authored by YunaiV
1 parent a65b8f63

Vue3 CRUD Schema 模版,data 完整提交

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 {
187 187 templates.forEach((vmPath, filePath) -> {
188 188 filePath = formatFilePath(filePath, bindingMap);
189 189 String content = templateEngine.getTemplate(vmPath).render(bindingMap);
  190 + // 去除字段后面多余的 , 逗号
  191 + content = content.replaceAll(",\n}", "\n}").replaceAll(",\n }", "\n }");
190 192 result.put(filePath, content);
191 193 });
192 194 return result;
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
... ... @@ -182,7 +182,12 @@
182 182 #if ($dictMethods.size() > 0)
183 183 import { DICT_TYPE#foreach ($dictMethod in $dictMethods), ${dictMethod}#end } from '@/utils/dict'
184 184 #end
  185 +#foreach ($column in $columns)
  186 + #if ($column.listOperationResult && $column.htmlType == "datetime")
185 187 import { dateFormatter } from '@/utils/formatTime'
  188 + #break
  189 + #end
  190 +#end
186 191 import download from '@/utils/download'
187 192 import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'
188 193 import ${simpleClassName}Form from './${simpleClassName}Form.vue'
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm
1 1 import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
  2 +#foreach ($column in $columns)
  3 + #if ($column.listOperationResult && $column.htmlType == "datetime")
2 4 import { dateFormatter } from '@/utils/formatTime'
3   -const { t } = useI18n() // 国际化
  5 + #break
  6 + #end
  7 +#end
4 8  
5 9 // 表单校验
6 10 export const rules = reactive({
... ... @@ -12,7 +16,7 @@ export const rules = reactive({
12 16 #end
13 17 })
14 18  
15   -// CrudSchema
  19 +// CrudSchema https://kailong110120130.gitee.io/vue-element-plus-admin-doc/hooks/useCrudSchemas.html
16 20 const crudSchemas = reactive<CrudSchema[]>([
17 21 #foreach($column in $columns)
18 22 #if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation)
... ... @@ -20,7 +24,7 @@ const crudSchemas = reactive&lt;CrudSchema[]&gt;([
20 24 #set ($javaField = $column.javaField)
21 25 #set ($javaType = $column.javaType)
22 26 {
23   - title: '${column.columnComment}',
  27 + label: '${column.columnComment}',
24 28 field: '${column.javaField}',
25 29 ## ========= 字典部分 =========
26 30 #if ("" != $dictType)## 有数据字典
... ... @@ -36,6 +40,7 @@ const crudSchemas = reactive&lt;CrudSchema[]&gt;([
36 40 ## ========= Table 表格部分 =========
37 41 #if (!$column.listOperationResult)
38 42 isTable: false,
  43 + #else
39 44 #if ($column.htmlType == "datetime")
40 45 formatter: dateFormatter,
41 46 #end
... ... @@ -51,7 +56,7 @@ const crudSchemas = reactive&lt;CrudSchema[]&gt;([
51 56 type: 'daterange',
52 57 defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
53 58 }
54   - }
  59 + },
55 60 #end
56 61 #end
57 62 ## ========= Form 表单部分 =========
... ... @@ -82,7 +87,7 @@ const crudSchemas = reactive&lt;CrudSchema[]&gt;([
82 87 form: {
83 88 component: 'Checkbox'
84 89 },
85   - #elseif($column.htmlType == "checkbox")## 单选框
  90 + #elseif($column.htmlType == "radio")## 单选框
86 91 form: {
87 92 component: 'Radio'
88 93 },
... ...