Sfoglia il codice sorgente

代码生成:CodegenEngineVue2Test 所需测试文件

puhui999 1 anno fa
parent
commit
c437201236
20 ha cambiato i file con 355 aggiunte e 550 eliminazioni
  1. 14 22
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm
  2. 13 18
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList
  3. 21 36
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm
  4. 14 22
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm
  5. 13 18
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList
  6. 24 32
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/index
  7. 14 13
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm
  8. 4 6
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList
  9. 35 76
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm
  10. 10 9
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm
  11. 8 10
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList
  12. 18 26
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/index
  13. 14 13
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm
  14. 35 76
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm
  15. 10 9
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm
  16. 16 24
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/index
  17. 21 36
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/StudentForm
  18. 16 24
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/index
  19. 32 49
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm
  20. 23 31
      yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/index

+ 14 - 22
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm

@@ -43,7 +43,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
       import ImageUpload from '@/components/ImageUpload';
       import FileUpload from '@/components/FileUpload';
       import Editor from '@/components/Editor';
@@ -90,19 +90,17 @@
     },
     methods: {
       /** 打开弹窗 */
-      open(id, studentId) {
+      async open(id, studentId) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         this.formData.studentId = studentId;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-              StudentApi.getStudentContact(id).then(res=>{
-              that.formData = res.data;
-              that.dialogTitle = "修改学生联系人";
-            })
+            const res = await StudentApi.getStudentContact(id);
+            this.formData = res.data;
+            this.dialogTitle = "修改学生联系人";
           } finally {
             this.formLoading = false;
           }
@@ -110,32 +108,26 @@
         this.dialogTitle = "新增学生联系人";
       },
       /** 提交按钮 */
