Commit d3a565f0112aa8e787bb116e6704f3f72913ae64

Authored by 芋道源码
Committed by Gitee
2 parents df51a678 c4372012

!761 代码生成:vue2 代码模版格式调整;代码生成:准备 CodegenEngineVue2Test 所需测试文件

Merge pull request !761 from puhui999/feature/sub-table
Showing 25 changed files with 393 additions and 589 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm
@@ -89,7 +89,7 @@ @@ -89,7 +89,7 @@
89 </template> 89 </template>
90 90
91 <script> 91 <script>
92 - import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' 92 + import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
93 #if ($hasImageUploadColumn) 93 #if ($hasImageUploadColumn)
94 import ImageUpload from '@/components/ImageUpload'; 94 import ImageUpload from '@/components/ImageUpload';
95 #end 95 #end
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm
@@ -8,12 +8,12 @@ @@ -8,12 +8,12 @@
8 <div class="app-container"> 8 <div class="app-container">
9 #if ( $subTable.subJoinMany )## 情况一:一对多,table + form 9 #if ( $subTable.subJoinMany )## 情况一:一对多,table + form
10 <el-form 10 <el-form
11 - ref="formRef"  
12 - :model="formData"  
13 - :rules="formRules"  
14 - v-loading="formLoading"  
15 - label-width="0px"  
16 - :inline-message="true" 11 + ref="formRef"
  12 + :model="formData"
  13 + :rules="formRules"
  14 + v-loading="formLoading"
  15 + label-width="0px"
  16 + :inline-message="true"
17 > 17 >
18 <el-table :data="formData" class="-mt-10px"> 18 <el-table :data="formData" class="-mt-10px">
19 <el-table-column label="序号" type="index" width="100" /> 19 <el-table-column label="序号" type="index" width="100" />
@@ -137,11 +137,11 @@ @@ -137,11 +137,11 @@
137 </el-row> 137 </el-row>
138 #else## 情况二:一对一,form 138 #else## 情况二:一对一,form
139 <el-form 139 <el-form
140 - ref="formRef"  
141 - :model="formData"  
142 - :rules="formRules"  
143 - label-width="100px"  
144 - v-loading="formLoading" 140 + ref="formRef"
  141 + :model="formData"
  142 + :rules="formRules"
  143 + label-width="100px"
  144 + v-loading="formLoading"
145 > 145 >
146 #foreach($column in $subColumns) 146 #foreach($column in $subColumns)
147 #if ($column.createOperation || $column.updateOperation) 147 #if ($column.createOperation || $column.updateOperation)
@@ -221,7 +221,7 @@ @@ -221,7 +221,7 @@
221 </template> 221 </template>
222 222
223 <script> 223 <script>
224 - import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' 224 + import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
225 #if ($hasImageUploadColumn) 225 #if ($hasImageUploadColumn)
226 import ImageUpload from '@/components/ImageUpload'; 226 import ImageUpload from '@/components/ImageUpload';
227 #end 227 #end
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm
@@ -61,9 +61,9 @@ @@ -61,9 +61,9 @@
61 </template> 61 </template>
62 62
63 <script> 63 <script>
64 - import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' 64 + import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
65 #if ($table.templateType == 11) 65 #if ($table.templateType == 11)
66 - import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue' 66 + import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue';
67 #end 67 #end
68 export default { 68 export default {
69 name: "${subSimpleClassName}List", 69 name: "${subSimpleClassName}List",
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm
@@ -12,10 +12,10 @@ @@ -12,10 +12,10 @@
12 #if ( $table.templateType == 2 && $column.id == $treeParentColumn.id ) 12 #if ( $table.templateType == 2 && $column.id == $treeParentColumn.id )
13 <el-form-item label="${comment}" prop="${javaField}"> 13 <el-form-item label="${comment}" prop="${javaField}">
14 <TreeSelect 14 <TreeSelect
15 - v-model="formData.${javaField}"  
16 - :options="${classNameVar}Tree"  
17 - :normalizer="normalizer"  
18 - placeholder="请选择${comment}" 15 + v-model="formData.${javaField}"
  16 + :options="${classNameVar}Tree"
  17 + :normalizer="normalizer"
  18 + placeholder="请选择${comment}"
19 /> 19 />
20 </el-form-item> 20 </el-form-item>
21 #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里 21 #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
@@ -107,7 +107,7 @@ @@ -107,7 +107,7 @@
107 </template> 107 </template>
108 108
109 <script> 109 <script>
110 - import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' 110 + import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
111 #if ($hasImageUploadColumn) 111 #if ($hasImageUploadColumn)
112 import ImageUpload from '@/components/ImageUpload'; 112 import ImageUpload from '@/components/ImageUpload';
113 #end 113 #end
@@ -212,7 +212,7 @@ @@ -212,7 +212,7 @@
212 this.title = "新增${table.classComment}"; 212 this.title = "新增${table.classComment}";
213 ## 特殊:树表专属逻辑 213 ## 特殊:树表专属逻辑
214 #if ( $table.templateType == 2 ) 214 #if ( $table.templateType == 2 )
215 - this.get${simpleClassName}Tree(); 215 + await this.get${simpleClassName}Tree();
216 #end 216 #end
217 }, 217 },
218 /** 提交按钮 */ 218 /** 提交按钮 */
@@ -263,7 +263,7 @@ @@ -263,7 +263,7 @@
263 this.#[[$modal]]#.msgSuccess("新增成功"); 263 this.#[[$modal]]#.msgSuccess("新增成功");
264 this.dialogVisible = false; 264 this.dialogVisible = false;
265 this.#[[$]]#emit('success'); 265 this.#[[$]]#emit('success');
266 - }finally { 266 + } finally {
267 this.formLoading = false; 267 this.formLoading = false;
268 } 268 }
269 }, 269 },
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 -  
4 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 #foreach($column in $columns) 5 #foreach($column in $columns)
@@ -68,24 +67,24 @@ @@ -68,24 +67,24 @@
68 ## 特殊:主子表专属逻辑 67 ## 特殊:主子表专属逻辑
69 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) 68 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
70 <el-table 69 <el-table
71 - v-loading="loading"  
72 - :data="list"  
73 - :stripe="true"  
74 - :highlight-current-row="true"  
75 - :show-overflow-tooltip="true"  
76 - @current-change="handleCurrentChange" 70 + v-loading="loading"
  71 + :data="list"
  72 + :stripe="true"
  73 + :highlight-current-row="true"
  74 + :show-overflow-tooltip="true"
  75 + @current-change="handleCurrentChange"
77 > 76 >
78 ## 特殊:树表专属逻辑 77 ## 特殊:树表专属逻辑
79 #elseif ( $table.templateType == 2 ) 78 #elseif ( $table.templateType == 2 )
80 <el-table 79 <el-table
81 - v-loading="loading"  
82 - :data="list"  
83 - :stripe="true"  
84 - :show-overflow-tooltip="true"  
85 - v-if="refreshTable"  
86 - row-key="id"  
87 - :default-expand-all="isExpandAll"  
88 - :tree-props="{children: 'children', hasChildren: 'hasChildren'}" 80 + v-loading="loading"
  81 + :data="list"
  82 + :stripe="true"
  83 + :show-overflow-tooltip="true"
  84 + v-if="refreshTable"
  85 + row-key="id"
  86 + :default-expand-all="isExpandAll"
  87 + :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
