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 } }, /** 搜索按钮操作 */