From a8e998ae4591fb97b0fc7a605226424316ae5742 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期四, 25 十二月 2025 16:44:38 +0800
Subject: [PATCH] 没有调机时间转跳到上下刀界面

---
 components/mold.vue |   90 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/components/mold.vue b/components/mold.vue
index 569f1d4..55e215b 100644
--- a/components/mold.vue
+++ b/components/mold.vue
@@ -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