deepsea 11 månader sedan
förälder
incheckning
5db33dffa9

+ 45 - 0
src/api/case.js

@@ -21,6 +21,14 @@ export const fetchCaseList = (data) => {
   });
 };
 
+export const getAutoPlanStatus = (param) => {
+  console.log('httpRequest-' + 'getAutoPlanStatus');
+  return api('/arbitrator/planExecList', { 
+      method: 'GET',
+      params: param 
+  });
+}
+
 export const fetchAutoCaseList = (planId) => {
   return api(`/plan/testcase/${planId}`, {
     method: "GET",
@@ -39,3 +47,40 @@ export const updateCase = (data) => {
     data,
   });
 };
+
+export const getPlanResult = (data) => {
+  console.log('httpRequest-' + 'getPlanResult');
+  return api('/execution/overView/testResultList',{
+      method: 'POST',
+      data
+  });
+}
+
+export const getAutoPlanDetail = (planId) => {
+return api('/plan/'+planId, {
+  method: 'GET'
+})
+}
+
+export const updateDmapCase = (data) => {
+console.log('httpRequest-' + 'updateDmapCase');
+return api('/mantis-test/v1.0.0/mantis/update/digital/map/case', {
+  method: 'POST',
+  data
+});
+}
+
+export const startPlan = (data) => {
+  console.log('httpRequest-' + 'startPlan');
+  return api('/arbitrator/start', {
+      method: 'POST',
+      data
+  });
+}
+
+export const cancelPlan = (param) => {
+  console.log('httpRequest-' + 'cancelPlan');
+  return api('/arbitrator/exec_queue/' + param + '/cancel',{
+      method: 'GET'
+  });
+}

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

@@ -263,13 +263,15 @@
                 <el-table-column label="name" prop="name"></el-table-column>
                 <el-table-column label="status">
                   <template slot-scope="scope">
-                    <span>{{scope.row.status }}</span>
+                    <div v-if="scope.row.status == 'ready'" style="background: #7BAF66;" class="bench-status">{{ scope.row.status }}</div>
+                    <div v-if="scope.row.status == 'running' || scope.row.status == 'waiting'" style="background: #eebe77;" class="bench-status">{{ scope.row.status }}</div>
+                    <div v-if="scope.row.status != 'running' && scope.row.status != 'ready' && scope.row.status != 'waiting'" style="background: #92949B;" class="bench-status">{{ scope.row.status }}</div>
                   </template>
                 </el-table-column>
               </el-table>
             </div>
-            <el-button @click="submitAutoCase" class="done-button"
-              >Done</el-button
+            <el-button @click="submitAutoCase" class="done-button" :class="autoTaskStatus"
+              >{{autoTaskStatus == 'ready' ? 'Done': (autoTaskStatus == 'waiting' || autoTaskStatus == 'running') ? 'Stop' : 'Done'}}</el-button
             >
           </div>
           <div
@@ -453,7 +455,11 @@
               <el-table-column label="Bench Name" prop="name" width="200">
               </el-table-column>
               <el-table-column label="Status" width="120">
-                <template slot-scope="scope">{{ scope.row.status }}</template>
+                <template slot-scope="scope">
+                  <div v-if="scope.row.status == 'ready'" style="background: #7BAF66;" class="bench-status">{{ scope.row.status }}</div>
+                  <div v-if="scope.row.status == 'running'" style="background: #eebe77;" class="bench-status">{{ scope.row.status }}</div>
+                  <div v-if="scope.row.status != 'running' && scope.row.status != 'ready'" style="background: #92949B;" class="bench-status">{{ scope.row.status }}</div>
+                </template>
               </el-table-column>
             </el-table>
             <el-button class="cancel-button" @click="clickBackToAutoCaseList"
@@ -654,6 +660,9 @@ export default {
       matchedBenchList(state) {
         return state.benchList.matchedBenchList;
       },
+      autoTaskStatus(state) {
+        return state.caseList.autoTaskStatus
+      }
     }),
   },
   updated() {
@@ -721,7 +730,7 @@ export default {
         match_agent_id: this.multipleSelection,
         custom_agent_id: this.multipleSelection,
       };
-      this.$store.dispatch("planList/startPlan", data);
+      this.$store.dispatch("caseList/startPlan", data);
       this.clickBackToAutoCaseList();
     },
     handleSelectionChange(val) {

+ 104 - 0
src/store/modules/case/actions.js

@@ -15,6 +15,22 @@ export default {
       const autoCaseList = await caseApi.fetchAutoCaseList(data.planId);
       console.log('autocaselist',autoCaseList.data)
       commit('setAutoCaseList', autoCaseList.data)
+      try{
+        let getAutoPlanStatusParam = {
+          name: data.planName,
+          currentPage: 1,
+          pageSize: 20,
+        };
+        caseApi.getAutoPlanStatus(getAutoPlanStatusParam).then((res) => {
+          let rows = res.data.rows;
+          commit('setAutoPlanStatus', rows);
+        })
+        .catch((err) => {
+          console.error(err);
+        }); 
+      } catch (e) {
+        
+      }
     } catch (err) {
       console.log("error", "服务异常", 1000);
     }
@@ -33,5 +49,93 @@ export default {
   },
   setBenchImgList({commit}, benchId, img) {
     commit(benchId, img)
+  },
+  setPlanExecId({commit}, id) {
+    commit('setPlanExecId', id)
+  },
+  async getAutoPlanResult({ commit }, info) {
+    let getPlanResultParam = {
+      planExecId: info.planId
+    };
+    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++;
+          }
+        }
+        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 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);
+              });
+          }
+        }
+      })
+      .catch((err) => {
+        console.error(err);
+      });
+    // autoPlanResult();
+  },
+  async startPlan({commit}, data) {
+    try {
+      const result = await caseApi.startPlan(data);
+      commit('setAutoStatus', result)
+    }catch(e) {
+
+    }
+  },
+  async cancelPlan({commit}, data) {
+    const result = caseApi.cancelPlan(data)
+    commit('cancelPlan')
+  },
+  setCurrentTask({commit}, id) {
+    commit('setCurrentTask', id)
   }
 };

