From 7c0f20e25e870e055f88952f9ec57677730eda67 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期四, 11 十二月 2025 12:06:30 +0800
Subject: [PATCH] Merge branch 'master' of http://159.223.171.199:10439/r/YiWuProject

---
 UI-Project/src/views/StockBasicData/stockBasicData.vue |  386 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 289 insertions(+), 97 deletions(-)

diff --git a/UI-Project/src/views/StockBasicData/stockBasicData.vue b/UI-Project/src/views/StockBasicData/stockBasicData.vue
index 591e943..6c17a1a 100644
--- a/UI-Project/src/views/StockBasicData/stockBasicData.vue
+++ b/UI-Project/src/views/StockBasicData/stockBasicData.vue
@@ -1,43 +1,22 @@
 <script setup>
-import {Search} from "@element-plus/icons-vue";
-import {reactive} from "vue";
+import {onBeforeUnmount, onMounted, onUnmounted, reactive, ref} from "vue";
 import {useRouter} from "vue-router"
+import request from "@/utils/request"
+import {closeWebSocket, initializeWebSocket} from '@/utils/WebSocketService';
+import {ElMessage, ElMessageBox} from 'element-plus'
+import {useI18n} from 'vue-i18n'
 const router = useRouter()
 const adda = ref(false)
-import { WebSocketHost ,host} from '@/utils/constants'
-import request from "@/utils/request"
-import { ref, onMounted , onBeforeUnmount,onUnmounted} from "vue";
-import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
-// import { ref } from 'vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
-//  import LanguageMixin from './lang/LanguageMixin'
-  import { useI18n } from 'vue-i18n'
-  const { t } = useI18n()
-  let language = ref(localStorage.getItem('lang') || 'zh')
-
+const {t} = useI18n()
+let language = ref(localStorage.getItem('lang') || 'zh')
 const tableData = ref([])
+const blindb = ref(false)
 const slot = ref('')
-const requestData = {  
-  line: 2001  
-};  
-const now = new Date();
-const timeRange = ref([new Date(now.setHours(0, 0, 0, 0)), new Date(now.setHours(23, 59, 59, 999))])
+const requestData = {
+  line: 2001
+};
+const timeRange = ref([])
 const selectValuesa = reactive([]);
-// request.post("/cacheGlass/taskCache/selectEdgTask",{
-//   ...requestData,  
-
-// }).then((res) => {
-//           if (res.code == 200) {
-            
-//           console.log(res.data);
-//           tableData.value = res.data
-//           console.log(res.data[0].slot);
-//           } else {
-//           ElMessage.warning(res.msg)
-        
-//           }
-//           });
-
 // 纾ㄨ竟浠诲姟鏌ヨ
 const setEdgGlassInfoRequest = async () => {
   let celllist=[]
@@ -52,8 +31,6 @@
       stateList=[selectValuesa[1]];
     }
   }
-
-
   const response = await request.post("/cacheGlass/edgGlassTaskInfo/setEdgGlassInfoRequest", {
     cellList: celllist,
     stateList: stateList,
@@ -65,9 +42,7 @@
   } else {
     ElMessage.error(response.message);
   }
-
 }
-
 // 鐮存崯
  const open = async(row) => { 
   try {
@@ -80,25 +55,20 @@
         type: 'warning',  
       } 
     );
-    if (confirmResult === 'confirm') {  
-      // 鐢ㄦ埛鐐瑰嚮浜嗏�滄槸鈥濓紝鐜板湪璋冪敤鍒犻櫎鎺ュ彛  
+    if (confirmResult === 'confirm') {
       const response = await request.post("/cacheGlass/edgStorageCage/edgReportStatus", {
-        glassId: row.glass_id,
-        controlsId: 8,
-        line: 2001,
-        machine: '鍐峰姞宸�',
+        glassId: row.glassId,
+        state: 8,
+        line: row.line,
+        workingProcedure: '纾ㄨ竟',
     })
     if (response.code === 200) {
       ElMessage.success(response.message);
-      } else {  
-        // 鍒犻櫎澶辫触锛屾偍鍙互澶勭悊閿欒鎴栨樉绀洪敊璇俊鎭粰鐢ㄦ埛  
+      } else {
       ElMessage.error(response.msg);
-        // alert('鍒犻櫎澶辫触锛�' + deleteResponse.message); 
       }  
     }  
-  } catch (error) {  
-    // 澶勭悊鍙兘鍑虹幇鐨勯敊璇紝姣斿 ElMessageBox 鎶涘嚭鐨勫紓甯哥瓑  
-    console.error('鍙戠敓閿欒:', error);  
+  } catch (error) {
   }  
 };  
 // 鎷胯蛋 
