Commit b3a40af214aba8121795779c186c8e41de279b07

Authored by puhui999
1 parent 436eb29d

【代码优化】代码生成: vue3_vben5_antd schema 主子表模板优化

yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
@@ -154,15 +154,15 @@ public class CodegenEngine { @@ -154,15 +154,15 @@ public class CodegenEngine {
154 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("api/api.ts"), 154 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("api/api.ts"),
155 vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts")) 155 vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
156 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_normal.vue"), // 特殊:主子表专属逻辑 156 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_normal.vue"), // 特殊:主子表专属逻辑
157 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue")) 157 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue"))
158 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_inner.vue"), // 特殊:主子表专属逻辑 158 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_inner.vue"), // 特殊:主子表专属逻辑
159 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue")) 159 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue"))
160 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_erp.vue"), // 特殊:主子表专属逻辑 160 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_erp.vue"), // 特殊:主子表专属逻辑
161 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue")) 161 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue"))
162 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_inner.vue"), // 特殊:主子表专属逻辑 162 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_inner.vue"), // 特殊:主子表专属逻辑
163 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}List.vue")) 163 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
164 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑 164 .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑
165 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}List.vue")) 165 + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
166 .build(); 166 .build();
167 167
168 @Resource 168 @Resource
@@ -451,6 +451,8 @@ public class CodegenEngine { @@ -451,6 +451,8 @@ public class CodegenEngine {
451 filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName()); 451 filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName());
452 filePath = StrUtil.replace(filePath, "${subSimpleClassName}", 452 filePath = StrUtil.replace(filePath, "${subSimpleClassName}",
453 ((List<String>) bindingMap.get("subSimpleClassNames")).get(subIndex)); 453 ((List<String>) bindingMap.get("subSimpleClassNames")).get(subIndex));
  454 + filePath = StrUtil.replace(filePath, "${subSimpleClassName_strikeCase}",
  455 + ((List<String>) bindingMap.get("subSimpleClassName_strikeCases")).get(subIndex));
454 } 456 }
455 return filePath; 457 return filePath;
456 } 458 }
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm
@@ -23,6 +23,7 @@ export namespace ${simpleClassName}Api { @@ -23,6 +23,7 @@ export namespace ${simpleClassName}Api {
23 #end 23 #end
24 #end 24 #end
25 } 25 }
  26 +
