① 基本信息
| 问题描述 | 内网用户在审核资料的时候,点击提交按钮或者是回退按钮,出现弹窗之后点击取消按钮,弹窗关闭,但是并网资料页面所有提交按钮或者是回退都在转圈圈,很久没有停止下来,无法进行提交和回退 |
|---|---|
| 一级模块 | 并网资料流程 |
| 二级模块 | 并网资料信息 |
| 涉及类型 | 集中式新能源 |
| 台账标注区域 | 三区(内网审核界面,与本仓库共用同一批组件代码) |
| 严重性 | 严重 |
| 是否阻断流程 | 是 |
| 当前状态 | 2.1.待开发 |
| 研发处理人 | 李文慧 |
| 处理状态 | 待调整 |
② 问题截图
③ 旧代码涉及的项目文件及行数(backup730 分支)
xnybw5f / src/approval/projectData/component/batchInfo.vue
第 1693-1710 行(表格内"提交"/"回退"按钮,均绑定同一个共享变量 :loading="sendLoading" / :loading="backLoading")
xnybw5f / src/approval/projectData/component/batchInfo.vue
第 4100-4116 行(backFlow 方法)、第 4118-4188 行(submitFlow 方法)
④ 代码现状与修复方案
第一处问题:加载状态是"全页面共享"而不是"按行独立"。 资料列表里每一行的"提交"按钮和"回退"按钮,绑定的都是同一个 sendLoading / backLoading 布尔值,而不是各自行独立的状态:
<el-button ... :loading="sendLoading" @click="submitFlow(scope.row, scope.$index, infoItem)">提交</el-button> // 第1693/1702/1710行等多处 <el-button ... :loading="backLoading" @click="backFlow(scope.row, scope.$index, infoItem)">回退</el-button> // 第1701/1709行
这解释了为什么截图中"所有"提交/回退按钮会同时转圈——只要其中一个被置为 true,全表所有行的按钮都会一起显示加载态。
第二处问题(真正卡死的原因):接口返回非成功状态时,加载状态没有被重置。 backFlow() 只在业务返回码为 0 时才把 backLoading 置回 false,没有 else 分支兜底:
backFlow(row, rowIndex, item) {
this.checkInformation = item
this.backLoading = true // 第4102行:点击回退,立即置为loading
backFlowList(row.informationFlow).then(res => {
if (res.data.code === 0) {
...
this.backLoading = false // 第4110行:只有code===0才复位
this.nodeBackVisible = true
}
// 缺少 else 分支:code非0时,backLoading永远停在true
}).catch((error) => {
this.$message.error('调用接口出错:' + error)
this.backLoading = false // 第4115行:仅网络异常/Promise reject才会走到这里
})
},
submitFlow() 存在完全相同的模式——只有 res.data.status === 'success' 时才把 sendLoading 复位:
this.sendLoading = true
...
commitFile(newParam).then(res => {
if (res.data.status === 'success') {
...
this.sendLoading = false // 第4185行:仅success才复位
this.searchFormFun(item)
}
// 缺少 else 分支
}).catch((error) => {
this.$message.error('调用接口出错:' + error)
this.sendLoading = false
})
两个问题叠加:只要一次"提交"或"回退"请求返回了 HTTP 200 但业务码非成功(例如用户在紧随其后弹出的"流程节点选择"弹窗里点击"取消",导致后续保存/查询请求被中断或返回业务失败码),
sendLoading/backLoading 就会永久停留在 true,而这两个变量又是全表共享的,于是就出现了截图中"所有提交/回退按钮同时转圈、长时间不恢复"的现象。
建议修复方式:
backFlowList(row.informationFlow).then(res => { if (res.data.code === 0) { ... this.backLoading = false this.nodeBackVisible = true } }).catch((error) => { this.$message.error('调用接口出错:' + error) this.backLoading = false }) backFlowList(row.informationFlow).then(res => { if (res.data.code === 0) { ... this.nodeBackVisible = true } else { this.$message.error(res.data.msg || '获取回退节点失败') } this.backLoading = false // 无论成功失败都要复位 }).catch((error) => { this.$message.error('调用接口出错:' + error) this.backLoading = false })
同时建议把 sendLoading/backLoading 由"整表共享的单一布尔值"改为"按行记录 loading 状态"(例如 this.$set(row, '_sendLoading', true/false),按钮改绑 :loading="scope.row._sendLoading"),避免一行的操作影响全表其它行按钮的视觉状态,也能防止未来同类"漏写 else 复位"的问题波及全表。