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 2898148ce6..8d48c20794 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 @@ -3,6 +3,12 @@ import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleCl import { useVbenModal } from '@vben/common-ui'; import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue'; +## 特殊:主子表专属逻辑 +#if ( $table.templateType == 10 || $table.templateType == 12 ) + #foreach ($subSimpleClassName in $subSimpleClassNames) + import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue' + #end +#end import { computed, ref } from 'vue'; import { $t } from '#/locales'; @@ -10,20 +16,6 @@ import { useVbenForm } from '#/adapter/form'; import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; import { useFormSchema } from '../data'; -#if ( $table.templateType == 10 || $table.templateType == 12 ) -#if ( $subTables && $subTables.size() > 0 ) -#foreach ($subTable in $subTables) - #set ($index = $foreach.count - 1) - #set ($subSimpleClassName = $subSimpleClassNames.get($index)) - #if ($subTable.subJoinMany) ## 一对多 -import { useVbenVxeGrid } from '#/adapter/vxe-table'; -import { use${subSimpleClassName}GridColumns } from '../data'; - #else -import { use${subSimpleClassName}FormSchema } from '../data'; - #end -#end -#end -#end const emit = defineEmits(['success']); const formData = ref<${simpleClassName}Api.${simpleClassName}>(); @@ -48,43 +40,17 @@ const getTitle = computed(() => { ## 特殊:主子表专属逻辑 #if ( $table.templateType == 10 || $table.templateType == 12 ) -#if ( $subTables && $subTables.size() > 0 ) -/** 子表的表单 */ -const subTabsName = ref('$subClassNameVars.get(0)') -## 特殊:主子表专属逻辑 -#foreach ($subTable in $subTables) - #set ($index = $foreach.count - 1) - #set ($subSimpleClassName = $subSimpleClassNames.get($index)) - #set ($subClassNameVar = $subClassNameVars.get($index)) - #if ($subTable.subJoinMany) ## 一对多 -const [${subSimpleClassName}Grid, ${subClassNameVar}GridApi] = useVbenVxeGrid({ - gridOptions: { - columns: use${subSimpleClassName}GridColumns(), - border: true, - showOverflow: true, - autoResize: true, - keepSource: true, - rowConfig: { - keyField: 'id', - }, - pagerConfig: { - enabled: false, - }, - toolbarConfig: { - enabled: false, - }, - }, -}); - #else -const [${subSimpleClassName}Form, ${subClassNameVar}FormApi] = useVbenForm({ - layout: 'horizontal', - schema: use${subSimpleClassName}FormSchema(), - showDefaultActions: false -}); + #if ( $subTables && $subTables.size() > 0 ) + + /** 子表的表单 */ + const subTabsName = ref('$subClassNameVars.get(0)') + #foreach ($subClassNameVar in $subClassNameVars) + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + const ${subClassNameVar}FormRef = ref>() + #end #end #end -#end -#end const [Form, formApi] = useVbenForm({ layout: 'horizontal', @@ -92,7 +58,6 @@ const [Form, formApi] = useVbenForm({ showDefaultActions: false }); -// TODO @puhui999: 处理完成主子表标准模式和内嵌模式下的表单提交 const [Modal, modalApi] = useVbenModal({ async onConfirm() { const { valid } = await formApi.validate(); @@ -107,9 +72,9 @@ const [Modal, modalApi] = useVbenModal({ #set ($index = $foreach.count - 1) #set ($subClassNameVar = $subClassNameVars.get($index)) #if ($subTable.subJoinMany) ## 一对多 - + ## TODO 列表值校验? #else - const { valid: ${subClassNameVar}Valid } = await ${subClassNameVar}FormApi.validate(); + const ${subClassNameVar}Valid = await ${subClassNameVar}FormRef.value?.validate(); if (!${subClassNameVar}Valid) { subTabsName.value = '${subClassNameVar}'; return; @@ -129,9 +94,9 @@ const [Modal, modalApi] = useVbenModal({ #set ($index = $foreach.count - 1) #set ($subClassNameVar = $subClassNameVars.get($index)) #if ($subTable.subJoinMany) - data.${subClassNameVar}s = ${subClassNameVar}GridApi.grid.getData(); + data.${subClassNameVar}s = ${subClassNameVar}FormRef.value?.getData(); #else - data.${subClassNameVar} = await ${subClassNameVar}FormApi.getValues(); + data.${subClassNameVar} = await ${subClassNameVar}FormRef.value?.getValues(); #end #end #end @@ -187,67 +152,9 @@ const [Modal, modalApi] = useVbenModal({ #set ($index = $foreach.count - 1) #set ($subClassNameVar = $subClassNameVars.get($index)) #set ($subSimpleClassName = $subSimpleClassNames.get($index)) - #set ($subColumns = $subColumnsList.get($index))##当前字段数组 - #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 - - #if ($subTable.subJoinMany) ## 一对多 - <${subSimpleClassName}Grid class="mx-4"> - #foreach($column in $subColumns) - #if ($column.createOperation || $column.updateOperation) - #set ($javaField = $column.javaField) - #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写 - #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里 - - #elseif($column.htmlType == "imageUpload")## 图片上传 - - #elseif($column.htmlType == "fileUpload")## 文件上传 - - #elseif($column.htmlType == "editor")## 文本编辑器 -