lhh 6 months ago
parent
commit
96974337a6
1 changed files with 16 additions and 10 deletions
  1. 16 10
      src/views/IOTDataAnalysis/components/IOTLeft.vue

+ 16 - 10
src/views/IOTDataAnalysis/components/IOTLeft.vue

@@ -146,22 +146,26 @@ const getCount = (totalArr, num) => {
   return (num / total) * 100;
 };
 
-const getBasicsInfo = () => {
-  QueryBasicsInfo().then((res) => {
+const getBasicsInfo = async () => {
+  try {
+    let res = await QueryBasicsInfo();
     if (res?.data?.code == "200") {
       basicsInfo.totalDevices = res?.data?.data?.totalDevices || '';
       basicsInfo.onlineDevices = res?.data?.data?.onlineDevices || '';
       basicsInfo.offlineDevices = res?.data?.data?.offlineDevices || '';
       basicsInfo.onlineRate = res?.data?.data?.onlineRate || '';
+    }else{
+      console.log('QueryBasicsInfo返回数据有误')
     }
-  }).catch((error) => {
-    throw error
-  });
+  } catch (error) {
+    console.log(error)
+  }
 };
 
 //设备类型/设备分布数据
-const GetListEquipment = () => {
-  QueryListEquipment().then((res) => {
+const GetListEquipment = async () => {
+  try {
+    let res = await QueryListEquipment();
     if (res?.data?.code == "200") {
       const data = res?.data?.data;
       const typeObj = {};
@@ -185,10 +189,12 @@ const GetListEquipment = () => {
       });
       equipmentData.value = Object.values(typeObj);
       console.log("equipmentData", equipmentData);
+    }else{
+      console.log('QueryListEquipment返回值有误')
     }
-  }).catch(error => {
-    throw error
-  });
+  } catch (error) {
+    console.log(error)
+  }
 };
 
 //获取设备分布数据