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/test/ytjRtInfo.vue      |    6 
 src/views/test/testBatch.vue      |   56 ++++++++++----
 src/views/datas/dataHis.vue       |   50 ++++++++++--
 src/views/test/index.vue          |   23 ++++-
 src/views/test/devCard.vue        |   11 ++
 src/views/test/jhyRtInfo.vue      |   14 +++
 src/components/echarts/bar2.vue   |    7 +
 src/views/test/jhyTestDetails.vue |   15 ++-
 8 files changed, 140 insertions(+), 42 deletions(-)

diff --git a/src/components/echarts/bar2.vue b/src/components/echarts/bar2.vue
index 60bc961..16cca2c 100644
--- a/src/components/echarts/bar2.vue
+++ b/src/components/echarts/bar2.vue
@@ -98,7 +98,7 @@
             let max = Math.max(...data);
             let min = Math.min(...(data.filter((item) => item != 0)));
             let val = params.value;
-            console.log('min, max, val', min, max, val, '=============');
+            // console.log('min, max, val', min, max, val, '=============');
             
             if (val == min) {
               return minColor;
@@ -146,6 +146,10 @@
   myChart.setOption(option);
 }
 
+function resize() {
+  myChart.resize();
+}
+
 onMounted(() => {
   initChart();
 });
@@ -162,6 +166,7 @@
 
 defineExpose({
   updateChart,
+  resize,
 });
 </script>
 
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">
diff --git a/src/views/test/devCard.vue b/src/views/test/devCard.vue
index 18bdf4b..6af7ca0 100644
--- a/src/views/test/devCard.vue
+++ b/src/views/test/devCard.vue
@@ -24,6 +24,11 @@
   },
 });
 
+// 鏄惁鍙湁涓�缁�
+const isOnlyOne = computed(() => {
+  return 1 == props.info.state[0].batteryCount;
+});
+
 const testStates = computed(() => {
   if (1 == props.devType) {
     if (props.info.state.testPause) {
@@ -39,7 +44,7 @@
     //   props.info.state ? states[props.info.state[v].workMode] || "--" : "--"
     // );
     let [res1, res2] = [0, 1].map((v) => props.info.state[v].moduleStatus);
-  return `缁�1:${res1}, 缁�2: ${res2}`;
+    return isOnlyOne.value ? `缁�1:${res1}` : `缁�1:${res1}, 缁�2: ${res2}`;
   }
 });
 </script>
@@ -94,11 +99,11 @@
               <div class="link"></div>
             </div>
             <div class="item index">
-              #2
+              {{ isOnlyOne ? "--" : "#2" }}
               <div class="link"></div>
             </div>
             <div class="item">
-              {{ info.state[1].moduleStatus }}
+              {{ isOnlyOne ? "--" : info.state[1].moduleStatus }}
               <div class="link"></div>
             </div>
           </template>
diff --git a/src/views/test/index.vue b/src/views/test/index.vue
index 995f2c5..b5cc44a 100644
--- a/src/views/test/index.vue
+++ b/src/views/test/index.vue
@@ -49,6 +49,19 @@
   return _list.filter((v) => v.devId == currentDevId.value)[0] || {};
 });
 
+// 鏄惁鍙互淇敼鍧囪 浠數姹犵粍鏁�
+const canChangeBattCount = computed(() => {
+  // !currentDev.state[0].isTesting && !currentDev.state[1].isTesting
+  if (1 == devType.value || !currentDev.value.state) {
+    return false;
+  }
+  if (onlyOneGroup.value) {
+    return !currentDev.value.state[0].isTesting;
+  } else {
+    return !currentDev.value.state[0].isTesting && !currentDev.value.state[1].isTesting;
+  }
+});
+
 const testMode = computed(() => {
   if (1 == devType.value) {
     return ["--", "鏀剧數娴嬭瘯", "鍏呯數娴嬭瘯"][currentDev.value.state?.testType];
@@ -59,7 +72,7 @@
         ? states[currentDev.value.state[v].workMode] || "--"
         : "--"
     );
-    return `缁�1:${res1}, 缁�2: ${res2}`;
+    return onlyOneGroup.value ? `缁�1:${res1}` : `缁�1:${res1}, 缁�2: ${res2}`;
   }
 });
 
@@ -76,7 +89,7 @@
         ? currentDev.value.state[v].moduleStatus || "--"
         : "--"
     );
-    return `缁�1:${res1}, 缁�2: ${res2}`;
+    return onlyOneGroup.value ? `缁�1:${res1}` : `缁�1:${res1}, 缁�2: ${res2}`;
   }
 });
 