@@ -113,97 +83,306 @@
         type: 'warning',  
       } 
     );
-    if (confirmResult === 'confirm') {  
-      // 鐢ㄦ埛鐐瑰嚮浜嗏�滄槸鈥濓紝鐜板湪璋冪敤鍒犻櫎鎺ュ彛  
+    if (confirmResult === 'confirm') {
       const response = await request.post("/cacheGlass/edgStorageCage/edgReportStatus", {
-        glassId: row.glass_id,
-        controlsId: 9,
-        line: 2001,
-        machine: '鍐峰姞宸�',
+        glassId: row.glassId,
+        state: 9,
+        line: row.line,
+        workingProcedure: '纾ㄨ竟',
     })
     if (response.code === 200) {
       ElMessage.success(response.message);
-      } else {  
-        // 鍒犻櫎澶辫触锛屾偍鍙互澶勭悊閿欒鎴栨樉绀洪敊璇俊鎭粰鐢ㄦ埛  
+      } else {
       ElMessage.error(response.msg);
-        // alert('鍒犻櫎澶辫触锛�' + deleteResponse.message); 
       }  
     }  
-  } catch (error) {  
-    // 澶勭悊鍙兘鍑虹幇鐨勯敊璇紝姣斿 ElMessageBox 鎶涘嚭鐨勫紓甯哥瓑  
-    console.error('鍙戠敓閿欒:', error);  
+  } catch (error) {
   }  
 };   
 let socket = null;
