deepsea 1 year ago
parent
commit
1f32e971bf

+ 5 - 1
src/components/TabList/index.vue

@@ -261,7 +261,11 @@
               >
                 <el-table-column label="ID" prop="id"></el-table-column>
                 <el-table-column label="name" prop="name"></el-table-column>
-                <el-table-column label="status" prop="status"></el-table-column>
+                <el-table-column label="status">
+                  <template slot-scope="scope">
+                    <span>{{scope.row.status }}</span>
+                  </template>
+                </el-table-column>
               </el-table>
             </div>
             <el-button @click="submitAutoCase" class="done-button"

+ 116 - 1
src/store/modules/plan/actions.js

@@ -19,7 +19,13 @@ export default {
     }
   },
   async startPlan({commit}, data) {
-    const result = await planApi.startPlan(data);
+    try {
+      const result = await planApi.startPlan(data);
+      commit('setAutoPlanStatus', result)
+    }catch(e) {
+
+    }
+    
     console.log('startPlanResult', result.data)
   },
   async fetchPlanDetail({ commit }, data) {
@@ -32,5 +38,114 @@ export default {
   },
   clearPlanList({commit}) {
     commit('clearPlanList')
+  },
+  setCurrentTask({commit}, id) {
+    commit('setCurrentTask', id)
+  },
+  setPlanExecId({commit}, id) {
+    commit('setPlanExecId', id)
+  },
+  async getAutoPlanStatus({ commit }, name) {
+    try{
+      let getAutoPlanStatusParam = {
+        name: name,
+        currentPage: 1,
+        pageSize: 20,
+      };
+      planApi.getAutoPlanStatus(getAutoPlanStatusParam).then((res) => {
+        let rows = res.data.rows;
+        for (let i in rows) {
+          if (rows[i].id == planExecId.value) {
+            autoTaskStatus.value = rows[i].status;
+            break;
+          }
+        }
+        console.log('autoTaskStatus.value', autoTaskStatus.value);
+        if (autoTaskStatus.value == "running" || autoTaskStatus.value == "waiting") {
+          // activeAutoTab.value = 1;
+          autoTaskStep.value = 3;
+        } else {
+          // activeAutoTab.value = 2;
+          autoTaskStep.value = 1;
+        }
+      })
+      .catch((err) => {
+        logResultSubmitLoading.value = false;
+        console.error(err);
+      }); 
+    } catch (e) {
+      
+    }
+  },
+  async getAutoPlanResult({ commit }, key) {
+    let getPlanResultParam = {
+      planExecId: state.planExecId,
+    };
+    planApi.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++;
+          }
+        }
+        autoTaskItems = res.data.list;
+        let rate = (finishedCaseNum / planCaseNum) * 100;
+        // console.log("rate", rate);
+        taskItems[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 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);
+            planApi
+              .updateDmapCase(updateAutoCaseParam)
+              .then((res) => {
+                // console.log("resUpdateAutoCase", res);
+              })
+              .catch((err) => {
+                console.error(err);
+              });
+          }
+        }
+      })
+      .catch((err) => {
+        autoTaskSubmitLoading.value = false;
+        console.error(err);
+      });
+    // autoPlanResult();
   }
 };

+ 5 - 1
src/store/modules/plan/index.js

@@ -7,7 +7,11 @@ export default {
     return {
       planList: [],
       autoPlanList: [],
-      tempPlanList: []
+      tempPlanList: [],
+      currentTaskIndex: 0,
+      autoTaskSubmitLoading: false,
+      autoTaskStatus: 'ready',
+      planExecId: 0
     };
   },
   mutations,

+ 15 - 0
src/store/modules/plan/mutations.js

@@ -138,5 +138,20 @@ export default {
       }
       state.planList.push(t)
     }
+  },
+  setCurrentTask(state, id) {
+    state.currentTaskIndex = id
+  },
+  setAutoPlanStatus(state, res) {
+    state.autoTaskSubmitLoading = false;
+    state.autoTaskStatus = "running";
+    state.planExecId = res.data.info[0];
+    localStorage.set("autoCurrentTaskData", {
+      index: state.currentTaskIndex,
+      id: state.planExecId,
+    });
+  },
+  setPlanExecId(state, id) {
+    state.planExecId = id
   }
 };

+ 19 - 0
src/views/ordinaryPage/index.vue

@@ -977,6 +977,19 @@ export default {
       this.isConnected = false;
       this.$store.dispatch("common/setSquareStatus", false);
     })
+
+    let autoCurrentTaskData = localStorage.get("autoCurrentTaskData");
+    autoCurrentTaskData = JSON.parse(autoCurrentTaskData)
+    if (autoCurrentTaskData) {
+      this.$store.dispatch("planList/setPlanExecId", autoCurrentTaskData.id)
+      getAutoPlanResult(autoCurrentTaskData.index);
+      autoPlanResultInterval.value = setInterval(() => {
+        getAutoPlanResult(autoCurrentTaskData.index);
+      }, 15000);
+      // autoTaskMode.value = "Running";
+      autoTaskStatus.value = "running";
+      autoTaskStep.value = 3;
+    }
   },
   methods: {
     turnToNextManualCase() {},
@@ -1025,6 +1038,8 @@ export default {
         });
         this.isShowCaseList = true;
         sessionStorage.setItem("autoCase", 0);
+        // currentTaskIndex.value = key;
+        this.$store.dispatch("planList/setCurrentTask", id);
       } else {
         if (id == 109) id = 222;
         this.currentPlanId = id;
@@ -1032,6 +1047,7 @@ export default {
           planId: id,
         });
         this.isShowAutoCaseList = true;
+        this.$store.dispatch("planList/setCurrentTask", id);
         sessionStorage.setItem("autoCase", 1);
       }
 
@@ -2447,6 +2463,9 @@ export default {
         }
       }
     },
+    getAutoPlanResult(key) {
+      
+    }
   },
   watch: {
     benchDisplayVisible(newValue, oldValue) {