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 76f17674ab..0ec4f98260 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 @@ -154,15 +154,15 @@ public class CodegenEngine { .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("api/api.ts"), vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts")) .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_normal.vue"), // 特殊:主子表专属逻辑 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue")) + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue")) .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_inner.vue"), // 特殊:主子表专属逻辑 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue")) + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue")) .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_erp.vue"), // 特殊:主子表专属逻辑 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue")) + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue")) .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_inner.vue"), // 特殊:主子表专属逻辑 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}List.vue")) + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue")) .put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑 - vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}List.vue")) + vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue")) .build(); @Resource @@ -451,6 +451,8 @@ public class CodegenEngine { filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName()); filePath = StrUtil.replace(filePath, "${subSimpleClassName}", ((List) bindingMap.get("subSimpleClassNames")).get(subIndex)); + filePath = StrUtil.replace(filePath, "${subSimpleClassName_strikeCase}", + ((List) bindingMap.get("subSimpleClassName_strikeCases")).get(subIndex)); } return filePath; } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm index 37d1c5f96a..18dd72bd13 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm +++ b/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 { #end #end } + #end /** ${table.classComment}信息 */ export interface ${simpleClassName} { @@ -104,6 +105,7 @@ export function export${simpleClassName}(params: any) { #set ($subClassNameVar = $subClassNameVars.get($index)) // ==================== 子表($subTable.classComment) ==================== + ## 情况一:MASTER_ERP 时,需要分查询页子表 #if ( $table.templateType == 11 ) /** 获得${subTable.classComment}分页 */ diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm index 3ab28d2a1c..8f7420a810 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm +++ b/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[] { maxCount: 1, }, #elseif($column.htmlType == "editor")## 文本编辑器 - component: 'Editor', + component: 'RichTextarea', #elseif($column.htmlType == "select")## 下拉框 component: 'Select', componentProps: { @@ -279,6 +279,7 @@ export function useGridColumns( #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) // ==================== 子表($subTable.classComment) ==================== + #if ($table.templateType == 11) ## erp 情况 /** 新增/修改的表单 */ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { @@ -331,7 +332,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { maxCount: 1, }, #elseif($column.htmlType == "editor")## 文本编辑器 - component: 'Editor', + component: 'RichTextarea', #elseif($column.htmlType == "select")## 下拉框 component: 'Select', componentProps: { @@ -391,6 +392,56 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { #end ]; } + +/** 列表的搜索表单 */ +export function use${subSimpleClassName}GridFormSchema(): VbenFormSchema[] { + return [ + #foreach($column in $subColumns) + #if ($column.listOperation) + #set ($dictType = $column.dictType) + #set ($javaType = $column.javaType) + #set ($javaField = $column.javaField) + #set ($comment = $column.columnComment) + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") + #set ($dictMethod = "number") + #elseif ($javaType == "String") + #set ($dictMethod = "string") + #elseif ($javaType == "Boolean") + #set ($dictMethod = "boolean") + #end + { + fieldName: '${javaField}', + label: '${comment}', + #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor") + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入${comment}', + }, + #elseif ($column.htmlType == "select" || $column.htmlType == "radio") + component: 'Select', + componentProps: { + allowClear: true, + #if ("" != $dictType)## 设置了 dictType 数据字典的情况 + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), + #else## 未设置 dictType 数据字典的情况 + options: [], + #end + placeholder: '请选择${comment}', + }, + #elseif($column.htmlType == "datetime") + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + #end + }, + #end + #end + ]; +} + /** 列表的字段 */ export function use${subSimpleClassName}GridColumns( onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, @@ -434,17 +485,18 @@ export function use${subSimpleClassName}GridColumns( options: [ { code: 'edit', - show: hasAccessByCodes(['${subTable.moduleName}:${subSimpleClassName_strikeCase}:update']), + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']), }, { code: 'delete', - show: hasAccessByCodes(['${subTable.moduleName}:${subSimpleClassName_strikeCase}:delete']), + show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']), }, ], }, }, ]; } + #else #if ($subTable.subJoinMany) ## 一对多 /** 新增/修改列表的字段 */ @@ -510,6 +562,7 @@ export function use${subSimpleClassName}GridColumns( }, ]; } + #else /** 新增/修改的表单 */ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { @@ -562,7 +615,7 @@ export function use${subSimpleClassName}GridColumns( maxCount: 1, }, #elseif($column.htmlType == "editor")## 文本编辑器 - component: 'Editor', + component: 'RichTextarea', #elseif($column.htmlType == "select")## 下拉框 component: 'Select', componentProps: { @@ -622,6 +675,7 @@ export function use${subSimpleClassName}GridColumns( #end ]; } + #end #if ($table.templateType == 12) ## 内嵌情况 /** 列表的字段 */ @@ -649,6 +703,7 @@ export function use${subSimpleClassName}GridColumns( #end ]; } + #end #end #end \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/form.vue.vm index bdb7dd7d21..46e1ecc0a6 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/form.vue.vm +++ b/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 ## 特殊:主子表专属逻辑 #if ( $table.templateType == 10 || $table.templateType == 12 ) #foreach ($subSimpleClassName in $subSimpleClassNames) - import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue' + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) + import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue' #end #end @@ -125,9 +127,7 @@ const [Modal, modalApi] = useVbenModal({ if (!data) { return; } - if (data.id) { - // 编辑 modalApi.lock(); try { data = await get${simpleClassName}(data.id); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm index 41c4692702..bf27df8052 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm +++ b/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 './modules/form.vue'; ## 特殊:主子表专属逻辑 #if ( $table.templateType == 11 || $table.templateType == 12 ) #foreach ($subSimpleClassName in $subSimpleClassNames) - import ${subSimpleClassName}List from './modules/${subSimpleClassName}List.vue' + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) + import ${subSimpleClassName}List from './modules/${subSimpleClassName_strikeCase}-list.vue' #end #end @@ -26,9 +28,12 @@ import { downloadByData } from '#/utils/download'; import { useGridColumns, useGridFormSchema } from './data'; -#if ($table.templateType == 12) ## 内嵌情况 +#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况 /** 子表的列表 */ const subTabsName = ref('$subClassNameVars.get(0)') +#if ($table.templateType == 11) +const select${simpleClassName} = ref<${simpleClassName}Api.${simpleClassName}>(); +#end #end const [FormModal, formModalApi] = useVbenModal({ @@ -54,12 +59,6 @@ function onRefresh() { #end } -/** 导出表格 */ -async function onExport() { - const data = await export${simpleClassName}(await gridApi.formApi.getValues()); - downloadByData(data, '${table.classComment}.xls'); -} - /** 创建${table.classComment} */ function onCreate() { formModalApi.setData({}).open(); @@ -96,6 +95,12 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) { } } +/** 导出表格 */ +async function onExport() { + const data = await export${simpleClassName}(await gridApi.formApi.getValues()); + downloadByData(data, '${table.classComment}.xls'); +} + /** 表格操作按钮的回调函数 */ function onActionClick({ code, @@ -108,14 +113,14 @@ function onActionClick({ break; } #end - case 'delete': { - onDelete(row); - break; - } case 'edit': { onEdit(row); break; } + case 'delete': { + onDelete(row); + break; + } } } @@ -125,7 +130,11 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, gridOptions: { columns: useGridColumns(onActionClick), +#if (${table.templateType} == 11) + height: '600px', +#else height: 'auto', +#end #if (${table.templateType} == 2)## 树表设置 treeConfig: { parentField: '${treeParentColumn.javaField}', @@ -162,12 +171,22 @@ const [Grid, gridApi] = useVbenVxeGrid({ rowConfig: { keyField: 'id', isHover: true, +#if (${table.templateType} == 11) + isCurrent: true, +#end }, toolbarConfig: { refresh: { code: 'query' }, search: true, }, } as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>, +#if (${table.templateType} == 11) + gridEvents:{ + cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => { + select${simpleClassName}.value = row; + }, + } +#end }); @@ -175,11 +194,14 @@ const [Grid, gridApi] = useVbenVxeGrid({ +#if ($table.templateType == 11) ## erp情况 +
+#end #if ($table.templateType == 12) ## 内嵌情况 + +#if ($table.templateType == 11) ## erp情况 + + + #foreach ($subTable in $subTables) + #set ($index = $foreach.count - 1) + #set ($subClassNameVar = $subClassNameVars.get($index)) + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) + + <${subSimpleClassName}List :${subJoinColumn_strikeCase}="select${simpleClassName}?.id" /> + + #end + +
+#end
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_erp.vue.vm index 8cfb015f78..1b2c3f8200 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_erp.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_erp.vue.vm @@ -2,192 +2,85 @@ #set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) -#set ($subClassNameVar = $subClassNameVars.get($subIndex)) -#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写