-const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlass`;
-// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
+const socketUrl = `ws://${window.ipConfig.serverUrl}/api/cacheGlass/api/talk/edgTasks`;
 const handleMessage = (data) => {
-  // 鏇存柊 tableData 鐨勬暟鎹�
-  tableData.value = data.edgTasks[0]
+  const formattedTasks = data.edgTasks[0].map(cageInfo => {
+    if (cageInfo && cageInfo.createTime) {
+      cageInfo.formattedCreateTime = formatTimestamp(cageInfo.createTime);
+    }
+    return cageInfo;
+  });
+  tableData.value = formattedTasks
+};
+//  妯℃嫙鏁版嵁
+// const generateMockData = () => {
+//   const mockList = [
+//     {
+//       glassId: 'GL251209001',
+//       width: 520,
+//       height: 310,
+//       thickness: 10,
+//       filmsid: '閽㈠寲鐜荤拑',
+//       line: 1,
+//       state: 2, // 鏈(杈�
+//       createTime: Date.now() - 3600 * 1000 * 2, // 2灏忔椂鍓嶇殑鏃堕棿鎴�
+//       formattedCreateTime: formatTimestamp(Date.now() - 3600 * 1000 * 2)
+//     },
+//     {
+//       glassId: 'GL251209002',
+//       width: 600,
+//       height: 380,
+//       thickness: 12,
+//       filmsid: '娴硶鐜荤拑',
+//       line: 2,
+//       state: 1, // 纾ㄨ竟涓�
+//       createTime: Date.now() - 3600 * 1000 * 1, // 1灏忔椂鍓嶇殑鏃堕棿鎴�
+//       formattedCreateTime: formatTimestamp(Date.now() - 3600 * 1000 * 1)
+//     },
+//     {
+//       glassId: 'GL251209003',
+//       width: 480,
+//       height: 290,
+//       thickness: 8,
+//       filmsid: '澶硅兌鐜荤拑',
+//       line: 1,
+//       state: 1, // 宸茬(杈�
+//       createTime: Date.now() - 3600 * 1000 * 6, // 6灏忔椂鍓嶇殑鏃堕棿鎴�
+//       formattedCreateTime: formatTimestamp(Date.now() - 3600 * 1000 * 6)
+//     },
+//     {
+//       glassId: 'GL251209004',
+//       width: 550,
+//       height: 330,
+//       thickness: 9,
+//       filmsid: '涓┖鐜荤拑',
+//       line: 2,
+//       state: 0,
+//       createTime: Date.now() - 3600 * 1000 * 3,
+//       formattedCreateTime: formatTimestamp(Date.now() - 3600 * 1000 * 3)
+//     },
+//     {
+//       glassId: 'GL251209005',
+//       width: 580,
+//       height: 350,
+//       thickness: 11,
+//       filmsid: '闃插脊鐜荤拑',
+//       line: '1',
+//       state: 0,
+//       createTime: Date.now() - 3600 * 1000 * 4,
+//       formattedCreateTime: formatTimestamp(Date.now() - 3600 * 1000 * 4)
+//     }
+   
+//   ];
+//   return mockList;
+// };
+//   tableData.value = generateMockData();
+//   ElMessage.success('妯℃嫙鏁版嵁鍔犺浇鎴愬姛锛�');
+// 鍘嗗彶浠诲姟
+const iframeUrl = ref('');
+const handlehistorical = (row) => {
+  blindb.value = true;
+  iframeUrl.value = `${window.location.origin}/#/StockBasicData/stockhistory`;
 };
 onMounted(() => {
   socket = initializeWebSocket(socketUrl, handleMessage);
 });
   onUnmounted(() => {
     if (socket) {
-    closeWebSocket(socket);
+      closeWebSocket(socket);
     }
-    });
+  });
+//   function getStatusTypeb(state) {
+//   switch (state) {
+//     case 0:
+//       return 'info';
+//     case 1:
+//       return 'success';
+//     case 1:
+//       return 'danger';
+//   }
+// }
+// 1. 杈呭姪锛氳幏鍙栬鐪熷疄绱㈠紩
+function getRowRealIndex(row) {
+  return tableData.value.findIndex(item => item.glassId === row.glassId);
+}
+
+// 2. 杈呭姪锛氳幏鍙栨寚瀹氱嚎璺渶鏂拌鐘舵��
+function getLineLatestState(line) {
+  const targetLine = String(line || '').trim();
+  if (!targetLine) return -1;
+  for (const row of tableData.value) {
+    const rowLine = String(row.line || '').trim();
+    if (rowLine === targetLine) {
+      return Number(row.state);
+    }
+  }
+  return -1;
+}
+
+// 3. 鏍稿績鍒ゆ柇锛氭槸鍚﹂渶瑕侀珮浜�/鏍囩孩
+function isNeedHighlight(row) {
+  const currentState = Number(row.state);
+  const currentLine = String(row.line || '').trim();
+  if (!currentLine) return false;
+
+  // 鍘熸湁閫昏緫锛氭湭纾ㄨ竟 + 鍓嶅簭鏈夌(杈逛腑/宸茬(杈�
+  if (currentState === 0) {
+    const currentIndex = getRowRealIndex(row);
+    if (currentIndex === -1) return false;
+    for (let i = 0; i < currentIndex; i++) {
+      const compareRow = tableData.value[i];
+      const compareLine = String(compareRow?.line || '').trim();
+      const compareState = Number(compareRow?.state);
+      if (compareLine === currentLine && [1, 2].includes(compareState)) {
+        return true;
+      }
+    }
+  }
+
+  // 鏂板閫昏緫锛氱(杈逛腑 + 鍚岀嚎璺渶鏂版槸宸茬(杈�
+  if (currentState === 1) {
+    const latestState = getLineLatestState(currentLine);
+    if (latestState === 2) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+// 4. 鍘熷棰滆壊鏄犲皠
+function getOriginalColor(state) {
+  const stateNum = Number(state);
+  switch (stateNum) {
+    case 0: return 'info';
+    case 1: return 'success';
+    case 2: return 'primary';
+    default: return 'info';
+  }
+}
+
+// 5. 鏍囩绫诲瀷鍑芥暟锛堣皟鐢╥sNeedHighlight锛�
+function getStatusTypeb(row) {
+  const currentState = Number(row.state);
+  if ([0, 1].includes(currentState) && isNeedHighlight(row)) {
+    return 'danger';
+  }
+  return getOriginalColor(row.state);
+}
+
+// 6. 琛屾牱寮忓嚱鏁帮紙璋冪敤isNeedHighlight锛�
+function getTableRowClass({ row }) {
+  const currentState = Number(row.state);
+  if ([0, 1].includes(currentState) && isNeedHighlight(row)) {
+    return 'leak-edge-highlight';
+  }
+  return '';
+}
+
+function getStatusTextb(state) {
+  switch (state) {
+    case 0:
+      return t('workOrder.nedging');
+    case 1:
+      return t('workOrder.edging');
+    case 2:
+      return t('workOrder.finedging');
+  }
+}
+function formatTimestamp(timestamp) {
+  const date = new Date(timestamp);
+  const year = date.getFullYear();
+  const month = String(date.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮嬶紝闇�瑕佸姞1锛屽苟琛ラ浂
+  const day = String(date.getDate()).padStart(2, '0'); // 琛ラ浂
+  const hours = String(date.getHours()).padStart(2, '0'); // 琛ラ浂锛堝鏋滈渶瑕佹樉绀烘椂闂达級
+  const minutes = String(date.getMinutes()).padStart(2, '0'); // 琛ラ浂锛堝鏋滈渶瑕佹樉绀烘椂闂达級
+  const seconds = String(date.getSeconds()).padStart(2, '0'); // 琛ラ浂锛堝鏋滈渶瑕佹樉绀烘椂闂达級
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+}
 onBeforeUnmount(() => {
-  console.log("鍏抽棴浜�")
   closeWebSocket();
 });
 </script>
 <template>
-  <div>
-    <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;" v-loading="loading">
-      <el-select v-model="selectValuesa[0]" filterable :placeholder="$t('璇烽�夋嫨绾胯矾')" clearable>
-            <el-option label="纾ㄨ竟涓�绾�" value="2001"></el-option>
-            <el-option label="纾ㄨ竟浜岀嚎" value="2002"></el-option>
+  <div style="height: 500px;">
+    <div>
+      <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;" >
+        <div style="display: flex;">
+        <!-- <el-button style="margin-left: 20px;" id="searchButton" type="success" @click="handlehistorical">{{
+          $t('searchOrder.historicaltasks')
+        }}
+      </el-button> -->
+        <el-select v-model="selectValuesa[0]" filterable :placeholder="$t('workOrder.cway')" clearable
+                   style="margin-left: 20px;margin-bottom: 10px;">
+          <el-option :label="$t('workOrder.edgingone')" value="930"></el-option>
+          <el-option :label="$t('workOrder.edgingtwo')" value="931"></el-option>
+        </el-select>
+        <el-select v-model="selectValuesa[1]" filterable :placeholder="$t('workOrder.cstate')" clearable
+                   style="margin-left: 20px;margin-bottom: 10px;">
+          <el-option :label="$t('workOrder.nedging')" value="0"></el-option>
+          <el-option :label="$t('workOrder.edging')" value="1"></el-option>
+          <el-option :label="$t('workOrder.finedging')" value="2"></el-option>
           </el-select>
-
-          <el-select v-model="selectValuesa[1]" filterable :placeholder="$t('璇烽�夋嫨鐘舵��')" clearable >
-            <el-option label="鏈(杈�" value="0"></el-option>
-            <el-option label="纾ㄨ竟涓�" value="1"></el-option>
-            <el-option label="宸茬(杈�" value="2"></el-option>
-          </el-select>
-          <span class="demonstration">鏃堕棿娈�</span>
-            <el-date-picker v-model="timeRange" type="datetimerange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�"
-              end-placeholder="缁撴潫鏃ユ湡">
+          <span class="demonstration" style="margin-left: 20px;margin-top: 3px;">{{ $t('workOrder.time') }}</span>
+            <el-date-picker v-model="timeRange" type="datetimerange" range-separator="鑷�" :start-placeholder="$t('reportmanage.starttime')"  style="margin-left: 15px;" value-format = "YYYY-MM-DD hh:mm:ss"
+              :end-placeholder="$t('reportmanage.endtime')">
             </el-date-picker>
-          <el-button type="primary" style="margin-left: 10px;" @click="setEdgGlassInfoRequest()">{{
+          <el-button type="primary" style="margin-left: 10px;margin-bottom: 10px;" @click="setEdgGlassInfoRequest()">{{
         $t('reportmanage.inquire')
       }}</el-button>
-
+      </div>
       <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
-        <el-table height="240" ref="table" 
+        <el-table height="750" ref="table" 
         @selection-change="handleSelectionChange"
-        :data="tableData" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
+        :data="tableData" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"
+        :row-class-name="getTableRowClass"
+        >
         <el-table-column prop="glassId" align="center" :label="$t('workOrder.glassID')" min-width="180" />
           <el-table-column prop="width" align="center" :label="$t('workOrder.width')" min-width="120" />
           <el-table-column prop="height" align="center" :label="$t('workOrder.height')" min-width="80" />
           <el-table-column prop="thickness" align="center" :label="$t('workOrder.thickness')" min-width="120" />
-          <el-table-column prop="glassType" align="center" :label="$t('workOrder.glasstype')" min-width="120" />
+          <el-table-column prop="filmsid" align="center" :label="$t('workOrder.glasstype')" min-width="120" />
           <el-table-column prop="line" align="center" :label="$t('workOrder.line')" min-width="120" />
-          <el-table-column prop="status" :label="$t('workOrder.status')" align="center" width="200">
-            <template #default="scope">
+          <el-table-column prop="formattedCreateTime" align="center" :label="$t('workOrder.time')" min-width="120" />
+          <el-table-column prop="state" :label="$t('workOrder.status')" align="center" width="200">
+            <!-- <template #default="scope">
               {{ scope.row.status==0?"鏈(杈�":scope.row.status==1?"纾ㄨ竟涓�":"宸茬(杈�" }}
-            </template>
+            </template> -->
+            <template #default="scope"> 
+          <el-tag :type="getStatusTypeb(scope.row || {}, scope.index)">  
+          {{ getStatusTextb(scope.row.state) }}  
+        </el-tag>   
+        <!-- <el-tag :type="getStatusTypeb(scope.row.state)">  
+          {{ getStatusTextb(scope.row.state) }}  
+        </el-tag>   -->
+      </template> 
         </el-table-column>
-
-
           <el-table-column fixed="right" :label="$t('workOrder.operate')" align="center" width="200">
             <template #default="scope">
-              <el-button size="mini" type="text" plain @click="open(scope.row)">{{ $t('workOrder.breakage') }}</el-button>
-              <el-button size="mini" type="text" plain @click="opena(scope.row)">{{ $t('workOrder.takeout') }}</el-button>
+              <el-button type="text" plain @click="open(scope.row)">{{
+                  $t('workOrder.breakage')
+                }}
+              </el-button>
+              <el-button type="text" plain @click="opena(scope.row)">{{
+                  $t('workOrder.takeout')
+                }}
+              </el-button>
             </template>
-        </el-table-column>
+          </el-table-column>
         </el-table>
       </div>
-    </el-card>
+      </el-card>
+    </div>
+  <!-- 鍘嗗彶浠诲姟 -->
+<el-dialog v-model="blindb" top="10vh" width="95%" @close="iframeUrl=''">
+     <iframe 
+     :src="iframeUrl" 
+     marginwidth="2000px"
+     marginheight="2000px"
+     width="100%" 
+     height="700px" 
+     frameborder="0"
+     ></iframe>
+  </el-dialog>
   </div>
 </template>
-
 <style scoped>
 #dt { display:block; float:left;line-height: 20px;margin-left: 100px;}
 #dta { display:block; float:left;line-height: 20px;margin-left: 80%;}
@@ -224,4 +403,17 @@
   height: 460px;
   /* margin-top: -60px; */
 }
+/* 婕忕(杈硅鏁磋楂樹寒鏍峰紡锛堢┛閫弒coped锛� */
+:deep(.leak-edge-highlight) {
+  background-color: #fff1f0 !important; /* 娴呯孩鑳屾櫙锛堝拰danger鏍囩鍛煎簲锛� */
+}
+/* 琛屽唴鍗曞厓鏍兼枃瀛楁爣绾� */
+:deep(.leak-edge-highlight > td) {
+  color: #f5222d !important; /* 绾㈣壊鏂囧瓧 */
+  font-weight: 500 !important; /* 鍙�夛細鏂囧瓧鍔犵矖锛屾洿閱掔洰 */
+}
+/* 榧犳爣鎮诞鏃朵繚鎸侀珮浜紙鍙�夛級 */
+:deep(.el-table__row.leak-edge-highlight:hover > td) {
+  background-color: #fee2e2 !important;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.8.0