26 #end 27 #end
27 /** ${table.classComment}信息 */ 28 /** ${table.classComment}信息 */
28 export interface ${simpleClassName} { 29 export interface ${simpleClassName} {
@@ -104,6 +105,7 @@ export function export${simpleClassName}(params: any) { @@ -104,6 +105,7 @@ export function export${simpleClassName}(params: any) {
104 #set ($subClassNameVar = $subClassNameVars.get($index)) 105 #set ($subClassNameVar = $subClassNameVars.get($index))
105 106
106 // ==================== 子表($subTable.classComment) ==================== 107 // ==================== 子表($subTable.classComment) ====================
  108 +
107 ## 情况一:MASTER_ERP 时,需要分查询页子表 109 ## 情况一:MASTER_ERP 时,需要分查询页子表
108 #if ( $table.templateType == 11 ) 110 #if ( $table.templateType == 11 )
109 /** 获得${subTable.classComment}分页 */ 111 /** 获得${subTable.classComment}分页 */
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm
@@ -88,7 +88,7 @@ export function useFormSchema(): VbenFormSchema[] { @@ -88,7 +88,7 @@ export function useFormSchema(): VbenFormSchema[] {
88 maxCount: 1, 88 maxCount: 1,
89 }, 89 },
90 #elseif($column.htmlType == "editor")## 文本编辑器 90 #elseif($column.htmlType == "editor")## 文本编辑器
91 - component: 'Editor', 91 + component: 'RichTextarea',
92 #elseif($column.htmlType == "select")## 下拉框 92 #elseif($column.htmlType == "select")## 下拉框
93 component: 'Select', 93 component: 'Select',
94 componentProps: { 94 componentProps: {
@@ -279,6 +279,7 @@ export function useGridColumns( @@ -279,6 +279,7 @@ export function useGridColumns(
279 #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 279 #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
280 #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) 280 #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
281 // ==================== 子表($subTable.classComment) ==================== 281 // ==================== 子表($subTable.classComment) ====================
  282 +
282 #if ($table.templateType == 11) ## erp 情况 283 #if ($table.templateType == 11) ## erp 情况
283 /** 新增/修改的表单 */ 284 /** 新增/修改的表单 */
284 export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { 285 export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
@@ -331,7 +332,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { @@ -331,7 +332,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
331 maxCount: 1, 332 maxCount: 1,
332 }, 333 },
333 #elseif($column.htmlType == "editor")## 文本编辑器 334 #elseif($column.htmlType == "editor")## 文本编辑器
334 - component: 'Editor', 335 + component: 'RichTextarea',
335 #elseif($column.htmlType == "select")## 下拉框 336 #elseif($column.htmlType == "select")## 下拉框
336 component: 'Select', 337 component: 'Select',
337 componentProps: { 338 componentProps: {
@@ -391,6 +392,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { @@ -391,6 +392,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
391 #end 392 #end
392 ]; 393 ];
393 } 394 }
  395 +
394 /** 列表的字段 */ 396 /** 列表的字段 */
395 export function use${subSimpleClassName}GridColumns( 397 export function use${subSimpleClassName}GridColumns(
396 onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, 398 onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
@@ -445,6 +447,7 @@ export function use${subSimpleClassName}GridColumns( @@ -445,6 +447,7 @@ export function use${subSimpleClassName}GridColumns(
445 }, 447 },
446 ]; 448 ];
447 } 449 }
  450 +
448 #else 451 #else
449 #if ($subTable.subJoinMany) ## 一对多 452 #if ($subTable.subJoinMany) ## 一对多
450 /** 新增/修改列表的字段 */ 453 /** 新增/修改列表的字段 */
@@ -510,6 +513,7 @@ export function use${subSimpleClassName}GridColumns( @@ -510,6 +513,7 @@ export function use${subSimpleClassName}GridColumns(
510 }, 513 },
511 ]; 514 ];
512 } 515 }
  516 +
513 #else 517 #else
514 /** 新增/修改的表单 */ 518 /** 新增/修改的表单 */
515 export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { 519 export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
@@ -562,7 +566,7 @@ export function use${subSimpleClassName}GridColumns( @@ -562,7 +566,7 @@ export function use${subSimpleClassName}GridColumns(
562 maxCount: 1, 566 maxCount: 1,
563 }, 567 },
564 #elseif($column.htmlType == "editor")## 文本编辑器 568 #elseif($column.htmlType == "editor")## 文本编辑器
565 - component: 'Editor', 569 + component: 'RichTextarea',
566 #elseif($column.htmlType == "select")## 下拉框 570 #elseif($column.htmlType == "select")## 下拉框
567 component: 'Select', 571 component: 'Select',
568 componentProps: { 572 componentProps: {
@@ -622,6 +626,7 @@ export function use${subSimpleClassName}GridColumns( @@ -622,6 +626,7 @@ export function use${subSimpleClassName}GridColumns(
622 #end 626 #end
623 ]; 627 ];
624 } 628 }
  629 +
625 #end 630 #end
626 #if ($table.templateType == 12) ## 内嵌情况 631 #if ($table.templateType == 12) ## 内嵌情况
627 /** 列表的字段 */ 632 /** 列表的字段 */
@@ -649,6 +654,7 @@ export function use${subSimpleClassName}GridColumns( @@ -649,6 +654,7 @@ export function use${subSimpleClassName}GridColumns(
649 #end 654 #end
650 ]; 655 ];
651 } 656 }
  657 +