@@ -138,7 +151,7 @@
 
 function setBattCount() {
   jhyBattCountVisible.value = true;
-  console.log("cur", currentDev, "=============");
+  // console.log("cur", currentDev, "=============");
 }
 
 /**
@@ -151,7 +164,7 @@
 }
 
 function pauseYtj(type) {
-  console.log("currentDev", currentDev, "=============");
+  // console.log("currentDev", currentDev, "=============");
   if (!currentDev.value.devId) {
     return false;
   }
@@ -272,7 +285,7 @@
             size="small"
             :disabled="!currentDev.devOnline"
             class="btn-start btn-grp1"
-            v-if="!currentDev.state[0].isTesting"
+            v-if="canChangeBattCount"
             @click="setBattCount"
             >璁剧疆缁勬暟</el-button
           >
diff --git a/src/views/test/jhyRtInfo.vue b/src/views/test/jhyRtInfo.vue
index a2e39bd..0dac298 100644
--- a/src/views/test/jhyRtInfo.vue
+++ b/src/views/test/jhyRtInfo.vue
@@ -126,6 +126,13 @@
   changeTab();
 });
 
+watch(() => props.onlyOneGroup, (val) => {
+  if (battVolChart.value) {
+    battVolChart.value[0].resize();
+    battVolChart.value[1]?.resize();
+  }
+});
+
 function changeTab() {
   if (infoTab.value == 2) {
     updateChart();
@@ -155,7 +162,12 @@
 }
 
 onMounted(() => {
-  // sendData(JSON.stringify({ devId: props.devId, devType: 1 }));
+  // console.log('devId,' , props.devId, 'onMounted', '=============');
+  
+  let reg = /^2/;
+  if (reg.test(props.devId)) {
+    sendData(JSON.stringify({ devId: props.devId, devType: 2 }));
+  }
 });
 </script>
 
diff --git a/src/views/test/jhyTestDetails.vue b/src/views/test/jhyTestDetails.vue
index 0d9613c..ba13ce4 100644
--- a/src/views/test/jhyTestDetails.vue
+++ b/src/views/test/jhyTestDetails.vue
@@ -29,8 +29,9 @@
 });
 
 // TODO  鏈夊嚑缁�
-const onlyOneGroup = ref(false);
-
+const onlyOneGroup = computed(() => {
+  return rtDatas.value.devStates[0].batteryCount == 1;
+});
 
 const devInfo = ref({});
 
@@ -115,12 +116,12 @@
   let [res1, res2] = [0, 1].map(
     (v) => states[rtDatas.value.devStates[v].workMode]
   );
-  return `缁�1:${res1}, 缁�2: ${res2}`;
+  return onlyOneGroup.value ? `缁�1:${res1}` : `缁�1:${res1}, 缁�2: ${res2}`;
 });
 
 const testStates = computed(() => {
   let [res1, res2] = [0, 1].map((v) => rtDatas.value.devStates[v].moduleStatus);
-  return `缁�1:${res1}, 缁�2: ${res2}`;
+  return onlyOneGroup.value ? `缁�1:${res1}` : `缁�1:${res1}, 缁�2: ${res2}`;
 });
 
 function getInfo() {
@@ -253,7 +254,11 @@
         </div>
       </div>
     </yc-card>
-    <jhy-rt-info class="p-content" :onlyOneGroup="onlyOneGroup" :devId="devId"></jhy-rt-info>
+    <jhy-rt-info
+      class="p-content"
+      :onlyOneGroup="onlyOneGroup"
+      :devId="devId"
+    ></jhy-rt-info>
     <!-- 寮圭獥 -->
     <el-dialog
       title="璁剧疆娴嬭瘯鍙傛暟"
diff --git a/src/views/test/testBatch.vue b/src/views/test/testBatch.vue
index e17ce52..7d0a6b0 100644
--- a/src/views/test/testBatch.vue
+++ b/src/views/test/testBatch.vue
@@ -58,6 +58,24 @@
   );
 });
 
+// 鏄惁鍙互淇敼鍧囪 浠粍鏁�
+const canChangeBattCount = computed(() => {
+  if (
+    devType.value != 2 ||
+    selectData.value[2].length == 0 ||
+    selectData.value[2].filter((v) => v.devOnline == 1).length == 0
+  ) {
+    return false;
+  }
+  return selectData.value[2]
+    .filter((v) => v.devOnline == 1)
+    .every((v) => {
+      return onlyOneGroup.value
+        ? v.state[0].isTesting == 0
+        : v.state[0].isTesting == 0 && v.state[1].isTesting == 0;
+    });
+});
+
 // 涓�浣撴満 鎸夐挳鍙敤鎺у埗 鍏叡鏂规硶
 function computeYT(someFn) {
   return computed(() => {
@@ -68,16 +86,16 @@
     ) {
       return false;
     } else {
-      return selectData.value[1]
-        .filter((v) => v.devOnline == 1)
-        .some(someFn);
+      return selectData.value[1].filter((v) => v.devOnline == 1).some(someFn);
     }
   });
 }
 // 涓�浣撴満 鎸夐挳鍙敤鎺у埗 鍚姩
 const canStartYT = computeYT((v) => v.state.isTesting == 0);
 // 涓�浣撴満 鎸夐挳鍙敤鎺у埗 鏆傚仠
-const canPauseYT = computeYT((v) => v.state.isTesting == 1 && v.state.testPause == 0);
+const canPauseYT = computeYT(
+  (v) => v.state.isTesting == 1 && v.state.testPause == 0
+);
 // 涓�浣撴満 鎸夐挳鍙敤鎺у埗 缁х画
 const canContinueYT = computeYT((v) => v.state.testPause == 1);
 // 涓�浣撴満 鎸夐挳鍙敤鎺у埗 鍋滄
@@ -93,9 +111,7 @@
     ) {
       return false;
     } else {
-      return selectData.value[2]
-        .filter((v) => v.devOnline == 1)
-        .some(someFn);
+      return selectData.value[2].filter((v) => v.devOnline == 1).some(someFn);
     }
   });
 }
@@ -104,9 +120,13 @@
 // 鍧囪 浠� 鎸夐挳鍙敤鎺у埗 鍚姩缁�2
 const canStartJH2 = computeJH((v) => v.state[1].isTesting == 0);
 // 鍧囪 浠� 鎸夐挳鍙敤鎺у埗 鏆傚仠缁�1
-const canPauseJH1 = computeJH((v) => v.state[0].isTesting == 1 && v.state[0].isTestPause == 0);
+const canPauseJH1 = computeJH(
+  (v) => v.state[0].isTesting == 1 && v.state[0].isTestPause == 0
+);
 // 鍧囪 浠� 鎸夐挳鍙敤鎺у埗 鏆傚仠缁�2
-const canPauseJH2 = computeJH((v) => v.state[1].isTesting == 1 && v.state[1].isTestPause == 0);
+const canPauseJH2 = computeJH(
+  (v) => v.state[1].isTesting == 1 && v.state[1].isTestPause == 0
+);
 // 鍧囪 浠� 鎸夐挳鍙敤鎺у埗 缁х画缁�1
 const canContinueJH1 = computeJH((v) => v.state[0].isTestPause == 1);
 // 鍧囪 浠� 鎸夐挳鍙敤鎺у埗 缁х画缁�2
@@ -318,11 +338,16 @@
 function pauseYtj(type) {
   let devIds = devs.value;
   if (type == 1) {
-    devIds = devIds.filter(
-      (v) => v.devOnline == 1 && v.state.isTesting == 1 && v.state.testPause == 0
-    ).map((v) => v.devId);
+    devIds = devIds
+      .filter(
+        (v) =>
+          v.devOnline == 1 && v.state.isTesting == 1 && v.state.testPause == 0
+      )
+      .map((v) => v.devId);
   } else {
-    devIds = devIds.filter((v) => v.devOnline == 1 && v.state.testPause == 1).map((v) => v.devId);
+    devIds = devIds
+      .filter((v) => v.devOnline == 1 && v.state.testPause == 1)
+      .map((v) => v.devId);
   }
   let loading = $loading();
   pauseA200ParamPl(devIds, type)
@@ -474,9 +499,7 @@
           <el-button
             size="small"
             class="btn-start btn-grp1"
-            :disabled="
-              !selectData[devType].filter((v) => v.devOnline == 1).length
-            "
+            :disabled="!canChangeBattCount"
             @click="setBattCount"
             >璁剧疆缁勬暟</el-button
           >
@@ -620,6 +643,7 @@
         v-if="jhyBattCountVisible"
         :isBatch="true"
         :devs="devs"
+        :isOnlyOne="onlyOneGroup"
       ></batt-count-content>
     </el-dialog>
   </div>
diff --git a/src/views/test/ytjRtInfo.vue b/src/views/test/ytjRtInfo.vue
index 9e2e04f..ea0bbfb 100644
--- a/src/views/test/ytjRtInfo.vue
+++ b/src/views/test/ytjRtInfo.vue
@@ -86,13 +86,13 @@
 }
 
 onActivated(() => {
+  });
+
+onMounted(() => {
   let reg = /^1/;
   if (reg.test(props.devId)) {
     sendData(JSON.stringify({ devId: props.devId, devType: 1 }));
   }
-});
-
-onMounted(() => {
   // sendData(JSON.stringify({ devId: props.devId, devType: 1 }));
 });
 </script>

--
Gitblit v1.9.1