From c50d27f5cbb43713c455a15ce12ea15442395c4b Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 21 Nov 2023 11:58:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=EF=BC=9A?= =?UTF-8?q?=E5=AE=8C=E5=96=84=20vue2=20=E6=A8=A1=E7=89=88=EF=BC=8C?= =?UTF-8?q?=E9=80=82=E9=85=8D=E6=A0=91=E8=A1=A8=E5=92=8C=E4=B8=BB=E5=AD=90?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/codegen/vue/api/api.js.vm | 2 +- .../vue/views/components/form_sub_erp.vue.vm | 5 +++-- .../views/components/form_sub_normal.vue.vm | 2 ++ .../vue/views/components/list_sub_erp.vue.vm | 14 +++++++++--- .../resources/codegen/vue/views/form.vue.vm | 22 +++++++++---------- .../resources/codegen/vue/views/index.vue.vm | 21 +++++++++++++----- 6 files changed, 44 insertions(+), 22 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm index fdafffd54..906d12c29 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm @@ -79,7 +79,7 @@ export function export${simpleClassName}Excel(params) { #if ( $table.templateType == 11 ) // 获得${subTable.classComment}分页 - export function get${simpleClassName}Page(params) { + export function get${subSimpleClassName}Page(params) { return request({ url: '${baseURL}/${subSimpleClassName_strikeCase}/page', method: 'get', diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm index eb7c45b3b..e44b16bb7 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm @@ -1,3 +1,4 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 #set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 @@ -155,13 +156,13 @@ try { ${simpleClassName}Api.get${subSimpleClassName}(id).then(res=>{ that.formData = res.data; - that.dialogTitle = "修改${table.classComment}"; + that.dialogTitle = "修改${subTable.classComment}"; }) } finally { this.formLoading = false; } } - this.dialogTitle = "新增${table.classComment}"; + this.dialogTitle = "新增${subTable.classComment}"; }, /** 提交按钮 */ submitForm() { diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm index ae6cf7b63..c450fecb0 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm @@ -5,6 +5,7 @@ #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm index 0e61203d6..d6c050719 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm @@ -214,7 +214,7 @@ this.title = "新增${table.classComment}"; ## 特殊:树表专属逻辑 #if ( $table.templateType == 2 ) - this.get${simpleClassName}Tree() + this.get${simpleClassName}Tree(); #end }, /** 提交按钮 */ @@ -241,7 +241,7 @@ data.${subClassNameVar}#if ( $subTable.subJoinMany)s#end = that.getRef('${subClassNameVar}FormRef').getData(); #end }).catch((err) => { - validate = false + validate = false; that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单 }) #end @@ -266,11 +266,11 @@ that.#[[$]]#emit('success'); }); }finally { - this.formLoading = false + this.formLoading = false; } }, - getRef(refName){ // TODO puhui999: 获得表单 ref,提取出来的目的呢是解决 #[[$]]# 在 if 中 end闭合不了的问题,代码生成后可删除此方法 - return this.#[[$]]#refs[refName] + getRef(refName){ + return this.#[[$]]#refs[refName]; }, ## 特殊:主子表专属逻辑 #if ( $table.templateType == 10 || $table.templateType == 12 ) @@ -278,12 +278,12 @@ /** 校验子表单 */ validateSubFrom(item) { return new Promise((resolve, reject) => { - this.$refs[item].validate() + this.getRef(item).validate() .then(() => { - resolve() + resolve(); }) .catch(() => { - reject(item) + reject(item); }) }) }, @@ -299,14 +299,14 @@ ]; const validArr = []; // 校验 for (const item of validFormRefArr) { - validArr.push(this.validateSubFrom(item)) + validArr.push(this.validateSubFrom(item)); } return new Promise((resolve, reject) => { // 校验所有 Promise.all(validArr).then(() => { - resolve() + resolve(); }).catch((err) => { - reject(err) + reject(err); }) }) }, diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm index 33ec21596..2150cbf76 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm @@ -152,14 +152,14 @@ ## 特殊:主子表专属逻辑 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) - + #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}="currentRow.id" /> + <${subSimpleClassName}List v-if="currentRow.id" :${subJoinColumn_strikeCase}="currentRow.id" /> #end @@ -247,7 +247,14 @@ export default { #end #end #end - } + }, + ## 特殊:主子表专属逻辑-erp + #if ( $table.templateType == 11) + #if ( $subTables && $subTables.size() > 0 ) + /** 子表的列表 */ + subTabsName: '$subClassNameVars.get(0)' + #end + #end }; }, created() { @@ -285,7 +292,7 @@ export default { }, /** 添加/修改操作 */ openForm(id) { - this.#[[$]]#refs["formRef"].open(id) + this.#[[$]]#refs["formRef"].open(id); }, /** 删除按钮操作 */ handleDelete(row) { @@ -319,7 +326,11 @@ export default { #if ( $table.templateType == 11 ) /** 选中行操作 */ handleCurrentChange(row) { - this.currentRow = row + this.currentRow = row; + #if ( $subTables && $subTables.size() > 0 ) + /** 子表的列表 */ + this.subTabsName = '$subClassNameVars.get(0)'; + #end }, #end ## 特殊:树表专属逻辑