deepsea 11 miesięcy temu
rodzic
commit
afe8d3f5d7

+ 5 - 60
src/store/modules/case/actions.js

@@ -54,70 +54,12 @@ export default {
     commit('setPlanExecId', id)
   },
   async getAutoPlanResult({ commit }, info) {
-    return;
     let getPlanResultParam = {
-      planExecId: info.planId
+      planExecId: String(info.planExecId)
     };
     caseApi.getPlanResult(getPlanResultParam)
       .then((res) => {
-        // autoTaskMode.value = "Bench Search";
-        let planCaseNum = res.data.list.length;
-        let finishedCaseNum = 0;
-        for (let i in res.data.list) {
-          if (res.data.list[i].status) {
-            finishedCaseNum++;
-          }
-        }
-        state.autoTaskItems = res.data.list;
-        let rate = (finishedCaseNum / planCaseNum) * 100;
-        // console.log("rate", rate);
-        taskItems[info.key].percentage = rate;
-
-        getAutoPlanStatus();
-        // console.log("taskItems.value", taskItems.value);
-        // console.log("taskItems.value[key]", taskItems.value[key]);
-        if (rate == 100) {
-          clearInterval(state.autoPlanResultInterval);
-          localStorage.remove("autoCurrentTaskData");
-
-          getAutoPlanStatus();
-
-          for (let i in state.autoTaskItems) {
-            let unique_id = "";
-            for (let j in taskItems.value[2].case) {
-              if (taskItems[2].case[j].title == autoTaskItems[i].caseName) {
-                unique_id = taskItems.value[2].case[j].unique_identifier;
-              }
-            }
-            let result = JSON.parse(
-              JSON.stringify(autoTaskItems[i].result)
-            );
-            if (result == "passed") {
-              result = "pass";
-            } else if (result == "failed") {
-              result = "fail";
-            }
-            let updateAutoCaseParam = {
-              comments: undefined,
-              issue_descr: undefined,
-              result: result,
-              sw: "e4245",
-              tb_type: undefined,
-              testing_carline: autoTaskItems[i].Carline,
-              testing_variant: autoTaskItems[i].Variant,
-              unique_identifier: unique_id,
-            };
-            console.log("updateAutoCaseParam", updateAutoCaseParam);
-            caseApi
-              .updateDmapCase(updateAutoCaseParam)
-              .then((res) => {
-                // console.log("resUpdateAutoCase", res);
-              })
-              .catch((err) => {
-                console.error(err);
-              });
-          }
-        }
+        commit('setAutoPlanResult', {info, res})
       })
       .catch((err) => {
         console.error(err);
@@ -163,5 +105,8 @@ export default {
     } catch (e) {
       
     }
+  },
+  setCurrentPlanId({commit}, planId) {
+    commit('setCurrentPlanId', planId)
   }
 };

+ 4 - 1
src/store/modules/case/index.js

@@ -13,7 +13,10 @@ export default {
       planExecId: 0,
       planExecIdMap: {},
       currentTaskIndex: 0,
-      autoTaskItems: []
+      autoTaskItems: [],
+      autoTaskItemsMap: {},
+      autoTaskPercentMap: {},
+      currentPlanId: 0
     };
   },
   getters,

+ 33 - 11
src/store/modules/case/mutations.js

@@ -35,10 +35,8 @@ export default {
     state.autoTaskStatusMap[data.id] = "running";
     state.planExecId = data.res.data.info[0];
     state.planExecIdMap[data.id] = data.res.data.info[0];
-    localStorage.setItem("autoCurrentTaskData", JSON.stringify({
-      index: state.currentTaskIndex,
-      id: state.planExecId,
-    }));
+    debugger
+    localStorage.setItem("autoCurrentTaskData", JSON.stringify(state.planExecIdMap));
     state.autoCaseList.forEach(c => {
       c.status = "running"
     })
@@ -60,12 +58,36 @@ export default {
         break;
       }
     }
-    // localStorage.setItem("autoCurrentTaskData", JSON.stringify({
-    //   index: state.currentTaskIndex,
-    //   id: state.planExecId,
-    // }));
-    // state.autoCaseList.forEach(c => {
-    //   c.status = "running"
-    // })
+  },
+  setAutoPlanResult(state, data) {
+    let planCaseNum = data.res.data.list.length;
+    let finishedCaseNum = 0;
+    for (let i in data.res.data.list) {
+      if (data.res.data.list[i].status) {
+        finishedCaseNum++;
+      }
+    }
+    state.autoTaskItemsMap[data.info.planId] = data.res.data.list;
+    let rate = (finishedCaseNum / planCaseNum) * 100;
+    state.autoTaskPercentMap[data.info.planId] = rate;
+    state.autoTaskStatusMap[data.info.planId] = data.res.data.detail.status;
+    if (state.currentPlanId) {
+      let cases = state.autoTaskItemsMap[state.currentPlanId];
+      cases.forEach(c => {
+        let caseId = c.testcase_id;
+        let caseTemp = state.autoCaseList.find(t => t.id == caseId);
+        if (caseTemp) {
+          caseTemp.status = c.status;
+        }
+        // console.log('autoCaseList', state.autoCaseList);
+      })
+    }
+    if (rate == 100) {
+      // clearInterval(state.autoPlanResultInterval);
+      // localStorage.remove("autoCurrentTaskData");
+    }
+  },
+  setCurrentPlanId(state, planId) {
+    state.currentPlanId = planId;
   }
 };

+ 13 - 8
src/views/ordinaryPage/index.vue

@@ -932,15 +932,19 @@ export default {
       this.$store.dispatch("common/setConnectedStatus", false);
     });
 
-    let autoCurrentTaskData = window.localStorage.getItem(
-      "autoCurrentTaskData"
-    );
-    autoCurrentTaskData = JSON.parse(autoCurrentTaskData);
-    if (autoCurrentTaskData) {
-      this.$store.dispatch("caseList/setPlanExecId", autoCurrentTaskData.id);
-      this.$store.dispatch('caseList/getAutoPlanResult',{planId: autoCurrentTaskData.id, key: autoCurrentTaskData.index});
+    
+    {
       this.autoPlanResultInterval = setInterval(() => {
-        this.$store.dispatch('caseList/getAutoPlanResult',{planId: autoCurrentTaskData.id, key: autoCurrentTaskData.index});
+        debugger
+        let autoCurrentTaskData = window.localStorage.getItem("autoCurrentTaskData");
+        autoCurrentTaskData = JSON.parse(autoCurrentTaskData);
+        if (autoCurrentTaskData) {
+          for (let planId in autoCurrentTaskData) {
+            let planExecId = autoCurrentTaskData[planId];
+            this.$store.dispatch("caseList/setPlanExecId", planExecId);
+            this.$store.dispatch('caseList/getAutoPlanResult',{planId, planExecId});
+          }
+        }
       }, 15000);
     }
   },
@@ -1039,6 +1043,7 @@ export default {
       } else {
         if (id == 109) id = 222;
         this.currentPlanId = id;
+        this.$store.dispatch("caseList/setCurrentPlanId", id);
         this.$store.dispatch("caseList/fetchAutoCaseList", {
           planId: id,
           planName: name