Explorar o código

bug 修复首屏加载时水滴状态和右上状态数量不一致问题

Jay hai 10 meses
pai
achega
b70991a2a8
Modificáronse 1 ficheiros con 17 adicións e 26 borrados
  1. 17 26
      src/views/ordinaryPage/index.vue

+ 17 - 26
src/views/ordinaryPage/index.vue

@@ -927,28 +927,30 @@ export default {
       ticket_type: 0,
     });
     window.bmMapItemActivate = this.bmMapItemActivate;
-    
+
     // 获取奥迪-台架列表
     this.$store.dispatch("benchList/fetchBenchList").then(() => {
       // 加载右侧台架照片
       this.getImageName();
-      // 更新台架各状态总台数
-      // this.refreshBenchStatus();
 
-      this.benchList.forEach( (item, index) => {
-        // 获取奥迪-各台架详情
-        this.$store.dispatch("benchList/getBenchDetail", item.id).then(() => {
-          // 获取全部台架信息后
-          if (this.benchList.length - 1 == index) {
-            // 更新台架各状态总台数
-            this.refreshBenchStatus(); 
-          }
+      // 获取奥迪-各台架详情
+      let pArr = [];
+      this.benchList.forEach((item, index) => {
+        let p = new Promise((resolve, reject) => {
+          this.$store.dispatch("benchList/getBenchDetail", item.id).then(() => {
+            // console.log(index)
+            resolve()
+          });
         })
+        pArr.push(p)
       });
-      // setTimeout(() => { // 请求异步原因,强制2秒后执行
-      //   console.log("各状态台架数量刷新时间:", Date.now());
-      //   this.refreshBenchStatus(); // 更新台架各状态总台数
-      // }, 1000);
+      // 获取全部台架信息后
+      Promise.all(pArr).then(()=>{
+        // console.log("台架详情已全部获取完成")
+        // 更新台架各状态总台数
+        this.refreshBenchStatus();
+      });
+
     });
   },
 
@@ -1002,17 +1004,6 @@ export default {
     // 调用定时器方法,返回定时器id,用于按条件清空
     that.timerId = that.myInterval((count) => {
       this.$store.dispatch("benchList/fetchBenchList").then(() => {
-        // this.refreshBenchStatus();
-        // if (!this.waterdotrefresh) {
-        //   this.waterdotrefresh = true;
-        //   window.getsqlData(window.sdkInstance, window.uwbInstance,true)
-        // }
-        // setTimeout(() => { // 请求异步原因,强制2秒后执行
-        //   console.log("各状态台架数量刷新时间:", Date.now());
-        //   this.refreshBenchStatus(); // 更新台架各状态总台数
-        //   window.getsqlDataRealTime();
-        // }, 1000);
-
         // 加载右侧台架照片
         this.getImageName();