From 90c8680cbc67d4b2680b1e5af4ad1129a96efa0c Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 06 五月 2025 14:39:09 +0800
Subject: [PATCH] 1.设备工具明细和树-过期标红

---
 src/components/Table/lims-table.vue                           |    3 +++
 src/views/CNAS/resourceDemand/device/index.vue                |   24 ++++++++++++++++++++++--
 src/views/CNAS/resourceDemand/device/component/management.vue |   14 +++++++++++++-
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/components/Table/lims-table.vue b/src/components/Table/lims-table.vue
index 2df0ddc..1f4e431 100644
--- a/src/components/Table/lims-table.vue
+++ b/src/components/Table/lims-table.vue
@@ -505,4 +505,7 @@
 .lims-table .highlight-danger-row-border td:last-child {
   border-right: 4px solid #f56c6c;
 }
+>>>.red-row td {
+  background: #FFCCCC !important;
+}
 </style>
diff --git a/src/views/CNAS/resourceDemand/device/component/management.vue b/src/views/CNAS/resourceDemand/device/component/management.vue
index 7bfa710..191a580 100644
--- a/src/views/CNAS/resourceDemand/device/component/management.vue
+++ b/src/views/CNAS/resourceDemand/device/component/management.vue
@@ -33,7 +33,7 @@
     </div>
 		<div class="table" v-show="!showData">
 			<lims-table :tableData="tableData" :column="column" :tableLoading="tableLoading" :height="'calc(100vh - 300px)'"
-				:page="page" @pagination="pagination"></lims-table>
+				:page="page" @pagination="pagination" :row-class-name="tableRowClassName"></lims-table>
 		</div>
 		<el-dialog :title="isUp ? '璁惧璇︽儏' : '妗f淇'" :visible.sync="dialogVisible" width="70%" top="5vh"
 			:before-close="handleClose">
@@ -606,6 +606,18 @@
 			this.page.size = limit;
 			this.getList();
 		},
+    tableRowClassName({ row }) {
+      const today = new Date();
+      const targetDate = new Date(row.activationDate);
+      const fiveDaysBeforeTarget = new Date(targetDate);
+      // 璁$畻鍓嶄簲澶╃殑鏃ユ湡
+      fiveDaysBeforeTarget.setDate(targetDate.getDate() - 5);
+      // 姣旇緝鏃堕渶瑕佺‘淇濇瘮杈冪殑鏄畬鏁寸殑鏃ユ湡鏃堕棿锛屽寘鍚椂鍒嗙
+      if (today > fiveDaysBeforeTarget) {
+        return 'red-row';
+      }
+      return '';
+    },
 		refresh() {
 			this.queryParams = {};
 			this.page.current = 1;
diff --git a/src/views/CNAS/resourceDemand/device/index.vue b/src/views/CNAS/resourceDemand/device/index.vue
index 063a9b2..e01dc60 100644
--- a/src/views/CNAS/resourceDemand/device/index.vue
+++ b/src/views/CNAS/resourceDemand/device/index.vue
@@ -12,7 +12,9 @@
         <div slot-scope="{ node, data }" class="custom-tree-node">
           <el-row style="width: 100%;">
             <el-col :span="24">
-              <p class="single-line-ellipsis" style="width: 100%">
+              <p class="single-line-ellipsis" style="width: 100%" :style="{
+              color: isLeafNode(data) && shouldHighlight(data) ? 'red' : ''
+            }">
                 <i :class="`node_i ${data.children != undefined
                   ? data.code === '[1]'
                     ? 'el-icon-folder-opened'
@@ -22,7 +24,9 @@
                   "></i>
                 {{ data.label }}
               </p>
-              <p>
+              <p :style="{
+              color: isLeafNode(data) && shouldHighlight(data) ? 'red' : ''
+            }">
                 {{ data.managementNumber === undefined ? '' : data.managementNumber }}
               </p>
             </el-col>
@@ -198,9 +202,25 @@
       treeDevice().then(res => {
         let data = res.data;
         this.list = data;
+        console.log('this.list--', this.list)
         this.loading = false
       });
     },
+    // 鍒ゆ柇鏄惁鏄彾瀛愯妭鐐�
+    isLeafNode(data) {
+      return !data.children || data.children.length === 0;
+    },
+    // 鍒ゆ柇鏄惁闇�瑕佹爣绾�
+    shouldHighlight(data) {
+      if (!data.activationDate) return false;
+      const today = new Date();
+      const targetDate = new Date(data.activationDate);
+      const fiveDaysBeforeTarget = new Date(targetDate);
+      // 璁$畻鍓嶄簲澶╃殑鏃ユ湡
+      fiveDaysBeforeTarget.setDate(targetDate.getDate() - 5);
+
+      return today > fiveDaysBeforeTarget;
+    },
     handleNodeClick(val, node, el) {
       // 鐐瑰嚮涓存椂缂撳瓨
       this.clickNodeVal = val;

--
Gitblit v1.9.3