From c45531e760a5f4cc69dd2314a4f5bbcdc881d30a Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Thu, 03 Apr 2025 09:55:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/SignMachineNest/components/MachineLeft/MachineData.vue |   45 +++++++++++++++++++--------------------------
 1 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/src/views/SignMachineNest/components/MachineLeft/MachineData.vue b/src/views/SignMachineNest/components/MachineLeft/MachineData.vue
index 20cbff0..0a4db03 100644
--- a/src/views/SignMachineNest/components/MachineLeft/MachineData.vue
+++ b/src/views/SignMachineNest/components/MachineLeft/MachineData.vue
@@ -13,9 +13,9 @@
 </template>
 
 <script setup>
-import { getFlightStatistics } from '@/api/home/machineNest.js'
 import { pxToRem } from '@/utils/rem';
 import CommonTitle from '@/components/CommonTitle.vue';
+import { useStore } from 'vuex';
 import rwcs from '@/assets/images/signMachineNest/machineLeft/rwcs.png';
 import sjs from '@/assets/images/signMachineNest/machineLeft/sjs.png';
 import jscb from '@/assets/images/signMachineNest/machineLeft/jscb.png';
@@ -23,33 +23,26 @@
 import fxlc from '@/assets/images/signMachineNest/machineLeft/fxlc.png';
 import fxsc from '@/assets/images/signMachineNest/machineLeft/fxsc.png';
 
-const statisticsList = ref([
-  { imgurl: rwcs, num: 1314, text: '任务次数(次)' },
-  { imgurl: sjs, num: 1314, text: '事件数(件)' },
-  { imgurl: jscb, num: 1314, text: '节省成本(万元)' },
-  { imgurl: rwcg, num: 1314, text: '任务成果(个)' },
-  { imgurl: fxlc, num: 1314, text: '飞行里程(公里)' },
-  { imgurl: fxsc, num: 1314, text: '飞行时长' },
-]);
+const store = useStore();
 
-// 获取机巢统计数据
-const getMachineData = () => {
-  let dockSn = ref('4TADKCM0010016');
-  getFlightStatistics(dockSn.value).then(res => {
-    if (res.data.code !== 0) return;
-    const result = res.data.data;
-    statisticsList.value[0].num = result.fly_count || 0;
-    statisticsList.value[1].num = result.event_count || 0;
-    statisticsList.value[2].num = result.total_cost_saved || 0;
-    statisticsList.value[3].num = result.achievement_count || 0;
-    statisticsList.value[4].num = result.flight_mileage || 0;
-    statisticsList.value[5].num = `${result.hour_count}:${result.min_count}` || 0;
-  })
-};
+const statisticsList = ref([]);
 
-onMounted(() => {
-  getMachineData();
-});
+// 添加监听
+watch(
+  () => store.state.home.singleTotal,
+  (newValue) => {
+    if (!newValue) return;
+    statisticsList.value = [
+      { imgurl: rwcs, num: newValue.fly_count || 0, text: '任务次数(次)' },
+      { imgurl: sjs, num: newValue.event_count || 0, text: '事件数(件)' },
+      { imgurl: jscb, num: newValue.total_cost_saved || 0, text: '节省成本(万元)' },
+      { imgurl: rwcg, num: newValue.achievement_count || 0, text: '任务成果(个)' },
+      { imgurl: fxlc, num: newValue.flight_mileage || 0, text: '飞行里程(公里)' },
+      { imgurl: fxsc, num: newValue.hour_count || 0, text: '飞行时长(H)' }
+    ];
+  },
+  { immediate: true, deep: true }
+);
 </script>
 
 <style lang="scss" scoped>

--
Gitblit v1.9.3