deepsea 1 рік тому
батько
коміт
00d1589dec

+ 4 - 2
src/components/TabList/index.vue

@@ -263,9 +263,10 @@
                 <el-table-column label="name" prop="name" width="180"></el-table-column>
                 <el-table-column label="status">
                   <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 == 'ready' || scope.row.status == 'valid' || scope.row.status == null || !scope.row.status" style="background: #7BAF66;" class="bench-status">{{ 'ready' }}</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>
+                    <div v-if="scope.row.status == 'error'" style="background: #f96262;" class="bench-status">{{ scope.row.status }}</div>
+                    <div v-if="scope.row.status != 'running' && scope.row.status != 'ready' && scope.row.status != 'waiting' && scope.row.status != 'valid' && scope.row.status != 'error' && !!scope.row.status" style="background: #92949B;" class="bench-status">{{ scope.row.status }}</div>
                   </template>
                 </el-table-column>
               </el-table>
@@ -758,6 +759,7 @@ export default {
         custom_agent_id: this.multipleSelection,
       };
       data.planId = this.currentPlanId;
+      data.planName = this.currentPlanName;
       this.$store.dispatch("caseList/startPlan", data);
       this.clickBackToAutoCaseList();
     },

+ 6 - 4
src/store/modules/case/actions.js

