From b378c1336fed0fce37cdcef53a574ce745627723 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期六, 18 十月 2025 10:04:27 +0800
Subject: [PATCH] 添加上下刀计数

---
 components/mold.vue |   64 +++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/components/mold.vue b/components/mold.vue
index f719e1b..2216b17 100644
--- a/components/mold.vue
+++ b/components/mold.vue
@@ -225,7 +225,7 @@
 				this.selectedToolNo = tool.no;
 				this.toolName = tool.name;
 				this.toolModel = tool.model;
-                this.activeToolNo = tool.no; // 璁板綍閫変腑
+				this.activeToolNo = tool.no; // 璁板綍閫変腑
 			},
 			confirmTool() {
 				this.showToolDialog = false;
@@ -251,6 +251,7 @@
 				this.toolList = this.toolList.map(t => t.no === this.selectedToolNo ? { ...t, useLimit: v } : t);
 				this.$showMessage('浣跨敤涓婇檺宸茶缃紙浠呭墠绔樉绀猴級');
 			},
+			// 涓婂垁鏃朵紶閫掑綋鍓嶄笂鍒�璁℃暟
 			async handleUpTool() {
 				if (!this.workOrderNo) { this.$showMessage('宸ュ崟鍙蜂笉鑳戒负绌�'); return; }
 				if (!this.machineNo) { this.$showMessage('鏈哄彴鍙蜂笉鑳戒负绌�'); return; }
@@ -259,12 +260,17 @@
 				const useLimit = Number(this.useLimitInput);
 				if (isNaN(useLimit) || useLimit <= 0) { this.$showMessage('璇疯緭鍏ユ湁鏁堢殑浣跨敤涓婇檺'); return; }
 
+				// 鏌ユ壘褰撳墠鍒�鍏风殑涓婂垁璁℃暟
+				const currentTool = this.toolRecords.find(r => r.no === this.selectedToolNo);
+				const sdjs = currentTool && currentTool.upCount != null ? Number(currentTool.upCount) : null;
+
 				const payload = {
 					workOrderNo: this.workOrderNo,
 					machineNo: this.machineNo,
 					toolNo: this.selectedToolNo,
 					type: '涓婂垁',
-					useLimit
+					useLimit,
+					sdjs // 涓婂垁璁℃暟
 				};
 				try {
 					this.submitting = true;
@@ -286,6 +292,7 @@
 					this.submitting = false;
 				}
 			},
