From 5cc9eb2d302ffe6218221208a28b60f91b57e41e Mon Sep 17 00:00:00 2001
From: he wei <858544502@qq.com>
Date: 星期六, 09 十一月 2024 14:02:59 +0800
Subject: [PATCH] U bug修复

---
 src/views/datas/dataHis.vue |   50 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/views/datas/dataHis.vue b/src/views/datas/dataHis.vue
index 99ae02b..880395f 100644
--- a/src/views/datas/dataHis.vue
+++ b/src/views/datas/dataHis.vue
@@ -87,12 +87,46 @@
           }
           let label = type;
           let value = v;
-          let children = arr.map((vv) => ({
-            ...vv,
-            label: vv.testStarttime,
-            value: vv.testRecordCount,
-          }));
-          return { label, value, disabled: !arr.length, children };
+          let children = [];
+          let count = arr.length;
+          if (devType.value == 1) {
+            children = arr.map((vv) => ({
+              ...vv,
+              label: vv.testStarttime,
+              value: vv.testRecordCount,
+            }));
+          } else {
+            // 娣诲姞涓�绾� 鍖哄垎鏄粍1杩樻槸缁�2
+            let _obj = {};
+            for (let i = arr.length; i--; ) {
+              let item = arr[i];
+              let idx = item.battIdx;
+              _obj[idx] = _obj[idx] || [];
+              _obj[idx].push(item);
+            }
+
+            Object.keys(_obj).forEach((vv) => {
+              let item = _obj[vv];
+              let idx = `缁�${vv * 1 + 1}`;
+              let _count = item.length;
+              children.push({
+                label: idx,
+                  count: _count,
+                value: `group_${vv}`,
+                children: item.map((vvv) => ({
+                  ...vvv,
+                  label: vvv.testStarttime,
+                  value: vvv.testRecordCount,
+                })),
+              });
+            });
+            // children = arr.map((vv) => ({
+            //   ...vv,
+            //   label: vv.testStarttime,
+            //   value: vv.testRecordCount,
+            // }));
+          }
+          return { label, value, count, disabled: !arr.length, children };
         });
       }
       testRecordList.value = _list;
@@ -191,7 +225,7 @@
 }
 
 function selectRecord() {
-  let res = testRecordCode.value[1];
+  let res = testRecordCode.value[testRecordCode.value.length - 1];
   // console.log("res", res, "=============");
 
   getRecordInf(currentDevId.value, res)
@@ -306,7 +340,7 @@
           @change="selectRecord"
           ><template #default="{ node, data }">
             <span>{{ data.label }}</span>
-            <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
+            <span v-if="!node.isLeaf"> ({{ data.count }}) </span>
           </template></el-cascader
         >
         <div class="info-title">

--
Gitblit v1.9.1