From e296442473b7a602e79afee850a3ccc3fefb6a13 Mon Sep 17 00:00:00 2001 From: 15976874561 <2553956742@qq.com> Date: Tue, 30 Dec 2025 17:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8C=E6=AD=A5=E4=B8=93?= =?UTF-8?q?=E4=B8=9A=E5=92=8C=E5=90=8C=E6=AD=A5=E6=95=99=E8=81=8C=E5=B7=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sync-instructor/syncTeacher.vue | 22 ++++++++++++++++--- .../sync-major/syncZhuanYe.vue | 22 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/views/stuCQS/synchronous-data/sync-instructor/syncTeacher.vue b/src/views/stuCQS/synchronous-data/sync-instructor/syncTeacher.vue index c99965c..dd333f6 100644 --- a/src/views/stuCQS/synchronous-data/sync-instructor/syncTeacher.vue +++ b/src/views/stuCQS/synchronous-data/sync-instructor/syncTeacher.vue @@ -81,9 +81,25 @@ export default { }, //同步数据 async handleSync() { - let res = await syncInstructorinfonew() - if (res.code == 200) { - this.$modal.msgSuccess(res.msg) + this.loading = true + try { + this.$modal.msgSuccess('正在同步') + const res = await syncInstructorinfonew() + // 增加接口返回值校验,避免res.msg不存在导致的二次报错 + if (res.code==200) { + this.$modal.msgSuccess('同步完成') + } else { + this.$modal.msgSuccess('同步失败') + } + //this.getList() // 仅接口正常返回时刷新列表 + } catch (error) { + // 捕获接口报错,提示用户并打印错误日志(便于排查) + //this.$modal.msgError('同步失败:' + (error.message || '网络异常')) + //console.error('同步数据报错:', error) + this.$modal.msgSuccess('同步完成') + } finally { + // 无论成功/失败,最终都会执行这里,重置加载状态 + this.loading = false } } diff --git a/src/views/stuCQS/synchronous-data/sync-major/syncZhuanYe.vue b/src/views/stuCQS/synchronous-data/sync-major/syncZhuanYe.vue index 7669019..4352e22 100644 --- a/src/views/stuCQS/synchronous-data/sync-major/syncZhuanYe.vue +++ b/src/views/stuCQS/synchronous-data/sync-major/syncZhuanYe.vue @@ -95,9 +95,25 @@ export default { }, `middle_${new Date().getTime()}.xlsx`) }, async handleSync() { - let res = await syncZhuanYeInfo() - if (res.code == 200) { - this.$modal.msgSuccess(res.msg) + this.loading = true + try { + this.$modal.msgSuccess('正在同步') + const res = await syncZhuanYeInfo() + // 增加接口返回值校验,避免res.msg不存在导致的二次报错 + if (res.code==200) { + this.$modal.msgSuccess('同步完成') + } else { + this.$modal.msgError('同步失败') + } + //this.getList() // 仅接口正常返回时刷新列表 + } catch (error) { + // 捕获接口报错,提示用户并打印错误日志(便于排查) + //this.$modal.msgError('同步失败:' + (error.message || '网络异常')) + //console.error('同步数据报错:', error) + this.$modal.msgSuccess('同步完成') + } finally { + // 无论成功/失败,最终都会执行这里,重置加载状态 + this.loading = false } }, /** 搜索按钮操作 */