deepsea il y a 1 an
Parent
commit
86934131f9
2 fichiers modifiés avec 31 ajouts et 14 suppressions
  1. 1 0
      src/store/modules/case/index.js
  2. 30 14
      src/store/modules/case/mutations.js

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

@@ -26,6 +26,7 @@ export default {
       autoTaskItems: [],
       autoTaskItemsMap: {},
       autoTaskPercentMap: {},
+      taskPercentMap: {},
       currentPlanId: 0
     };
   },

+ 30 - 14
src/store/modules/case/mutations.js

@@ -5,29 +5,45 @@ export default {
     while (state.caseListMap[uuid] && state.caseListMap[uuid].length) {
       state.caseListMap[uuid].pop();
     }
+
     caseList.forEach((caseA) => {
       if (!state.caseListMap[uuid]) {
         state.caseListMap[uuid] = []
       }
-      if(!state.caseListMap[uuid].some(p => p.case_no == caseA.case_no)) {
+      if (!state.caseListMap[uuid].some(p => p.case_no == caseA.case_no)) {
         state.caseListMap[uuid].push(caseA)
       }
     });
+    
     if (state.caseListMap[uuid] && state.caseListMap[uuid].length) {
       state.caseList = state.caseListMap[uuid];
     }
+
+    let length = state.caseList ? state.caseList.length : 0;
+    let finished = 0;
+    for (let i = 0; i < length; i++) {
+      if (
+        state.caseList[i].result == "pass" ||
+        state.caseList[i].result == "fail" ||
+        state.caseList[i].result == "tb"
+      ) {
+        finished++;
+      }
+    }
+    let rate = (finished / length) * 100;
+    state.autoTaskPercentMap[uuid] = rate;
   },
   setAutoCaseList(state, data) {
     let autoCaseList = data.autoCaseList;
     let planId = data.planId;
-    while(state.autoCaseListMap[planId] && state.autoCaseListMap[planId].length) {
+    while (state.autoCaseListMap[planId] && state.autoCaseListMap[planId].length) {
       state.autoCaseListMap[planId].pop()
     }
     autoCaseList.forEach((caseA) => {
       if (!state.autoCaseListMap[planId]) {
         state.autoCaseListMap[planId] = []
       }
-      if(!state.autoCaseListMap[planId].some(p => p.id == caseA.id)) {
+      if (!state.autoCaseListMap[planId].some(p => p.id == caseA.id)) {
         state.autoCaseListMap[planId].push(caseA)
       }
     });
@@ -37,7 +53,7 @@ export default {
   },
   setAutoPlanStatus(state, rows) {
     let map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
-    for(let key in map) {
+    for (let key in map) {
       let planExecId = map[key];
       for (let i in res) {
         if (res[i].id == planExecId) {
@@ -58,21 +74,22 @@ export default {
           // console.log('autoCaseList', state.autoCaseList);
         })
       }
-    }    
+    }
   },
   setPlanExecId(state, id) {
     state.planExecId = id
   },
   setAutoStatus(state, data) {
     // state.autoTaskSubmitLoading = false;
-    state.autoTaskStatus = "running";
-    state.autoTaskStatusMap[data.id] = "running";
+    debugger
+    state.autoTaskStatus = data.res.data.result;
+    state.autoTaskStatusMap[data.id] = data.res.data.result;
     state.planExecId = data.res.data.info[0];
     state.planExecIdMap[data.id] = data.res.data.info[0];
     localStorage.setItem("autoCurrentTaskData", JSON.stringify(state.planExecIdMap));
-    state.autoCaseListMap[data.id].forEach(c => {
-      c.status = "running"
-    })
+    // state.autoCaseListMap[data.id].forEach(c => {
+    //   c.status = "running"
+    // })
   },
   setCurrentTask(state, id) {
     state.currentTaskIndex = id;
@@ -81,12 +98,12 @@ export default {
     }
   },
   cancelPlan(state, res) {
-    state.autoTaskStatus = "ready";
+    state.autoTaskStatus = "stopped";
     localStorage.removeItem("autoCurrentTaskData")
   },
   setAllAutoPlanStatus(state, data) {
     let map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
-    for(let key in map) {
+    for (let key in map) {
       let planExecId = map[key];
       for (let i in data.res) {
         if (data.res[i].id == planExecId) {
@@ -129,8 +146,7 @@ export default {
         let caseTemp = state.autoCaseList.find(t => t.id == caseId);
         if (caseTemp) {
           caseTemp.status = c.status;
-          if(caseTemp.status == 'finished')
-          {
+          if (caseTemp.status == 'finished') {
             caseTemp.status = c.result;
           }
         }