@@ -20,7 +20,7 @@ export default {
         let getAutoPlanStatusParam = {
           name: data.planName,
           currentPage: 1,
-          pageSize: 20,
+          pageSize: 200,
         };
         caseApi.getAutoPlanStatus(getAutoPlanStatusParam).then((res) => {
           let rows = res.data.rows;
@@ -72,14 +72,16 @@ export default {
       const result = await caseApi.startPlan(data.data);
       commit('setAutoStatus', {
         id: data.planId,
+        name: data.planName,
         res: result
       })
     }catch(e) {
 
     }
   },
-  async cancelPlan({commit}, data) {
-    const result = caseApi.cancelPlan(data)
+  async cancelPlan({commit, state}) {
+    debugger
+    const result = caseApi.cancelPlan(state.currentTaskIndex)
     commit('cancelPlan')
   },
   setCurrentTask({commit}, id) {
@@ -90,7 +92,7 @@ export default {
       let getAutoPlanStatusParam = {
         name: data.planName,
         currentPage: 1,
-        pageSize: 20,
+        pageSize: 200,
       };
       caseApi.getAutoPlanStatus(getAutoPlanStatusParam).then((res) => {
         let rows = res.data.rows;

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

@@ -6,6 +6,7 @@ export default {
   namespaced: true,
   state() {
     let map = {}
+    let map1 = {}
     let autoTaskStatusMap = {}
     if (localStorage.getItem("autoCurrentTaskData")) {
       map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
@@ -13,9 +14,13 @@ export default {
         autoTaskStatusMap[key] = 'ready'
       }
     }
+    if (localStorage.getItem("autoCurrentTaskName")) {
+      map1 = JSON.parse(localStorage.getItem("autoCurrentTaskName"))
+    }
     return {
       autoCaseList: [],
       autoCaseListMap: {},
+      autoTaskNameMap: map1,
       caseList: [],
       caseListMap: [],
       autoTaskStatus: 'ready',

+ 12 - 8
src/store/modules/case/mutations.js

@@ -82,14 +82,18 @@ export default {
   setAutoStatus(state, data) {
     // state.autoTaskSubmitLoading = false;
     debugger
-    state.autoTaskStatus = data.res.data.result;
-    state.autoTaskStatusMap[data.id] = data.res.data.result;
+    state.autoTaskStatus = data.res.data.result == 'SUCCESS' ? 'running': data.res.data.result;
+    // state.autoTaskStatusMap[data.id] = data.res.data.result == 'SUCCESS' ? 'running': data.res.data.result;
     state.planExecId = data.res.data.info[0];
     state.planExecIdMap[data.id] = data.res.data.info[0];
+    state.autoTaskNameMap[data.id] = data.name;
     localStorage.setItem("autoCurrentTaskData", JSON.stringify(state.planExecIdMap));
-    // state.autoCaseListMap[data.id].forEach(c => {
-    //   c.status = "running"
-    // })
+    localStorage.setItem("autoCurrentTaskName", JSON.stringify(state.autoTaskNameMap));
+    state.autoCaseListMap[data.id].forEach(c => {
+      if (!c.status) {
+        c.status = 'waiting'
+      }
+    })
   },
   setCurrentTask(state, id) {
     state.currentTaskIndex = id;
@@ -97,9 +101,9 @@ export default {
       state.autoCaseList = state.autoCaseListMap[id]
     }
   },
-  cancelPlan(state, res) {
+  cancelPlan(state) {
     state.autoTaskStatus = "stopped";
-    localStorage.removeItem("autoCurrentTaskData")
+    state.autoTaskStatusMap[state.currentTaskIndex] = "stopped";
   },
   setAllAutoPlanStatus(state, data) {
     let map = JSON.parse(localStorage.getItem("autoCurrentTaskData"))
@@ -137,7 +141,7 @@ export default {
     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;
+    // state.autoTaskStatusMap[data.info.planId] = data.res.data.detail.status;
     if (state.currentPlanId) {
       let cases = state.autoTaskItemsMap[state.currentPlanId];
       if (!cases) return;

+ 5 - 0
src/views/ordinaryPage/index.less

@@ -31,6 +31,11 @@
   background-color: #92949B;
 }
 
+.taskBtn.stopped {
+  background-image: none;
+  background-color: #F96262;
+}
+
 .process-percent {
   border-radius: 30px;
   background-color: #000;

+ 17 - 4
src/views/ordinaryPage/index.vue

@@ -473,6 +473,7 @@
             :isShowIssueDetail="isShowIssueDetail"
             :currentIssue="currentIssue"
             :currentPlanId="currentPlanId"
+            :currentPlanName="currentPlanName"
             :submitAutoCase="submitAutoCase"
             :clickBackToAutoCaseList="clickBackToAutoCaseList"
             :clickBackToIssueList="clickBackToIssueList"
@@ -609,6 +610,7 @@ export default {
       currentCase: null,
       currentIssue: null,
       currentPlanId: null,
+      currentPlanName: null,
       currentCaseIndex: 0,
       tabs: [
         {
@@ -1021,10 +1023,22 @@ export default {
     {
       this.autoPlanResultInterval = setInterval(() => {
         let autoCurrentTaskData = window.localStorage.getItem("autoCurrentTaskData");
+        let autoCurrentTaskName = window.localStorage.getItem("autoCurrentTaskName");
         autoCurrentTaskData = JSON.parse(autoCurrentTaskData);
+        autoCurrentTaskName = JSON.parse(autoCurrentTaskName);
         if (autoCurrentTaskData) {
           for (let planId in autoCurrentTaskData) {
             let planExecId = autoCurrentTaskData[planId];
+            if (autoCurrentTaskName) {
+              let planName = autoCurrentTaskName[planId];
+              if (planName) {
+                this.$store.dispatch("caseList/fetchAutoCaseList", {
+                  planId: planId,
+                  planName: planName
+                });
+              }
+            }
+            
             this.$store.dispatch("caseList/setPlanExecId", planExecId);
             this.$store.dispatch('caseList/getAutoPlanResult',{planId, planExecId});
           }
@@ -1097,10 +1111,7 @@ export default {
     },
     submitAutoCase() {
       if (this.autoTaskStatus == 'waiting' || this.autoTaskStatus == 'running') {
-        let plan = JSON.parse(localStorage.getItem('autoCurrentTaskData'))
-        let planId = plan.id || 0;
-        this.$store.dispatch('caseList/cancelPlan', planId);
-        clearInterval(this.autoPlanResultInterval)
+        this.$store.dispatch('caseList/cancelPlan');
         this.clickBackToTaskList()
         this.isShowAutoCaseList = false;
         return
@@ -1117,6 +1128,7 @@ export default {
       debugger
       if (!auto || auto == "undefined" || auto == "false") {
         this.currentPlanId = id;
+        this.currentPlanName = name;
         this.$store.dispatch("caseList/fetchCaseList", {
           uuid: id,
           page_num: 1,
@@ -1128,6 +1140,7 @@ export default {
       } else {
         if (id == 109) id = 222;
         this.currentPlanId = id;
+        this.currentPlanName = name;
         this.$store.dispatch("caseList/setCurrentPlanId", id);
         this.$store.dispatch("caseList/fetchAutoCaseList", {
           planId: id,