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 1565ab9cd7..37d1c5f96a 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 @@ -4,6 +4,26 @@ import { requestClient } from '#/api/request'; #set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") export namespace ${simpleClassName}Api { +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + #set ($subColumns = $subColumnsList.get($index))##当前字段数组 + /** ${subTable.classComment}信息 */ + export interface ${subSimpleClassName} { + #foreach ($column in $subColumns) + #if ($column.createOperation || $column.updateOperation) + #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal") + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment} + #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime") + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment} + #else + ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment} + #end + #end + #end + } +#end /** ${table.classComment}信息 */ export interface ${simpleClassName} { #foreach ($column in $columns) @@ -33,26 +53,6 @@ export namespace ${simpleClassName}Api { #end #end } -## 特殊:主子表专属逻辑 -#foreach ($subTable in $subTables) - #set ($index = $foreach.count - 1) - #set ($subSimpleClassName = $subSimpleClassNames.get($index)) - #set ($subColumns = $subColumnsList.get($index))##当前字段数组 - /** ${subTable.classComment}信息 */ - export interface ${subSimpleClassName} { - #foreach ($column in $subColumns) - #if ($column.createOperation || $column.updateOperation) - #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal") - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment} - #elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime") - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment} - #else - ${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment} - #end - #end - #end - } -#end } #if ( $table.templateType != 2 ) 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 12f6de370b..a600d3de26 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 @@ -167,13 +167,13 @@ export function useGridFormSchema(): VbenFormSchema[] { { fieldName: '${javaField}', label: '${comment}', - #if ($column.htmlType == "input") + #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor") component: 'Input', componentProps: { allowClear: true, placeholder: '请输入${comment}', }, - #elseif ($column.htmlType == "select") + #elseif ($column.htmlType == "select" || $column.htmlType == "radio") component: 'Select', componentProps: { allowClear: true, @@ -184,16 +184,6 @@ export function useGridFormSchema(): VbenFormSchema[] { #end placeholder: '请选择${comment}', }, - #elseif ($column.htmlType == "radio") - component: 'Select', - componentProps: { - allowClear: true, - #if ("" != $dictType)## 设置了 dictType 数据字典的情况 - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), - #else## 未设置 dictType 数据字典的情况 - options: [], - #end - }, #elseif($column.htmlType == "datetime") component: 'RangePicker', componentProps: { @@ -400,7 +390,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] { /** 列表的字段 */ export function use${subSimpleClassName}GridColumns( onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, -): VxeTableGridOptions<${subSimpleClassName}Api.${subSimpleClassName}>['columns'] { +): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] { return [ #foreach($column in $subColumns) #if ($column.listOperationResult) @@ -471,37 +461,39 @@ export function use${subSimpleClassName}GridColumns( /** 列表的字段 */ export function use${subSimpleClassName}GridColumns( onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, - ): VxeTableGridOptions<${subSimpleClassName}Api.${subSimpleClassName}>['columns'] { + ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] { return [ #foreach($column in $subColumns) - #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写 - #set ($dictType = $column.dictType) - #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 - { - field: '${javaField}', - title: '${comment}', - minWidth: 120, - slots: { default: '${javaField}' }, - #if ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio") - #if ("" != $dictType)## 有数据字典 - params: { - options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), - }, - #else - params: { - options: [], + #if ($column.createOperation || $column.updateOperation) + #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写 + #set ($dictType = $column.dictType) + #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 + { + field: '${javaField}', + title: '${comment}', + minWidth: 120, + slots: { default: '${javaField}' }, + #if ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio") + #if ("" != $dictType)## 有数据字典 + params: { + options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'), + }, + #else + params: { + options: [], + }, + #end + #end }, #end - #end - }, #end #end { 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 88156fb95e..2898148ce6 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 @@ -57,8 +57,7 @@ const subTabsName = ref('$subClassNameVars.get(0)') #set ($subSimpleClassName = $subSimpleClassNames.get($index)) #set ($subClassNameVar = $subClassNameVars.get($index)) #if ($subTable.subJoinMany) ## 一对多 -/** {$subTable.classComment}表格配置 */ -const [${subSimpleClassName}Grid, {$subClassNameVar}GridApi] = useVbenVxeGrid({ +const [${subSimpleClassName}Grid, ${subClassNameVar}GridApi] = useVbenVxeGrid({ gridOptions: { columns: use${subSimpleClassName}GridColumns(), border: true, @@ -77,9 +76,9 @@ const [${subSimpleClassName}Grid, {$subClassNameVar}GridApi] = useVbenVxeGrid({ }, }); #else -const [${subSimpleClassName}Form, {$subClassNameVar}FormApi] = useVbenForm({ +const [${subSimpleClassName}Form, ${subClassNameVar}FormApi] = useVbenForm({ layout: 'horizontal', - schema: useFormSchema(), + schema: use${subSimpleClassName}FormSchema(), showDefaultActions: false }); #end @@ -107,12 +106,15 @@ const [Modal, modalApi] = useVbenModal({ #foreach ($subTable in $subTables) #set ($index = $foreach.count - 1) #set ($subClassNameVar = $subClassNameVars.get($index)) - try { - await ${subClassNameVar}FormRef.value.validate() - } catch (e) { - subTabsName.value = '${subClassNameVar}' - return - } + #if ($subTable.subJoinMany) ## 一对多 + + #else + const { valid: ${subClassNameVar}Valid } = await ${subClassNameVar}FormApi.validate(); + if (!${subClassNameVar}Valid) { + subTabsName.value = '${subClassNameVar}'; + return; + } + #end #end #end #end @@ -126,7 +128,11 @@ const [Modal, modalApi] = useVbenModal({ #foreach ($subTable in $subTables) #set ($index = $foreach.count - 1) #set ($subClassNameVar = $subClassNameVars.get($index)) - data.${subClassNameVar}#if ( $subTable.subJoinMany)s#end = ${subClassNameVar}FormRef.value.getData() + #if ($subTable.subJoinMany) + data.${subClassNameVar}s = ${subClassNameVar}GridApi.grid.getData(); + #else + data.${subClassNameVar} = await ${subClassNameVar}FormApi.getValues(); + #end #end #end #end @@ -238,7 +244,7 @@ const [Modal, modalApi] = useVbenModal({ #end #end #end - + #else <${subSimpleClassName}Form class="mx-4" /> #end 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 43c2a3730f..f488d97f15 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 @@ -134,12 +134,11 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, #else## 标准表数据加载 query: async ({ page }, formValues) => { - const { items, total } = await get${simpleClassName}Page({ + return await get${simpleClassName}Page({ pageNo: page.currentPage, pageSize: page.pageSize, ...formValues, }); - return { items, total }; }, #end },