Commit c437201236dd16a63802bbbb504cbc9173e9ed79
1 parent
b4d16b36
代码生成:CodegenEngineVue2Test 所需测试文件
Showing
20 changed files
with
355 additions
and
550 deletions
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentContactForm
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | </template> |
| 44 | 44 | |
| 45 | 45 | <script> |
| 46 | - import * as StudentApi from '@/api/infra/demo' | |
| 46 | + import * as StudentApi from '@/api/infra/demo'; | |
| 47 | 47 | import ImageUpload from '@/components/ImageUpload'; |
| 48 | 48 | import FileUpload from '@/components/FileUpload'; |
| 49 | 49 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -90,19 +90,17 @@ |
| 90 | 90 | }, |
| 91 | 91 | methods: { |
| 92 | 92 | /** 打开弹窗 */ |
| 93 | - open(id, studentId) { | |
| 93 | + async open(id, studentId) { | |
| 94 | 94 | this.dialogVisible = true; |
| 95 | 95 | this.reset(); |
| 96 | - const that = this; | |
| 97 | 96 | this.formData.studentId = studentId; |
| 98 | 97 | // 修改时,设置数据 |
| 99 | 98 | if (id) { |
| 100 | 99 | this.formLoading = true; |
| 101 | 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 | 104 | } finally { |
| 107 | 105 | this.formLoading = false; |
| 108 | 106 | } |
| ... | ... | @@ -110,32 +108,26 @@ |
| 110 | 108 | this.dialogTitle = "新增学生联系人"; |
| 111 | 109 | }, |
| 112 | 110 | /** 提交按钮 */ |
| 113 | - submitForm() { | |
| 111 | + async submitForm() { | |
| 112 | + await this.$refs["formRef"].validate(); | |
| 114 | 113 | this.formLoading = true; |
| 115 | 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 | 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 | 122 | return; |
| 129 | 123 | } |
| 130 | 124 | // 添加的提交 |
| 131 | - StudentApi.createStudentContact(data).then(response => { | |
| 125 | + await StudentApi.createStudentContact(data); | |
| 132 | 126 | this.$modal.msgSuccess("新增成功"); |
| 133 | 127 | this.dialogVisible = false; |
| 134 | 128 | this.$emit('success'); |
| 135 | - }); | |
| 136 | - }); | |
| 137 | 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 | 52 | </template> |
| 53 | 53 | |
| 54 | 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 | 57 | export default { |
| 58 | 58 | name: "StudentContactList", |
| 59 | 59 | components: { |
| ... | ... | @@ -91,14 +91,12 @@ |
| 91 | 91 | }, |
| 92 | 92 | methods: { |
| 93 | 93 | /** 查询列表 */ |
| 94 | - getList() { | |
| 94 | + async getList() { | |
| 95 | 95 | try { |
| 96 | 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 | 100 | } finally { |
| 103 | 101 | this.loading = false; |
| 104 | 102 | } |
| ... | ... | @@ -111,22 +109,19 @@ |
| 111 | 109 | /** 添加/修改操作 */ |
| 112 | 110 | openForm(id) { |
| 113 | 111 | if (!this.studentId) { |
| 114 | - that.$modal.msgError('请选择一个学生'); | |
| 112 | + this.$modal.msgError('请选择一个学生'); | |
| 115 | 113 | return; |
| 116 | 114 | } |
| 117 | 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 | 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 | 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 | 43 | </template> |
| 44 | 44 | |
| 45 | 45 | <script> |
| 46 | - import * as StudentApi from '@/api/infra/demo' | |
| 46 | + import * as StudentApi from '@/api/infra/demo'; | |
| 47 | 47 | import ImageUpload from '@/components/ImageUpload'; |
| 48 | 48 | import FileUpload from '@/components/FileUpload'; |
| 49 | 49 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -89,18 +89,16 @@ |
| 89 | 89 | }, |
| 90 | 90 | methods: { |
| 91 | 91 | /** 打开弹窗 */ |
| 92 | - open(id) { | |
| 92 | + async open(id) { | |
| 93 | 93 | this.dialogVisible = true; |
| 94 | 94 | this.reset(); |
| 95 | - const that = this; | |
| 96 | 95 | // 修改时,设置数据 |
| 97 | 96 | if (id) { |
| 98 | 97 | this.formLoading = true; |
| 99 | 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 | 102 | } finally { |
| 105 | 103 | this.formLoading = false; |
| 106 | 104 | } |
| ... | ... | @@ -108,42 +106,29 @@ |
| 108 | 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 | 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 | 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 | 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 | 129 | this.formLoading = false; |
| 142 | 130 | } |
| 143 | 131 | }, |
| 144 | - getRef(refName){ | |
| 145 | - return this.$refs[refName]; | |
| 146 | - }, | |
| 147 | 132 | /** 表单重置 */ |
| 148 | 133 | reset() { |
| 149 | 134 | this.formData = { |
| ... | ... | @@ -158,7 +143,7 @@ |
| 158 | 143 | memo: undefined, |
| 159 | 144 | }; |
| 160 | 145 | this.resetForm("formRef"); |
| 161 | - }, | |
| 146 | + } | |
| 162 | 147 | } |
| 163 | 148 | }; |
| 164 | 149 | </script> | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/StudentTeacherForm
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | </template> |
| 44 | 44 | |
| 45 | 45 | <script> |
| 46 | - import * as StudentApi from '@/api/infra/demo' | |
| 46 | + import * as StudentApi from '@/api/infra/demo'; | |
| 47 | 47 | import ImageUpload from '@/components/ImageUpload'; |
| 48 | 48 | import FileUpload from '@/components/FileUpload'; |
| 49 | 49 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -90,19 +90,17 @@ |
| 90 | 90 | }, |
| 91 | 91 | methods: { |
| 92 | 92 | /** 打开弹窗 */ |
| 93 | - open(id, studentId) { | |
| 93 | + async open(id, studentId) { | |
| 94 | 94 | this.dialogVisible = true; |
| 95 | 95 | this.reset(); |
| 96 | - const that = this; | |
| 97 | 96 | this.formData.studentId = studentId; |
| 98 | 97 | // 修改时,设置数据 |
| 99 | 98 | if (id) { |
| 100 | 99 | this.formLoading = true; |
| 101 | 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 | 104 | } finally { |
| 107 | 105 | this.formLoading = false; |
| 108 | 106 | } |
| ... | ... | @@ -110,32 +108,26 @@ |
| 110 | 108 | this.dialogTitle = "新增学生班主任"; |
| 111 | 109 | }, |
| 112 | 110 | /** 提交按钮 */ |
| 113 | - submitForm() { | |
| 111 | + async submitForm() { | |
| 112 | + await this.$refs["formRef"].validate(); | |
| 114 | 113 | this.formLoading = true; |
| 115 | 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 | 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 | 122 | return; |
| 129 | 123 | } |
| 130 | 124 | // 添加的提交 |
| 131 | - StudentApi.createStudentTeacher(data).then(response => { | |
| 125 | + await StudentApi.createStudentTeacher(data); | |
| 132 | 126 | this.$modal.msgSuccess("新增成功"); |
| 133 | 127 | this.dialogVisible = false; |
| 134 | 128 | this.$emit('success'); |
| 135 | - }); | |
| 136 | - }); | |
| 137 | 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 | 52 | </template> |
| 53 | 53 | |
| 54 | 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 | 57 | export default { |
| 58 | 58 | name: "StudentTeacherList", |
| 59 | 59 | components: { |
| ... | ... | @@ -91,14 +91,12 @@ |
| 91 | 91 | }, |
| 92 | 92 | methods: { |
| 93 | 93 | /** 查询列表 */ |
| 94 | - getList() { | |
| 94 | + async getList() { | |
| 95 | 95 | try { |
| 96 | 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 | 100 | } finally { |
| 103 | 101 | this.loading = false; |
| 104 | 102 | } |
| ... | ... | @@ -111,22 +109,19 @@ |
| 111 | 109 | /** 添加/修改操作 */ |
| 112 | 110 | openForm(id) { |
| 113 | 111 | if (!this.studentId) { |
| 114 | - that.$modal.msgError('请选择一个学生'); | |
| 112 | + this.$modal.msgError('请选择一个学生'); | |
| 115 | 113 | return; |
| 116 | 114 | } |
| 117 | 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 | 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 | 125 | } catch {} |
| 131 | 126 | }, |
| 132 | 127 | } | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_erp/vue/index
| 1 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | - | |
| 4 | 3 | <!-- 搜索工作栏 --> |
| 5 | 4 | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 6 | 5 | <el-form-item label="名字" prop="name"> |
| ... | ... | @@ -45,12 +44,12 @@ |
| 45 | 44 | </el-row> |
| 46 | 45 | |
| 47 | 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 | 54 | <el-table-column label="编号" align="center" prop="id"> |
| 56 | 55 | <template v-slot="scope"> |
| ... | ... | @@ -131,8 +130,8 @@ |
| 131 | 130 | <script> |
| 132 | 131 | import * as StudentApi from '@/api/infra/demo'; |
| 133 | 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 | 135 | export default { |
| 137 | 136 | name: "Student", |
| 138 | 137 | components: { |
| ... | ... | @@ -177,13 +176,12 @@ export default { |
| 177 | 176 | }, |
| 178 | 177 | methods: { |
| 179 | 178 | /** 查询列表 */ |
| 180 | - getList() { | |
| 179 | + async getList() { | |
| 181 | 180 | try { |
| 182 | 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 | 185 | } finally { |
| 188 | 186 | this.loading = false; |
| 189 | 187 | } |
| ... | ... | @@ -203,31 +201,25 @@ export default { |
| 203 | 201 | this.$refs["formRef"].open(id); |
| 204 | 202 | }, |
| 205 | 203 | /** 删除按钮操作 */ |
| 206 | - handleDelete(row) { | |
| 207 | - const that = this; | |
| 208 | - try { | |
| 204 | + async handleDelete(row) { | |
| 209 | 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 | 211 | } catch {} |
| 217 | 212 | }, |
| 218 | 213 | /** 导出按钮操作 */ |
| 219 | - handleExport() { | |
| 220 | - const that = this; | |
| 214 | + async handleExport() { | |
| 215 | + await this.$modal.confirm('是否确认导出所有学生数据项?'); | |
| 221 | 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 | 220 | } catch { |
| 229 | 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 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | 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 | 11 | <el-table :data="formData" class="-mt-10px"> |
| 12 | 12 | <el-table-column label="序号" type="index" width="100" /> |
| ... | ... | @@ -86,7 +86,7 @@ |
| 86 | 86 | </template> |
| 87 | 87 | |
| 88 | 88 | <script> |
| 89 | - import * as StudentApi from '@/api/infra/demo' | |
| 89 | + import * as StudentApi from '@/api/infra/demo'; | |
| 90 | 90 | import ImageUpload from '@/components/ImageUpload'; |
| 91 | 91 | import FileUpload from '@/components/FileUpload'; |
| 92 | 92 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -130,8 +130,9 @@ |
| 130 | 130 | } |
| 131 | 131 | try { |
| 132 | 132 | this.formLoading = true; |
| 133 | + // 这里还是需要获取一下 this 的不然取不到 formData | |
| 133 | 134 | const that = this; |
| 134 | - StudentApi.getStudentContactListByStudentId(val).then(res=>{ | |
| 135 | + StudentApi.getStudentContactListByStudentId(val).then(function (res){ | |
| 135 | 136 | that.formData = res.data; |
| 136 | 137 | }) |
| 137 | 138 | } finally { |
| ... | ... | @@ -156,20 +157,20 @@ |
| 156 | 157 | video: undefined, |
| 157 | 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 | 164 | handleDelete(index) { |
| 164 | - this.formData.splice(index, 1) | |
| 165 | + this.formData.splice(index, 1); | |
| 165 | 166 | }, |
| 166 | 167 | /** 表单校验 */ |
| 167 | 168 | validate(){ |
| 168 | - return this.$refs["formRef"].validate() | |
| 169 | + return this.$refs["formRef"].validate(); | |
| 169 | 170 | }, |
| 170 | 171 | /** 表单值 */ |
| 171 | 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 | 40 | </template> |
| 41 | 41 | |
| 42 | 42 | <script> |
| 43 | - import * as StudentApi from '@/api/infra/demo' | |
| 43 | + import * as StudentApi from '@/api/infra/demo'; | |
| 44 | 44 | export default { |
| 45 | 45 | name: "StudentContactList", |
| 46 | 46 | props:[ |
| ... | ... | @@ -70,13 +70,11 @@ |
| 70 | 70 | }, |
| 71 | 71 | methods: { |
| 72 | 72 | /** 查询列表 */ |
| 73 | - getList() { | |
| 73 | + async getList() { | |
| 74 | 74 | try { |
| 75 | 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 | 78 | } finally { |
| 81 | 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 | 52 | </template> |
| 53 | 53 | |
| 54 | 54 | <script> |
| 55 | - import * as StudentApi from '@/api/infra/demo' | |
| 55 | + import * as StudentApi from '@/api/infra/demo'; | |
| 56 | 56 | import ImageUpload from '@/components/ImageUpload'; |
| 57 | 57 | import FileUpload from '@/components/FileUpload'; |
| 58 | 58 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -104,18 +104,16 @@ |
| 104 | 104 | }, |
| 105 | 105 | methods: { |
| 106 | 106 | /** 打开弹窗 */ |
| 107 | - open(id) { | |
| 107 | + async open(id) { | |
| 108 | 108 | this.dialogVisible = true; |
| 109 | 109 | this.reset(); |
| 110 | - const that = this; | |
| 111 | 110 | // 修改时,设置数据 |
| 112 | 111 | if (id) { |
| 113 | 112 | this.formLoading = true; |
| 114 | 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 | 117 | } finally { |
| 120 | 118 | this.formLoading = false; |
| 121 | 119 | } |
| ... | ... | @@ -123,84 +121,45 @@ |
| 123 | 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 | 140 | this.formLoading = true; |
| 128 | 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 | 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 | 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 | 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 | 164 | reset() { |
| 206 | 165 | this.formData = { |
| ... | ... | @@ -215,7 +174,7 @@ |
| 215 | 174 | memo: undefined, |
| 216 | 175 | }; |
| 217 | 176 | this.resetForm("formRef"); |
| 218 | - }, | |
| 177 | + } | |
| 219 | 178 | } |
| 220 | 179 | }; |
| 221 | 180 | </script> | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/StudentTeacherForm
| 1 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | 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 | 10 | <el-form-item label="名字" prop="name"> |
| 11 | 11 | <el-input v-model="formData.name" placeholder="请输入名字" /> |
| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | </template> |
| 43 | 43 | |
| 44 | 44 | <script> |
| 45 | - import * as StudentApi from '@/api/infra/demo' | |
| 45 | + import * as StudentApi from '@/api/infra/demo'; | |
| 46 | 46 | import ImageUpload from '@/components/ImageUpload'; |
| 47 | 47 | import FileUpload from '@/components/FileUpload'; |
| 48 | 48 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -97,8 +97,9 @@ |
| 97 | 97 | } |
| 98 | 98 | try { |
| 99 | 99 | this.formLoading = true; |
| 100 | + // 这里还是需要获取一下 this 的不然取不到 formData | |
| 100 | 101 | const that = this; |
| 101 | - StudentApi.getStudentTeacherByStudentId(val).then(res=>{ | |
| 102 | + StudentApi.getStudentTeacherByStudentId(val).then(function (res){ | |
| 102 | 103 | const data = res.data; |
| 103 | 104 | if (!data) { |
| 104 | 105 | return |
| ... | ... | @@ -115,11 +116,11 @@ |
| 115 | 116 | methods: { |
| 116 | 117 | /** 表单校验 */ |
| 117 | 118 | validate(){ |
| 118 | - return this.$refs["formRef"].validate() | |
| 119 | + return this.$refs["formRef"].validate(); | |
| 119 | 120 | }, |
| 120 | 121 | /** 表单值 */ |
| 121 | 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 | 40 | </template> |
| 41 | 41 | |
| 42 | 42 | <script> |
| 43 | - import * as StudentApi from '@/api/infra/demo' | |
| 43 | + import * as StudentApi from '@/api/infra/demo'; | |
| 44 | 44 | export default { |
| 45 | 45 | name: "StudentTeacherList", |
| 46 | 46 | props:[ |
| ... | ... | @@ -70,17 +70,15 @@ |
| 70 | 70 | }, |
| 71 | 71 | methods: { |
| 72 | 72 | /** 查询列表 */ |
| 73 | - getList() { | |
| 73 | + async getList() { | |
| 74 | 74 | try { |
| 75 | 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 | 82 | } finally { |
| 85 | 83 | this.loading = false; |
| 86 | 84 | } | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_inner/vue/index
| 1 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | - | |
| 4 | 3 | <!-- 搜索工作栏 --> |
| 5 | 4 | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 6 | 5 | <el-form-item label="名字" prop="name"> |
| ... | ... | @@ -128,8 +127,8 @@ |
| 128 | 127 | <script> |
| 129 | 128 | import * as StudentApi from '@/api/infra/demo'; |
| 130 | 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 | 132 | export default { |
| 134 | 133 | name: "Student", |
| 135 | 134 | components: { |
| ... | ... | @@ -172,13 +171,12 @@ export default { |
| 172 | 171 | }, |
| 173 | 172 | methods: { |
| 174 | 173 | /** 查询列表 */ |
| 175 | - getList() { | |
| 174 | + async getList() { | |
| 176 | 175 | try { |
| 177 | 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 | 180 | } finally { |
| 183 | 181 | this.loading = false; |
| 184 | 182 | } |
| ... | ... | @@ -198,31 +196,25 @@ export default { |
| 198 | 196 | this.$refs["formRef"].open(id); |
| 199 | 197 | }, |
| 200 | 198 | /** 删除按钮操作 */ |
| 201 | - handleDelete(row) { | |
| 202 | - const that = this; | |
| 203 | - try { | |
| 199 | + async handleDelete(row) { | |
| 204 | 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 | 206 | } catch {} |
| 212 | 207 | }, |
| 213 | 208 | /** 导出按钮操作 */ |
| 214 | - handleExport() { | |
| 215 | - const that = this; | |
| 209 | + async handleExport() { | |
| 210 | + await this.$modal.confirm('是否确认导出所有学生数据项?'); | |
| 216 | 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 | 215 | } catch { |
| 224 | 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 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | 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 | 11 | <el-table :data="formData" class="-mt-10px"> |
| 12 | 12 | <el-table-column label="序号" type="index" width="100" /> |
| ... | ... | @@ -86,7 +86,7 @@ |
| 86 | 86 | </template> |
| 87 | 87 | |
| 88 | 88 | <script> |
| 89 | - import * as StudentApi from '@/api/infra/demo' | |
| 89 | + import * as StudentApi from '@/api/infra/demo'; | |
| 90 | 90 | import ImageUpload from '@/components/ImageUpload'; |
| 91 | 91 | import FileUpload from '@/components/FileUpload'; |
| 92 | 92 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -130,8 +130,9 @@ |
| 130 | 130 | } |
| 131 | 131 | try { |
| 132 | 132 | this.formLoading = true; |
| 133 | + // 这里还是需要获取一下 this 的不然取不到 formData | |
| 133 | 134 | const that = this; |
| 134 | - StudentApi.getStudentContactListByStudentId(val).then(res=>{ | |
| 135 | + StudentApi.getStudentContactListByStudentId(val).then(function (res){ | |
| 135 | 136 | that.formData = res.data; |
| 136 | 137 | }) |
| 137 | 138 | } finally { |
| ... | ... | @@ -156,20 +157,20 @@ |
| 156 | 157 | video: undefined, |
| 157 | 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 | 164 | handleDelete(index) { |
| 164 | - this.formData.splice(index, 1) | |
| 165 | + this.formData.splice(index, 1); | |
| 165 | 166 | }, |
| 166 | 167 | /** 表单校验 */ |
| 167 | 168 | validate(){ |
| 168 | - return this.$refs["formRef"].validate() | |
| 169 | + return this.$refs["formRef"].validate(); | |
| 169 | 170 | }, |
| 170 | 171 | /** 表单值 */ |
| 171 | 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 | 52 | </template> |
| 53 | 53 | |
| 54 | 54 | <script> |
| 55 | - import * as StudentApi from '@/api/infra/demo' | |
| 55 | + import * as StudentApi from '@/api/infra/demo'; | |
| 56 | 56 | import ImageUpload from '@/components/ImageUpload'; |
| 57 | 57 | import FileUpload from '@/components/FileUpload'; |
| 58 | 58 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -104,18 +104,16 @@ |
| 104 | 104 | }, |
| 105 | 105 | methods: { |
| 106 | 106 | /** 打开弹窗 */ |
| 107 | - open(id) { | |
| 107 | + async open(id) { | |
| 108 | 108 | this.dialogVisible = true; |
| 109 | 109 | this.reset(); |
| 110 | - const that = this; | |
| 111 | 110 | // 修改时,设置数据 |
| 112 | 111 | if (id) { |
| 113 | 112 | this.formLoading = true; |
| 114 | 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 | 117 | } finally { |
| 120 | 118 | this.formLoading = false; |
| 121 | 119 | } |
| ... | ... | @@ -123,84 +121,45 @@ |
| 123 | 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 | 140 | this.formLoading = true; |
| 128 | 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 | 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 | 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 | 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 | 164 | reset() { |
| 206 | 165 | this.formData = { |
| ... | ... | @@ -215,7 +174,7 @@ |
| 215 | 174 | memo: undefined, |
| 216 | 175 | }; |
| 217 | 176 | this.resetForm("formRef"); |
| 218 | - }, | |
| 177 | + } | |
| 219 | 178 | } |
| 220 | 179 | }; |
| 221 | 180 | </script> | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_master_normal/vue/StudentTeacherForm
| 1 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | 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 | 10 | <el-form-item label="名字" prop="name"> |
| 11 | 11 | <el-input v-model="formData.name" placeholder="请输入名字" /> |
| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | </template> |
| 43 | 43 | |
| 44 | 44 | <script> |
| 45 | - import * as StudentApi from '@/api/infra/demo' | |
| 45 | + import * as StudentApi from '@/api/infra/demo'; | |
| 46 | 46 | import ImageUpload from '@/components/ImageUpload'; |
| 47 | 47 | import FileUpload from '@/components/FileUpload'; |
| 48 | 48 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -97,8 +97,9 @@ |
| 97 | 97 | } |
| 98 | 98 | try { |
| 99 | 99 | this.formLoading = true; |
| 100 | + // 这里还是需要获取一下 this 的不然取不到 formData | |
| 100 | 101 | const that = this; |
| 101 | - StudentApi.getStudentTeacherByStudentId(val).then(res=>{ | |
| 102 | + StudentApi.getStudentTeacherByStudentId(val).then(function (res){ | |
| 102 | 103 | const data = res.data; |
| 103 | 104 | if (!data) { |
| 104 | 105 | return |
| ... | ... | @@ -115,11 +116,11 @@ |
| 115 | 116 | methods: { |
| 116 | 117 | /** 表单校验 */ |
| 117 | 118 | validate(){ |
| 118 | - return this.$refs["formRef"].validate() | |
| 119 | + return this.$refs["formRef"].validate(); | |
| 119 | 120 | }, |
| 120 | 121 | /** 表单值 */ |
| 121 | 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 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | - | |
| 4 | 3 | <!-- 搜索工作栏 --> |
| 5 | 4 | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 6 | 5 | <el-form-item label="名字" prop="name"> |
| ... | ... | @@ -155,13 +154,12 @@ export default { |
| 155 | 154 | }, |
| 156 | 155 | methods: { |
| 157 | 156 | /** 查询列表 */ |
| 158 | - getList() { | |
| 157 | + async getList() { | |
| 159 | 158 | try { |
| 160 | 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 | 163 | } finally { |
| 166 | 164 | this.loading = false; |
| 167 | 165 | } |
| ... | ... | @@ -181,31 +179,25 @@ export default { |
| 181 | 179 | this.$refs["formRef"].open(id); |
| 182 | 180 | }, |
| 183 | 181 | /** 删除按钮操作 */ |
| 184 | - handleDelete(row) { | |
| 185 | - const that = this; | |
| 186 | - try { | |
| 182 | + async handleDelete(row) { | |
| 187 | 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 | 189 | } catch {} |
| 195 | 190 | }, |
| 196 | 191 | /** 导出按钮操作 */ |
| 197 | - handleExport() { | |
| 198 | - const that = this; | |
| 192 | + async handleExport() { | |
| 193 | + await this.$modal.confirm('是否确认导出所有学生数据项?'); | |
| 199 | 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 | 198 | } catch { |
| 207 | 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 | 43 | </template> |
| 44 | 44 | |
| 45 | 45 | <script> |
| 46 | - import * as StudentApi from '@/api/infra/demo' | |
| 46 | + import * as StudentApi from '@/api/infra/demo'; | |
| 47 | 47 | import ImageUpload from '@/components/ImageUpload'; |
| 48 | 48 | import FileUpload from '@/components/FileUpload'; |
| 49 | 49 | import Editor from '@/components/Editor'; |
| ... | ... | @@ -89,18 +89,16 @@ |
| 89 | 89 | }, |
| 90 | 90 | methods: { |
| 91 | 91 | /** 打开弹窗 */ |
| 92 | - open(id) { | |
| 92 | + async open(id) { | |
| 93 | 93 | this.dialogVisible = true; |
| 94 | 94 | this.reset(); |
| 95 | - const that = this; | |
| 96 | 95 | // 修改时,设置数据 |
| 97 | 96 | if (id) { |
| 98 | 97 | this.formLoading = true; |
| 99 | 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 | 102 | } finally { |
| 105 | 103 | this.formLoading = false; |
| 106 | 104 | } |
| ... | ... | @@ -108,42 +106,29 @@ |
| 108 | 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 | 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 | 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 | 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 | 129 | this.formLoading = false; |
| 142 | 130 | } |
| 143 | 131 | }, |
| 144 | - getRef(refName){ | |
| 145 | - return this.$refs[refName]; | |
| 146 | - }, | |
| 147 | 132 | /** 表单重置 */ |
| 148 | 133 | reset() { |
| 149 | 134 | this.formData = { |
| ... | ... | @@ -158,7 +143,7 @@ |
| 158 | 143 | memo: undefined, |
| 159 | 144 | }; |
| 160 | 145 | this.resetForm("formRef"); |
| 161 | - }, | |
| 146 | + } | |
| 162 | 147 | } |
| 163 | 148 | }; |
| 164 | 149 | </script> | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_one/vue/index
| 1 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | - | |
| 4 | 3 | <!-- 搜索工作栏 --> |
| 5 | 4 | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 6 | 5 | <el-form-item label="名字" prop="name"> |
| ... | ... | @@ -155,13 +154,12 @@ export default { |
| 155 | 154 | }, |
| 156 | 155 | methods: { |
| 157 | 156 | /** 查询列表 */ |
| 158 | - getList() { | |
| 157 | + async getList() { | |
| 159 | 158 | try { |
| 160 | 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 | 163 | } finally { |
| 166 | 164 | this.loading = false; |
| 167 | 165 | } |
| ... | ... | @@ -181,31 +179,25 @@ export default { |
| 181 | 179 | this.$refs["formRef"].open(id); |
| 182 | 180 | }, |
| 183 | 181 | /** 删除按钮操作 */ |
| 184 | - handleDelete(row) { | |
| 185 | - const that = this; | |
| 186 | - try { | |
| 182 | + async handleDelete(row) { | |
| 187 | 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 | 189 | } catch {} |
| 195 | 190 | }, |
| 196 | 191 | /** 导出按钮操作 */ |
| 197 | - handleExport() { | |
| 198 | - const that = this; | |
| 192 | + async handleExport() { | |
| 193 | + await this.$modal.confirm('是否确认导出所有学生数据项?'); | |
| 199 | 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 | 198 | } catch { |
| 207 | 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 | 8 | </el-form-item> |
| 9 | 9 | <el-form-item label="父编号" prop="parentId"> |
| 10 | 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 | 16 | </el-form-item> |
| 17 | 17 | </el-form> |
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | </template> |
| 25 | 25 | |
| 26 | 26 | <script> |
| 27 | - import * as CategoryApi from '@/api/infra/demo' | |
| 27 | + import * as CategoryApi from '@/api/infra/demo'; | |
| 28 | 28 | import TreeSelect from "@riophae/vue-treeselect"; |
| 29 | 29 | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| 30 | 30 | export default { |
| ... | ... | @@ -56,71 +56,54 @@ |
| 56 | 56 | }, |
| 57 | 57 | methods: { |
| 58 | 58 | /** 打开弹窗 */ |
| 59 | - open(id) { | |
| 59 | + async open(id) { | |
| 60 | 60 | this.dialogVisible = true; |
| 61 | 61 | this.reset(); |
| 62 | - const that = this; | |
| 63 | 62 | // 修改时,设置数据 |
| 64 | 63 | if (id) { |
| 65 | 64 | this.formLoading = true; |
| 66 | 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 | 69 | } finally { |
| 72 | 70 | this.formLoading = false; |
| 73 | 71 | } |
| 74 | 72 | } |
| 75 | 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 | 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 | 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 | 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 | 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 | 109 | normalizer(node) { |
| ... | ... | @@ -141,7 +124,7 @@ |
| 141 | 124 | parentId: undefined, |
| 142 | 125 | }; |
| 143 | 126 | this.resetForm("formRef"); |
| 144 | - }, | |
| 127 | + } | |
| 145 | 128 | } |
| 146 | 129 | }; |
| 147 | 130 | </script> |
| 148 | 131 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue2_tree/vue/index
| 1 | 1 | <template> |
| 2 | 2 | <div class="app-container"> |
| 3 | - | |
| 4 | 3 | <!-- 搜索工作栏 --> |
| 5 | 4 | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 6 | 5 | <el-form-item label="名字" prop="name"> |
| ... | ... | @@ -31,14 +30,14 @@ |
| 31 | 30 | </el-row> |
| 32 | 31 | |
| 33 | 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 | 42 | <el-table-column label="编号" align="center" prop="id"> |
| 44 | 43 | <template v-slot="scope"> |
| ... | ... | @@ -104,12 +103,11 @@ export default { |
| 104 | 103 | }, |
| 105 | 104 | methods: { |
| 106 | 105 | /** 查询列表 */ |
| 107 | - getList() { | |
| 106 | + async getList() { | |
| 108 | 107 | try { |
| 109 | 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 | 111 | } finally { |
| 114 | 112 | this.loading = false; |
| 115 | 113 | } |
| ... | ... | @@ -129,31 +127,25 @@ export default { |
| 129 | 127 | this.$refs["formRef"].open(id); |
| 130 | 128 | }, |
| 131 | 129 | /** 删除按钮操作 */ |
| 132 | - handleDelete(row) { | |
| 133 | - const that = this; | |
| 134 | - try { | |
| 130 | + async handleDelete(row) { | |
| 135 | 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 | 137 | } catch {} |
| 143 | 138 | }, |
| 144 | 139 | /** 导出按钮操作 */ |
| 145 | - handleExport() { | |
| 146 | - const that = this; | |
| 140 | + async handleExport() { | |
| 141 | + await this.$modal.confirm('是否确认导出所有分类数据项?'); | |
| 147 | 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 | 146 | } catch { |
| 155 | 147 | } finally { |
| 156 | - that.exportLoading = false; | |
| 148 | + this.exportLoading = false; | |
| 157 | 149 | } |
| 158 | 150 | }, |
| 159 | 151 | /** 展开/折叠操作 */ | ... | ... |