From 6a4254ee140fa16d922db221ddf06e66c2164057 Mon Sep 17 00:00:00 2001
From: yangyin <1850366751@qq.com>
Date: 星期五, 14 七月 2023 11:48:17 +0800
Subject: [PATCH] 提交代码

---
 src/views/HomeView.vue |   58 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index b913d58..e5b0021 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -116,6 +116,7 @@
 import * as echarts from "echarts"; //寮曞叆echarts
 import axios from "axios";
 import { useRouter } from "vue-router";
+import { showLoadingToast, showFailToast, allowMultipleToast } from "vant";
 const router = useRouter();
 const pointName = ref("");
 const myChart = shallowRef(null);
@@ -154,16 +155,27 @@
   isOnTapInterval: false,
   monitorList: [],
   c_monitorList: [],
-  // PointID: "1620681990539972608",
   PointID: "",
-  // token:
-  //   "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOjEsIkxvZ2luTmFtZSI6Inl3YWRtaW4iLCJMb2dpblB3ZCI6ImFkbWluIiwiQ29ycElEIjoxLCJJc0FkbWluIjp0cnVlLCJpYXQiOjE2ODkyMTg3NzEsIm5iZiI6MTY4OTIxODc3MSwiZXhwIjoxNjg5MzA1MTcxLCJpc3MiOiJpc3RhdGlvbiIsImF1ZCI6ImlzdGF0aW9uIn0.cUxpJbn8krlTpaHkmd_nTgzc6YQzPxBn6pCJ0mFHAS8",
+  CorpID: "",
   token: "",
 });
 onMounted(() => {
-  // console.log(router.currentRoute.value.query, 162);
   state.PointID = router.currentRoute.value.query.PointID;
   state.token = router.currentRoute.value.query.Token;
+  state.CorpID = router.currentRoute.value.query.CorpID;
+  allowMultipleToast();
+  if (state.token == "") {
+    showFailToast("token鏃犳晥,璇烽噸璇�");
+    return;
+  }
+  if (state.PointID == "") {
+    showFailToast("娴嬬偣ID闇�瑕�>0,璇烽噸璇�");
+    return;
+  }
+  if (state.CorpID == undefined || state.CorpID == "") {
+    showFailToast("CorpID闇�瑕�>0,璇烽噸璇�");
+    return;
+  }
   state.currentRecordParas.RecordTime = moment().format("YYYY-MM-DD");
   initialRealTimeRecord();
   getRecordDetail();
@@ -192,7 +204,7 @@
       Authorization: `Bearer ${state.token}`,
     },
     params: {
-      CorpID: 14,
+      CorpID: state.CorpID,
       MonitorPointID: state.PointID,
     },
   })
@@ -250,6 +262,10 @@
 };
 //鍒濆鍖栬幏鍙栨暟鎹�
 const initialRealTimeRecord = () => {
+  let loading = showLoadingToast({
+    message: "鍔犺浇涓�...",
+    forbidClick: true,
+  });
   axios({
     url: "http://47.101.141.88:9019/Run/MonitorRealRecord/Mobile/GetByMonitorPointIDOfDay@V1.0",
     method: "GET",
@@ -257,12 +273,13 @@
       Authorization: `Bearer ${state.token}`,
     },
     params: {
-      CorpID: 14,
+      CorpID: state.CorpID,
       MonitorPointID: state.PointID,
       Day: state.currentRecordParas.RecordTime,
     },
   })
     .then((res) => {
+      loading.close();
       if (res.data.Code != 0) {
         return;
       }
@@ -276,27 +293,28 @@
         last_record.DataStatus
       );
       state.currentRecordParas.RecordValue = last_record.DataValue;
-      let m_MonitorList = data.map((item) => {
+      let m_MonitorList = [];
+      let monitor_List = [];
+      data.forEach((item) => {
         let totalState = DataStatusTextEmun(item.DataStatus);
-        return {
+        m_MonitorList.push({
           RecordTime: subTime(item.DataTime, 11, 16),
           RecordStatusText: totalState,
           RecordValue: item.DataValue,
-        };
+        });
       });
-      let monitor_List = data.map((item) => {
+      data.forEach((item) => {
         let normalState = DataStatusTextEmun(item.DataStatus);
         if (normalState == "姝e父") {
-          return {
+          monitor_List.push({
             RecordTime: subTime(item.DataTime, 11, 16),
             RecordStatusText: normalState,
             RecordValue: item.DataValue,
-          };
+          });
         }
       });
       state.monitorList = m_MonitorList; //婧愭暟鎹�
       state.c_monitorList = monitor_List.reverse(); //鍒囨崲鏁版嵁
-
       setTimeout(() => {
         drawBar();
       }, 200);
@@ -421,6 +439,10 @@
   myChart.value.clear();
   myChart.value.setOption(option, true);
   window.addEventListener("resize", selfAdaption);
+  if (times.value) {
+    // 鍒ゆ柇娓呴櫎
+    clearInterval(times.value);
+  }
   times.value = setInterval(countdown, 1000);
 };
 //  鑷�傚簲
@@ -440,7 +462,7 @@
       Authorization: `Bearer ${state.token}`,
     },
     params: {
-      CorpID: 14,
+      CorpID: state.CorpID,
       ID: state.PointID,
     },
   })
@@ -504,6 +526,9 @@
   }
   if (value[0] == "BJ") {
     text = "鎶ヨ";
+  }
+  if (value[0] == "BC") {
+    text = "姝e父";
   }
   return text;
 };
@@ -646,4 +671,9 @@
     box-shadow: 0 2px 6px 0 rgba(114, 124, 245, 0.5);
   }
 }
+.loading {
+  position: absolute;
+  padding-top: 75%;
+  padding-left: 45%;
+}
 </style>

--
Gitblit v1.9.3