+ 3 - 0
src/store/modules/case/getters.js

@@ -2,4 +2,7 @@ export default {
   getCaseList(state) {
     return state.caseList
   },
+  getAutoCaseList(state) {
+    return state.autoCaseList
+  }
 };

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

@@ -8,6 +8,9 @@ export default {
     return {
       autoCaseList: [],
       caseList: [],
+      autoTaskStatus: 'ready',
+      planExecId: 0,
+      currentTaskIndex: 0
     };
   },
   getters,

+ 35 - 1
src/store/modules/case/mutations.js

@@ -7,11 +7,45 @@ export default {
     });
   },
   setAutoCaseList(state, caseList) {
-    debugger
     caseList.forEach((caseA) => {
       if(!state.autoCaseList.some(p => p.id == caseA.id)) {
         state.autoCaseList.push(caseA)
       }
     });
+  },
+  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;
+      }
+    }
+    state.autoCaseList.forEach(c => {
+      c.status = state.autoTaskStatus
+    })
+  },
+  setPlanExecId(state, id) {
+    state.planExecId = id
+  },
+  setAutoStatus(state, res) {
+    // state.autoTaskSubmitLoading = false;
+    state.autoTaskStatus = "running";
+    state.planExecId = res.data.info[0];
+    localStorage.setItem("autoCurrentTaskData", JSON.stringify({
+      index: state.currentTaskIndex,
+      id: state.planExecId,
+    }));
+    state.autoCaseList.forEach(c => {
+      c.status = "running"
+    })
+  },
+  setCurrentTask(state, id) {
+    state.currentTaskIndex = id
+  },
+  cancelPlan(state, res) {
+    state.autoTaskStatus = "ready";
+    localStorage.removeItem("autoCurrentTaskData")
   }
 };

+ 0 - 119
src/store/modules/plan/actions.js

@@ -18,16 +18,6 @@ export default {
       console.log("error", "服务异常", 1000);
     }
   },
-  async startPlan({commit}, data) {
-    try {
-      const result = await planApi.startPlan(data);
-      commit('setAutoPlanStatus', result)
-    }catch(e) {
-
-    }
-    
-    console.log('startPlanResult', result.data)
-  },
   async fetchPlanDetail({ commit }, data) {
     try {
       const detail = await planApi.getAutoPlanDetail(data.planId)
@@ -38,114 +28,5 @@ 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();
   }
 };

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

@@ -10,7 +10,6 @@ export default {
       tempPlanList: [],
       currentTaskIndex: 0,
       autoTaskSubmitLoading: false,
-      autoTaskStatus: 'ready',
       planExecId: 0
     };
   },

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

@@ -138,20 +138,5 @@ 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
   }
 };

+ 20 - 10
src/views/ordinaryPage/index.vue

@@ -791,6 +791,7 @@ export default {
       gridItems: [1, 2, 3, 4, 5, 6, 7, 8, 9],
       timerIdMap: { num: 0 },
       timerId: 0,
+      autoPlanResultInterval: 0
     };
   },
   computed: {
@@ -834,6 +835,9 @@ export default {
       issueList: (state) => {
         return state.issueList.issueList;
       },
+      autoTaskStatus: (state) => {
+        return state.caseList.autoTaskStatus
+      },
       filterBenchList: (state) => {
         return state.benchList.filterBenchList.sort((a, b) => {
           let i = 0;
@@ -1023,14 +1027,11 @@ export default {
     );
     autoCurrentTaskData = JSON.parse(autoCurrentTaskData);
     if (autoCurrentTaskData) {
-      this.$store.dispatch("planList/setPlanExecId", autoCurrentTaskData.id);
-      getAutoPlanResult(autoCurrentTaskData.index);
-      autoPlanResultInterval.value = setInterval(() => {
-        getAutoPlanResult(autoCurrentTaskData.index);
+      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});
       }, 15000);
-      // autoTaskMode.value = "Running";
-      autoTaskStatus.value = "running";
-      autoTaskStep.value = 3;
     }
   },
   methods: {
@@ -1097,6 +1098,15 @@ export default {
       }
     },
     submitAutoCase() {
+      debugger
+      if (this.autoTaskStatus == 'waiting' || this.autoTaskStatus == 'running') {
+        let plan = JSON.stringify(localStorage.getItem('autoCurrentTaskData'))
+        let planId = plan.id || 0;
+        this.$store.dispatch('caseList/cancelPlan', planId);
+        clearInterval(this.autoPlanResultInterval)
+        this.clickBackToTaskList()
+        return
+      }
       this.isShowAutoCaseList = false;
       this.isShowAutoCaseCommit = true;
     },
@@ -1115,16 +1125,16 @@ export default {
         });
         this.isShowCaseList = true;
         sessionStorage.setItem("autoCase", 0);
-        // currentTaskIndex.value = key;
-        this.$store.dispatch("planList/setCurrentTask", id);
+        this.$store.dispatch("caseList/setCurrentTask", id);
       } else {
         if (id == 109) id = 222;
         this.currentPlanId = id;
         this.$store.dispatch("caseList/fetchAutoCaseList", {
           planId: id,
+          planName: name
         });
         this.isShowAutoCaseList = true;
-        this.$store.dispatch("planList/setCurrentTask", id);
+        this.$store.dispatch("caseList/setCurrentTask", id);
         sessionStorage.setItem("autoCase", 1);
       }