89 > 88 >
90 #else 89 #else
91 <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> 90 <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
@@ -183,7 +182,7 @@ import Editor from &#39;@/components/Editor&#39;; @@ -183,7 +182,7 @@ import Editor from &#39;@/components/Editor&#39;;
183 #if ( $table.templateType != 10 ) 182 #if ( $table.templateType != 10 )
184 #if ( $subTables && $subTables.size() > 0 ) 183 #if ( $subTables && $subTables.size() > 0 )
185 #foreach ($subSimpleClassName in $subSimpleClassNames) 184 #foreach ($subSimpleClassName in $subSimpleClassNames)
186 - import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue' 185 + import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue';
187 #end 186 #end
188 #end 187 #end
189 #end 188 #end
@@ -298,7 +297,7 @@ export default { @@ -298,7 +297,7 @@ export default {
298 await this.#[[$modal]]#.confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?') 297 await this.#[[$modal]]#.confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?')
299 try { 298 try {
300 await ${simpleClassName}Api.delete${simpleClassName}(${primaryColumn.javaField}); 299 await ${simpleClassName}Api.delete${simpleClassName}(${primaryColumn.javaField});
301 - this.getList(); 300 + await this.getList();
302 this.#[[$modal]]#.msgSuccess("删除成功"); 301 this.#[[$modal]]#.msgSuccess("删除成功");
303 } catch {} 302 } catch {}
304 }, 303 },
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 </template> 43 </template>
44 44
45 <script> 45 <script>
46 - import * as StudentApi from '@/api/infra/demo' 46 + import * as StudentApi from '@/api/infra/demo';
47 import ImageUpload from '@/components/ImageUpload'; 47 import ImageUpload from '@/components/ImageUpload';
48 import FileUpload from '@/components/FileUpload'; 48 import FileUpload from '@/components/FileUpload';
49 import Editor from '@/components/Editor'; 49 import Editor from '@/components/Editor';
@@ -90,19 +90,17 @@ @@ -90,19 +90,17 @@
90 }, 90 },
91 methods: { 91 methods: {
92 /** 打开弹窗 */ 92 /** 打开弹窗 */
93 - open(id, studentId) { 93 + async open(id, studentId) {
94 this.dialogVisible = true; 94 this.dialogVisible = true;
95 this.reset(); 95 this.reset();
96 - const that = this;  
97 this.formData.studentId = studentId; 96 this.formData.studentId = studentId;
98 // 修改时,设置数据 97 // 修改时,设置数据
99 if (id) { 98 if (id) {
100 this.formLoading = true; 99 this.formLoading = true;
101 try { 100 try {
102 - StudentApi.getStudentContact(id).then(res=>{  
103 - that.formData = res.data;  
104 - that.dialogTitle = "修改学生联系人";  
105 - }) 101 + const res = await StudentApi.getStudentContact(id);
  102 + this.formData = res.data;
  103 + this.dialogTitle = "修改学生联系人";
106 } finally { 104 } finally {
107 this.formLoading = false; 105 this.formLoading = false;
108 } 106 }
@@ -110,32 +108,26 @@ @@ -110,32 +108,26 @@
110 this.dialogTitle = "新增学生联系人"; 108 this.dialogTitle = "新增学生联系人";
111 }, 109 },
112 /** 提交按钮 */ 110 /** 提交按钮 */
113 - submitForm() { 111 + async submitForm() {
  112 + await this.$refs["formRef"].validate();
114 this.formLoading = true; 113 this.formLoading = true;
115 try { 114 try {
116 - let data = this.formData;  
117 - this.$refs["formRef"].validate(valid => {  
118 - if (!valid) {  
119 - return;  
120 - } 115 + const data = this.formData;
121 // 修改的提交 116 // 修改的提交
122 if (data.id) { 117 if (data.id) {
123 - StudentApi.updateStudentContact(data).then(response => {  
124 - this.$modal.msgSuccess("修改成功");  
125 - this.dialogVisible = false;  
126 - this.$emit('success');  
127 - }); 118 + await StudentApi.updateStudentContact(data);
  119 + this.$modal.msgSuccess("修改成功");
  120 + this.dialogVisible = false;
  121 + this.$emit('success');
128 return; 122 return;
129 } 123 }
130 // 添加的提交 124 // 添加的提交
131 - StudentApi.createStudentContact(data).then(response => { 125 + await StudentApi.createStudentContact(data);
132 this.$modal.msgSuccess("新增成功"); 126 this.$modal.msgSuccess("新增成功");
133 this.dialogVisible = false; 127 this.dialogVisible = false;
134 this.$emit('success'); 128 this.$emit('success');
135 - });  
136 - });  
137 }finally { 129 }finally {
138 - this.formLoading = false 130 + this.formLoading = false;
139 } 131 }
140 }, 132 },
141 /** 表单重置 */ 133 /** 表单重置 */
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList
@@ -52,8 +52,8 @@ @@ -52,8 +52,8 @@
52 </template> 52 </template>
53 53
54 <script> 54 <script>
55 - import * as StudentApi from '@/api/infra/demo'  
56 - import StudentContactForm from './StudentContactForm.vue' 55 + import * as StudentApi from '@/api/infra/demo';
  56 + import StudentContactForm from './StudentContactForm.vue';
57 export default { 57 export default {
58 name: "StudentContactList", 58 name: "StudentContactList",
59 components: { 59 components: {
@@ -91,14 +91,12 @@ @@ -91,14 +91,12 @@
91 }, 91 },
92 methods: { 92 methods: {
93 /** 查询列表 */ 93 /** 查询列表 */
94 - getList() { 94 + async getList() {
95 try { 95 try {
96 this.loading = true; 96 this.loading = true;
97 - const that = this;  
98 - StudentApi.getStudentContactPage(this.queryParams).then(response => {  
99 - that.list = response.data.list;  
100 - that.total = response.data.total;  
101 - }); 97 + const res = await StudentApi.getStudentContactPage(this.queryParams);
  98 + this.list = res.data.list;
  99 + this.total = res.data.total;
102 } finally { 100 } finally {
103 this.loading = false; 101 this.loading = false;
104 } 102 }
@@ -111,22 +109,19 @@ @@ -111,22 +109,19 @@
111 /** 添加/修改操作 */ 109 /** 添加/修改操作 */
112 openForm(id) { 110 openForm(id) {
113 if (!this.studentId) { 111 if (!this.studentId) {
114 - that.$modal.msgError('请选择一个学生'); 112 + this.$modal.msgError('请选择一个学生');
115 return; 113 return;
116 } 114 }
117 this.$refs["formRef"].open(id, this.studentId); 115 this.$refs["formRef"].open(id, this.studentId);
118 }, 116 },
119 /** 删除按钮操作 */ 117 /** 删除按钮操作 */
120 - handleDelete(row) {  
121 - const that = this; 118 + async handleDelete(row) {
  119 + const id = row.id;
  120 + await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?');
122 try { 121 try {
123 - const id = row.id;  
124 - this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{  
125 - return StudentApi.deleteStudentContact(id);  
126 - }).then(() => {  
127 - that.getList();  
128 - that.$modal.msgSuccess("删除成功");  
129 - }).catch(() => {}); 122 + await StudentApi.deleteStudentContact(id);
  123 + await this.getList();
  124 + this.$modal.msgSuccess("删除成功");
130 } catch {} 125 } catch {}
131 }, 126 },
132 } 127 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 </template> 43 </template>
44 44
45 <script> 45 <script>
46 - import * as StudentApi from '@/api/infra/demo' 46 + import * as StudentApi from '@/api/infra/demo';
47 import ImageUpload from '@/components/ImageUpload'; 47 import ImageUpload from '@/components/ImageUpload';
48 import FileUpload from '@/components/FileUpload'; 48 import FileUpload from '@/components/FileUpload';
49 import Editor from '@/components/Editor'; 49 import Editor from '@/components/Editor';
@@ -89,18 +89,16 @@ @@ -89,18 +89,16 @@
89 }, 89 },
90 methods: { 90 methods: {
91 /** 打开弹窗 */ 91 /** 打开弹窗 */
92 - open(id) { 92 + async open(id) {
93 this.dialogVisible = true; 93 this.dialogVisible = true;
94 this.reset(); 94 this.reset();
95 - const that = this;  
96 // 修改时,设置数据 95 // 修改时,设置数据
97 if (id) { 96 if (id) {
98 this.formLoading = true; 97 this.formLoading = true;
99 try { 98 try {
100 - StudentApi.getStudent(id).then(res=>{  
101 - that.formData = res.data;  
102 - that.title = "修改学生";  
103 - }) 99 + const res = await StudentApi.getStudent(id);
  100 + this.formData = res.data;
  101 + this.title = "修改学生";
104 } finally { 102 } finally {
105 this.formLoading = false; 103 this.formLoading = false;
106 } 104 }
@@ -108,42 +106,29 @@ @@ -108,42 +106,29 @@
108 this.title = "新增学生"; 106 this.title = "新增学生";
109 }, 107 },
110 /** 提交按钮 */ 108 /** 提交按钮 */
111 - submitForm() {  
112 - this.formLoading = true; 109 + async submitForm() {
  110 + // 校验主表
  111 + await this.$refs["formRef"].validate();
  112 + this.formLoading = true;
113 try { 113 try {
114 - const that = this;  
115 - let data = this.formData;  
116 - let validate = false;  
117 - // 校验主表  
118 - this.getRef("formRef").validate(valid => {  
119 - validate = valid;  
120 - });  
121 - // 所有表单校验通过后方可提交  
122 - if (!validate) {  
123 - return;  
124 - }  
125 - // 修改的提交 114 + const data = this.formData;
  115 + // 修改的提交
126 if (data.id) { 116 if (data.id) {
127 - StudentApi.updateStudent(data).then(response => {  
128 - that.$modal.msgSuccess("修改成功");  
129 - that.dialogVisible = false;  
130 - that.$emit('success');  
131 - }); 117 + await StudentApi.updateStudent(data);
  118 + this.$modal.msgSuccess("修改成功");
  119 + this.dialogVisible = false;
  120 + this.$emit('success');
132 return; 121 return;
133 } 122 }
134 // 添加的提交 123 // 添加的提交
135 - StudentApi.createStudent(data).then(response => {  
136 - that.$modal.msgSuccess("新增成功");  
137 - that.dialogVisible = false;  
138 - that.$emit('success');  
139 - });  
140 - }finally { 124 + await StudentApi.createStudent(data);
  125 + this.$modal.msgSuccess("新增成功");
  126 + this.dialogVisible = false;
  127 + this.$emit('success');
  128 + } finally {
141 this.formLoading = false; 129 this.formLoading = false;
142 } 130 }
143 }, 131 },
144 - getRef(refName){  
145 - return this.$refs[refName];  
146 - },  
147 /** 表单重置 */ 132 /** 表单重置 */
148 reset() { 133 reset() {
149 this.formData = { 134 this.formData = {
@@ -158,7 +143,7 @@ @@ -158,7 +143,7 @@
158 memo: undefined, 143 memo: undefined,
159 }; 144 };
160 this.resetForm("formRef"); 145 this.resetForm("formRef");
161 - }, 146 + }
162 } 147 }
163 }; 148 };
164 </script> 149 </script>
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 </template> 43 </template>
44 44
45 <script> 45 <script>
46 - import * as StudentApi from '@/api/infra/demo' 46 + import * as StudentApi from '@/api/infra/demo';
47 import ImageUpload from '@/components/ImageUpload'; 47 import ImageUpload from '@/components/ImageUpload';
48 import FileUpload from '@/components/FileUpload'; 48 import FileUpload from '@/components/FileUpload';
49 import Editor from '@/components/Editor'; 49 import Editor from '@/components/Editor';
@@ -90,19 +90,17 @@ @@ -90,19 +90,17 @@
90 }, 90 },
91 methods: { 91 methods: {
92 /** 打开弹窗 */ 92 /** 打开弹窗 */
93 - open(id, studentId) { 93 + async open(id, studentId) {
94 this.dialogVisible = true; 94 this.dialogVisible = true;
95 this.reset(); 95 this.reset();
96 - const that = this;  
97 this.formData.studentId = studentId; 96 this.formData.studentId = studentId;
98 // 修改时,设置数据 97 // 修改时,设置数据
99 if (id) { 98 if (id) {
100 this.formLoading = true; 99 this.formLoading = true;
101 try { 100 try {
102 - StudentApi.getStudentTeacher(id).then(res=>{  
103 - that.formData = res.data;  
104 - that.dialogTitle = "修改学生班主任";  
105 - }) 101 + const res = await StudentApi.getStudentTeacher(id);
  102 + this.formData = res.data;
  103 + this.dialogTitle = "修改学生班主任";
106 } finally { 104 } finally {
107 this.formLoading = false; 105 this.formLoading = false;
108 } 106 }
@@ -110,32 +108,26 @@ @@ -110,32 +108,26 @@
110 this.dialogTitle = "新增学生班主任"; 108 this.dialogTitle = "新增学生班主任";
111 }, 109 },
112 /** 提交按钮 */ 110 /** 提交按钮 */
113 - submitForm() { 111 + async submitForm() {
  112 + await this.$refs["formRef"].validate();
114 this.formLoading = true; 113 this.formLoading = true;
115 try { 114 try {
116 - let data = this.formData;  
117 - this.$refs["formRef"].validate(valid => {  
118 - if (!valid) {  
119 - return;  
120 - } 115 + const data = this.formData;
121 // 修改的提交 116 // 修改的提交
122 if (data.id) { 117 if (data.id) {
123 - StudentApi.updateStudentTeacher(data).then(response => {  
124 - this.$modal.msgSuccess("修改成功");  
125 - this.dialogVisible = false;  
126 - this.$emit('success');  
127 - }); 118 + await StudentApi.updateStudentTeacher(data);
  119 + this.$modal.msgSuccess("修改成功");
  120 + this.dialogVisible = false;
  121 + this.$emit('success');
128 return; 122 return;
129 } 123 }
130 // 添加的提交 124 // 添加的提交
131 - StudentApi.createStudentTeacher(data).then(response => { 125 + await StudentApi.createStudentTeacher(data);
132 this.$modal.msgSuccess("新增成功"); 126 this.$modal.msgSuccess("新增成功");
133 this.dialogVisible = false; 127 this.dialogVisible = false;
134 this.$emit('success'); 128 this.$emit('success');
135 - });  
136 - });  
137 }finally { 129 }finally {
138 - this.formLoading = false 130 + this.formLoading = false;
139 } 131 }
140 }, 132 },
141 /** 表单重置 */ 133 /** 表单重置 */
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList
@@ -52,8 +52,8 @@ @@ -52,8 +52,8 @@
52 </template> 52 </template>
53 53
54 <script> 54 <script>
55 - import * as StudentApi from '@/api/infra/demo'  
56 - import StudentTeacherForm from './StudentTeacherForm.vue' 55 + import * as StudentApi from '@/api/infra/demo';
  56 + import StudentTeacherForm from './StudentTeacherForm.vue';
57 export default { 57 export default {
58 name: "StudentTeacherList", 58 name: "StudentTeacherList",
59 components: { 59 components: {
@@ -91,14 +91,12 @@ @@ -91,14 +91,12 @@
91 }, 91 },
92 methods: { 92 methods: {
93 /** 查询列表 */ 93 /** 查询列表 */
94 - getList() { 94 + async getList() {
95 try { 95 try {
96 this.loading = true; 96 this.loading = true;
97 - const that = this;  
98 - StudentApi.getStudentTeacherPage(this.queryParams).then(response => {  
99 - that.list = response.data.list;  
100 - that.total = response.data.total;  
101 - }); 97 + const res = await StudentApi.getStudentTeacherPage(this.queryParams);
  98 + this.list = res.data.list;
  99 + this.total = res.data.total;
102 } finally { 100 } finally {
103 this.loading = false; 101 this.loading = false;
104 } 102 }
@@ -111,22 +109,19 @@ @@ -111,22 +109,19 @@
111 /** 添加/修改操作 */ 109 /** 添加/修改操作 */
112 openForm(id) { 110 openForm(id) {
113 if (!this.studentId) { 111 if (!this.studentId) {
114 - that.$modal.msgError('请选择一个学生'); 112 + this.$modal.msgError('请选择一个学生');
115 return; 113 return;
116 } 114 }
117 this.$refs["formRef"].open(id, this.studentId); 115 this.$refs["formRef"].open(id, this.studentId);
118 }, 116 },
119 /** 删除按钮操作 */ 117 /** 删除按钮操作 */
120 - handleDelete(row) {  
121 - const that = this; 118 + async handleDelete(row) {
  119 + const id = row.id;
  120 + await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?');
122 try { 121 try {
123 - const id = row.id;  
124 - this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{  
125 - return StudentApi.deleteStudentTeacher(id);  
126 - }).then(() => {  
127 - that.getList();  
128 - that.$modal.msgSuccess("删除成功");  
129 - }).catch(() => {}); 122 + await StudentApi.deleteStudentTeacher(id);
  123 + await this.getList();
  124 + this.$modal.msgSuccess("删除成功");
130 } catch {} 125 } catch {}
131 }, 126 },
132 } 127 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/index
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 -  
4 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 <el-form-item label="名字" prop="name"> 5 <el-form-item label="名字" prop="name">
@@ -45,12 +44,12 @@ @@ -45,12 +44,12 @@
45 </el-row> 44 </el-row>
46 45
47 <el-table 46 <el-table
48 - v-loading="loading"  
49 - :data="list"  
50 - :stripe="true"  
51 - :highlight-current-row="true"  
52 - :show-overflow-tooltip="true"  
53 - @current-change="handleCurrentChange" 47 + v-loading="loading"
  48 + :data="list"
  49 + :stripe="true"
  50 + :highlight-current-row="true"
  51 + :show-overflow-tooltip="true"
  52 + @current-change="handleCurrentChange"
54 > 53 >
55 <el-table-column label="编号" align="center" prop="id"> 54 <el-table-column label="编号" align="center" prop="id">
56 <template v-slot="scope"> 55 <template v-slot="scope">
@@ -131,8 +130,8 @@ @@ -131,8 +130,8 @@
131 <script> 130 <script>
132 import * as StudentApi from '@/api/infra/demo'; 131 import * as StudentApi from '@/api/infra/demo';
133 import StudentForm from './StudentForm.vue'; 132 import StudentForm from './StudentForm.vue';
134 - import StudentContactList from './components/StudentContactList.vue'  
135 - import StudentTeacherList from './components/StudentTeacherList.vue' 133 + import StudentContactList from './components/StudentContactList.vue';
  134 + import StudentTeacherList from './components/StudentTeacherList.vue';
136 export default { 135 export default {
137 name: "Student", 136 name: "Student",
138 components: { 137 components: {
@@ -177,13 +176,12 @@ export default { @@ -177,13 +176,12 @@ export default {
177 }, 176 },
178 methods: { 177 methods: {
179 /** 查询列表 */ 178 /** 查询列表 */
180 - getList() { 179 + async getList() {
181 try { 180 try {
182 this.loading = true; 181 this.loading = true;
183 - StudentApi.getStudentPage(this.queryParams).then(response => {  
184 - this.list = response.data.list;  
185 - this.total = response.data.total;  
186 - }); 182 + const res = await StudentApi.getStudentPage(this.queryParams);
  183 + this.list = res.data.list;
  184 + this.total = res.data.total;
187 } finally { 185 } finally {
188 this.loading = false; 186 this.loading = false;
189 } 187 }
@@ -203,31 +201,25 @@ export default { @@ -203,31 +201,25 @@ export default {
203 this.$refs["formRef"].open(id); 201 this.$refs["formRef"].open(id);
204 }, 202 },
205 /** 删除按钮操作 */ 203 /** 删除按钮操作 */
206 - handleDelete(row) {  
207 - const that = this;  
208 - try { 204 + async handleDelete(row) {
209 const id = row.id; 205 const id = row.id;
210 - this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{  
211 - return StudentApi.deleteStudent(id);  
212 - }).then(() => {  
213 - that.getList();  
214 - that.$modal.msgSuccess("删除成功");  
215 - }).catch(() => {}); 206 + await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
  207 + try {
  208 + await StudentApi.deleteStudent(id);
  209 + await this.getList();
  210 + this.$modal.msgSuccess("删除成功");
216 } catch {} 211 } catch {}
217 }, 212 },
218 /** 导出按钮操作 */ 213 /** 导出按钮操作 */
219 - handleExport() {  
220 - const that = this; 214 + async handleExport() {
  215 + await this.$modal.confirm('是否确认导出所有学生数据项?');
221 try { 216 try {
222 - this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {  
223 - that.exportLoading = true;  
224 - return StudentApi.exportStudentExcel(params);  
225 - }).then(response => {  
226 - that.$download.excel(response, '学生.xls');  
227 - }); 217 + this.exportLoading = true;
  218 + const res = await StudentApi.exportStudentExcel(this.queryParams);
  219 + this.$download.excel(res.data, '学生.xls');
228 } catch { 220 } catch {
229 } finally { 221 } finally {
230 - that.exportLoading = false; 222 + this.exportLoading = false;
231 } 223 }
232 }, 224 },
233 /** 选中行操作 */ 225 /** 选中行操作 */
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 <el-form 3 <el-form
4 - ref="formRef"  
5 - :model="formData"  
6 - :rules="formRules"  
7 - v-loading="formLoading"  
8 - label-width="0px"  
9 - :inline-message="true" 4 + ref="formRef"
  5 + :model="formData"
  6 + :rules="formRules"
  7 + v-loading="formLoading"
  8 + label-width="0px"
  9 + :inline-message="true"
10 > 10 >
11 <el-table :data="formData" class="-mt-10px"> 11 <el-table :data="formData" class="-mt-10px">
12 <el-table-column label="序号" type="index" width="100" /> 12 <el-table-column label="序号" type="index" width="100" />
@@ -86,7 +86,7 @@ @@ -86,7 +86,7 @@
86 </template> 86 </template>
87 87
88 <script> 88 <script>
89 - import * as StudentApi from '@/api/infra/demo' 89 + import * as StudentApi from '@/api/infra/demo';
90 import ImageUpload from '@/components/ImageUpload'; 90 import ImageUpload from '@/components/ImageUpload';
91 import FileUpload from '@/components/FileUpload'; 91 import FileUpload from '@/components/FileUpload';
92 import Editor from '@/components/Editor'; 92 import Editor from '@/components/Editor';
@@ -130,8 +130,9 @@ @@ -130,8 +130,9 @@
130 } 130 }
131 try { 131 try {
132 this.formLoading = true; 132 this.formLoading = true;
  133 + // 这里还是需要获取一下 this 的不然取不到 formData
133 const that = this; 134 const that = this;
134 - StudentApi.getStudentContactListByStudentId(val).then(res=>{ 135 + StudentApi.getStudentContactListByStudentId(val).then(function (res){
135 that.formData = res.data; 136 that.formData = res.data;
136 }) 137 })
137 } finally { 138 } finally {
@@ -156,20 +157,20 @@ @@ -156,20 +157,20 @@
156 video: undefined, 157 video: undefined,
157 memo: undefined, 158 memo: undefined,
158 } 159 }
159 - row.studentId = this.studentId  
160 - this.formData.push(row) 160 + row.studentId = this.studentId;
  161 + this.formData.push(row);
161 }, 162 },
162 /** 删除按钮操作 */ 163 /** 删除按钮操作 */
163 handleDelete(index) { 164 handleDelete(index) {
164 - this.formData.splice(index, 1) 165 + this.formData.splice(index, 1);
165 }, 166 },
166 /** 表单校验 */ 167 /** 表单校验 */
167 validate(){ 168 validate(){
168 - return this.$refs["formRef"].validate() 169 + return this.$refs["formRef"].validate();
169 }, 170 },
170 /** 表单值 */ 171 /** 表单值 */
171 getData(){ 172 getData(){
172 - return this.formData 173 + return this.formData;
173 } 174 }
174 } 175 }
175 }; 176 };
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 </template> 40 </template>
41 41
42 <script> 42 <script>
43 - import * as StudentApi from '@/api/infra/demo' 43 + import * as StudentApi from '@/api/infra/demo';
44 export default { 44 export default {
45 name: "StudentContactList", 45 name: "StudentContactList",
46 props:[ 46 props:[
@@ -70,13 +70,11 @@ @@ -70,13 +70,11 @@
70 }, 70 },
71 methods: { 71 methods: {
72 /** 查询列表 */ 72 /** 查询列表 */
73 - getList() { 73 + async getList() {
74 try { 74 try {
75 this.loading = true; 75 this.loading = true;
76 - const that = this;  
77 - StudentApi.getStudentContactListByStudentId(this.studentId).then(response=>{  
78 - that.list = response.data;  
79 - }) 76 + const res = await StudentApi.getStudentContactListByStudentId(this.studentId);
  77 + this.list = res.data;
80 } finally { 78 } finally {
81 this.loading = false; 79 this.loading = false;
82 } 80 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 </template> 52 </template>
53 53
54 <script> 54 <script>
55 - import * as StudentApi from '@/api/infra/demo' 55 + import * as StudentApi from '@/api/infra/demo';
56 import ImageUpload from '@/components/ImageUpload'; 56 import ImageUpload from '@/components/ImageUpload';
57 import FileUpload from '@/components/FileUpload'; 57 import FileUpload from '@/components/FileUpload';
58 import Editor from '@/components/Editor'; 58 import Editor from '@/components/Editor';
@@ -104,18 +104,16 @@ @@ -104,18 +104,16 @@
104 }, 104 },
105 methods: { 105 methods: {
106 /** 打开弹窗 */ 106 /** 打开弹窗 */
107 - open(id) { 107 + async open(id) {
108 this.dialogVisible = true; 108 this.dialogVisible = true;
109 this.reset(); 109 this.reset();
110 - const that = this;  
111 // 修改时,设置数据 110 // 修改时,设置数据
112 if (id) { 111 if (id) {
113 this.formLoading = true; 112 this.formLoading = true;
114 try { 113 try {
115 - StudentApi.getStudent(id).then(res=>{  
116 - that.formData = res.data;  
117 - that.title = "修改学生";  
118 - }) 114 + const res = await StudentApi.getStudent(id);
  115 + this.formData = res.data;
  116 + this.title = "修改学生";
119 } finally { 117 } finally {
120 this.formLoading = false; 118 this.formLoading = false;
121 } 119 }
@@ -123,84 +121,45 @@ @@ -123,84 +121,45 @@
123 this.title = "新增学生"; 121 this.title = "新增学生";
124 }, 122 },
125 /** 提交按钮 */ 123 /** 提交按钮 */
126 - submitForm() { 124 + async submitForm() {
  125 + // 校验主表
  126 + await this.$refs["formRef"].validate();
  127 + // 校验子表
  128 + try {
  129 + await this.$refs['studentContactFormRef'].validate();
  130 + } catch (e) {
  131 + this.subTabsName = 'studentContact';
  132 + return;
  133 + }
  134 + try {
  135 + await this.$refs['studentTeacherFormRef'].validate();
  136 + } catch (e) {
  137 + this.subTabsName = 'studentTeacher';
  138 + return;
  139 + }
127 this.formLoading = true; 140 this.formLoading = true;
128 try { 141 try {
129 - const that = this;  
130 - let data = this.formData;  
131 - let validate = false;  
132 - // 校验主表  
133 - this.getRef("formRef").validate(valid => {  
134 - validate = valid;  
135 - });  
136 - // 校验子表  
137 - this.validateSubFrom01().then(() => {  
138 - // 全部校验通过-拼接子表的数据  
139 - // 拼接子表的数据  
140 - data.studentContacts = that.getRef('studentContactFormRef').getData();  
141 - data.studentTeacher = that.getRef('studentTeacherFormRef').getData();  
142 - }).catch((err) => {  
143 - validate = false;  
144 - that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单  
145 - })  
146 - // 所有表单校验通过后方可提交  
147 - if (!validate) {  
148 - return;  
149 - } 142 + const data = this.formData;
  143 + // 拼接子表的数据
  144 + data.studentContacts = this.$refs['studentContactFormRef'].getData();
  145 + data.studentTeacher = this.$refs['studentTeacherFormRef'].getData();
150 // 修改的提交 146 // 修改的提交
151 if (data.id) { 147 if (data.id) {
152 - StudentApi.updateStudent(data).then(response => {  
153 - that.$modal.msgSuccess("修改成功");  
154 - that.dialogVisible = false;  
155 - that.$emit('success');  
156 - }); 148 + await StudentApi.updateStudent(data);
  149 + this.$modal.msgSuccess("修改成功");
  150 + this.dialogVisible = false;
  151 + this.$emit('success');
157 return; 152 return;
158 } 153 }
159 // 添加的提交 154 // 添加的提交
160 - StudentApi.createStudent(data).then(response => {  
161 - that.$modal.msgSuccess("新增成功");  
162 - that.dialogVisible = false;  
163 - that.$emit('success');  
164 - });  
165 - }finally { 155 + await StudentApi.createStudent(data);
  156 + this.$modal.msgSuccess("新增成功");
  157 + this.dialogVisible = false;
  158 + this.$emit('success');
  159 + } finally {
166 this.formLoading = false; 160 this.formLoading = false;
167 } 161 }
168 }, 162 },
169 - getRef(refName){  
170 - return this.$refs[refName];  
171 - },  
172 - /** 校验子表单 */  
173 - validateSubFrom(item) {  
174 - return new Promise((resolve, reject) => {  
175 - this.getRef(item).validate()  
176 - .then(() => {  
177 - resolve();  
178 - })  
179 - .catch(() => {  
180 - reject(item);  
181 - })  
182 - })  
183 - },  
184 - /** 校验所有子表单 */  
185 - validateSubFrom01() {  
186 - // 需要校验的表单 ref  
187 - const validFormRefArr = [  
188 - "studentContactFormRef",  
189 - "studentTeacherFormRef",  
190 - ];  
191 - const validArr = []; // 校验  
192 - for (const item of validFormRefArr) {  
193 - validArr.push(this.validateSubFrom(item));  
194 - }  
195 - return new Promise((resolve, reject) => {  
196 - // 校验所有  
197 - Promise.all(validArr).then(() => {  
198 - resolve();  
199 - }).catch((err) => {  
200 - reject(err);  
201 - })  
202 - })  
203 - },  
204 /** 表单重置 */ 163 /** 表单重置 */
205 reset() { 164 reset() {
206 this.formData = { 165 this.formData = {
@@ -215,7 +174,7 @@ @@ -215,7 +174,7 @@
215 memo: undefined, 174 memo: undefined,
216 }; 175 };
217 this.resetForm("formRef"); 176 this.resetForm("formRef");
218 - }, 177 + }
219 } 178 }
220 }; 179 };
221 </script> 180 </script>
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 <el-form 3 <el-form
4 - ref="formRef"  
5 - :model="formData"  
6 - :rules="formRules"  
7 - label-width="100px"  
8 - v-loading="formLoading" 4 + ref="formRef"
  5 + :model="formData"
  6 + :rules="formRules"
  7 + label-width="100px"
  8 + v-loading="formLoading"
9 > 9 >
10 <el-form-item label="名字" prop="name"> 10 <el-form-item label="名字" prop="name">
11 <el-input v-model="formData.name" placeholder="请输入名字" /> 11 <el-input v-model="formData.name" placeholder="请输入名字" />
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 </template> 42 </template>
43 43
44 <script> 44 <script>
45 - import * as StudentApi from '@/api/infra/demo' 45 + import * as StudentApi from '@/api/infra/demo';
46 import ImageUpload from '@/components/ImageUpload'; 46 import ImageUpload from '@/components/ImageUpload';
47 import FileUpload from '@/components/FileUpload'; 47 import FileUpload from '@/components/FileUpload';
48 import Editor from '@/components/Editor'; 48 import Editor from '@/components/Editor';
@@ -97,8 +97,9 @@ @@ -97,8 +97,9 @@
97 } 97 }
98 try { 98 try {
99 this.formLoading = true; 99 this.formLoading = true;
  100 + // 这里还是需要获取一下 this 的不然取不到 formData
100 const that = this; 101 const that = this;
101 - StudentApi.getStudentTeacherByStudentId(val).then(res=>{ 102 + StudentApi.getStudentTeacherByStudentId(val).then(function (res){
102 const data = res.data; 103 const data = res.data;
103 if (!data) { 104 if (!data) {
104 return 105 return
@@ -115,11 +116,11 @@ @@ -115,11 +116,11 @@
115 methods: { 116 methods: {
116 /** 表单校验 */ 117 /** 表单校验 */
117 validate(){ 118 validate(){
118 - return this.$refs["formRef"].validate() 119 + return this.$refs["formRef"].validate();
119 }, 120 },
120 /** 表单值 */ 121 /** 表单值 */
121 getData(){ 122 getData(){
122 - return this.formData 123 + return this.formData;
123 } 124 }
124 } 125 }
125 }; 126 };
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 </template> 40 </template>
41 41
42 <script> 42 <script>
43 - import * as StudentApi from '@/api/infra/demo' 43 + import * as StudentApi from '@/api/infra/demo';
44 export default { 44 export default {
45 name: "StudentTeacherList", 45 name: "StudentTeacherList",
46 props:[ 46 props:[
@@ -70,17 +70,15 @@ @@ -70,17 +70,15 @@
70 }, 70 },
71 methods: { 71 methods: {
72 /** 查询列表 */ 72 /** 查询列表 */
73 - getList() { 73 + async getList() {
74 try { 74 try {
75 this.loading = true; 75 this.loading = true;
76 - const that = this;  
77 - StudentApi.getStudentTeacherByStudentId(this.studentId).then(response=>{  
78 - const data = response.data;  
79 - if (!data) {  
80 - return  
81 - }  
82 - that.list.push(data)  
83 - }) 76 + const res = await StudentApi.getStudentTeacherByStudentId(this.studentId);
  77 + const data = res.data;
  78 + if (!data) {
  79 + return;
  80 + }
  81 + this.list.push(data);
84 } finally { 82 } finally {
85 this.loading = false; 83 this.loading = false;
86 } 84 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/index
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 -  
4 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 <el-form-item label="名字" prop="name"> 5 <el-form-item label="名字" prop="name">
@@ -128,8 +127,8 @@ @@ -128,8 +127,8 @@
128 <script> 127 <script>
129 import * as StudentApi from '@/api/infra/demo'; 128 import * as StudentApi from '@/api/infra/demo';
130 import StudentForm from './StudentForm.vue'; 129 import StudentForm from './StudentForm.vue';
131 - import StudentContactList from './components/StudentContactList.vue'  
132 - import StudentTeacherList from './components/StudentTeacherList.vue' 130 + import StudentContactList from './components/StudentContactList.vue';
  131 + import StudentTeacherList from './components/StudentTeacherList.vue';
133 export default { 132 export default {
134 name: "Student", 133 name: "Student",
135 components: { 134 components: {
@@ -172,13 +171,12 @@ export default { @@ -172,13 +171,12 @@ export default {
172 }, 171 },
173 methods: { 172 methods: {
174 /** 查询列表 */ 173 /** 查询列表 */
175 - getList() { 174 + async getList() {
176 try { 175 try {
177 this.loading = true; 176 this.loading = true;
178 - StudentApi.getStudentPage(this.queryParams).then(response => {  
179 - this.list = response.data.list;  
180 - this.total = response.data.total;  
181 - }); 177 + const res = await StudentApi.getStudentPage(this.queryParams);
  178 + this.list = res.data.list;
  179 + this.total = res.data.total;
182 } finally { 180 } finally {
183 this.loading = false; 181 this.loading = false;
184 } 182 }
@@ -198,31 +196,25 @@ export default { @@ -198,31 +196,25 @@ export default {
198 this.$refs["formRef"].open(id); 196 this.$refs["formRef"].open(id);
199 }, 197 },
200 /** 删除按钮操作 */ 198 /** 删除按钮操作 */
201 - handleDelete(row) {  
202 - const that = this;  
203 - try { 199 + async handleDelete(row) {
204 const id = row.id; 200 const id = row.id;
205 - this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{  
206 - return StudentApi.deleteStudent(id);  
207 - }).then(() => {  
208 - that.getList();  
209 - that.$modal.msgSuccess("删除成功");  
210 - }).catch(() => {}); 201 + await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
  202 + try {
  203 + await StudentApi.deleteStudent(id);
  204 + await this.getList();
  205 + this.$modal.msgSuccess("删除成功");
211 } catch {} 206 } catch {}
212 }, 207 },
213 /** 导出按钮操作 */ 208 /** 导出按钮操作 */
214 - handleExport() {  
215 - const that = this; 209 + async handleExport() {
  210 + await this.$modal.confirm('是否确认导出所有学生数据项?');
216 try { 211 try {
217 - this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {  
218 - that.exportLoading = true;  
219 - return StudentApi.exportStudentExcel(params);  
220 - }).then(response => {  
221 - that.$download.excel(response, '学生.xls');  
222 - }); 212 + this.exportLoading = true;
  213 + const res = await StudentApi.exportStudentExcel(this.queryParams);
  214 + this.$download.excel(res.data, '学生.xls');
223 } catch { 215 } catch {
224 } finally { 216 } finally {
225 - that.exportLoading = false; 217 + this.exportLoading = false;
226 } 218 }
227 }, 219 },
228 } 220 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 <el-form 3 <el-form
4 - ref="formRef"  
5 - :model="formData"  
6 - :rules="formRules"  
7 - v-loading="formLoading"  
8 - label-width="0px"  
9 - :inline-message="true" 4 + ref="formRef"
  5 + :model="formData"
  6 + :rules="formRules"
  7 + v-loading="formLoading"
  8 + label-width="0px"
  9 + :inline-message="true"
10 > 10 >
11 <el-table :data="formData" class="-mt-10px"> 11 <el-table :data="formData" class="-mt-10px">
12 <el-table-column label="序号" type="index" width="100" /> 12 <el-table-column label="序号" type="index" width="100" />
@@ -86,7 +86,7 @@ @@ -86,7 +86,7 @@
86 </template> 86 </template>
87 87
88 <script> 88 <script>
89 - import * as StudentApi from '@/api/infra/demo' 89 + import * as StudentApi from '@/api/infra/demo';
90 import ImageUpload from '@/components/ImageUpload'; 90 import ImageUpload from '@/components/ImageUpload';
91 import FileUpload from '@/components/FileUpload'; 91 import FileUpload from '@/components/FileUpload';
92 import Editor from '@/components/Editor'; 92 import Editor from '@/components/Editor';
@@ -130,8 +130,9 @@ @@ -130,8 +130,9 @@
130 } 130 }
131 try { 131 try {
132 this.formLoading = true; 132 this.formLoading = true;
  133 + // 这里还是需要获取一下 this 的不然取不到 formData
133 const that = this; 134 const that = this;
134 - StudentApi.getStudentContactListByStudentId(val).then(res=>{ 135 + StudentApi.getStudentContactListByStudentId(val).then(function (res){
135 that.formData = res.data; 136 that.formData = res.data;
136 }) 137 })
137 } finally { 138 } finally {
@@ -156,20 +157,20 @@ @@ -156,20 +157,20 @@
156 video: undefined, 157 video: undefined,
157 memo: undefined, 158 memo: undefined,
158 } 159 }
159 - row.studentId = this.studentId  
160 - this.formData.push(row) 160 + row.studentId = this.studentId;
  161 + this.formData.push(row);
161 }, 162 },
162 /** 删除按钮操作 */ 163 /** 删除按钮操作 */
163 handleDelete(index) { 164 handleDelete(index) {
164 - this.formData.splice(index, 1) 165 + this.formData.splice(index, 1);
165 }, 166 },
166 /** 表单校验 */ 167 /** 表单校验 */
167 validate(){ 168 validate(){
168 - return this.$refs["formRef"].validate() 169 + return this.$refs["formRef"].validate();
169 }, 170 },
170 /** 表单值 */ 171 /** 表单值 */
171 getData(){ 172 getData(){
172 - return this.formData 173 + return this.formData;
173 } 174 }
174 } 175 }
175 }; 176 };
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 </template> 52 </template>
53 53
54 <script> 54 <script>
55 - import * as StudentApi from '@/api/infra/demo' 55 + import * as StudentApi from '@/api/infra/demo';
56 import ImageUpload from '@/components/ImageUpload'; 56 import ImageUpload from '@/components/ImageUpload';
57 import FileUpload from '@/components/FileUpload'; 57 import FileUpload from '@/components/FileUpload';
58 import Editor from '@/components/Editor'; 58 import Editor from '@/components/Editor';
@@ -104,18 +104,16 @@ @@ -104,18 +104,16 @@
104 }, 104 },
105 methods: { 105 methods: {
106 /** 打开弹窗 */ 106 /** 打开弹窗 */
107 - open(id) { 107 + async open(id) {
108 this.dialogVisible = true; 108 this.dialogVisible = true;
109 this.reset(); 109 this.reset();
110 - const that = this;  
111 // 修改时,设置数据 110 // 修改时,设置数据
112 if (id) { 111 if (id) {
113 this.formLoading = true; 112 this.formLoading = true;
114 try { 113 try {
115 - StudentApi.getStudent(id).then(res=>{  
116 - that.formData = res.data;  
117 - that.title = "修改学生";  
118 - }) 114 + const res = await StudentApi.getStudent(id);
  115 + this.formData = res.data;
  116 + this.title = "修改学生";
119 } finally { 117 } finally {
120 this.formLoading = false; 118 this.formLoading = false;
121 } 119 }
@@ -123,84 +121,45 @@ @@ -123,84 +121,45 @@
123 this.title = "新增学生"; 121 this.title = "新增学生";
124 }, 122 },
125 /** 提交按钮 */ 123 /** 提交按钮 */
126 - submitForm() { 124 + async submitForm() {
  125 + // 校验主表
  126 + await this.$refs["formRef"].validate();
  127 + // 校验子表
  128 + try {
  129 + await this.$refs['studentContactFormRef'].validate();
  130 + } catch (e) {
  131 + this.subTabsName = 'studentContact';
  132 + return;
  133 + }
  134 + try {
  135 + await this.$refs['studentTeacherFormRef'].validate();
  136 + } catch (e) {
  137 + this.subTabsName = 'studentTeacher';
  138 + return;
  139 + }
127 this.formLoading = true; 140 this.formLoading = true;
128 try { 141 try {
129 - const that = this;  
130 - let data = this.formData;  
131 - let validate = false;  
132 - // 校验主表  
133 - this.getRef("formRef").validate(valid => {  
134 - validate = valid;  
135 - });  
136 - // 校验子表  
137 - this.validateSubFrom01().then(() => {  
138 - // 全部校验通过-拼接子表的数据  
139 - // 拼接子表的数据  
140 - data.studentContacts = that.getRef('studentContactFormRef').getData();  
141 - data.studentTeacher = that.getRef('studentTeacherFormRef').getData();  
142 - }).catch((err) => {  
143 - validate = false;  
144 - that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单  
145 - })  
146 - // 所有表单校验通过后方可提交  
147 - if (!validate) {  
148 - return;  
149 - } 142 + const data = this.formData;
  143 + // 拼接子表的数据
  144 + data.studentContacts = this.$refs['studentContactFormRef'].getData();
  145 + data.studentTeacher = this.$refs['studentTeacherFormRef'].getData();
150 // 修改的提交 146 // 修改的提交
151 if (data.id) { 147 if (data.id) {
152 - StudentApi.updateStudent(data).then(response => {  
153 - that.$modal.msgSuccess("修改成功");  
154 - that.dialogVisible = false;  
155 - that.$emit('success');  
156 - }); 148 + await StudentApi.updateStudent(data);
  149 + this.$modal.msgSuccess("修改成功");
  150 + this.dialogVisible = false;
  151 + this.$emit('success');
157 return; 152 return;
158 } 153 }
159 // 添加的提交 154 // 添加的提交
160 - StudentApi.createStudent(data).then(response => {  
161 - that.$modal.msgSuccess("新增成功");  
162 - that.dialogVisible = false;  
163 - that.$emit('success');  
164 - });  
165 - }finally { 155 + await StudentApi.createStudent(data);
  156 + this.$modal.msgSuccess("新增成功");
  157 + this.dialogVisible = false;
  158 + this.$emit('success');
  159 + } finally {
166 this.formLoading = false; 160 this.formLoading = false;
167 } 161 }
168 }, 162 },
169 - getRef(refName){  
170 - return this.$refs[refName];  
171 - },  
172 - /** 校验子表单 */  
173 - validateSubFrom(item) {  
174 - return new Promise((resolve, reject) => {  
175 - this.getRef(item).validate()  
176 - .then(() => {  
177 - resolve();  
178 - })  
179 - .catch(() => {  
180 - reject(item);  
181 - })  
182 - })  
183 - },  
184 - /** 校验所有子表单 */  
185 - validateSubFrom01() {  
186 - // 需要校验的表单 ref  
187 - const validFormRefArr = [  
188 - "studentContactFormRef",  
189 - "studentTeacherFormRef",  
190 - ];  
191 - const validArr = []; // 校验  
192 - for (const item of validFormRefArr) {  
193 - validArr.push(this.validateSubFrom(item));  
194 - }  
195 - return new Promise((resolve, reject) => {  
196 - // 校验所有  
197 - Promise.all(validArr).then(() => {  
198 - resolve();  
199 - }).catch((err) => {  
200 - reject(err);  
201 - })  
202 - })  
203 - },  
204 /** 表单重置 */ 163 /** 表单重置 */
205 reset() { 164 reset() {
206 this.formData = { 165 this.formData = {
@@ -215,7 +174,7 @@ @@ -215,7 +174,7 @@
215 memo: undefined, 174 memo: undefined,
216 }; 175 };
217 this.resetForm("formRef"); 176 this.resetForm("formRef");
218 - }, 177 + }
219 } 178 }
220 }; 179 };
221 </script> 180 </script>
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 <el-form 3 <el-form
4 - ref="formRef"  
5 - :model="formData"  
6 - :rules="formRules"  
7 - label-width="100px"  
8 - v-loading="formLoading" 4 + ref="formRef"
  5 + :model="formData"
  6 + :rules="formRules"
  7 + label-width="100px"
  8 + v-loading="formLoading"
9 > 9 >
10 <el-form-item label="名字" prop="name"> 10 <el-form-item label="名字" prop="name">
11 <el-input v-model="formData.name" placeholder="请输入名字" /> 11 <el-input v-model="formData.name" placeholder="请输入名字" />
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 </template> 42 </template>
43 43
44 <script> 44 <script>
45 - import * as StudentApi from '@/api/infra/demo' 45 + import * as StudentApi from '@/api/infra/demo';
46 import ImageUpload from '@/components/ImageUpload'; 46 import ImageUpload from '@/components/ImageUpload';
47 import FileUpload from '@/components/FileUpload'; 47 import FileUpload from '@/components/FileUpload';
48 import Editor from '@/components/Editor'; 48 import Editor from '@/components/Editor';
@@ -97,8 +97,9 @@ @@ -97,8 +97,9 @@
97 } 97 }
98 try { 98 try {
99 this.formLoading = true; 99 this.formLoading = true;
  100 + // 这里还是需要获取一下 this 的不然取不到 formData
100 const that = this; 101 const that = this;
101 - StudentApi.getStudentTeacherByStudentId(val).then(res=>{ 102 + StudentApi.getStudentTeacherByStudentId(val).then(function (res){
102 const data = res.data; 103 const data = res.data;
103 if (!data) { 104 if (!data) {
104 return 105 return
@@ -115,11 +116,11 @@ @@ -115,11 +116,11 @@
115 methods: { 116 methods: {
116 /** 表单校验 */ 117 /** 表单校验 */
117 validate(){ 118 validate(){
118 - return this.$refs["formRef"].validate() 119 + return this.$refs["formRef"].validate();
119 }, 120 },
120 /** 表单值 */ 121 /** 表单值 */
121 getData(){ 122 getData(){
122 - return this.formData 123 + return this.formData;
123 } 124 }
124 } 125 }
125 }; 126 };
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/index
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 -  
4 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 <el-form-item label="名字" prop="name"> 5 <el-form-item label="名字" prop="name">
@@ -155,13 +154,12 @@ export default { @@ -155,13 +154,12 @@ export default {
155 }, 154 },
156 methods: { 155 methods: {
157 /** 查询列表 */ 156 /** 查询列表 */
158 - getList() { 157 + async getList() {
159 try { 158 try {
160 this.loading = true; 159 this.loading = true;
161 - StudentApi.getStudentPage(this.queryParams).then(response => {  
162 - this.list = response.data.list;  
163 - this.total = response.data.total;  
164 - }); 160 + const res = await StudentApi.getStudentPage(this.queryParams);
  161 + this.list = res.data.list;
  162 + this.total = res.data.total;
165 } finally { 163 } finally {
166 this.loading = false; 164 this.loading = false;
167 } 165 }
@@ -181,31 +179,25 @@ export default { @@ -181,31 +179,25 @@ export default {
181 this.$refs["formRef"].open(id); 179 this.$refs["formRef"].open(id);
182 }, 180 },
183 /** 删除按钮操作 */ 181 /** 删除按钮操作 */
184 - handleDelete(row) {  
185 - const that = this;  
186 - try { 182 + async handleDelete(row) {
187 const id = row.id; 183 const id = row.id;
188 - this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{  
189 - return StudentApi.deleteStudent(id);  
190 - }).then(() => {  
191 - that.getList();  
192 - that.$modal.msgSuccess("删除成功");  
193 - }).catch(() => {}); 184 + await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
  185 + try {
  186 + await StudentApi.deleteStudent(id);
  187 + await this.getList();
  188 + this.$modal.msgSuccess("删除成功");
194 } catch {} 189 } catch {}
195 }, 190 },
196 /** 导出按钮操作 */ 191 /** 导出按钮操作 */
197 - handleExport() {  
198 - const that = this; 192 + async handleExport() {
  193 + await this.$modal.confirm('是否确认导出所有学生数据项?');
199 try { 194 try {
200 - this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {  
201 - that.exportLoading = true;  
202 - return StudentApi.exportStudentExcel(params);  
203 - }).then(response => {  
204 - that.$download.excel(response, '学生.xls');  
205 - }); 195 + this.exportLoading = true;
  196 + const res = await StudentApi.exportStudentExcel(this.queryParams);
  197 + this.$download.excel(res.data, '学生.xls');
206 } catch { 198 } catch {
207 } finally { 199 } finally {
208 - that.exportLoading = false; 200 + this.exportLoading = false;
209 } 201 }
210 }, 202 },
211 } 203 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/StudentForm
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 </template> 43 </template>
44 44
45 <script> 45 <script>
46 - import * as StudentApi from '@/api/infra/demo' 46 + import * as StudentApi from '@/api/infra/demo';
47 import ImageUpload from '@/components/ImageUpload'; 47 import ImageUpload from '@/components/ImageUpload';
48 import FileUpload from '@/components/FileUpload'; 48 import FileUpload from '@/components/FileUpload';
49 import Editor from '@/components/Editor'; 49 import Editor from '@/components/Editor';
@@ -89,18 +89,16 @@ @@ -89,18 +89,16 @@
89 }, 89 },
90 methods: { 90 methods: {
91 /** 打开弹窗 */ 91 /** 打开弹窗 */
92 - open(id) { 92 + async open(id) {
93 this.dialogVisible = true; 93 this.dialogVisible = true;
94 this.reset(); 94 this.reset();
95 - const that = this;  
96 // 修改时,设置数据 95 // 修改时,设置数据
97 if (id) { 96 if (id) {
98 this.formLoading = true; 97 this.formLoading = true;
99 try { 98 try {
100 - StudentApi.getStudent(id).then(res=>{  
101 - that.formData = res.data;  
102 - that.title = "修改学生";  
103 - }) 99 + const res = await StudentApi.getStudent(id);
  100 + this.formData = res.data;
  101 + this.title = "修改学生";
104 } finally { 102 } finally {
105 this.formLoading = false; 103 this.formLoading = false;
106 } 104 }
@@ -108,42 +106,29 @@ @@ -108,42 +106,29 @@
108 this.title = "新增学生"; 106 this.title = "新增学生";
109 }, 107 },
110 /** 提交按钮 */ 108 /** 提交按钮 */
111 - submitForm() {  
112 - this.formLoading = true; 109 + async submitForm() {
  110 + // 校验主表
  111 + await this.$refs["formRef"].validate();
  112 + this.formLoading = true;
113 try { 113 try {
114 - const that = this;  
115 - let data = this.formData;  
116 - let validate = false;  
117 - // 校验主表  
118 - this.getRef("formRef").validate(valid => {  
119 - validate = valid;  
120 - });  
121 - // 所有表单校验通过后方可提交  
122 - if (!validate) {  
123 - return;  
124 - }  
125 - // 修改的提交 114 + const data = this.formData;
  115 + // 修改的提交
126 if (data.id) { 116 if (data.id) {
127 - StudentApi.updateStudent(data).then(response => {  
128 - that.$modal.msgSuccess("修改成功");  
129 - that.dialogVisible = false;  
130 - that.$emit('success');  
131 - }); 117 + await StudentApi.updateStudent(data);
  118 + this.$modal.msgSuccess("修改成功");
  119 + this.dialogVisible = false;
  120 + this.$emit('success');
132 return; 121 return;
133 } 122 }
134 // 添加的提交 123 // 添加的提交
135 - StudentApi.createStudent(data).then(response => {  
136 - that.$modal.msgSuccess("新增成功");  
137 - that.dialogVisible = false;  
138 - that.$emit('success');  
139 - });  
140 - }finally { 124 + await StudentApi.createStudent(data);
  125 + this.$modal.msgSuccess("新增成功");
  126 + this.dialogVisible = false;
  127 + this.$emit('success');
  128 + } finally {
141 this.formLoading = false; 129 this.formLoading = false;
142 } 130 }
143 }, 131 },
144 - getRef(refName){  
145 - return this.$refs[refName];  
146 - },  
147 /** 表单重置 */ 132 /** 表单重置 */
148 reset() { 133 reset() {
149 this.formData = { 134 this.formData = {
@@ -158,7 +143,7 @@ @@ -158,7 +143,7 @@
158 memo: undefined, 143 memo: undefined,
159 }; 144 };
160 this.resetForm("formRef"); 145 this.resetForm("formRef");
161 - }, 146 + }
162 } 147 }
163 }; 148 };
164 </script> 149 </script>
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/index
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 -  
4 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 <el-form-item label="名字" prop="name"> 5 <el-form-item label="名字" prop="name">
@@ -155,13 +154,12 @@ export default { @@ -155,13 +154,12 @@ export default {
155 }, 154 },
156 methods: { 155 methods: {
157 /** 查询列表 */ 156 /** 查询列表 */
158 - getList() { 157 + async getList() {
159 try { 158 try {
160 this.loading = true; 159 this.loading = true;
161 - StudentApi.getStudentPage(this.queryParams).then(response => {  
162 - this.list = response.data.list;  
163 - this.total = response.data.total;  
164 - }); 160 + const res = await StudentApi.getStudentPage(this.queryParams);
  161 + this.list = res.data.list;
  162 + this.total = res.data.total;
165 } finally { 163 } finally {
166 this.loading = false; 164 this.loading = false;
167 } 165 }
@@ -181,31 +179,25 @@ export default { @@ -181,31 +179,25 @@ export default {
181 this.$refs["formRef"].open(id); 179 this.$refs["formRef"].open(id);
182 }, 180 },
183 /** 删除按钮操作 */ 181 /** 删除按钮操作 */
184 - handleDelete(row) {  
185 - const that = this;  
186 - try { 182 + async handleDelete(row) {
187 const id = row.id; 183 const id = row.id;
188 - this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{  
189 - return StudentApi.deleteStudent(id);  
190 - }).then(() => {  
191 - that.getList();  
192 - that.$modal.msgSuccess("删除成功");  
193 - }).catch(() => {}); 184 + await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
  185 + try {
  186 + await StudentApi.deleteStudent(id);
  187 + await this.getList();
  188 + this.$modal.msgSuccess("删除成功");
194 } catch {} 189 } catch {}
195 }, 190 },
196 /** 导出按钮操作 */ 191 /** 导出按钮操作 */
197 - handleExport() {  
198 - const that = this; 192 + async handleExport() {
  193 + await this.$modal.confirm('是否确认导出所有学生数据项?');
199 try { 194 try {
200 - this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {  
201 - that.exportLoading = true;  
202 - return StudentApi.exportStudentExcel(params);  
203 - }).then(response => {  
204 - that.$download.excel(response, '学生.xls');  
205 - }); 195 + this.exportLoading = true;
  196 + const res = await StudentApi.exportStudentExcel(this.queryParams);
  197 + this.$download.excel(res.data, '学生.xls');
206 } catch { 198 } catch {
207 } finally { 199 } finally {
208 - that.exportLoading = false; 200 + this.exportLoading = false;
209 } 201 }
210 }, 202 },
211 } 203 }
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm
@@ -8,10 +8,10 @@ @@ -8,10 +8,10 @@
8 </el-form-item> 8 </el-form-item>
9 <el-form-item label="父编号" prop="parentId"> 9 <el-form-item label="父编号" prop="parentId">
10 <TreeSelect 10 <TreeSelect
11 - v-model="formData.parentId"  
12 - :options="categoryTree"  
13 - :normalizer="normalizer"  
14 - placeholder="请选择父编号" 11 + v-model="formData.parentId"
  12 + :options="categoryTree"
  13 + :normalizer="normalizer"
  14 + placeholder="请选择父编号"
15 /> 15 />
16 </el-form-item> 16 </el-form-item>
17 </el-form> 17 </el-form>
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 </template> 24 </template>
25 25
26 <script> 26 <script>
27 - import * as CategoryApi from '@/api/infra/demo' 27 + import * as CategoryApi from '@/api/infra/demo';
28 import TreeSelect from "@riophae/vue-treeselect"; 28 import TreeSelect from "@riophae/vue-treeselect";
29 import "@riophae/vue-treeselect/dist/vue-treeselect.css"; 29 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
30 export default { 30 export default {
@@ -56,71 +56,54 @@ @@ -56,71 +56,54 @@
56 }, 56 },
57 methods: { 57 methods: {
58 /** 打开弹窗 */ 58 /** 打开弹窗 */
59 - open(id) { 59 + async open(id) {
60 this.dialogVisible = true; 60 this.dialogVisible = true;
61 this.reset(); 61 this.reset();
62 - const that = this;  
63 // 修改时,设置数据 62 // 修改时,设置数据
64 if (id) { 63 if (id) {
65 this.formLoading = true; 64 this.formLoading = true;
66 try { 65 try {
67 - CategoryApi.getCategory(id).then(res=>{  
68 - that.formData = res.data;  
69 - that.title = "修改分类";  
70 - }) 66 + const res = await CategoryApi.getCategory(id);
  67 + this.formData = res.data;
  68 + this.title = "修改分类";
71 } finally { 69 } finally {
72 this.formLoading = false; 70 this.formLoading = false;
73 } 71 }
74 } 72 }
75 this.title = "新增分类"; 73 this.title = "新增分类";
76 - this.getCategoryTree(); 74 + await this.getCategoryTree();
77 }, 75 },
78 /** 提交按钮 */ 76 /** 提交按钮 */
79 - submitForm() {  
80 - this.formLoading = true; 77 + async submitForm() {
  78 + // 校验主表
  79 + await this.$refs["formRef"].validate();
  80 + this.formLoading = true;
81 try { 81 try {
82 - const that = this;  
83 - let data = this.formData;  
84 - let validate = false;  
85 - // 校验主表  
86 - this.getRef("formRef").validate(valid => {  
87 - validate = valid;  
88 - });  
89 - // 所有表单校验通过后方可提交  
90 - if (!validate) {  
91 - return;  
92 - }  
93 - // 修改的提交 82 + const data = this.formData;
  83 + // 修改的提交
94 if (data.id) { 84 if (data.id) {
95 - CategoryApi.updateCategory(data).then(response => {  
96 - that.$modal.msgSuccess("修改成功");  
97 - that.dialogVisible = false;  
98 - that.$emit('success');  
99 - }); 85 + await CategoryApi.updateCategory(data);
  86 + this.$modal.msgSuccess("修改成功");
  87 + this.dialogVisible = false;
  88 + this.$emit('success');
100 return; 89 return;
101 } 90 }
102 // 添加的提交 91 // 添加的提交
103 - CategoryApi.createCategory(data).then(response => {  
104 - that.$modal.msgSuccess("新增成功");  
105 - that.dialogVisible = false;  
106 - that.$emit('success');  
107 - });  
108 - }finally { 92 + await CategoryApi.createCategory(data);
  93 + this.$modal.msgSuccess("新增成功");
  94 + this.dialogVisible = false;
  95 + this.$emit('success');
  96 + } finally {
109 this.formLoading = false; 97 this.formLoading = false;
110 } 98 }
111 }, 99 },
112 - getRef(refName){  
113 - return this.$refs[refName];  
114 - },  
115 /** 获得分类树 */ 100 /** 获得分类树 */
116 - getCategoryTree() {  
117 - const that = this;  
118 - that.categoryTree = [];  
119 - CategoryApi.getCategoryList().then(res=>{  
120 - const root = { id: 0, name: '顶级分类', children: [] };  
121 - root.children = this.handleTree(res.data, 'id', 'parentId')  
122 - that.categoryTree.push(root)  
123 - }); 101 + async getCategoryTree() {
  102 + this.categoryTree = [];
  103 + const res = await CategoryApi.getCategoryList();
  104 + const root = { id: 0, name: '顶级分类', children: [] };
  105 + root.children = this.handleTree(res.data, 'id', 'parentId')
  106 + this.categoryTree.push(root)
124 }, 107 },
125 /** 转换分类数据结构 */ 108 /** 转换分类数据结构 */
126 normalizer(node) { 109 normalizer(node) {
@@ -141,7 +124,7 @@ @@ -141,7 +124,7 @@
141 parentId: undefined, 124 parentId: undefined,
142 }; 125 };
143 this.resetForm("formRef"); 126 this.resetForm("formRef");
144 - }, 127 + }
145 } 128 }
146 }; 129 };
147 </script> 130 </script>
148 \ No newline at end of file 131 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/index
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 -  
4 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 <el-form-item label="名字" prop="name"> 5 <el-form-item label="名字" prop="name">
@@ -31,14 +30,14 @@ @@ -31,14 +30,14 @@
31 </el-row> 30 </el-row>
32 31
33 <el-table 32 <el-table
34 - v-loading="loading"  
35 - :data="list"  
36 - :stripe="true"  
37 - :show-overflow-tooltip="true"  
38 - v-if="refreshTable"  
39 - row-key="id"  
40 - :default-expand-all="isExpandAll"  
41 - :tree-props="{children: 'children', hasChildren: 'hasChildren'}" 33 + v-loading="loading"
  34 + :data="list"
  35 + :stripe="true"
  36 + :show-overflow-tooltip="true"
  37 + v-if="refreshTable"
  38 + row-key="id"
  39 + :default-expand-all="isExpandAll"
  40 + :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
42 > 41 >
43 <el-table-column label="编号" align="center" prop="id"> 42 <el-table-column label="编号" align="center" prop="id">
44 <template v-slot="scope"> 43 <template v-slot="scope">
@@ -104,12 +103,11 @@ export default { @@ -104,12 +103,11 @@ export default {
104 }, 103 },
105 methods: { 104 methods: {
106 /** 查询列表 */ 105 /** 查询列表 */
107 - getList() { 106 + async getList() {
108 try { 107 try {
109 this.loading = true; 108 this.loading = true;
110 - CategoryApi.getCategoryList(this.queryParams).then(response => {  
111 - this.list = this.handleTree(response.data, 'id', 'parentId');  
112 - }) 109 + const res = await CategoryApi.getCategoryList(this.queryParams);
  110 + this.list = this.handleTree(res.data, 'id', 'parentId');
113 } finally { 111 } finally {
114 this.loading = false; 112 this.loading = false;
115 } 113 }
@@ -129,31 +127,25 @@ export default { @@ -129,31 +127,25 @@ export default {
129 this.$refs["formRef"].open(id); 127 this.$refs["formRef"].open(id);
130 }, 128 },
131 /** 删除按钮操作 */ 129 /** 删除按钮操作 */
132 - handleDelete(row) {  
133 - const that = this;  
134 - try { 130 + async handleDelete(row) {
135 const id = row.id; 131 const id = row.id;
136 - this.$modal.confirm('是否确认删除分类编号为"' + id + '"的数据项?').then(()=>{  
137 - return CategoryApi.deleteCategory(id);  
138 - }).then(() => {  
139 - that.getList();  
140 - that.$modal.msgSuccess("删除成功");  
141 - }).catch(() => {}); 132 + await this.$modal.confirm('是否确认删除分类编号为"' + id + '"的数据项?')
  133 + try {
  134 + await CategoryApi.deleteCategory(id);
  135 + await this.getList();
  136 + this.$modal.msgSuccess("删除成功");
142 } catch {} 137 } catch {}
143 }, 138 },
144 /** 导出按钮操作 */ 139 /** 导出按钮操作 */
145 - handleExport() {  
146 - const that = this; 140 + async handleExport() {
  141 + await this.$modal.confirm('是否确认导出所有分类数据项?');
147 try { 142 try {
148 - this.$modal.confirm('是否确认导出所有分类数据项?').then(() => {  
149 - that.exportLoading = true;  
150 - return CategoryApi.exportCategoryExcel(params);  
151 - }).then(response => {  
152 - that.$download.excel(response, '分类.xls');  
153 - }); 143 + this.exportLoading = true;
  144 + const res = await CategoryApi.exportCategoryExcel(this.queryParams);
  145 + this.$download.excel(res.data, '分类.xls');
154 } catch { 146 } catch {
155 } finally { 147 } finally {
156 - that.exportLoading = false; 148 + this.exportLoading = false;
157 } 149 }
158 }, 150 },
159 /** 展开/折叠操作 */ 151 /** 展开/折叠操作 */