From 1c23dc22cc3350d4989522282e6b3e1c5e64436f Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期四, 25 十二月 2025 10:48:46 +0800
Subject: [PATCH] 调试

---
 components/mold.vue |   98 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 94 insertions(+), 4 deletions(-)

diff --git a/components/mold.vue b/components/mold.vue
index ff12f7e..55e215b 100644
--- a/components/mold.vue
+++ b/components/mold.vue
@@ -832,16 +832,16 @@
                 }
                 
                 const staffNo = this.tiaojiStaffNo.split(':')[0];
-                const totalQty = okQty + badQty; // 璇曚骇鎬绘暟 = 鑹搧鏁� + 涓嶈壇鍝佹暟
+                const currentCjNum = this.order?.currentCjNum || 0;
                 
                 // 璋冪敤鎶ヨ瘯浜ф暟鎺ュ彛(浣跨敤鎶ュ伐鐣岄潰鐨勬帴鍙�)
                 const payload = {
                     orderNo: this.workOrderNo,
                     orderId: this.orderId, // 闇�瑕佷粠宸ュ崟鏁版嵁涓幏鍙�
-                    bf: totalQty, // 璇曚骇鎬绘暟
+                    bf: badQty, // bf浼犻�掍笉鑹搧鏁�
                     staffNo: staffNo,
-                    initCjNum: this.order?.initCjNum || 0,
-                    currentCjNum: this.order?.currentCjNum || 0,
+                    initCjNum: currentCjNum - badQty - okQty, // initCjNum = currentCjNum - bf - 鑹搧鏁�
+                    currentCjNum: currentCjNum,
                     type: 'tiaoji', // 鏍囪瘑涓鸿皟鏈烘姤宸�
                     tiaojiOkQty: okQty, // 鏂板:鑹搧鏁�
                     tiaojiBadQty: badQty // 鏂板:涓嶈壇鍝佹暟
@@ -867,6 +867,9 @@
                     // 鍒锋柊鏁版嵁
                     await this.fetchFormData();
                     await this.fetchDefaultToolFromWorkOrder();
+                    
+                    // 鏂板锛氳嚜鍔ㄥ鐞嗚皟鏈洪�佹鐣岄潰鐨勬寜閽�昏緫
+                    await this.autoHandleMachineInspection();
                 } catch (err) {
                     console.error('璋冩満鎶ュ伐閿欒:', err);
                     this.$showMessage('璋冩満鎶ュ伐澶辫触锛岃妫�鏌ョ綉缁�');
@@ -875,6 +878,93 @@
                 }
             },
             
+            // 鏂板锛氳嚜鍔ㄥ鐞嗚皟鏈洪�佹鐣岄潰鐨勬寜閽�昏緫
+            async autoHandleMachineInspection() {
+                try {
+                    // 1. 浣跨敤 FindByOrderNo 鑾峰彇璋冩満閫佹鐣岄潰鐨勪笁涓椂闂�
+                    const statusRes = await this.$post({
+                        url: '/MesOrderSta/FindByOrderNo',
+                        data: {
+                            orderId: this.orderId,
+                            orderNo: this.workOrderNo
+                        }
+                    });
+                    
+                    if (!statusRes || !statusRes.data || !statusRes.data.tbBillList) {
+                        console.error('鑾峰彇宸ュ崟鐘舵�佸け璐�');
+                        this.$showMessage('鑾峰彇宸ュ崟鐘舵�佸け璐�');
+                        return;
+                    }
+                    
+                    const statusForm = statusRes.data.tbBillList;
+                    const maStartTime = statusForm.maStartTime;
+                    const maShoutTime = statusForm.maShoutTime;
+                    const maEndTime = statusForm.maEndTime;
+                    
+                    // 2. 鍑嗗闇�瑕佹洿鏂扮殑鏃堕棿鏁版嵁
+                    let needSave = false;
+                    let updateData = {
+                        id: statusForm.id,
+                        orderId: this.orderId,
+                        machineNo: this.machineNo,
+                        flag: -1
+                    };
+                    
+                    // 璁板綍鍝簺鎿嶄綔琚墽琛屼簡
+                    let actions = [];
+                    
+                    // 3. 浠庝笂鍒颁笅鏍规嵁鏄剧ず妗嗛噷鏄惁鏈夋椂闂翠緷娆¤缃�
+                    // 濡傛灉璋冩満寮�濮嬫椂闂翠负绌猴紝璁剧疆璋冩満寮�濮嬫椂闂�
+                    if (!maStartTime) {
+                        updateData.maStartTime = this.$getDate('yyyy-mm-dd hh24:mi:ss');
+                        updateData.flag = -1; // 璋冩満寮�濮嬬殑flag=-1
+                        needSave = true;
+                        actions.push('璋冩満寮�濮�');
+                    } else {
+                        updateData.maStartTime = maStartTime;
+                    }
+                    
+                    // 濡傛灉閫佹鍛煎彨鏃堕棿涓虹┖锛岃缃�佹鍛煎彨鏃堕棿
+                    if (!maShoutTime) {
+                        updateData.maShoutTime = this.$getDate('yyyy-mm-dd hh24:mi:ss');
+                        updateData.flag = 1; // 棣栨閫佹鍛煎彨鐨刦lag=1
+                        needSave = true;
+                        actions.push('閫佹鍛煎彨');
+                    } else {
+                        updateData.maShoutTime = maShoutTime;
+                    }
+                    
+                    // 璋冩満瀹屾垚鏃堕棿淇濇寔涓嶅彉
+                    updateData.maEndTime = maEndTime || '';
+                    
+                    // 4. 濡傛灉鏈夐渶瑕佹洿鏂扮殑鏃堕棿锛岃皟鐢ㄤ繚瀛樻帴鍙�
+                    if (needSave) {
+                        const saveRes = await this.$post({
+                            url: '/MesOrderSta/ChangeMachineTime',
+                            data: updateData
+                        });
+                        
+                        if (saveRes && saveRes.data && saveRes.data.tbBillList) {
+                            const successMsg = actions.join('銆�') + '鎴愬姛';
+                            this.$showMessage(successMsg);
+                            console.log('璋冩満閫佹鐣岄潰鏃堕棿鑷姩鏇存柊鎴愬姛:', actions);
+                        } else {
+                            const failMsg = actions.join('銆�') + '澶辫触';
+                            this.$showMessage(failMsg);
+                            console.error('璋冩満閫佹鐣岄潰鏃堕棿鑷姩鏇存柊澶辫触');
+                        }
+                    } else {
+                        // 鎵�鏈夋椂闂撮兘宸插瓨鍦紝鏃犻渶鏇存柊
+                        this.$showMessage('璋冩満寮�濮嬪拰閫佹鍛煎彨宸插畬鎴�');
+                        console.log('璋冩満寮�濮嬪拰閫佹鍛煎彨鏃堕棿宸插瓨鍦紝鏃犻渶鏇存柊');
+                    }
+                } catch (err) {
+                    console.error('鑷姩澶勭悊璋冩満閫佹鐣岄潰澶辫触:', err);
+                    this.$showMessage('鑷姩澶勭悊璋冩満閫佹澶辫触');
+                    // 涓嶄腑鏂富娴佺▼锛屽彧璁板綍閿欒
+                }
+            },
+            
             // 鏂板锛氳幏鍙栬皟鏈哄笀鍌呭垪琛�
             async fetchTiaojiStaff() {
                 try {

--
Gitblit v1.9.3