From a88c93fc609a3e435a98e492b53b4612a5297f57 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 17 Nov 2023 18:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=EF=BC=9A?= =?UTF-8?q?=E9=87=8D=E6=9E=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=EF=BC=8890%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vue/views/components/form_sub_erp.vue.vm | 400 ++++++------ .../views/components/form_sub_inner.vue.vm | 2 +- .../views/components/form_sub_normal.vue.vm | 570 +++++++----------- .../views/components/list_sub_inner.vue.vm | 2 +- 4 files changed, 431 insertions(+), 543 deletions(-) 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 c1b4a0a0f..2293189f6 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 @@ -2,203 +2,211 @@ #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 - \ No newline at end of file + #if ($hasEditorColumn) + import Editor from '@/components/Editor'; + #end + export default { + name: "${simpleClassName}", + components: { + #if ($hasImageUploadColumn) + ImageUpload, + #end + #if ($hasFileUploadColumn) + FileUpload, + #end + #if ($hasEditorColumn) + Editor, + #end + }, + data() { + return { + // 弹出层标题 + dialogTitle: "", + // 是否显示弹出层 + dialogVisible: false, + // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 + formLoading: false, + // 表单参数 + formData: { + #foreach ($column in $columns) + #if ($column.createOperation || $column.updateOperation) + #if ($column.htmlType == "checkbox") + $column.javaField: [], + #else + $column.javaField: undefined, + #end + #end + #end + }, + // 表单校验 + formRules: { + #foreach ($column in $columns) + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 + #set($comment=$column.columnComment) + $column.javaField: [{ required: true, message: "${comment}不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }], + #end + #end + }, + }; + }, + methods: { + /** 表单重置 */ + reset() { + this.formData = { + #foreach ($column in $columns) + #if ($column.createOperation || $column.updateOperation) + #if ($column.htmlType == "checkbox") + $column.javaField: [], + #else + $column.javaField: undefined, + #end + #end + #end + }; + this.resetForm("formRef"); + }, + /** 打开弹窗 */ + open(id) { + this.dialogVisible = true; + this.reset(); + const that = this; + // 修改时,设置数据 + if (id) { + this.formLoading = true; + try { + ${simpleClassName}Api.get${subSimpleClassName}(id).then(res=>{ + that.formData = res.data; + that.title = "修改${table.classComment}"; + }) + } finally { + this.formLoading = false; + } + } + this.title = "新增${table.classComment}"; + }, + /** 提交按钮 */ + submitForm() { + this.formLoading = true; + try { + let data = this.formData; + this.#[[$]]#refs["formRef"].validate(valid => { + if (!valid) { + return; + } + // 修改的提交 + if (data.${primaryColumn.javaField}) { + ${simpleClassName}Api.update${simpleClassName}(data).then(response => { + this.#[[$modal]]#.msgSuccess("修改成功"); + this.dialogVisible = false; + this.#[[$]]#emit('success'); + }); + return; + } + // 添加的提交 + ${simpleClassName}Api.create${simpleClassName}(data).then(response => { + this.#[[$modal]]#.msgSuccess("新增成功"); + this.dialogVisible = false; + this.#[[$]]#emit('success'); + }); + }); + }finally { + this.formLoading = false + } + } + } + }; + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm index d8542c3d5..ca266be9d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm @@ -1,2 +1,2 @@ ## 主表的 normal 和 inner 使用相同的 form 表单 -#parse("codegen/vue3/views/components/form_sub_normal.vue.vm") \ No newline at end of file +#parse("codegen/vue/views/components/form_sub_normal.vue.vm") \ No newline at end of file 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 90df79812..b3f0a332b 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 @@ -4,359 +4,239 @@ #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + - \ No newline at end of file + }; + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm index 3fe648892..90b8e4153 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm @@ -1,4 +1,4 @@ ## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点: ## 1)inner 使用 list 不分页,erp 使用 page 分页 ## 2)erp 支持单个子表的新增、修改、删除,inner 不支持 -#parse("codegen/vue3/views/components/list_sub_erp.vue.vm") \ No newline at end of file +#parse("codegen/vue/views/components/list_sub_erp.vue.vm") \ No newline at end of file