652 #end 658 #end
653 #end 659 #end
654 #end 660 #end
655 \ No newline at end of file 661 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/form.vue.vm
@@ -6,7 +6,9 @@ import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGro @@ -6,7 +6,9 @@ import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGro
6 ## 特殊:主子表专属逻辑 6 ## 特殊:主子表专属逻辑
7 #if ( $table.templateType == 10 || $table.templateType == 12 ) 7 #if ( $table.templateType == 10 || $table.templateType == 12 )
8 #foreach ($subSimpleClassName in $subSimpleClassNames) 8 #foreach ($subSimpleClassName in $subSimpleClassNames)
9 - import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue' 9 + #set ($index = $foreach.count - 1)
  10 + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
  11 + import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
10 #end 12 #end
11 #end 13 #end
12 14
@@ -125,9 +127,7 @@ const [Modal, modalApi] = useVbenModal({ @@ -125,9 +127,7 @@ const [Modal, modalApi] = useVbenModal({
125 if (!data) { 127 if (!data) {
126 return; 128 return;
127 } 129 }
128 -  
129 if (data.id) { 130 if (data.id) {
130 - // 编辑  
131 modalApi.lock(); 131 modalApi.lock();
132 try { 132 try {
133 data = await get${simpleClassName}(data.id); 133 data = await get${simpleClassName}(data.id);
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm
@@ -10,7 +10,9 @@ import Form from &#39;./modules/form.vue&#39;; @@ -10,7 +10,9 @@ import Form from &#39;./modules/form.vue&#39;;
10 ## 特殊:主子表专属逻辑 10 ## 特殊:主子表专属逻辑
11 #if ( $table.templateType == 11 || $table.templateType == 12 ) 11 #if ( $table.templateType == 11 || $table.templateType == 12 )
12 #foreach ($subSimpleClassName in $subSimpleClassNames) 12 #foreach ($subSimpleClassName in $subSimpleClassNames)
13 - import ${subSimpleClassName}List from './modules/${subSimpleClassName}List.vue' 13 + #set ($index = $foreach.count - 1)
  14 + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
  15 + import ${subSimpleClassName}List from './modules/${subSimpleClassName_strikeCase}-list.vue'
14 #end 16 #end
15 #end 17 #end
16 18
@@ -54,12 +56,6 @@ function onRefresh() { @@ -54,12 +56,6 @@ function onRefresh() {
54 #end 56 #end
55 } 57 }
56 58
57 -/** 导出表格 */  
58 -async function onExport() {  
59 - const data = await export${simpleClassName}(await gridApi.formApi.getValues());  
60 - downloadByData(data, '${table.classComment}.xls');  
61 -}  
62 -  
63 /** 创建${table.classComment} */ 59 /** 创建${table.classComment} */
64 function onCreate() { 60 function onCreate() {
65 formModalApi.setData({}).open(); 61 formModalApi.setData({}).open();
@@ -96,6 +92,12 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) { @@ -96,6 +92,12 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
96 } 92 }
97 } 93 }
98 94
  95 +/** 导出表格 */
  96 +async function onExport() {
  97 + const data = await export${simpleClassName}(await gridApi.formApi.getValues());
  98 + downloadByData(data, '${table.classComment}.xls');
  99 +}
  100 +
99 /** 表格操作按钮的回调函数 */ 101 /** 表格操作按钮的回调函数 */
100 function onActionClick({ 102 function onActionClick({
101 code, 103 code,
@@ -108,14 +110,14 @@ function onActionClick({ @@ -108,14 +110,14 @@ function onActionClick({
108 break; 110 break;
109 } 111 }
110 #end 112 #end
111 - case 'delete': {  
112 - onDelete(row);  
113 - break;  
114 - }  
115 case 'edit': { 113 case 'edit': {
116 onEdit(row); 114 onEdit(row);
117 break; 115 break;
118 } 116 }
  117 + case 'delete': {
  118 + onDelete(row);
  119 + break;
  120 + }
119 } 121 }
120 } 122 }
121 123
@@ -179,7 +181,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ @@ -179,7 +181,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
179 #if ($table.templateType == 12) ## 内嵌情况 181 #if ($table.templateType == 12) ## 内嵌情况
180 <template #expand_content="{ row }"> 182 <template #expand_content="{ row }">
181 <!-- 子表的表单 --> 183 <!-- 子表的表单 -->
182 - <Tabs v-model:active-key="subTabsName"> 184 + <Tabs v-model:active-key="subTabsName" class="mx-8">
183 #foreach ($subTable in $subTables) 185 #foreach ($subTable in $subTables)
184 #set ($index = $foreach.count - 1) 186 #set ($index = $foreach.count - 1)
185 #set ($subClassNameVar = $subClassNameVars.get($index)) 187 #set ($subClassNameVar = $subClassNameVars.get($index))
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_normal.vue.vm
@@ -24,7 +24,7 @@ import { get${subSimpleClassName}By${SubJoinColumnName} } from &#39;#/api/${table.mo @@ -24,7 +24,7 @@ import { get${subSimpleClassName}By${SubJoinColumnName} } from &#39;#/api/${table.mo
24 #end 24 #end
25 25
26 const props = defineProps<{ 26 const props = defineProps<{
27 - ${subJoinColumn.javaField}?: any // ${subJoinColumn.columnComment}(主表的关联字段) 27 + ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
28 }>() 28 }>()
29 29
30 #if ($subTable.subJoinMany) ## 一对多 30 #if ($subTable.subJoinMany) ## 一对多
@@ -41,7 +41,7 @@ function onActionClick({ @@ -41,7 +41,7 @@ function onActionClick({
41 } 41 }
42 } 42 }
43 43
44 -const [${subSimpleClassName}Grid, ${subClassNameVar}GridApi] = useVbenVxeGrid({ 44 +const [Grid, gridApi] = useVbenVxeGrid({
45 gridOptions: { 45 gridOptions: {
46 columns: use${subSimpleClassName}GridEditColumns(onActionClick), 46 columns: use${subSimpleClassName}GridEditColumns(onActionClick),
47 border: true, 47 border: true,
@@ -60,34 +60,25 @@ gridOptions: { @@ -60,34 +60,25 @@ gridOptions: {
60 }, 60 },
61 }); 61 });
62 62
63 -/** 删除${subTable.classComment} */  
64 -const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => {  
65 - await ${subClassNameVar}GridApi.grid.remove(row); 63 +/** 添加${subTable.classComment} */
  64 +const onAdd = async () => {
  65 + await gridApi.grid.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1);
66 } 66 }
67 67
68 -/** 添加${subTable.classComment} */  
69 -const handleAdd = async () => {  
70 - await ${subClassNameVar}GridApi.grid.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1); 68 +/** 删除${subTable.classComment} */
  69 +const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => {
  70 + await gridApi.grid.remove(row);
71 } 71 }
72 72
73 /** 提供获取表格数据的方法供父组件调用 */ 73 /** 提供获取表格数据的方法供父组件调用 */
74 defineExpose({ 74 defineExpose({
75 getData: (): ${simpleClassName}Api.${subSimpleClassName}[] => { 75 getData: (): ${simpleClassName}Api.${subSimpleClassName}[] => {
76 - // 获取当前数据,但排除已删除的记录  
77 - const allData = ${subClassNameVar}GridApi.grid.getData();  
78 - const removedData = ${subClassNameVar}GridApi.grid.getRemoveRecords();  
79 - const removedIds = new Set(removedData.map((row) => row.id));  
80 -  
81 - // 过滤掉已删除的记录  
82 - const currentData = allData.filter((row) => !removedIds.has(row.id));  
83 -  
84 - // 获取新插入的记录并移除id  
85 - const insertedData = ${subClassNameVar}GridApi.grid.getInsertRecords().map((row) => {  
86 - delete row.id;  
87 - return row;  
88 - });  
89 -  
90 - return [...currentData, ...insertedData]; 76 + const data = gridApi.grid.getData() as ${simpleClassName}Api.${subSimpleClassName}[];
  77 + const removeRecords = gridApi.grid.getRemoveRecords() as ${simpleClassName}Api.${subSimpleClassName}[];
  78 + const insertRecords = gridApi.grid.getInsertRecords() as ${simpleClassName}Api.${subSimpleClassName}[];
  79 + return data
  80 + .filter((row) => !removeRecords.some((removed) => removed.id === row.id))
  81 + .concat(insertRecords.map((row: any) => ({ ...row, id: undefined })));
91 }, 82 },
92 }); 83 });
93 84
@@ -98,14 +89,13 @@ watch( @@ -98,14 +89,13 @@ watch(
98 if (!val) { 89 if (!val) {
99 return; 90 return;
100 } 91 }
101 -  
102 await nextTick(); 92 await nextTick();
103 - await ${subClassNameVar}GridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!)); 93 + await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
104 }, 94 },
105 { immediate: true }, 95 { immediate: true },
106 ); 96 );
107 #else 97 #else
108 -const [${subSimpleClassName}Form, ${subClassNameVar}FormApi] = useVbenForm({ 98 +const [Form, formApi] = useVbenForm({
109 layout: 'horizontal', 99 layout: 'horizontal',
110 schema: use${subSimpleClassName}FormSchema(), 100 schema: use${subSimpleClassName}FormSchema(),
111 showDefaultActions: false 101 showDefaultActions: false
@@ -114,10 +104,10 @@ showDefaultActions: false @@ -114,10 +104,10 @@ showDefaultActions: false
114 /** 暴露出表单校验方法和表单值获取方法 */ 104 /** 暴露出表单校验方法和表单值获取方法 */
115 defineExpose({ 105 defineExpose({
116 validate: async () => { 106 validate: async () => {
117 - const { valid } = await ${subClassNameVar}FormApi.validate(); 107 + const { valid } = await formApi.validate();
118 return valid; 108 return valid;
119 }, 109 },
120 - getValues: ${subClassNameVar}FormApi.getValues, 110 + getValues: formApi.getValues,
121 }); 111 });
122 112
123 /** 监听主表的关联字段的变化,加载对应的子表数据 */ 113 /** 监听主表的关联字段的变化,加载对应的子表数据 */
@@ -127,9 +117,8 @@ watch( @@ -127,9 +117,8 @@ watch(
127 if (!val) { 117 if (!val) {
128 return; 118 return;
129 } 119 }
130 -  
131 await nextTick(); 120 await nextTick();
132 - await ${subClassNameVar}FormApi.setValues(await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)); 121 + await formApi.setValues(await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
133 }, 122 },
134 { immediate: true }, 123 { immediate: true },
135 ); 124 );
@@ -138,7 +127,7 @@ watch( @@ -138,7 +127,7 @@ watch(
138 127
139 <template> 128 <template>
140 #if ($subTable.subJoinMany) ## 一对多 129 #if ($subTable.subJoinMany) ## 一对多
141 - <${subSimpleClassName}Grid class="mx-4"> 130 + <Grid class="mx-4">
142 #foreach($column in $subColumns) 131 #foreach($column in $subColumns)
143 #if ($column.createOperation || $column.updateOperation) 132 #if ($column.createOperation || $column.updateOperation)
144 #set ($javaField = $column.javaField) 133 #set ($javaField = $column.javaField)
@@ -191,13 +180,13 @@ watch( @@ -191,13 +180,13 @@ watch(
191 #end 180 #end
192 #end 181 #end
193 #end 182 #end
194 - </${subSimpleClassName}Grid>  
195 - <div class="flex justify-center">  
196 - <Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']"> 183 + </Grid>
  184 + <div class="flex justify-center -mt-4">
  185 + <Button :icon="h(Plus)" type="primary" ghost @click="onAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
197 {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }} 186 {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
198 </Button> 187 </Button>
199 </div> 188 </div>
200 #else 189 #else
201 - <${subSimpleClassName}Form class="mx-4" /> 190 + <Form class="mx-4" />
202 #end 191 #end
203 </template> 192 </template>
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm
@@ -28,7 +28,7 @@ import { get${subSimpleClassName}By${SubJoinColumnName} } from &#39;#/api/${table.mo @@ -28,7 +28,7 @@ import { get${subSimpleClassName}By${SubJoinColumnName} } from &#39;#/api/${table.mo
28 #end 28 #end
29 29
30 const props = defineProps<{ 30 const props = defineProps<{
31 - ${subJoinColumn.javaField}?: any // ${subJoinColumn.columnComment}(主表的关联字段) 31 + ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
32 }>() 32 }>()
33 33
34 #if ($table.templateType == 11) ## erp 34 #if ($table.templateType == 11) ## erp
@@ -46,6 +46,7 @@ function onCreate() { @@ -46,6 +46,7 @@ function onCreate() {
46 function onEdit(row: ${simpleClassName}Api.${subSimpleClassName}) { 46 function onEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
47 formModalApi.setData(row).open(); 47 formModalApi.setData(row).open();
48 } 48 }
  49 +
49 /** 删除${subTable.classComment} */ 50 /** 删除${subTable.classComment} */
50 async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) { 51 async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
51 const hideLoading = message.loading({ 52 const hideLoading = message.loading({
@@ -71,16 +72,17 @@ function onActionClick({ @@ -71,16 +72,17 @@ function onActionClick({
71 row, 72 row,
72 }: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) { 73 }: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
73 switch (code) { 74 switch (code) {
74 - case 'delete': {  
75 - onDelete(row);  
76 - break;  
77 - }  
78 case 'edit': { 75 case 'edit': {
79 onEdit(row); 76 onEdit(row);
80 break; 77 break;
81 } 78 }
  79 + case 'delete': {
  80 + onDelete(row);
  81 + break;
  82 + }
82 } 83 }
83 } 84 }
  85 +
84 #end 86 #end
85 const [Grid, gridApi] = useVbenVxeGrid({ 87 const [Grid, gridApi] = useVbenVxeGrid({
86 gridOptions: { 88 gridOptions: {
@@ -119,7 +121,6 @@ const onRefresh = async ()=&gt; { @@ -119,7 +121,6 @@ const onRefresh = async ()=&gt; {
119 if (!val) { 121 if (!val) {
120 return; 122 return;
121 } 123 }
122 -  
123 await nextTick(); 124 await nextTick();
124 await onRefresh() 125 await onRefresh()
125 }, 126 },
@@ -128,18 +129,16 @@ const onRefresh = async ()=&gt; { @@ -128,18 +129,16 @@ const onRefresh = async ()=&gt; {
128 </script> 129 </script>
129 130
130 <template> 131 <template>
131 - <div class="mx-4">  
132 - #if ($table.templateType == 11) ## erp  
133 - <FormModal @success="onRefresh" />  
134 - <Grid table-title="${subTable.classComment}列表">  
135 - <template #toolbar-tools>  
136 - <Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${subTable.moduleName}:${subSimpleClassName_strikeCase}:create']">  
137 - {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}  
138 - </Button>  
139 - </template>  
140 - </Grid>  
141 - #else  
142 - <Grid table-title="${subTable.classComment}列表" />  
143 - #end  
144 - </div> 132 + #if ($table.templateType == 11) ## erp
  133 + <FormModal @success="onRefresh" />
  134 + <Grid table-title="${subTable.classComment}列表">
  135 + <template #toolbar-tools>
  136 + <Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${subTable.moduleName}:${subSimpleClassName_strikeCase}:create']">
  137 + {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
  138 + </Button>
  139 + </template>
  140 + </Grid>
  141 + #else
  142 + <Grid table-title="${subTable.classComment}列表" />
  143 + #end
145 </template> 144 </template>
146 \ No newline at end of file 145 \ No newline at end of file