deepsea 11 months ago
parent
commit
0e7b2ca0bb

+ 10 - 2
src/store/modules/case/index.js

@@ -5,13 +5,21 @@ import mutations from "./mutations";
 export default {
   namespaced: true,
   state() {
+    let map = {}
+    let autoTaskStatusMap = {}
+    if (localStorage.getItem("autoCurrentTaskData")) {
+      map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
+      for (let key in map) {
+        autoTaskStatusMap[key] = 'ready'
+      }
+    }
     return {
       autoCaseList: [],
       caseList: [],
       autoTaskStatus: 'ready',
-      autoTaskStatusMap: {},
+      autoTaskStatusMap: autoTaskStatusMap,
       planExecId: 0,
-      planExecIdMap: {},
+      planExecIdMap: map,
       currentTaskIndex: 0,
       autoTaskItems: [],
       autoTaskItemsMap: {},

+ 49 - 17
src/store/modules/case/mutations.js

@@ -7,6 +7,9 @@ export default {
     });
   },
   setAutoCaseList(state, caseList) {
+    while(state.autoCaseList.length) {
+      state.autoCaseList.pop()
+    }
     caseList.forEach((caseA) => {
       if(!state.autoCaseList.some(p => p.id == caseA.id)) {
         state.autoCaseList.push(caseA)
@@ -14,17 +17,30 @@ export default {
     });
   },
   setAutoPlanStatus(state, rows) {
-    let obj = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
-    let planExecId = obj? obj.id : 0;
-    for (let i in rows) {
-      if (rows[i].id == planExecId) {
-        state.autoTaskStatus = rows[i].status;
-        break;
+    let map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
+    for(let key in map) {
+      let planExecId = map[key];
+      for (let i in res) {
+        if (res[i].id == planExecId) {
+          state.autoTaskStatus = res[i].status;
+          state.autoTaskStatusMap[key] = res[i].status;
+          break;
+        }
       }
-    }
-    state.autoCaseList.forEach(c => {
-      c.status = state.autoTaskStatus
-    })
+
+      if (state.currentPlanId) {
+        debugger
+        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);
+        })
+      }
+    }    
   },
   setPlanExecId(state, id) {
     state.planExecId = id
@@ -49,13 +65,28 @@ export default {
     localStorage.removeItem("autoCurrentTaskData")
   },
   setAllAutoPlanStatus(state, data) {
-    let obj = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
-    let planExecId = obj? obj.id : 0;
-    for (let i in data.res) {
-      if (data.res[i].id == planExecId) {
-        // state.autoTaskStatus = rows[i].status;
-        state.autoTaskStatusMap[data.id] = rows[i].status;
-        break;
+    debugger
+    let map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
+    for(let key in map) {
+      let planExecId = map[key];
+      for (let i in data.res) {
+        if (data.res[i].id == planExecId) {
+          state.autoTaskStatus = data.res[i].status;
+          state.autoTaskStatusMap[key] = data.res[i].status;
+          break;
+        }
+      }
+
+      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);
+        })
       }
     }
   },
@@ -73,6 +104,7 @@ export default {
     state.autoTaskStatusMap[data.info.planId] = data.res.data.detail.status;
     if (state.currentPlanId) {
       let cases = state.autoTaskItemsMap[state.currentPlanId];
+      if (!cases) return;
       cases.forEach(c => {
         let caseId = c.testcase_id;
         let caseTemp = state.autoCaseList.find(t => t.id == caseId);

+ 2 - 1
src/views/ordinaryPage/index.vue

@@ -1232,7 +1232,8 @@ export default {
           </div>`;
     },
     planRender(item) {
-      console.log(item, "plan");
+      console.log(item, "plan", this.autoTaskStatusMap[item.id]);
+      
       return `<div onClick="selectRowPlan('${item.uuid || item.id}', '${
         item.auto
       }', '${item.name}')" class="item-box" style="display:${