-      submitForm() {
+      async submitForm() {
+        await this.$refs["formRef"].validate();
         this.formLoading = true;
         try {
-          let data = this.formData;
-          this.$refs["formRef"].validate(valid => {
-            if (!valid) {
-              return;
-            }
+            const data = this.formData;
             // 修改的提交
             if (data.id) {
-              StudentApi.updateStudentContact(data).then(response => {
-                this.$modal.msgSuccess("修改成功");
-                this.dialogVisible = false;
-                this.$emit('success');
-              });
+            await  StudentApi.updateStudentContact(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
               return;
             }
             // 添加的提交
-            StudentApi.createStudentContact(data).then(response => {
+              await StudentApi.createStudentContact(data);
               this.$modal.msgSuccess("新增成功");
               this.dialogVisible = false;
               this.$emit('success');
-            });
-          });
         }finally {
-          this.formLoading = false
+          this.formLoading = false;
         }
       },
       /** 表单重置 */

+ 13 - 18
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactList

@@ -52,8 +52,8 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
-  import StudentContactForm from './StudentContactForm.vue'
+  import * as StudentApi from '@/api/infra/demo';
+  import StudentContactForm from './StudentContactForm.vue';
   export default {
     name: "StudentContactList",
     components: {
@@ -91,14 +91,12 @@
     },
     methods: {
       /** 查询列表 */
-      getList() {
+      async getList() {
         try {
           this.loading = true;
-          const that = this;
-          StudentApi.getStudentContactPage(this.queryParams).then(response => {
-            that.list = response.data.list;
-            that.total = response.data.total;
-          });
+            const res = await StudentApi.getStudentContactPage(this.queryParams);
+            this.list = res.data.list;
+            this.total = res.data.total;
         } finally {
           this.loading = false;
         }
@@ -111,22 +109,19 @@
       /** 添加/修改操作 */
       openForm(id) {
         if (!this.studentId) {
-          that.$modal.msgError('请选择一个学生');
+          this.$modal.msgError('请选择一个学生');
           return;
         }
         this.$refs["formRef"].open(id, this.studentId);
       },
       /** 删除按钮操作 */
-      handleDelete(row) {
-        const that = this;
+      async handleDelete(row) {
+        const id = row.id;
+        await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?');
         try {
-          const id = row.id;
-          this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
-            return StudentApi.deleteStudentContact(id);
-          }).then(() => {
-            that.getList();
-            that.$modal.msgSuccess("删除成功");
-          }).catch(() => {});
+          await StudentApi.deleteStudentContact(id);
+          await this.getList();
+          this.$modal.msgSuccess("删除成功");
         } catch {}
       },
     }

+ 21 - 36
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentForm

@@ -43,7 +43,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
   import ImageUpload from '@/components/ImageUpload';
   import FileUpload from '@/components/FileUpload';
   import Editor from '@/components/Editor';
@@ -89,18 +89,16 @@
     },
     methods: {
       /** 打开弹窗 */
-     open(id) {
+     async open(id) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-            StudentApi.getStudent(id).then(res=>{
-              that.formData = res.data;
-              that.title = "修改学生";
-            })
+            const res = await StudentApi.getStudent(id);
+            this.formData = res.data;
+            this.title = "修改学生";
           } finally {
             this.formLoading = false;
           }
@@ -108,42 +106,29 @@
         this.title = "新增学生";
               },
       /** 提交按钮 */
-      submitForm() {
-        this.formLoading = true;
+      async submitForm() {
+        // 校验主表
+        await this.$refs["formRef"].validate();
+                  this.formLoading = true;
         try {
-          const that = this;
-          let data = this.formData;
-          let validate = false;
-          // 校验主表
-          this.getRef("formRef").validate(valid => {
-            validate = valid;
-          });
-                  // 所有表单校验通过后方可提交
-          if (!validate) {
-            return;
-          }
-          // 修改的提交
+          const data = this.formData;
+                  // 修改的提交
           if (data.id) {
-                  StudentApi.updateStudent(data).then(response => {
-              that.$modal.msgSuccess("修改成功");
-              that.dialogVisible = false;
-              that.$emit('success');
-            });
+            await StudentApi.updateStudent(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
             return;
           }
           // 添加的提交
-          StudentApi.createStudent(data).then(response => {
-            that.$modal.msgSuccess("新增成功");
-            that.dialogVisible = false;
-            that.$emit('success');
-          });
-        }finally {
+          await StudentApi.createStudent(data);
+          this.$modal.msgSuccess("新增成功");
+          this.dialogVisible = false;
+          this.$emit('success');
+        } finally {
           this.formLoading = false;
         }
       },
-      getRef(refName){
-        return this.$refs[refName];
-      },
                       /** 表单重置 */
       reset() {
         this.formData = {
@@ -158,7 +143,7 @@
                             memo: undefined,
         };
         this.resetForm("formRef");
-      },
+      }
     }
   };
 </script>

+ 14 - 22
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm

@@ -43,7 +43,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
       import ImageUpload from '@/components/ImageUpload';
       import FileUpload from '@/components/FileUpload';
       import Editor from '@/components/Editor';
@@ -90,19 +90,17 @@
     },
     methods: {
       /** 打开弹窗 */
-      open(id, studentId) {
+      async open(id, studentId) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         this.formData.studentId = studentId;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-              StudentApi.getStudentTeacher(id).then(res=>{
-              that.formData = res.data;
-              that.dialogTitle = "修改学生班主任";
-            })
+            const res = await StudentApi.getStudentTeacher(id);
+            this.formData = res.data;
+            this.dialogTitle = "修改学生班主任";
           } finally {
             this.formLoading = false;
           }
@@ -110,32 +108,26 @@
         this.dialogTitle = "新增学生班主任";
       },
       /** 提交按钮 */
-      submitForm() {
+      async submitForm() {
+        await this.$refs["formRef"].validate();
         this.formLoading = true;
         try {
-          let data = this.formData;
-          this.$refs["formRef"].validate(valid => {
-            if (!valid) {
-              return;
-            }
+            const data = this.formData;
             // 修改的提交
             if (data.id) {
-              StudentApi.updateStudentTeacher(data).then(response => {
-                this.$modal.msgSuccess("修改成功");
-                this.dialogVisible = false;
-                this.$emit('success');
-              });
+            await  StudentApi.updateStudentTeacher(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
               return;
             }
             // 添加的提交
-            StudentApi.createStudentTeacher(data).then(response => {
+              await StudentApi.createStudentTeacher(data);
               this.$modal.msgSuccess("新增成功");
               this.dialogVisible = false;
               this.$emit('success');
-            });
-          });
         }finally {
-          this.formLoading = false
+          this.formLoading = false;
         }
       },
       /** 表单重置 */

+ 13 - 18
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherList

@@ -52,8 +52,8 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
-  import StudentTeacherForm from './StudentTeacherForm.vue'
+  import * as StudentApi from '@/api/infra/demo';
+  import StudentTeacherForm from './StudentTeacherForm.vue';
   export default {
     name: "StudentTeacherList",
     components: {
@@ -91,14 +91,12 @@
     },
     methods: {
       /** 查询列表 */
-      getList() {
+      async getList() {
         try {
           this.loading = true;
-          const that = this;
-          StudentApi.getStudentTeacherPage(this.queryParams).then(response => {
-            that.list = response.data.list;
-            that.total = response.data.total;
-          });
+            const res = await StudentApi.getStudentTeacherPage(this.queryParams);
+            this.list = res.data.list;
+            this.total = res.data.total;
         } finally {
           this.loading = false;
         }
@@ -111,22 +109,19 @@
       /** 添加/修改操作 */
       openForm(id) {
         if (!this.studentId) {
-          that.$modal.msgError('请选择一个学生');
+          this.$modal.msgError('请选择一个学生');
           return;
         }
         this.$refs["formRef"].open(id, this.studentId);
       },
       /** 删除按钮操作 */
-      handleDelete(row) {
-        const that = this;
+      async handleDelete(row) {
+        const id = row.id;
+        await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?');
         try {
-          const id = row.id;
-          this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
-            return StudentApi.deleteStudentTeacher(id);
-          }).then(() => {
-            that.getList();
-            that.$modal.msgSuccess("删除成功");
-          }).catch(() => {});
+          await StudentApi.deleteStudentTeacher(id);
+          await this.getList();
+          this.$modal.msgSuccess("删除成功");
         } catch {}
       },
     }

+ 24 - 32
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/index

@@ -1,6 +1,5 @@
 <template>
   <div class="app-container">
-
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="名字" prop="name">
@@ -45,12 +44,12 @@
     </el-row>
 
             <el-table
-          v-loading="loading"
-          :data="list"
-          :stripe="true"
-          :highlight-current-row="true"
-          :show-overflow-tooltip="true"
-          @current-change="handleCurrentChange"
+        v-loading="loading"
+        :data="list"
+        :stripe="true"
+        :highlight-current-row="true"
+        :show-overflow-tooltip="true"
+        @current-change="handleCurrentChange"
       >
                       <el-table-column label="编号" align="center" prop="id">
         <template v-slot="scope">
@@ -131,8 +130,8 @@
 <script>
 import * as StudentApi from '@/api/infra/demo';
 import StudentForm from './StudentForm.vue';
-    import StudentContactList from './components/StudentContactList.vue'
-    import StudentTeacherList from './components/StudentTeacherList.vue'
+    import StudentContactList from './components/StudentContactList.vue';
+    import StudentTeacherList from './components/StudentTeacherList.vue';
 export default {
   name: "Student",
   components: {
@@ -177,13 +176,12 @@ export default {
   },
   methods: {
     /** 查询列表 */
-    getList() {
+    async getList() {
       try {
       this.loading = true;
-            StudentApi.getStudentPage(this.queryParams).then(response => {
-        this.list = response.data.list;
-        this.total = response.data.total;
-      });
+              const res = await StudentApi.getStudentPage(this.queryParams);
+        this.list = res.data.list;
+        this.total = res.data.total;
       } finally {
         this.loading = false;
       }
@@ -203,31 +201,25 @@ export default {
       this.$refs["formRef"].open(id);
     },
     /** 删除按钮操作 */
-    handleDelete(row) {
-      const that = this;
-      try {
+    async handleDelete(row) {
       const id = row.id;
-      this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
-          return StudentApi.deleteStudent(id);
-        }).then(() => {
-        that.getList();
-        that.$modal.msgSuccess("删除成功");
-        }).catch(() => {});
+      await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
+      try {
+       await StudentApi.deleteStudent(id);
+       await this.getList();
+       this.$modal.msgSuccess("删除成功");
       } catch {}
     },
     /** 导出按钮操作 */
-    handleExport() {
-      const that = this;
+    async handleExport() {
+      await this.$modal.confirm('是否确认导出所有学生数据项?');
       try {
-          this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
-              that.exportLoading = true;
-              return StudentApi.exportStudentExcel(params);
-            }).then(response => {
-              that.$download.excel(response, '学生.xls');
-            });
+        this.exportLoading = true;
+        const res = await StudentApi.exportStudentExcel(this.queryParams);
+        this.$download.excel(res.data, '学生.xls');
       } catch {
       } finally {
-        that.exportLoading = false;
+        this.exportLoading = false;
       }
     },
               /** 选中行操作 */

+ 14 - 13
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactForm

@@ -1,12 +1,12 @@
 <template>
   <div class="app-container">
       <el-form
-          ref="formRef"
-          :model="formData"
-          :rules="formRules"
-          v-loading="formLoading"
-          label-width="0px"
-          :inline-message="true"
+        ref="formRef"
+        :model="formData"
+        :rules="formRules"
+        v-loading="formLoading"
+        label-width="0px"
+        :inline-message="true"
       >
         <el-table :data="formData" class="-mt-10px">
           <el-table-column label="序号" type="index" width="100" />
@@ -86,7 +86,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
       import ImageUpload from '@/components/ImageUpload';
       import FileUpload from '@/components/FileUpload';
       import Editor from '@/components/Editor';
@@ -130,8 +130,9 @@
           }
           try {
             this.formLoading = true;
+            // 这里还是需要获取一下 this 的不然取不到 formData
             const that = this;
-            StudentApi.getStudentContactListByStudentId(val).then(res=>{
+            StudentApi.getStudentContactListByStudentId(val).then(function (res){
               that.formData = res.data;
             })
           } finally {
@@ -156,20 +157,20 @@
                                 video: undefined,
                                 memo: undefined,
             }
-            row.studentId = this.studentId
-            this.formData.push(row)
+            row.studentId = this.studentId;
+            this.formData.push(row);
           },
           /** 删除按钮操作 */
           handleDelete(index) {
-            this.formData.splice(index, 1)
+            this.formData.splice(index, 1);
           },
       /** 表单校验 */
       validate(){
-        return this.$refs["formRef"].validate()
+        return this.$refs["formRef"].validate();
       },
       /** 表单值 */
       getData(){
-        return this.formData
+        return this.formData;
       }
     }
   };

+ 4 - 6
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentContactList

@@ -40,7 +40,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
   export default {
     name: "StudentContactList",
     props:[
@@ -70,13 +70,11 @@
     },
     methods: {
       /** 查询列表 */
-      getList() {
+      async getList() {
         try {
           this.loading = true;
-          const that = this;
-                StudentApi.getStudentContactListByStudentId(this.studentId).then(response=>{
-                  that.list = response.data;
-              })
+                const res = await StudentApi.getStudentContactListByStudentId(this.studentId);
+                this.list = res.data;
         } finally {
           this.loading = false;
         }

+ 35 - 76
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentForm

@@ -52,7 +52,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
   import ImageUpload from '@/components/ImageUpload';
   import FileUpload from '@/components/FileUpload';
   import Editor from '@/components/Editor';
@@ -104,18 +104,16 @@
     },
     methods: {
       /** 打开弹窗 */
-     open(id) {
+     async open(id) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-            StudentApi.getStudent(id).then(res=>{
-              that.formData = res.data;
-              that.title = "修改学生";
-            })
+            const res = await StudentApi.getStudent(id);
+            this.formData = res.data;
+            this.title = "修改学生";
           } finally {
             this.formLoading = false;
           }
@@ -123,84 +121,45 @@
         this.title = "新增学生";
               },
       /** 提交按钮 */
-      submitForm() {
+      async submitForm() {
+        // 校验主表
+        await this.$refs["formRef"].validate();
+                          // 校验子表
+                    try {
+                                            await this.$refs['studentContactFormRef'].validate();
+                    } catch (e) {
+                      this.subTabsName = 'studentContact';
+                      return;
+                    }
+                    try {
+                                            await this.$refs['studentTeacherFormRef'].validate();
+                    } catch (e) {
+                      this.subTabsName = 'studentTeacher';
+                      return;
+                    }
         this.formLoading = true;
         try {
-          const that = this;
-          let data = this.formData;
-          let validate = false;
-          // 校验主表
-          this.getRef("formRef").validate(valid => {
-            validate = valid;
-          });
-                    // 校验子表
-            this.validateSubFrom01().then(() => {
-            // 全部校验通过-拼接子表的数据
-            // 拼接子表的数据
-                data.studentContacts = that.getRef('studentContactFormRef').getData();
-                data.studentTeacher = that.getRef('studentTeacherFormRef').getData();
-            }).catch((err) => {
-                validate = false;
-                that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单
-            })
-          // 所有表单校验通过后方可提交
-          if (!validate) {
-            return;
-          }
+          const data = this.formData;
+                    // 拼接子表的数据
+              data.studentContacts = this.$refs['studentContactFormRef'].getData();
+              data.studentTeacher = this.$refs['studentTeacherFormRef'].getData();
           // 修改的提交
           if (data.id) {
-                  StudentApi.updateStudent(data).then(response => {
-              that.$modal.msgSuccess("修改成功");
-              that.dialogVisible = false;
-              that.$emit('success');
-            });
+            await StudentApi.updateStudent(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
             return;
           }
           // 添加的提交
-          StudentApi.createStudent(data).then(response => {
-            that.$modal.msgSuccess("新增成功");
-            that.dialogVisible = false;
-            that.$emit('success');
-          });
-        }finally {
+          await StudentApi.createStudent(data);
+          this.$modal.msgSuccess("新增成功");
+          this.dialogVisible = false;
+          this.$emit('success');
+        } finally {
           this.formLoading = false;
         }
       },
-      getRef(refName){
-        return this.$refs[refName];
-      },
-      /** 校验子表单 */
-      validateSubFrom(item) {
-        return new Promise((resolve, reject) => {
-          this.getRef(item).validate()
-          .then(() => {
-            resolve();
-          })
-          .catch(() => {
-            reject(item);
-          })
-        })
-      },
-      /** 校验所有子表单 */
-      validateSubFrom01() {
-        // 需要校验的表单 ref
-        const validFormRefArr = [
-              "studentContactFormRef",
-              "studentTeacherFormRef",
-        ];
-        const validArr = []; // 校验
-        for (const item of validFormRefArr) {
-          validArr.push(this.validateSubFrom(item));
-        }
-        return new Promise((resolve, reject) => {
-          // 校验所有
-          Promise.all(validArr).then(() => {
-            resolve();
-          }).catch((err) => {
-            reject(err);
-          })
-        })
-      },
                       /** 表单重置 */
       reset() {
         this.formData = {
@@ -215,7 +174,7 @@
                             memo: undefined,
         };
         this.resetForm("formRef");
-      },
+      }
     }
   };
 </script>

+ 10 - 9
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm

@@ -1,11 +1,11 @@
 <template>
   <div class="app-container">
       <el-form
-          ref="formRef"
-          :model="formData"
-          :rules="formRules"
-          label-width="100px"
-          v-loading="formLoading"
+        ref="formRef"
+        :model="formData"
+        :rules="formRules"
+        label-width="100px"
+        v-loading="formLoading"
       >
                      <el-form-item label="名字" prop="name">
                       <el-input v-model="formData.name" placeholder="请输入名字" />
@@ -42,7 +42,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
       import ImageUpload from '@/components/ImageUpload';
       import FileUpload from '@/components/FileUpload';
       import Editor from '@/components/Editor';
@@ -97,8 +97,9 @@
           }
           try {
             this.formLoading = true;
+            // 这里还是需要获取一下 this 的不然取不到 formData
             const that = this;
-            StudentApi.getStudentTeacherByStudentId(val).then(res=>{
+            StudentApi.getStudentTeacherByStudentId(val).then(function (res){
               const data = res.data;
               if (!data) {
                 return
@@ -115,11 +116,11 @@
     methods: {
       /** 表单校验 */
       validate(){
-        return this.$refs["formRef"].validate()
+        return this.$refs["formRef"].validate();
       },
       /** 表单值 */
       getData(){
-        return this.formData
+        return this.formData;
       }
     }
   };

+ 8 - 10
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherList

@@ -40,7 +40,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
   export default {
     name: "StudentTeacherList",
     props:[
@@ -70,17 +70,15 @@
     },
     methods: {
       /** 查询列表 */
-      getList() {
+      async getList() {
         try {
           this.loading = true;
-          const that = this;
-                StudentApi.getStudentTeacherByStudentId(this.studentId).then(response=>{
-                  const data = response.data;
-                  if (!data) {
-                    return
-                  }
-                  that.list.push(data)
-              })
+                const res = await  StudentApi.getStudentTeacherByStudentId(this.studentId);
+                const data = res.data;
+                if (!data) {
+                  return;
+                }
+                this.list.push(data);
         } finally {
           this.loading = false;
         }

+ 18 - 26
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/index

@@ -1,6 +1,5 @@
 <template>
   <div class="app-container">
-
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="名字" prop="name">
@@ -128,8 +127,8 @@
 <script>
 import * as StudentApi from '@/api/infra/demo';
 import StudentForm from './StudentForm.vue';
-    import StudentContactList from './components/StudentContactList.vue'
-    import StudentTeacherList from './components/StudentTeacherList.vue'
+    import StudentContactList from './components/StudentContactList.vue';
+    import StudentTeacherList from './components/StudentTeacherList.vue';
 export default {
   name: "Student",
   components: {
@@ -172,13 +171,12 @@ export default {
   },
   methods: {
     /** 查询列表 */
-    getList() {
+    async getList() {
       try {
       this.loading = true;
-            StudentApi.getStudentPage(this.queryParams).then(response => {
-        this.list = response.data.list;
-        this.total = response.data.total;
-      });
+              const res = await StudentApi.getStudentPage(this.queryParams);
+        this.list = res.data.list;
+        this.total = res.data.total;
       } finally {
         this.loading = false;
       }
@@ -198,31 +196,25 @@ export default {
       this.$refs["formRef"].open(id);
     },
     /** 删除按钮操作 */
-    handleDelete(row) {
-      const that = this;
-      try {
+    async handleDelete(row) {
       const id = row.id;
-      this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
-          return StudentApi.deleteStudent(id);
-        }).then(() => {
-        that.getList();
-        that.$modal.msgSuccess("删除成功");
-        }).catch(() => {});
+      await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
+      try {
+       await StudentApi.deleteStudent(id);
+       await this.getList();
+       this.$modal.msgSuccess("删除成功");
       } catch {}
     },
     /** 导出按钮操作 */
-    handleExport() {
-      const that = this;
+    async handleExport() {
+      await this.$modal.confirm('是否确认导出所有学生数据项?');
       try {
-          this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
-              that.exportLoading = true;
-              return StudentApi.exportStudentExcel(params);
-            }).then(response => {
-              that.$download.excel(response, '学生.xls');
-            });
+        this.exportLoading = true;
+        const res = await StudentApi.exportStudentExcel(this.queryParams);
+        this.$download.excel(res.data, '学生.xls');
       } catch {
       } finally {
-        that.exportLoading = false;
+        this.exportLoading = false;
       }
     },
               }

+ 14 - 13
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentContactForm

@@ -1,12 +1,12 @@
 <template>
   <div class="app-container">
       <el-form
-          ref="formRef"
-          :model="formData"
-          :rules="formRules"
-          v-loading="formLoading"
-          label-width="0px"
-          :inline-message="true"
+        ref="formRef"
+        :model="formData"
+        :rules="formRules"
+        v-loading="formLoading"
+        label-width="0px"
+        :inline-message="true"
       >
         <el-table :data="formData" class="-mt-10px">
           <el-table-column label="序号" type="index" width="100" />
@@ -86,7 +86,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
       import ImageUpload from '@/components/ImageUpload';
       import FileUpload from '@/components/FileUpload';
       import Editor from '@/components/Editor';
@@ -130,8 +130,9 @@
           }
           try {
             this.formLoading = true;
+            // 这里还是需要获取一下 this 的不然取不到 formData
             const that = this;
-            StudentApi.getStudentContactListByStudentId(val).then(res=>{
+            StudentApi.getStudentContactListByStudentId(val).then(function (res){
               that.formData = res.data;
             })
           } finally {
@@ -156,20 +157,20 @@
                                 video: undefined,
                                 memo: undefined,
             }
-            row.studentId = this.studentId
-            this.formData.push(row)
+            row.studentId = this.studentId;
+            this.formData.push(row);
           },
           /** 删除按钮操作 */
           handleDelete(index) {
-            this.formData.splice(index, 1)
+            this.formData.splice(index, 1);
           },
       /** 表单校验 */
       validate(){
-        return this.$refs["formRef"].validate()
+        return this.$refs["formRef"].validate();
       },
       /** 表单值 */
       getData(){
-        return this.formData
+        return this.formData;
       }
     }
   };

+ 35 - 76
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentForm

@@ -52,7 +52,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
   import ImageUpload from '@/components/ImageUpload';
   import FileUpload from '@/components/FileUpload';
   import Editor from '@/components/Editor';
@@ -104,18 +104,16 @@
     },
     methods: {
       /** 打开弹窗 */
-     open(id) {
+     async open(id) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-            StudentApi.getStudent(id).then(res=>{
-              that.formData = res.data;
-              that.title = "修改学生";
-            })
+            const res = await StudentApi.getStudent(id);
+            this.formData = res.data;
+            this.title = "修改学生";
           } finally {
             this.formLoading = false;
           }
@@ -123,84 +121,45 @@
         this.title = "新增学生";
               },
       /** 提交按钮 */
-      submitForm() {
+      async submitForm() {
+        // 校验主表
+        await this.$refs["formRef"].validate();
+                          // 校验子表
+                    try {
+                                            await this.$refs['studentContactFormRef'].validate();
+                    } catch (e) {
+                      this.subTabsName = 'studentContact';
+                      return;
+                    }
+                    try {
+                                            await this.$refs['studentTeacherFormRef'].validate();
+                    } catch (e) {
+                      this.subTabsName = 'studentTeacher';
+                      return;
+                    }
         this.formLoading = true;
         try {
-          const that = this;
-          let data = this.formData;
-          let validate = false;
-          // 校验主表
-          this.getRef("formRef").validate(valid => {
-            validate = valid;
-          });
-                    // 校验子表
-            this.validateSubFrom01().then(() => {
-            // 全部校验通过-拼接子表的数据
-            // 拼接子表的数据
-                data.studentContacts = that.getRef('studentContactFormRef').getData();
-                data.studentTeacher = that.getRef('studentTeacherFormRef').getData();
-            }).catch((err) => {
-                validate = false;
-                that.subTabsName = err.replace("FormRef", ""); // 定位到没有校验通过的子表单
-            })
-          // 所有表单校验通过后方可提交
-          if (!validate) {
-            return;
-          }
+          const data = this.formData;
+                    // 拼接子表的数据
+              data.studentContacts = this.$refs['studentContactFormRef'].getData();
+              data.studentTeacher = this.$refs['studentTeacherFormRef'].getData();
           // 修改的提交
           if (data.id) {
-                  StudentApi.updateStudent(data).then(response => {
-              that.$modal.msgSuccess("修改成功");
-              that.dialogVisible = false;
-              that.$emit('success');
-            });
+            await StudentApi.updateStudent(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
             return;
           }
           // 添加的提交
-          StudentApi.createStudent(data).then(response => {
-            that.$modal.msgSuccess("新增成功");
-            that.dialogVisible = false;
-            that.$emit('success');
-          });
-        }finally {
+          await StudentApi.createStudent(data);
+          this.$modal.msgSuccess("新增成功");
+          this.dialogVisible = false;
+          this.$emit('success');
+        } finally {
           this.formLoading = false;
         }
       },
-      getRef(refName){
-        return this.$refs[refName];
-      },
-      /** 校验子表单 */
-      validateSubFrom(item) {
-        return new Promise((resolve, reject) => {
-          this.getRef(item).validate()
-          .then(() => {
-            resolve();
-          })
-          .catch(() => {
-            reject(item);
-          })
-        })
-      },
-      /** 校验所有子表单 */
-      validateSubFrom01() {
-        // 需要校验的表单 ref
-        const validFormRefArr = [
-              "studentContactFormRef",
-              "studentTeacherFormRef",
-        ];
-        const validArr = []; // 校验
-        for (const item of validFormRefArr) {
-          validArr.push(this.validateSubFrom(item));
-        }
-        return new Promise((resolve, reject) => {
-          // 校验所有
-          Promise.all(validArr).then(() => {
-            resolve();
-          }).catch((err) => {
-            reject(err);
-          })
-        })
-      },
                       /** 表单重置 */
       reset() {
         this.formData = {
@@ -215,7 +174,7 @@
                             memo: undefined,
         };
         this.resetForm("formRef");
-      },
+      }
     }
   };
 </script>

+ 10 - 9
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm

@@ -1,11 +1,11 @@
 <template>
   <div class="app-container">
       <el-form
-          ref="formRef"
-          :model="formData"
-          :rules="formRules"
-          label-width="100px"
-          v-loading="formLoading"
+        ref="formRef"
+        :model="formData"
+        :rules="formRules"
+        label-width="100px"
+        v-loading="formLoading"
       >
                      <el-form-item label="名字" prop="name">
                       <el-input v-model="formData.name" placeholder="请输入名字" />
@@ -42,7 +42,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
       import ImageUpload from '@/components/ImageUpload';
       import FileUpload from '@/components/FileUpload';
       import Editor from '@/components/Editor';
@@ -97,8 +97,9 @@
           }
           try {
             this.formLoading = true;
+            // 这里还是需要获取一下 this 的不然取不到 formData
             const that = this;
-            StudentApi.getStudentTeacherByStudentId(val).then(res=>{
+            StudentApi.getStudentTeacherByStudentId(val).then(function (res){
               const data = res.data;
               if (!data) {
                 return
@@ -115,11 +116,11 @@
     methods: {
       /** 表单校验 */
       validate(){
-        return this.$refs["formRef"].validate()
+        return this.$refs["formRef"].validate();
       },
       /** 表单值 */
       getData(){
-        return this.formData
+        return this.formData;
       }
     }
   };

+ 16 - 24
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/index

@@ -1,6 +1,5 @@
 <template>
   <div class="app-container">
-
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="名字" prop="name">
@@ -155,13 +154,12 @@ export default {
   },
   methods: {
     /** 查询列表 */
-    getList() {
+    async getList() {
       try {
       this.loading = true;
-            StudentApi.getStudentPage(this.queryParams).then(response => {
-        this.list = response.data.list;
-        this.total = response.data.total;
-      });
+              const res = await StudentApi.getStudentPage(this.queryParams);
+        this.list = res.data.list;
+        this.total = res.data.total;
       } finally {
         this.loading = false;
       }
@@ -181,31 +179,25 @@ export default {
       this.$refs["formRef"].open(id);
     },
     /** 删除按钮操作 */
-    handleDelete(row) {
-      const that = this;
-      try {
+    async handleDelete(row) {
       const id = row.id;
-      this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
-          return StudentApi.deleteStudent(id);
-        }).then(() => {
-        that.getList();
-        that.$modal.msgSuccess("删除成功");
-        }).catch(() => {});
+      await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
+      try {
+       await StudentApi.deleteStudent(id);
+       await this.getList();
+       this.$modal.msgSuccess("删除成功");
       } catch {}
     },
     /** 导出按钮操作 */
-    handleExport() {
-      const that = this;
+    async handleExport() {
+      await this.$modal.confirm('是否确认导出所有学生数据项?');
       try {
-          this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
-              that.exportLoading = true;
-              return StudentApi.exportStudentExcel(params);
-            }).then(response => {
-              that.$download.excel(response, '学生.xls');
-            });
+        this.exportLoading = true;
+        const res = await StudentApi.exportStudentExcel(this.queryParams);
+        this.$download.excel(res.data, '学生.xls');
       } catch {
       } finally {
-        that.exportLoading = false;
+        this.exportLoading = false;
       }
     },
               }

+ 21 - 36
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/StudentForm

@@ -43,7 +43,7 @@
 </template>
 
 <script>
-  import * as StudentApi from '@/api/infra/demo'
+  import * as StudentApi from '@/api/infra/demo';
   import ImageUpload from '@/components/ImageUpload';
   import FileUpload from '@/components/FileUpload';
   import Editor from '@/components/Editor';
@@ -89,18 +89,16 @@
     },
     methods: {
       /** 打开弹窗 */
-     open(id) {
+     async open(id) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-            StudentApi.getStudent(id).then(res=>{
-              that.formData = res.data;
-              that.title = "修改学生";
-            })
+            const res = await StudentApi.getStudent(id);
+            this.formData = res.data;
+            this.title = "修改学生";
           } finally {
             this.formLoading = false;
           }
@@ -108,42 +106,29 @@
         this.title = "新增学生";
               },
       /** 提交按钮 */
-      submitForm() {
-        this.formLoading = true;
+      async submitForm() {
+        // 校验主表
+        await this.$refs["formRef"].validate();
+                  this.formLoading = true;
         try {
-          const that = this;
-          let data = this.formData;
-          let validate = false;
-          // 校验主表
-          this.getRef("formRef").validate(valid => {
-            validate = valid;
-          });
-                  // 所有表单校验通过后方可提交
-          if (!validate) {
-            return;
-          }
-          // 修改的提交
+          const data = this.formData;
+                  // 修改的提交
           if (data.id) {
-                  StudentApi.updateStudent(data).then(response => {
-              that.$modal.msgSuccess("修改成功");
-              that.dialogVisible = false;
-              that.$emit('success');
-            });
+            await StudentApi.updateStudent(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
             return;
           }
           // 添加的提交
-          StudentApi.createStudent(data).then(response => {
-            that.$modal.msgSuccess("新增成功");
-            that.dialogVisible = false;
-            that.$emit('success');
-          });
-        }finally {
+          await StudentApi.createStudent(data);
+          this.$modal.msgSuccess("新增成功");
+          this.dialogVisible = false;
+          this.$emit('success');
+        } finally {
           this.formLoading = false;
         }
       },
-      getRef(refName){
-        return this.$refs[refName];
-      },
                       /** 表单重置 */
       reset() {
         this.formData = {
@@ -158,7 +143,7 @@
                             memo: undefined,
         };
         this.resetForm("formRef");
-      },
+      }
     }
   };
 </script>

+ 16 - 24
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/index

@@ -1,6 +1,5 @@
 <template>
   <div class="app-container">
-
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="名字" prop="name">
@@ -155,13 +154,12 @@ export default {
   },
   methods: {
     /** 查询列表 */
-    getList() {
+    async getList() {
       try {
       this.loading = true;
-            StudentApi.getStudentPage(this.queryParams).then(response => {
-        this.list = response.data.list;
-        this.total = response.data.total;
-      });
+              const res = await StudentApi.getStudentPage(this.queryParams);
+        this.list = res.data.list;
+        this.total = res.data.total;
       } finally {
         this.loading = false;
       }
@@ -181,31 +179,25 @@ export default {
       this.$refs["formRef"].open(id);
     },
     /** 删除按钮操作 */
-    handleDelete(row) {
-      const that = this;
-      try {
+    async handleDelete(row) {
       const id = row.id;
-      this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(()=>{
-          return StudentApi.deleteStudent(id);
-        }).then(() => {
-        that.getList();
-        that.$modal.msgSuccess("删除成功");
-        }).catch(() => {});
+      await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
+      try {
+       await StudentApi.deleteStudent(id);
+       await this.getList();
+       this.$modal.msgSuccess("删除成功");
       } catch {}
     },
     /** 导出按钮操作 */
-    handleExport() {
-      const that = this;
+    async handleExport() {
+      await this.$modal.confirm('是否确认导出所有学生数据项?');
       try {
-          this.$modal.confirm('是否确认导出所有学生数据项?').then(() => {
-              that.exportLoading = true;
-              return StudentApi.exportStudentExcel(params);
-            }).then(response => {
-              that.$download.excel(response, '学生.xls');
-            });
+        this.exportLoading = true;
+        const res = await StudentApi.exportStudentExcel(this.queryParams);
+        this.$download.excel(res.data, '学生.xls');
       } catch {
       } finally {
-        that.exportLoading = false;
+        this.exportLoading = false;
       }
     },
               }

+ 32 - 49
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/CategoryForm

@@ -8,10 +8,10 @@
                     </el-form-item>
                     <el-form-item label="父编号" prop="parentId">
                       <TreeSelect
-                          v-model="formData.parentId"
-                          :options="categoryTree"
-                          :normalizer="normalizer"
-                          placeholder="请选择父编号"
+                        v-model="formData.parentId"
+                        :options="categoryTree"
+                        :normalizer="normalizer"
+                        placeholder="请选择父编号"
                       />
                     </el-form-item>
       </el-form>
@@ -24,7 +24,7 @@
 </template>
 
 <script>
-  import * as CategoryApi from '@/api/infra/demo'
+  import * as CategoryApi from '@/api/infra/demo';
     import TreeSelect from "@riophae/vue-treeselect";
   import "@riophae/vue-treeselect/dist/vue-treeselect.css";
     export default {
@@ -56,71 +56,54 @@
     },
     methods: {
       /** 打开弹窗 */
-     open(id) {
+     async open(id) {
         this.dialogVisible = true;
         this.reset();
-        const that = this;
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
           try {
-            CategoryApi.getCategory(id).then(res=>{
-              that.formData = res.data;
-              that.title = "修改分类";
-            })
+            const res = await CategoryApi.getCategory(id);
+            this.formData = res.data;
+            this.title = "修改分类";
           } finally {
             this.formLoading = false;
           }
         }
         this.title = "新增分类";
-                    this.getCategoryTree();
+                await this.getCategoryTree();
       },
       /** 提交按钮 */
-      submitForm() {
-        this.formLoading = true;
+      async submitForm() {
+        // 校验主表
+        await this.$refs["formRef"].validate();
+                  this.formLoading = true;
         try {
-          const that = this;
-          let data = this.formData;
-          let validate = false;
-          // 校验主表
-          this.getRef("formRef").validate(valid => {
-            validate = valid;
-          });
-                  // 所有表单校验通过后方可提交
-          if (!validate) {
-            return;
-          }
-          // 修改的提交
+          const data = this.formData;
+                  // 修改的提交
           if (data.id) {
-                  CategoryApi.updateCategory(data).then(response => {
-              that.$modal.msgSuccess("修改成功");
-              that.dialogVisible = false;
-              that.$emit('success');
-            });
+            await CategoryApi.updateCategory(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
             return;
           }
           // 添加的提交
-          CategoryApi.createCategory(data).then(response => {
-            that.$modal.msgSuccess("新增成功");
-            that.dialogVisible = false;
-            that.$emit('success');
-          });
-        }finally {
+          await CategoryApi.createCategory(data);
+          this.$modal.msgSuccess("新增成功");
+          this.dialogVisible = false;
+          this.$emit('success');
+        } finally {
           this.formLoading = false;
         }
       },
-      getRef(refName){
-        return this.$refs[refName];
-      },
                   /** 获得分类树 */
-          getCategoryTree() {
-            const that = this;
-            that.categoryTree = [];
-                  CategoryApi.getCategoryList().then(res=>{
-              const root = { id: 0, name: '顶级分类', children: [] };
-              root.children = this.handleTree(res.data, 'id', 'parentId')
-              that.categoryTree.push(root)
-            });
+         async getCategoryTree() {
+            this.categoryTree = [];
+            const res = await CategoryApi.getCategoryList();
+            const root = { id: 0, name: '顶级分类', children: [] };
+            root.children = this.handleTree(res.data, 'id', 'parentId')
+            this.categoryTree.push(root)
           },
                   /** 转换分类数据结构 */
           normalizer(node) {
@@ -141,7 +124,7 @@
                             parentId: undefined,
         };
         this.resetForm("formRef");
-      },
+      }
     }
   };
 </script>

+ 23 - 31
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/index

@@ -1,6 +1,5 @@
 <template>
   <div class="app-container">
-
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="名字" prop="name">
@@ -31,14 +30,14 @@
     </el-row>
 
             <el-table
-          v-loading="loading"
-          :data="list"
-          :stripe="true"
-          :show-overflow-tooltip="true"
-          v-if="refreshTable"
-          row-key="id"
-          :default-expand-all="isExpandAll"
-          :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
+        v-loading="loading"
+        :data="list"
+        :stripe="true"
+        :show-overflow-tooltip="true"
+        v-if="refreshTable"
+        row-key="id"
+        :default-expand-all="isExpandAll"
+        :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
       >
             <el-table-column label="编号" align="center" prop="id">
         <template v-slot="scope">
@@ -104,12 +103,11 @@ export default {
   },
   methods: {
     /** 查询列表 */
-    getList() {
+    async getList() {
       try {
       this.loading = true;
-              CategoryApi.getCategoryList(this.queryParams).then(response => {
-          this.list = this.handleTree(response.data, 'id', 'parentId');
-        })
+             const res = await CategoryApi.getCategoryList(this.queryParams);
+       this.list = this.handleTree(res.data, 'id', 'parentId');
       } finally {
         this.loading = false;
       }
@@ -129,31 +127,25 @@ export default {
       this.$refs["formRef"].open(id);
     },
     /** 删除按钮操作 */
-    handleDelete(row) {
-      const that = this;
-      try {
+    async handleDelete(row) {
       const id = row.id;
-      this.$modal.confirm('是否确认删除分类编号为"' + id + '"的数据项?').then(()=>{
-          return CategoryApi.deleteCategory(id);
-        }).then(() => {
-        that.getList();
-        that.$modal.msgSuccess("删除成功");
-        }).catch(() => {});
+      await this.$modal.confirm('是否确认删除分类编号为"' + id + '"的数据项?')
+      try {
+       await CategoryApi.deleteCategory(id);
+       await this.getList();
+       this.$modal.msgSuccess("删除成功");
       } catch {}
     },
     /** 导出按钮操作 */
-    handleExport() {
-      const that = this;
+    async handleExport() {
+      await this.$modal.confirm('是否确认导出所有分类数据项?');
       try {
-          this.$modal.confirm('是否确认导出所有分类数据项?').then(() => {
-              that.exportLoading = true;
-              return CategoryApi.exportCategoryExcel(params);
-            }).then(response => {
-              that.$download.excel(response, '分类.xls');
-            });
+        this.exportLoading = true;
+        const res = await CategoryApi.exportCategoryExcel(this.queryParams);
+        this.$download.excel(res.data, '分类.xls');
       } catch {
       } finally {
-        that.exportLoading = false;
+        this.exportLoading = false;
       }
     },
                     /** 展开/折叠操作 */