+			// 涓嬪垁鏃朵紶閫掑綋鍓嶄笅鍒�璁℃暟
 			async handleDownTool() {
 				if (!this.workOrderNo) { this.$showMessage('宸ュ崟鍙蜂笉鑳戒负绌�'); return; }
 				if (!this.machineNo) { this.$showMessage('鏈哄彴鍙蜂笉鑳戒负绌�'); return; }
@@ -294,12 +301,17 @@
 				const useLimit = Number(this.useLimitInput);
 				if (isNaN(useLimit) || useLimit <= 0) { this.$showMessage('璇疯緭鍏ユ湁鏁堢殑浣跨敤涓婇檺'); return; }
 
+				// 鏌ユ壘褰撳墠鍒�鍏风殑涓嬪垁璁℃暟
+				const currentTool = this.toolRecords.find(r => r.no === this.selectedToolNo);
+				const xdjs = currentTool && currentTool.downCount != null ? Number(currentTool.downCount) : null;
+
 				const payload = {
 					workOrderNo: this.workOrderNo,
 					machineNo: this.machineNo,
 					toolNo: this.selectedToolNo,
 					type: '涓嬪垁',
-					useLimit
+					useLimit,
+					xdjs // 涓嬪垁璁℃暟
 				};
 				try {
 					this.submitting = true;
@@ -367,7 +379,7 @@
 
 					const formatPercent = n => {
 						if (n === null || n === undefined || isNaN(n)) return '';
-                        // 濡傛灉鏄皬浜庣瓑浜�1鐨勫皬鏁帮紝鎸夋瘮渚嬫斁澶�
+						// 濡傛灉鏄皬浜庣瓑浜�1鐨勫皬鏁帮紝鎸夋瘮渚嬫斁澶�
 						if (n <= 1) return `${(n * 100).toFixed(0)}%`;
 						return `${Number(n).toFixed(0)}%`;
 					};
@@ -377,11 +389,11 @@
 						const downTimeRaw = getField(t, 'dowN_TIME', 'DOWN_TIME', 'downTime', 'DOWNTIME');
 						const lifeWarnRaw = getField(t, 'lifE_WARN', 'LIFE_WARN', 'lifeWarn', 'LIFEWARN');
 
-                        // 浣跨敤娆℃暟鍜屼笂闄�
+						// 浣跨敤娆℃暟鍜屼笂闄�
 						const useCount = getField(t, 'usE_COUNT', 'USE_COUNT', 'useCount');
 						const useLimit = getField(t, 'usE_LIMIT', 'USE_LIMIT', 'useLimit');
 
-                        // 璁$畻瀵垮懡姣旓紙浣跨敤娆℃暟/浣跨敤涓婇檺锛�
+						// 璁$畻瀵垮懡姣旓紙浣跨敤娆℃暟/浣跨敤涓婇檺锛�
 						let percent = '';
 						if (
 							useCount != null && useLimit != null &&
@@ -391,7 +403,7 @@
 							percent = ((Number(useCount) / Number(useLimit)) * 100).toFixed(0) + '%';
 						}
 
-                        // 棰勮鍊兼牸寮忓寲
+						// 棰勮鍊兼牸寮忓寲
 						const parseNumber = v => {
 							if (v === null || v === undefined || v === '') return null;
 							const s = String(v).replace(/[,锛�%]/g, '').trim();
@@ -405,7 +417,7 @@
 						};
 						const lifeWarnNum = parseNumber(lifeWarnRaw);
 
-                        // 棰勮瑙勫垯锛氬綋瀵垮懡姣� >= 棰勮鍊兼椂鏍囪 棰勮
+						// 棰勮瑙勫垯锛氬綋瀵垮懡姣� >= 棰勮鍊兼椂鏍囪 棰勮
 						let warnStatus = getField(t, 'status', 'STATUS') || '';
 						if (lifeWarnNum !== null && useCount != null && useLimit != null && !isNaN(useCount) && !isNaN(useLimit) && Number(useLimit) > 0) {
 							const percentNum = Number(useCount) / Number(useLimit);
@@ -444,24 +456,24 @@
 				}
 			},
 			// 鑷姩甯﹀嚭宸ュ崟鍒�鍏蜂俊鎭�
-            async fetchDefaultToolFromWorkOrder() {
-                if (!this.machineNo) return; // 娉ㄦ剰锛氳繖閲岀敤鏈哄彴鍙�
-                try {
-                    const res = await this.$post({
-                        url: '/Womdaa/GetWomdaasByShow',
-                        data: JSON.stringify({ machineNo: this.machineNo }),
-                        headers: { 'Content-Type': 'application/json' }
-                    });
-                    if (res.status === 0 && Array.isArray(res.data?.tbBillList) && res.data.tbBillList.length > 0) {
-                        const tool = res.data.tbBillList[0];
-                        this.selectedToolNo = tool.cutterId || tool.cutteR_ID || '';
-                        this.toolName = tool.cutterName || tool.cutteR_NAME || '';
-                        this.toolModel = tool.cutterModel || tool.cutteR_MODEL || '';
-                    }
-                } catch (e) {
-                    console.warn('鑷姩甯﹀嚭宸ュ崟鍒�鍏峰け璐�', e);
-                }
-            },
+			async fetchDefaultToolFromWorkOrder() {
+				if (!this.machineNo) return; // 娉ㄦ剰锛氳繖閲岀敤鏈哄彴鍙�
+				try {
+					const res = await this.$post({
+						url: '/Womdaa/GetWomdaasByShow',
+						data: JSON.stringify({ machineNo: this.machineNo }),
+						headers: { 'Content-Type': 'application/json' }
+					});
+					if (res.status === 0 && Array.isArray(res.data?.tbBillList) && res.data.tbBillList.length > 0) {
+						const tool = res.data.tbBillList[0];
+						this.selectedToolNo = tool.cutterId || tool.cutteR_ID || '';
+						this.toolName = tool.cutterName || tool.cutteR_NAME || '';
+						this.toolModel = tool.cutterModel || tool.cutteR_MODEL || '';
+					}
+				} catch (e) {
+					console.warn('鑷姩甯﹀嚭宸ュ崟鍒�鍏峰け璐�', e);
+				}
+			},
 			formatDateTime(dateTimeStr) {
 				if (!dateTimeStr) return '';
 				try {

--
Gitblit v1.9.3