From 53abbe71cc12744523bc2db27ead4dda4e30e91e Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Thu, 15 May 2025 17:15:55 +0800
Subject: [PATCH] feat:添加空状态

---
 src/views/wel/components/statistics.vue |  125 ++++++-----------------------------------
 1 files changed, 19 insertions(+), 106 deletions(-)

diff --git a/src/views/wel/components/statistics.vue b/src/views/wel/components/statistics.vue
index 7e17f8a..7896992 100644
--- a/src/views/wel/components/statistics.vue
+++ b/src/views/wel/components/statistics.vue
@@ -9,89 +9,7 @@
         <img src="/src/assets/images/workbench/st2.png" alt="" />
       </div>
     </div>
-    <!-- <div
-      class="grid-container"
-      v-if="permission.device_statistics_four && !permission.device_statistics_six"
-    >
-      <div v-for="(item, index) in Object.keys(newtitleData)" :key="index" class="device-card">
-        <div class="device-title">
-          <img :src="test[item].img" :alt="newtitleData[item].name" />
-          <div class="itemcenter">
-            <div>{{ test[item]?.name || '--' }}</div>
-            <span class="shu">{{ newtitleData[item].total_num }}</span>
-            <span>个</span>
-          </div>
-        </div>
-        <div class="status-list">
-          <template v-if="test[item]?.name == '机巢' || test[item]?.name == '无人机'">
-            <div
-              v-for="statusKey in [4, 0, -1]"
-              :key="statusKey"
-              class="status-item"
-              :class="getStatusStyle(test[item]?.name, statusKey)"
-              :style="{ color: getStatusColor(test[item]?.name, statusKey) }"
-            >
-              <span
-                class="indicator"
-                :style="{
-                  backgroundColor: getStatusBackground(test[item]?.name, statusKey),
-                  color: getStatusColor(test[item]?.name, statusKey),
-                }"
-              ></span>
-              <span class="label">{{ getStatusLabel(test[item]?.name, statusKey) }}</span>
-              <span class="count">
-                {{ newtitleData[item].status_map[statusKey] }}
-                {{ test[item]?.name === '无人机' ? '架' : '个' }}
-              </span>
-            </div>
-          </template>
-          <template v-else-if="test[item]?.name == '监控设备'">
-            <div
-              v-for="statusKey in [1, 0]"
-              :key="statusKey"
-              class="status-item"
-              :class="getStatusStyle(test[item]?.name, statusKey)"
-              :style="{ color: getStatusColor(test[item]?.name, statusKey) }"
-            >
-              <span
-                class="indicator"
-                :style="{
-                  backgroundColor: getStatusBackground(test[item]?.name, statusKey),
-                  color: getStatusColor(test[item]?.name, statusKey),
-                }"
-              ></span>
-              <span class="label">{{ getStatusLabel(test[item]?.name, statusKey) }}</span>
-              <span class="count">
-                {{ newtitleData[item].status_map[statusKey] }}
-                {{ test[item]?.name === '无人机' ? '架' : '个' }}
-              </span>
-            </div>
-          </template>
 
-          <template v-else>
-            <div
-              v-for="(status, statusIndex) in newtitleData[item].status_map"
-              :key="statusIndex"
-              class="status-item"
-              :class="getStatusStyle(test[item]?.name, statusIndex)"
-              :style="{ color: getStatusColor(test[item]?.name, statusIndex) }"
-            >
-              <span
-                class="indicator"
-                :style="{
-                  backgroundColor: getStatusBackground(test[item]?.name, statusIndex),
-                  color: getStatusColor(test[item]?.name, statusIndex),
-                }"
-              ></span>
-              <span class="label">{{ getStatusLabel(test[item]?.name, statusIndex) }}</span>
-              <span class="count"
-                >{{ status }} {{ test[item]?.name === '无人机' ? '架' : '个' }}</span
-              >
-            </div>
-          </template>
-        </div>
-      </div>
-    </div> -->
     <div class="grid-container">
       <div v-for="(item, index) in Object.keys(newtitleData)" :key="index" class="device-card">
         <div class="device-title">
@@ -327,36 +245,23 @@
       return statusSelect[statusCode] || `未知状态(${statusCode})`;
   }
 };
-// const px = {
-// '4':0,
-//   '0':1,
-//   '-1':2
-// }
-// const status_map = newtitleData.value.plant_list.status_map
-// newtitleData.value.plant_list.status_map = Object.entries(status_map).sort((a,b) => {
-//   return px[a[0]] - px[b[0]]
-// })
-// console.log(Object.entries(status_map).sort((a,b) => {
-//   return px[a[0]] - px[b[0]]
-// }));
+
 const getStaticsList = () => {
   getStatics(userInfo.value.detail.areaCode).then(res => {
     console.log('permission.value', permission.value);
-    console.log('设备', res.data.data);
+    // console.log('设备', res.data.data);
     if (permission.value?.device_statistics_six) {
-      const { move_list, ...filteredData } = res.data.data;
+      const { move_list, monitor_list, ...filteredData } = res.data.data;
       newtitleData.value = filteredData;
-
       return;
     }
 
     for (let key in res.data.data) {
-      if (
-        permission.value?.device_statistics_four &&
-        (key === 'flow_type_list' || key === 'insure_list')
-      )
-        continue;
-      newtitleData.value[key] = res.data.data[key];
+      if (permission.value?.device_statistics_four) {
+        const { flow_type_list, insure_list, ...filteredData } = res.data.data;
+        newtitleData.value = filteredData;
+        return;
+      }
     }
   });
 };
@@ -367,7 +272,15 @@
   monitor: '个',
   mobile: '个',
 };
-
+watch(
+  () => [
+    userInfo.value.detail?.areaCode,
+    permission.value.device_statistics_six,
+    permission.value?.device_statistics_four,
+  ],
+  () => getStaticsList(),
+  { immediate: true }
+);
 onMounted(() => {
   getStaticsList();
 });
@@ -413,12 +326,12 @@
     // display: grid;
     // grid-template-columns: repeat(4, 1fr);
     display: flex;
-   justify-content: space-between;
+    justify-content: space-around;
     .device-card {
       display: flex;
       align-items: center;
       margin-top: 30px;
-      margin-left: 10px;
+
       .device-title {
         display: flex;
         align-items: center;

--
Gitblit v1.9.3