|
|
@@ -37,6 +37,14 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="rx-ec">
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-refresh"
|
|
|
+ type="text"
|
|
|
+ style="color: #fff; font-size: 14px"
|
|
|
+ :loading="loading"
|
|
|
+ @click="handleRefresh"
|
|
|
+ >刷新</el-button
|
|
|
+ >
|
|
|
<el-button
|
|
|
icon="el-icon-full-screen"
|
|
|
type="text"
|
|
|
@@ -987,6 +995,63 @@
|
|
|
this.drawer = false;
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 刷新当前选中工序相关的接口:
|
|
|
+ * 1) 重新拉取工单详情(workorderInfo);
|
|
|
+ * 2) 重新拉取工序实例列表(getTaskInstanceList);
|
|
|
+ * 3) 用之前选中的工序 taskId 在新列表里重新定位,避免 handIdx 中
|
|
|
+ * “未执行到此工序” 的 count 守卫拦截(先同步 desIndex 再调用 handIdx);
|
|
|
+ * 4) 刷新当前工序与下道工序的展示名。
|
|
|
+ * 整个过程用 loading 锁防止重复点击。
|
|
|
+ */
|
|
|
+ async handleRefresh() {
|
|
|
+ if (this.loading) return;
|
|
|
+
|
|
|
+ // 刷新前先记住当前选中的工序实例 id,用于刷新后保留用户选择
|
|
|
+ const previousTaskId =
|
|
|
+ this.curTaskObj?.taskId ?? this.routeList[this.desIndex]?.taskId;
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ // 1) 刷新工单详情
|
|
|
+ await this.getOrderData();
|
|
|
+
|
|
|
+ // 2) 刷新工序实例列表(routeList) —— 内部已调用 handIdx 基于
|
|
|
+ // workOrderInfo.taskId 重置选中和连接线宽度
|
|
|
+ await this.getTaskFn();
|
|
|
+
|
|
|
+ // 3) 按之前选中的工序重新定位到步骤条对应节点
|
|
|
+ if (
|
|
|
+ previousTaskId !== undefined &&
|
|
|
+ previousTaskId !== null &&
|
|
|
+ previousTaskId !== ''
|
|
|
+ ) {
|
|
|
+ const idx = this.routeList.findIndex(
|
|
|
+ (item) => String(item.taskId) === String(previousTaskId)
|
|
|
+ );
|
|
|
+ if (idx > -1 && idx !== this.desIndex) {
|
|
|
+ // 先更新 desIndex 再调用 handIdx,
|
|
|
+ // 让 handIdx 内部的 count 守卫视为“当前位置”放行
|
|
|
+ this.desIndex = idx;
|
|
|
+ await this.handIdx(idx, this.routeList[idx]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4) 刷新当前工序 / 下道工序的名称
|
|
|
+ if (this.workOrderInfo && this.workOrderInfo.id) {
|
|
|
+ await this.getTaskName(this.workOrderInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$message.success('刷新成功');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('[刷新当前工序] 失败', error);
|
|
|
+ this.$message.error('刷新失败,请稍后重试');
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
feedSuccess() {
|
|
|
this.getOrderData();
|
|
|
this.getTaskFn();
|