diff --git a/src/views/infra/demo/demo01/Demo01ContactForm.vue b/src/views/infra/demo/demo01/Demo01ContactForm.vue index 1587ca0710b51952b1f8fc9c3902257e3106d6aa..844e7b797d22978e7894c1ab1f5363dde5ec34ad 100644 --- a/src/views/infra/demo/demo01/Demo01ContactForm.vue +++ b/src/views/infra/demo/demo01/Demo01ContactForm.vue @@ -18,9 +18,8 @@ - - - + + @@ -115,7 +111,7 @@ export default { description: null, avatar: null, createTime: [], - } + }, }; }, created() { @@ -123,13 +119,12 @@ export default { }, methods: { /** 查询列表 */ - getList() { + async getList() { try { this.loading = true; - Demo01ContactApi.getDemo01ContactPage(this.queryParams).then(response => { - this.list = response.data.list; - this.total = response.data.total; - }); + const res = await Demo01ContactApi.getDemo01ContactPage(this.queryParams); + this.list = res.data.list; + this.total = res.data.total; } finally { this.loading = false; } @@ -146,34 +141,28 @@ export default { }, /** 添加/修改操作 */ openForm(id) { - this.$refs["formRef"].open(id) + this.$refs["formRef"].open(id); }, /** 删除按钮操作 */ - 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 Demo01ContactApi.deleteDemo01Contact(id); - }).then(() => { - that.getList(); - that.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + await Demo01ContactApi.deleteDemo01Contact(id); + 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 Demo01ContactApi.exportDemo01ContactExcel(params); - }).then(response => { - that.$download.excel(response, '示例联系人.xls'); - }); + this.exportLoading = true; + const res = await Demo01ContactApi.exportDemo01ContactExcel(this.queryParams); + this.$download.excel(res.data, '示例联系人.xls'); } catch { } finally { - that.exportLoading = false; + this.exportLoading = false; } }, } diff --git a/src/views/infra/demo/demo02/Demo02CategoryForm.vue b/src/views/infra/demo/demo02/Demo02CategoryForm.vue index 9865965114b6be85a324a3a33894b7896aebd556..ff9b78b4b44277d250385b1f88d62ab2e97c21fa 100644 --- a/src/views/infra/demo/demo02/Demo02CategoryForm.vue +++ b/src/views/infra/demo/demo02/Demo02CategoryForm.vue @@ -8,10 +8,10 @@ @@ -56,69 +56,54 @@ export default { }, methods: { /** 打开弹窗 */ - open(id) { + async open(id) { this.dialogVisible = true; this.reset(); - const that = this; // 修改时,设置数据 if (id) { this.formLoading = true; try { - Demo02CategoryApi.getDemo02Category(id).then(res=>{ - that.formData = res.data; - that.title = "修改示例分类"; - }) + const res = await Demo02CategoryApi.getDemo02Category(id); + this.formData = res.data; + this.title = "修改示例分类"; } finally { this.formLoading = false; } } this.title = "新增示例分类"; - this.getDemo02CategoryTree() + this.getDemo02CategoryTree(); }, - /** 提交按钮 */ - submitForm() { + async submitForm() { + // 校验主表 + await this.$refs["formRef"].validate(); this.formLoading = true; try { - const that = this; - let data = this.formData; - - this.getRef("formRef").validate(valid => { - if (!valid) { - return; - } - // 修改的提交 - if (data.id) { - Demo02CategoryApi.updateDemo02Category(data).then(response => { - that.$modal.msgSuccess("修改成功"); - that.dialogVisible = false; - that.$emit('success'); - }); - return; - } - // 添加的提交 - Demo02CategoryApi.createDemo02Category(data).then(response => { - that.$modal.msgSuccess("新增成功"); - that.dialogVisible = false; - that.$emit('success'); - }); - }); + const data = this.formData; + // 修改的提交 + if (data.id) { + await Demo02CategoryApi.updateDemo02Category(data); + this.$modal.msgSuccess("修改成功"); + this.dialogVisible = false; + this.$emit('success'); + return; + } + // 添加的提交 + await Demo02CategoryApi.createDemo02Category(data); + this.$modal.msgSuccess("新增成功"); + this.dialogVisible = false; + this.$emit('success'); }finally { - this.formLoading = false + this.formLoading = false; } }, - getRef(refName){ // TODO puhui999: 获得表单 ref,提取出来的目的呢是解决 $ 在 if 中 end闭合不了的问题,代码生成后可删除此方法 - return this.$refs[refName] - }, /** 获得示例分类树 */ - getDemo02CategoryTree() { - const that = this; - that.demo02CategoryTree = []; - Demo02CategoryApi.getDemo02CategoryList().then(res=>{ - const root = { id: 0, name: '顶级示例分类', children: [] }; - root.children = this.handleTree(res.data, 'id', 'parentId') - that.demo02CategoryTree.push(root) - }); + async getDemo02CategoryTree() { + this.demo02CategoryTree = []; + const res = await Demo02CategoryApi.getDemo02CategoryList(); + const root = { id: 0, name: '顶级示例分类', children: [] }; + root.children = this.handleTree(res.data, 'id', 'parentId') + this.demo02CategoryTree.push(root) }, /** 转换示例分类数据结构 */ normalizer(node) { @@ -139,7 +124,7 @@ export default { parentId: undefined, }; this.resetForm("formRef"); - }, + } } }; diff --git a/src/views/infra/demo/demo02/index.vue b/src/views/infra/demo/demo02/index.vue index 61bca72d129a9f3edddd1a701f727edfb35a1884..d7a09e289f06d14094f67b4c87d1529cdab99917 100644 --- a/src/views/infra/demo/demo02/index.vue +++ b/src/views/infra/demo/demo02/index.vue @@ -38,14 +38,14 @@ @@ -64,7 +64,6 @@ - @@ -86,7 +85,6 @@ export default { exportLoading: false, // 显示搜索条件 showSearch: true, - // 总条数 // 示例分类列表 list: [], // 是否展开,默认全部展开 @@ -100,7 +98,7 @@ export default { name: null, parentId: null, createTime: [], - } + }, }; }, created() { @@ -108,12 +106,11 @@ export default { }, methods: { /** 查询列表 */ - getList() { + async getList() { try { this.loading = true; - Demo02CategoryApi.getDemo02CategoryList(this.queryParams).then(response => { - this.list = this.handleTree(response.data, 'id', 'parentId'); - }) + const res = await Demo02CategoryApi.getDemo02CategoryList(this.queryParams); + this.list = this.handleTree(res.data, 'id', 'parentId'); } finally { this.loading = false; } @@ -130,34 +127,28 @@ export default { }, /** 添加/修改操作 */ openForm(id) { - this.$refs["formRef"].open(id) + this.$refs["formRef"].open(id); }, /** 删除按钮操作 */ - 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 Demo02CategoryApi.deleteDemo02Category(id); - }).then(() => { - that.getList(); - that.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + await Demo02CategoryApi.deleteDemo02Category(id); + 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 Demo02CategoryApi.exportDemo02CategoryExcel(params); - }).then(response => { - that.$download.excel(response, '示例分类.xls'); - }); + this.exportLoading = true; + const res = await Demo02CategoryApi.exportDemo02CategoryExcel(this.queryParams); + this.$download.excel(res.data, '示例分类.xls'); } catch { } finally { - that.exportLoading = false; + this.exportLoading = false; } }, /** 展开/折叠操作 */ diff --git a/src/views/infra/demo/demo03/erp/Demo03StudentForm.vue b/src/views/infra/demo/demo03/erp/Demo03StudentForm.vue index be2638d7498516e3d3f2a22b4466d73cbba4ed5e..9d27284e211211a323883297f3cf781d55de95af 100644 --- a/src/views/infra/demo/demo03/erp/Demo03StudentForm.vue +++ b/src/views/infra/demo/demo03/erp/Demo03StudentForm.vue @@ -63,18 +63,16 @@ export default { }, methods: { /** 打开弹窗 */ - open(id) { + async open(id) { this.dialogVisible = true; this.reset(); - const that = this; // 修改时,设置数据 if (id) { this.formLoading = true; try { - Demo03StudentApi.getDemo03Student(id).then(res=>{ - that.formData = res.data; - that.title = "修改学生"; - }) + const res = await Demo03StudentApi.getDemo03Student(id); + this.formData = res.data; + this.title = "修改学生"; } finally { this.formLoading = false; } @@ -82,42 +80,29 @@ export default { this.title = "新增学生"; }, /** 提交按钮 */ - submitForm() { + 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) { - Demo03StudentApi.updateDemo03Student(data).then(response => { - that.$modal.msgSuccess("修改成功"); - that.dialogVisible = false; - that.$emit('success'); - }); + await Demo03StudentApi.updateDemo03Student(data); + this.$modal.msgSuccess("修改成功"); + this.dialogVisible = false; + this.$emit('success'); return; } // 添加的提交 - Demo03StudentApi.createDemo03Student(data).then(response => { - that.$modal.msgSuccess("新增成功"); - that.dialogVisible = false; - that.$emit('success'); - }); + await Demo03StudentApi.createDemo03Student(data); + this.$modal.msgSuccess("新增成功"); + this.dialogVisible = false; + this.$emit('success'); }finally { this.formLoading = false; } }, - getRef(refName){ // TODO puhui999: 获得表单 ref,提取出来的目的呢是解决 $ 在 if 中 end闭合不了的问题,代码生成后可删除此方法 - return this.$refs[refName] - }, /** 表单重置 */ reset() { this.formData = { @@ -128,7 +113,7 @@ export default { description: undefined, }; this.resetForm("formRef"); - }, + } } }; diff --git a/src/views/infra/demo/demo03/erp/components/Demo03CourseForm.vue b/src/views/infra/demo/demo03/erp/components/Demo03CourseForm.vue index 4cefc1647eb6be1c4b5094c567729ec3c9e3d872..a3f6943586853eda00190bf9d7b5d078686f4fbf 100644 --- a/src/views/infra/demo/demo03/erp/components/Demo03CourseForm.vue +++ b/src/views/infra/demo/demo03/erp/components/Demo03CourseForm.vue @@ -49,19 +49,17 @@ export default { }, 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 { - Demo03StudentApi.getDemo03Course(id).then(res=>{ - that.formData = res.data; - that.dialogTitle = "修改学生课程"; - }) + const res = await Demo03StudentApi.getDemo03Course(id); + this.formData = res.data; + this.dialogTitle = "修改学生课程"; } finally { this.formLoading = false; } @@ -69,32 +67,26 @@ export default { 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; - } - // 修改的提交 - if (data.id) { - Demo03StudentApi.updateDemo03Course(data).then(response => { - this.$modal.msgSuccess("修改成功"); - this.dialogVisible = false; - this.$emit('success'); - }); - return; - } - // 添加的提交 - Demo03StudentApi.createDemo03Course(data).then(response => { - this.$modal.msgSuccess("新增成功"); - this.dialogVisible = false; - this.$emit('success'); - }); - }); + const data = this.formData; + // 修改的提交 + if (data.id) { + await Demo03StudentApi.updateDemo03Course(data); + this.$modal.msgSuccess("修改成功"); + this.dialogVisible = false; + this.$emit('success'); + return; + } + // 添加的提交 + await Demo03StudentApi.createDemo03Course(data); + this.$modal.msgSuccess("新增成功"); + this.dialogVisible = false; + this.$emit('success'); }finally { - this.formLoading = false + this.formLoading = false; } }, /** 表单重置 */ diff --git a/src/views/infra/demo/demo03/erp/components/Demo03CourseList.vue b/src/views/infra/demo/demo03/erp/components/Demo03CourseList.vue index 81c9ff674862c9113c356f59b4494132d274a382..1c31ad4d557db2bf66f30e8a4868ac4cddccf0e5 100644 --- a/src/views/infra/demo/demo03/erp/components/Demo03CourseList.vue +++ b/src/views/infra/demo/demo03/erp/components/Demo03CourseList.vue @@ -73,14 +73,12 @@ export default { }, methods: { /** 查询列表 */ - getList() { + async getList() { try { this.loading = true; - const that = this; - Demo03StudentApi.getDemo03CoursePage(this.queryParams).then(response => { - that.list = response.data.list; - that.total = response.data.total; - }); + const res = await Demo03StudentApi.getDemo03CoursePage(this.queryParams); + this.list = res.data.list; + this.total = res.data.total; } finally { this.loading = false; } @@ -93,22 +91,19 @@ export default { /** 添加/修改操作 */ 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 Demo03StudentApi.deleteDemo03Course(id); - }).then(() => { - that.getList(); - that.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + await Demo03StudentApi.deleteDemo03Course(id); + await this.getList(); + this.$modal.msgSuccess("删除成功"); } catch {} }, } diff --git a/src/views/infra/demo/demo03/erp/components/Demo03GradeForm.vue b/src/views/infra/demo/demo03/erp/components/Demo03GradeForm.vue index f77fa58b42cb9ef06a132ea8833b793171191106..a733de5fdd8b2b18b7726d54e8033ff20cb5e103 100644 --- a/src/views/infra/demo/demo03/erp/components/Demo03GradeForm.vue +++ b/src/views/infra/demo/demo03/erp/components/Demo03GradeForm.vue @@ -49,19 +49,17 @@ export default { }, 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 { - Demo03StudentApi.getDemo03Grade(id).then(res=>{ - that.formData = res.data; - that.dialogTitle = "修改学生班级"; - }) + const res = await Demo03StudentApi.getDemo03Grade(id); + this.formData = res.data; + this.dialogTitle = "修改学生班级"; } finally { this.formLoading = false; } @@ -69,32 +67,26 @@ export default { 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; - } - // 修改的提交 - if (data.id) { - Demo03StudentApi.updateDemo03Grade(data).then(response => { - this.$modal.msgSuccess("修改成功"); - this.dialogVisible = false; - this.$emit('success'); - }); - return; - } - // 添加的提交 - Demo03StudentApi.createDemo03Grade(data).then(response => { - this.$modal.msgSuccess("新增成功"); - this.dialogVisible = false; - this.$emit('success'); - }); - }); + const data = this.formData; + // 修改的提交 + if (data.id) { + await Demo03StudentApi.updateDemo03Grade(data); + this.$modal.msgSuccess("修改成功"); + this.dialogVisible = false; + this.$emit('success'); + return; + } + // 添加的提交 + await Demo03StudentApi.createDemo03Grade(data); + this.$modal.msgSuccess("新增成功"); + this.dialogVisible = false; + this.$emit('success'); }finally { - this.formLoading = false + this.formLoading = false; } }, /** 表单重置 */ diff --git a/src/views/infra/demo/demo03/erp/components/Demo03GradeList.vue b/src/views/infra/demo/demo03/erp/components/Demo03GradeList.vue index 298ac2610298307d096a171437c1c6d290257171..96b31bdb3678d15da024e294a353c96bef3ffdd9 100644 --- a/src/views/infra/demo/demo03/erp/components/Demo03GradeList.vue +++ b/src/views/infra/demo/demo03/erp/components/Demo03GradeList.vue @@ -73,14 +73,12 @@ export default { }, methods: { /** 查询列表 */ - getList() { + async getList() { try { this.loading = true; - const that = this; - Demo03StudentApi.getDemo03GradePage(this.queryParams).then(response => { - that.list = response.data.list; - that.total = response.data.total; - }); + const res = await Demo03StudentApi.getDemo03GradePage(this.queryParams); + this.list = res.data.list; + this.total = res.data.total; } finally { this.loading = false; } @@ -93,22 +91,19 @@ export default { /** 添加/修改操作 */ 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 Demo03StudentApi.deleteDemo03Grade(id); - }).then(() => { - that.getList(); - that.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + await Demo03StudentApi.deleteDemo03Grade(id); + await this.getList(); + this.$modal.msgSuccess("删除成功"); } catch {} }, } diff --git a/src/views/infra/demo/demo03/erp/index.vue b/src/views/infra/demo/demo03/erp/index.vue index 8731ff3c32348643a5d57a171f29414144fdb92a..14b1261e8df4a43268d05ac37211f56dd7ea8fc1 100644 --- a/src/views/infra/demo/demo03/erp/index.vue +++ b/src/views/infra/demo/demo03/erp/index.vue @@ -13,14 +13,11 @@ - + - + 搜索 @@ -32,31 +29,28 @@ 新增 - + v-hasPermi="['infra:demo03-student:create']">新增 - 导出 - + 导出 - - + + @@ -64,7 +58,7 @@ {{ parseTime(scope.row.birthday) }} - +