diff --git a/src/api/system/orderPro.js b/src/api/system/orderPro.js
index bcb368c..44fbd57 100644
--- a/src/api/system/orderPro.js
+++ b/src/api/system/orderPro.js
@@ -234,6 +234,14 @@ export function getPlotState() {
})
}
+// 读取并记住当前项目最后一次出图结果
+export function captureDrawingState(id) {
+ return request({
+ url: '/system/orderPro/drawingState/' + id,
+ method: 'get'
+ })
+}
+
// 金蝶生产订单(按项目 id)
export function getKingdeePrdMo(id) {
return request({
diff --git a/src/views/system/orderPro/index.vue b/src/views/system/orderPro/index.vue
index cfb27e7..17b0d5e 100644
--- a/src/views/system/orderPro/index.vue
+++ b/src/views/system/orderPro/index.vue
@@ -557,20 +557,18 @@
-
+
出图状态:{{ plotStatusText }}
+ {{ plotStateMsg }}
项目:{{ plotProjectName }}
-
-
-
@@ -656,8 +654,8 @@
+ :disabled="sendProcessRoutePlanLoading || isSkipProcessOrder || !!drawingNotSuccess()"
+ :title="sendPlanButtonTitle">
发送计划表({{ routePlanSendCount }}次)
@@ -2389,6 +2387,7 @@ import {
getRouteLog,
getBomUploadStatus,
getPlotState,
+ captureDrawingState,
getKingdeePrdMo,
getKingdeePurchaseOrder,
importDrawingByExcel,
@@ -2712,7 +2711,6 @@ export default {
this.getConfigIniOptions(); // 新增
this.$api = { addProduct, updateProduct };
- this.fetchPlotStatus();
},
computed: {
/** 是否做工艺=否:出图后不再把工艺表推给工艺。空值仍按需要工艺处理。 */
@@ -2720,6 +2718,16 @@ export default {
const v = this.productionObj && this.productionObj.needProcess;
return v === 0 || v === "0";
},
+ sendPlanButtonTitle() {
+ if (this.isSkipProcessOrder) {
+ return "该项目无需做工艺,不再推送给工艺";
+ }
+ const deny = this.drawingNotSuccess();
+ if (deny) {
+ return deny;
+ }
+ return "发送工艺计划表(钉钉推送给工艺),括号内为已成功发送次数";
+ },
/** 折叠区内已选筛选项数量(收起时角标) */
advancedFilterCount() {
const q = this.queryParams || {};
@@ -3057,62 +3065,126 @@ export default {
this.percentage = Number(((current / total) * 100).toFixed(2));
}
},
- // 获取出图状态
+ plotNameFromPath(path) {
+ const normalized = String(path || "").replace(/\\\\/g, "/");
+ return normalized.split("/").filter(Boolean).pop() || "";
+ },
+ plotPathMatchesCurrent(path) {
+ const orderNo = this.productionObj && this.productionObj.productionOrderNo;
+ if (!orderNo || !path) {
+ return false;
+ }
+ return String(path).replace(/\\\\/g, "/").indexOf(orderNo) !== -1;
+ },
+ applyPlotStateObject(stateObj) {
+ if (!stateObj || stateObj.processstate === undefined || stateObj.processstate === null || stateObj.processstate === "") {
+ this.plotStatusText = "暂无记录";
+ this.plotStatusType = "info";
+ this.plotStateMsg = (stateObj && stateObj.msg) || "";
+ this.plotOutputPath = (stateObj && stateObj.outputpath) || "";
+ this.plotProjectName = this.plotNameFromPath(this.plotOutputPath);
+ this.plotTargetDrawing = "";
+ return;
+ }
+ this.plotOutputPath = stateObj.outputpath || "";
+ this.plotProjectName = this.plotNameFromPath(this.plotOutputPath);
+ const msg = stateObj.msg || "";
+ this.plotStateMsg = msg;
+ const match = String(msg).match(/未找到装配图[::]\s*([^,,。\s"]+)/);
+ this.plotTargetDrawing = (match && match[1]) ? match[1] : (stateObj.sourcedrawing || "");
+ switch (String(stateObj.processstate)) {
+ case "0":
+ this.plotStatusText = "无任务";
+ this.plotStatusType = "info";
+ break;
+ case "1":
+ this.plotStatusText = "生成图纸中";
+ this.plotStatusType = "primary";
+ break;
+ case "2":
+ this.plotStatusText = "导出明细中";
+ this.plotStatusType = "primary";
+ break;
+ case "3":
+ this.plotStatusText = "导出PDF中";
+ this.plotStatusType = "primary";
+ break;
+ case "4":
+ this.plotStatusText = "已完成";
+ this.plotStatusType = "success";
+ break;
+ case "5":
+ this.plotStatusText = "出图失败";
+ this.plotStatusType = "danger";
+ break;
+ default:
+ this.plotStatusText = "异常";
+ this.plotStatusType = "warning";
+ }
+ },
+ applySavedPlotStatus(row) {
+ this.applyPlotStateObject({
+ processstate: row ? row.drawingState : null,
+ msg: (row && row.drawingStateMsg) || "",
+ outputpath: (row && row.drawingStatePath) || ""
+ });
+ },
+ rememberPlotOnProject(data) {
+ if (!data) {
+ return;
+ }
+ const fields = ["drawingState", "drawingStateMsg", "drawingStatePath", "drawingStateTime"];
+ if (this.productionObj && this.productionObj.id === data.id) {
+ fields.forEach((key) => this.$set(this.productionObj, key, data[key]));
+ }
+ const row = (this.orderProList || []).find((item) => item && item.id === data.id);
+ if (row) {
+ fields.forEach((key) => this.$set(row, key, data[key]));
+ }
+ this.applySavedPlotStatus(data);
+ },
+ async captureProjectPlotStatus(id) {
+ const projectId = id || (this.productionObj && this.productionObj.id);
+ if (!projectId) {
+ return null;
+ }
+ this.plotStatusLoading = true;
+ try {
+ const res = await captureDrawingState(projectId);
+ const data = (res && res.data) || null;
+ if (data) {
+ this.rememberPlotOnProject(data);
+ }
+ return data;
+ } catch (err) {
+ if (this.productionObj) {
+ this.applySavedPlotStatus(this.productionObj);
+ }
+ return null;
+ } finally {
+ this.plotStatusLoading = false;
+ }
+ },
+ // 刷新当前项目的出图结果。出图服务若正在处理其他令号,仍显示本项目上次记录。
fetchPlotStatus() {
+ if (this.productionObj && this.productionObj.id) {
+ this.captureProjectPlotStatus(this.productionObj.id);
+ return;
+ }
this.plotStatusLoading = true;
getPlotState().then(res => {
this.plotStatusLoading = false;
-
const stateObj = this.parsePlotStateResponse(res);
-
if (stateObj && stateObj.processstate !== undefined) {
- this.plotOutputPath = stateObj.outputpath || "";
- const path = String(this.plotOutputPath || "");
- const normalized = path.replace(/\\\\/g, "/");
- this.plotProjectName = normalized.split("/").filter(Boolean).pop() || "";
- const msg = stateObj.msg || "";
- this.plotStateMsg = msg || "";
- const match = String(msg).match(/未找到装配图[::]\s*([^,,。\s"]+)/);
- this.plotTargetDrawing = (match && match[1]) ? match[1] : (stateObj.sourcedrawing || "");
-
- const status = stateObj.processstate;
- switch (String(status)) {
- case '0':
- this.plotStatusText = '无任务';
- this.plotStatusType = 'info';
- break;
- case '1':
- this.plotStatusText = '生成图纸中';
- this.plotStatusType = 'primary';
- break;
- case '2':
- this.plotStatusText = '导出明细中';
- this.plotStatusType = 'primary';
- break;
- case '3':
- this.plotStatusText = '导出PDF中';
- this.plotStatusType = 'primary';
- break;
- case '4':
- this.plotStatusText = '已完成';
- this.plotStatusType = 'success';
- break;
- case '5':
- this.plotStatusText = '出图失败';
- this.plotStatusType = 'danger';
- break;
- default:
- this.plotStatusText = '异常';
- this.plotStatusType = 'warning';
- }
+ this.applyPlotStateObject(stateObj);
} else {
- this.plotStatusText = '解析状态失败';
- this.plotStatusType = 'warning';
+ this.plotStatusText = "解析状态失败";
+ this.plotStatusType = "warning";
}
- }).catch(err => {
+ }).catch(() => {
this.plotStatusLoading = false;
- this.plotStatusText = '获取失败';
- this.plotStatusType = 'danger';
+ this.plotStatusText = "获取失败";
+ this.plotStatusType = "danger";
});
},
async fetchProcessLog() {
@@ -3431,6 +3503,7 @@ export default {
this.routePlanSendCount = Object.prototype.hasOwnProperty.call(this.routePlanSendCountMap, row.id)
? this.routePlanSendCountMap[row.id]
: 0;
+ this.applySavedPlotStatus(row);
this.drawer = true;
// 打开抽屉后加载表格数据
this.loadChainTableData();
@@ -3438,6 +3511,7 @@ export default {
if (row && row.id) {
// 他人可能已「确认图纸已齐」,打开时拉最新状态,避免本地列表缓存导致无法下载
this.refreshProductionDrawingGate(row.id);
+ this.captureProjectPlotStatus(row.id);
this.fetchRoutePlanSendCount();
this.fetchProcessLog();
}
@@ -5112,22 +5186,25 @@ export default {
this.drawLog = stateObj.msg || "";
const ps = this.normalizePlotProcessState(stateObj.processstate);
+ if (this.plotPathMatchesCurrent(stateObj.outputpath)) {
+ this.applyPlotStateObject(stateObj);
+ }
- if (ps === 3) {
+ if (ps === 3 && this.plotPathMatchesCurrent(stateObj.outputpath)) {
this.applyPlotProgressFromMsg(stateObj.msg);
}
// 完成 / 失败:兼容 processstate 为字符串 "4"/"5"
- if (ps === 4) {
+ if (ps === 4 && this.plotPathMatchesCurrent(stateObj.outputpath)) {
this.percentage = 100;
this.clearDrawProgressTimer();
this.drawLoading = false;
- this.fetchPlotStatus();
- } else if (ps === 5) {
+ this.captureProjectPlotStatus();
+ } else if (ps === 5 && this.plotPathMatchesCurrent(stateObj.outputpath)) {
this.clearDrawProgressTimer();
this.drawLoading = false;
this.drawLog = stateObj.msg || "出图失败";
- this.fetchPlotStatus();
+ this.captureProjectPlotStatus();
}
} catch (pollErr) {
console.error("出图进度轮询失败:", pollErr);
@@ -5137,6 +5214,7 @@ export default {
this.drawLog = "出图失败:" + (e.msg || e.message || e);
this.drawLoading = false;
this.clearDrawProgressTimer();
+ this.captureProjectPlotStatus();
}
},
// 加载销齿链型号表格数据
@@ -5547,6 +5625,26 @@ export default {
this.$set(this.routePlanSendCountMap, this.productionObj.id, 0);
}
},
+ drawingNotSuccess(row) {
+ const item = row || this.productionObj;
+ if (!item) {
+ return "请先选择生产令号";
+ }
+ const msg = item.drawingStateMsg || "";
+ const failed = /失败|未找到|错误|异常/.test(msg);
+ const state = item.drawingState;
+ if (state === 4 || state === "4") {
+ return failed ? "项目尚未出图成功:" + msg : "";
+ }
+ if (state !== undefined && state !== null && state !== "") {
+ return msg ? "项目尚未出图成功:" + msg : "项目出图尚未完成,不能发送计划表或创建待办";
+ }
+ const bom = Number(item.bomStatus);
+ if (Number.isFinite(bom) && bom !== 0) {
+ return "";
+ }
+ return "项目尚未出图成功,不能发送计划表或创建待办";
+ },
async sendProcessRoutePlan() {
if (!this.productionObj || !this.productionObj.id) {
this.$message.warning("请先选择生产令号");
@@ -5556,6 +5654,14 @@ export default {
this.$message.info("该项目无需做工艺,不再推送给工艺");
return;
}
+ const drawingDeny = this.drawingNotSuccess();
+ if (drawingDeny) {
+ this.$message.warning(drawingDeny);
+ return;
+ }
+ if (this.sendProcessRoutePlanLoading) {
+ return;
+ }
this.sendProcessRoutePlanLoading = true;
try {
const res = await sendProcessRoutePlanExcel(this.productionObj.id);