From 0b3b3c54a8a6e4012cea104f1c63965215daeff2 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期五, 30 五月 2025 14:46:32 +0800
Subject: [PATCH] 1.首检检验表格生成

---
 H5/Js/IPQC_SJ/Add.js |  102 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 94 insertions(+), 8 deletions(-)

diff --git a/H5/Js/IPQC_SJ/Add.js b/H5/Js/IPQC_SJ/Add.js
index d33e4f4..a279da8 100644
--- a/H5/Js/IPQC_SJ/Add.js
+++ b/H5/Js/IPQC_SJ/Add.js
@@ -6,6 +6,7 @@
             formTbData: {         // 琛ㄥ崟鏁版嵁
             temperatureData: {} // 瀛樺偍鐨勫疄闄呮俯搴︺�佸疄闄呮祦閲忔暟鎹�
             },
+            indexZrxx:0,//鍒剁儹鎬ц兘index
             headers: [],
             showZr: false,
             waterOptions: [
@@ -39,8 +40,8 @@
                 { value: '550ml', text: '550ml' },
                 { value: '750ml', text: '750ml' },
                 { value: '999ml', text: '999ml' },
-                { value: '1min', text: '涓�鍒嗛挓娴侀噺' },
-                { value: '3min', text: '涓夊垎閽熸祦閲�' }
+                { value: '涓�鍒嗛挓娴侀噺', text: '涓�鍒嗛挓娴侀噺' },
+                { value: '涓夊垎閽熸祦閲�', text: '涓夊垎閽熸祦閲�' }
             ],//娴侀噺閫夐」
             selectedWater: [],// 宸查�夋按娓╁��
             selectedFlow: [],   // 宸查�夋祦閲忓��
@@ -129,16 +130,16 @@
         },
 
 
-        openZrPopup() {
+        openZrPopup(index) {
             this.showZr = true;
+            this.indexZrxx = this.tabActive;
+            this.loadTableConfig();
         },
         closeZrPopup() {
             this.showZr = false;
-            this.selectedWater = [];  // 鍏抽棴鏃舵竻绌洪�夋嫨
-            this.selectedFlow = [];   // 鍏抽棴鏃舵竻绌洪�夋嫨
+            // this.selectedWater = [];  // 鍏抽棴鏃舵竻绌洪�夋嫨
+            // this.selectedFlow = [];   // 鍏抽棴鏃舵竻绌洪�夋嫨
         },
-
-
         //閽堝娌℃湁涓婁笅闄愬�肩殑鏁版嵁锛屽彧闇�閫夋嫨鍚堟牸鎴栦笉鍚堟牸.鎸夐挳瑙﹀彂
         handleQualified(isQualified) {
             var input = "";
@@ -548,7 +549,7 @@
             const headers = [
                 '璁惧畾娓╁害', 
                 '瀹為檯娓╁害锛堚剝锛�', 
-                ...this.selectedFlow.sort().map(f => `娴侀噺${f}`)
+                ...this.selectedFlow.sort().map(f => `${f}`)
             ];
             this.headers = headers;
             console.log(this.headers);
@@ -580,5 +581,90 @@
             }, 100);
             console.log(this.formTbData);
         },
+        // 鏂板淇濆瓨閰嶇疆鏂规硶
+        saveTableConfig() {
+            const that = this;
+            that.isLoading = true;
+            
+            that.AxiosHttp("post", 'Ipqc/SaveTableConfig', {
+                selectedWater: (that.selectedWater),
+                selectedFlow: (that.selectedFlow),
+                tableData: (that.formTbData.temperatureData),
+                mxguid: that.tableData[that.indexZrxx].guid // 浣跨敤涓昏〃ID鍏宠仈
+            }, true).then(res1 => {
+                if (res1.status === 0) {
+                    that.$notify({ type: 'success', message: '閰嶇疆淇濆瓨鎴愬姛' });
+                } else {
+                    that.$toast.fail(res1.rtnMsg);
+                }
+                that.isLoading = false;
+            }).catch(error => {
+                that.$toast.fail("缃戠粶閿欒锛岃閲嶈瘯锛�");
+                that.isLoading = false;
+            });
+        },
+        // 鏂板鍔犺浇閰嶇疆鏂规硶
+        loadTableConfig() {
+            const that = this;
+            that.isLoading = true;
+            var mxguid =  that.tableData[that.indexZrxx].guid;
+
+
+            that.AxiosHttp("post", 'Ipqc/GetTableConfig', {
+                mxguid: mxguid,
+            }, true).then(res1 => {
+                if (res1.status === 0 && res1.data) {
+                    // 瑙f瀽瀛樺偍鐨勬暟鎹�
+                    that.selectedWater = JSON.parse(res1.data.selectedWater || '[]');
+                    that.selectedFlow = JSON.parse(res1.data.selectedFlow || '[]');
+                    that.formTbData.temperatureData = JSON.parse(res1.data.tableData || '{}');
+                    
+                    // 璋冪敤鏂扮殑娓叉煋鏂规硶
+                    this.renderExistingTable();
+                }
+                that.isLoading = false;
+            }).catch(error => {
+                that.isLoading = false;
+                that.$toast.fail("鍔犺浇閰嶇疆澶辫触");
+            });
+        },
+
+        // 鏂板娓叉煋宸叉湁鏁版嵁琛ㄦ牸鐨勬柟娉�
+        renderExistingTable() {
+            const that = this;
+            console.log(that.formTbData.temperatureData);
+            // 浠庣幇鏈夋暟鎹弽鍚戞帹瀵奸�夋嫨椤�
+            const existingWaters = Object.keys(that.formTbData.temperatureData);
+            const existingFlows = existingWaters.length > 0 
+                ? Object.keys(that.formTbData.temperatureData[existingWaters[0]])
+                    .filter(k => k !== 'temp')
+                : [];
+            
+            // 鐢熸垚琛ㄥご锛堜繚鐣欏師濮媍reateTb鐨勬牸寮忥級
+            that.headers = [
+                '璁惧畾娓╁害', 
+                '瀹為檯娓╁害锛堚剝锛�', 
+                ...existingFlows.map(f => `${f}`)
+            ];
+            
+            // 鐢熸垚琛屾暟鎹紙淇濈暀鍘熷缁撴瀯锛�
+            that.tableTbData = existingWaters.map(water => {
+                const values = that.formTbData.temperatureData[water];
+                return {
+                    temperature: water,
+                    values: Object.fromEntries([
+                        ['temp', values.temp || ''],
+                        ...existingFlows.map(flow => [flow, values[flow] || ''])
+                    ])
+                };
+            });
+            console.log(that.formTbData.temperatureData);
+            // 淇濈暀鍘熷婊氬姩閫昏緫
+            setTimeout(() => {
+                const tableEl = document.getElementById('temperature-table');
+                if (tableEl) tableEl.scrollIntoView({ behavior: 'smooth' });
+            }, 100);
+            console.log(that.formTbData.temperatureData);
+        },
     }
 })

--
Gitblit v1.9.3