From 25cb7cd50d12f48e93d6cde47420ca3458e9c47a Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期四, 12 六月 2025 21:39:43 +0800
Subject: [PATCH] 1

---
 代码管理/WMS/WIDESEA_WMSClient/src/extension/stock/stockView.js |   72 +++++++++++++++++++++++++++++-------
 1 files changed, 58 insertions(+), 14 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/stock/stockView.js" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/stock/stockView.js"
index 92ad623..1b2540a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/stock/stockView.js"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/stock/stockView.js"
@@ -19,6 +19,7 @@
   methods: {
     //涓嬮潰杩欎簺鏂规硶鍙互淇濈暀涔熷彲浠ュ垹闄�
     onInit() {
+      
       // let InOrder = this.buttons.find(x => x.value == 'StockOutbound');
       // if (InOrder) {
       //   InOrder.onClick = function () {
@@ -56,27 +57,36 @@
             return str = list[0] == "" ? "鏃�" : str;
           }
         }
-        if (column.field == 'materielInfo') {
-          const today = new Date()
-          column.formatter = (row) => {
-            if (row.details.length > 0) {
-              const today = new Date();
-              const closestDate = row.details
+    if (column.field == 'materielInfo') {
+    const today = new Date()
+    column.formatter = (row) => {
+        if (row.details.length > 0) {
+            const today = new Date();
+            const closestDate = row.details
                 .map(x => {
-                  const date = new Date(x.effectiveDate);
-                  const diffInDays = Math.ceil(Math.abs((today - date) / (1000 * 60 * 60 * 24)));
-                  return { date, diffInDays };
+                    const date = new Date(x.effectiveDate);
+                    const diffInDays = Math.ceil((date - today) / (1000 * 60 * 60 * 24)); // 鏀逛负璁$畻鍓╀綑澶╂暟
+                    return { date, diffInDays };
                 })
                 .reduce((closest, current) => (current.diffInDays < closest.diffInDays ? current : closest))
                 .date;
 
-              const daysSinceClosest = Math.ceil(Math.abs((today - closestDate) / (1000 * 60 * 60 * 24)));
-              return '<span style="color: #F56C6C">' + daysSinceClosest + "澶�" + '</span>';
+            const daysRemaining = Math.ceil((closestDate - today) / (1000 * 60 * 60 * 24));
+            
+            row.expiryDays = daysRemaining; 
+            
+            if (daysRemaining <= 0) {
+                return '<span style="color:rgb(30, 27, 27)">鏃犱繚璐ㄦ湡</span>';
             } else {
-              return '<span style="color: #F56C6C">' + "鏃犱繚璐ㄦ湡" + '</span>';
+                return '<span style="color: #F56C6C">' + daysRemaining + "澶�" + '</span>';
             }
+        } else {
+            row.expiryDays = null;
+            return '<span style="color:rgb(24, 18, 18)">鏃犱繚璐ㄦ湡</span>';
+        }
+    }
 
-          }
+          
         }
         if (column.field == 'sumStock') {
           column.formatter = (row) => {
@@ -86,7 +96,7 @@
                 .map(x => {
                   sum += (x.stockQuantity)
                 })
-              return '<span style="color: #F56C6C">' + sum + row.details[0].unit + '</span>';
+              return '<span style="color: #F56C6C">' + sum.toFixed(3) + row.details[0].unit + '</span>';
             } else {
               return '<span style="color: #F56C6C">' + "1涓�" + '</span>';
             }
@@ -94,11 +104,45 @@
           }
         }
       })
+      this.columns.forEach((column) => {
+        column.cellStyle = (row) => {
+        // 鍙鐞嗘湁淇濊川鏈熸暟鎹殑鎯呭喌
+        if (row.expiryDays !== null && row.expiryDays !== undefined) {
+            if (row.expiryDays <= 0) {
+                return { background: 'red' }; // 绾㈣壊鑳屾櫙锛堝凡杩囨湡锛�
+            } else if (row.expiryDays <= 30) {
+                return { background: 'yellow' }; // 榛勮壊鑳屾櫙锛堜复鏈燂級
+            }
+        }
+        return {}; // 榛樿鏃犺儗鏅壊
+    };
+
+
+    
+    
+        //濡傛灉鏍规嵁琛岀殑鏌愪釜鍊艰缃暣琛岄鑹�
+        //璁剧疆鏁磋鑳屾櫙棰滆壊
+        // x.cellStyle = (row, rowIndex, columnIndex) => {
+        //   if (row.ProductCode == '10044464880643') {
+        //     return { background: '#ddecfd' };
+        //   } 
+        // };
+        });
     },
     onInited() {
       //妗嗘灦鍒濆鍖栭厤缃悗
       //濡傛灉瑕侀厤缃槑缁嗚〃,鍦ㄦ鏂规硶鎿嶄綔
       //this.detailOptions.columns.forEach(column=>{ });
+      this.detailOptions.summary = true;
+        this.detailOptions.columns.forEach(x => {
+          if (x.field == 'stockQuantity') {
+              x.summary = true;
+              //璁$畻骞冲潎鍊�
+              // x.summary = 'avg';//2023.05.03鏇存柊voltable鏂囦欢鍚庢墠鑳戒娇鐢�
+              //璁剧疆灏忔暟鏄剧ず浣嶆暟(榛樿2浣�)
+              // x.numberLength = 4;
+          }
+        });
     },
     searchBefore(param) {
       //鐣岄潰鏌ヨ鍓�,鍙互缁檖aram.wheres娣诲姞鏌ヨ鍙傛暟

--
Gitblit v1.9.3