From 47759b90e17dd64c9bb11bf85581c0e687aee0ab Mon Sep 17 00:00:00 2001
From: fit2-zhao <yong.zhao@fit2cloud.com>
Date: Tue, 28 Dec 2021 14:40:00 +0800
Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?=
 =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E6=AD=A5=E9=AA=A4=E6=89=A7?=
 =?UTF-8?q?=E8=A1=8C=E7=BB=93=E6=9E=9C=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0?=
 =?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

--bug=1009281 --user=璧靛媷 [github#8902]鎺ュ彛鑷姩鍖栦腑閮ㄥ垎寮曠敤鍦烘櫙浼氬瓨鍦ㄦ墽琛屽悗鏃犳墽琛岃褰� https://www.tapd.cn/55049933/s/1087601
---
 .../automation/scenario/EditApiScenario.vue   | 38 ++++++++++---------
 .../component/ApiScenarioComponent.vue        | 32 ++++++++--------
 2 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
index f991fde07..9eed0f01c 100644
--- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
+++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
@@ -627,25 +627,27 @@ export default {
       });
     },
     stop() {
-      let url = "/api/automation/stop/" + this.reportId;
-      this.$get(url, response => {
-        this.debugLoading = false;
-        try {
-          if (this.websocket) {
-            this.websocket.close();
-          }
-          if (this.messageWebSocket) {
-            this.messageWebSocket.close();
-          }
-          this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
-          this.clearDebug();
-          this.$success(this.$t('report.test_stop_success'));
-          this.showHide();
-        } catch (e) {
+      if (this.reportId) {
+        let url = "/api/automation/stop/" + this.reportId;
+        this.$get(url, response => {
           this.debugLoading = false;
-        }
-      });
-      this.runScenario = undefined;
+          try {
+            if (this.websocket) {
+              this.websocket.close();
+            }
+            if (this.messageWebSocket) {
+              this.messageWebSocket.close();
+            }
+            this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
+            this.clearDebug();
+            this.$success(this.$t('report.test_stop_success'));
+            this.showHide();
+          } catch (e) {
+            this.debugLoading = false;
+          }
+        });
+        this.runScenario = undefined;
+      }
     },
     clearDebug() {
       this.reqError = 0;
diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue
index 979ab07b9..fee93eded 100644
--- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue
+++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue
@@ -22,7 +22,7 @@
           <i class="el-icon-warning"/>
         </el-tooltip>
       </span>
-      <span v-xpack v-if="scenario.versionEnable">{{$t('project.version.name')}}: {{ scenario.versionName }}</span>
+      <span v-xpack v-if="scenario.versionEnable">{{ $t('project.version.name') }}: {{ scenario.versionName }}</span>
     </template>
 
     <template v-slot:behindHeaderLeft>
@@ -104,7 +104,7 @@ export default {
     },
   },
   created() {
-    if(this.scenario.num){
+    if (this.scenario.num) {
       this.isShowNum = true;
     }
     if (!this.scenario.projectId) {
@@ -127,7 +127,7 @@ export default {
           if (this.scenario.hashTree) {
             this.setDisabled(this.scenario.hashTree, this.scenario.projectId);
           }
-          if(response.data.num){
+          if (response.data.num) {
             this.scenario.num = response.data.num;
             this.getWorkspaceId(response.data.projectId);
           }
@@ -140,11 +140,10 @@ export default {
           this.$emit('refReload');
         }
       })
-    }
-    else if(this.scenario.id && (this.scenario.referenced === 'Copy'||this.scenario.referenced === 'Created') && !this.scenario.loaded){
+    } else if (this.scenario.id && (this.scenario.referenced === 'Copy' || this.scenario.referenced === 'Created') && !this.scenario.loaded) {
       this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
         if (response.data) {
-          if(response.data.num){
+          if (response.data.num) {
             this.scenario.num = response.data.num;
             this.getWorkspaceId(response.data.projectId);
           } else {
@@ -163,8 +162,8 @@ export default {
     return {
       loading: false,
       isShowInput: false,
-      isShowNum:false,
-      isSameSpace:true
+      isShowNum: false,
+      isSameSpace: true
     }
   },
   computed: {
@@ -181,7 +180,9 @@ export default {
   methods: {
     run() {
       this.scenario.run = true;
-      this.$emit('runScenario', this.scenario);
+      let runScenario = JSON.parse(JSON.stringify(this.scenario));
+      runScenario.hashTree = [this.scenario];
+      this.$emit('runScenario', runScenario);
     },
     stop() {
       this.scenario.run = false;
@@ -284,16 +285,16 @@ export default {
     clickResource(resource) {
       let automationData = this.$router.resolve({
         name: 'ApiAutomation',
-        params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id,projectId:resource.projectId}
+        params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId}
       });
       window.open(automationData.href, '_blank');
     },
-    getWorkspaceId(projectId){
+    getWorkspaceId(projectId) {
       this.$get("/project/get/" + projectId, response => {
-        if(response.data){
-          if(response.data.workspaceId===getCurrentWorkspaceId()){
+        if (response.data) {
+          if (response.data.workspaceId === getCurrentWorkspaceId()) {
             this.isShowNum = true;
-          }else {
+          } else {
             this.isSameSpace = false;
           }
         }
@@ -363,7 +364,8 @@ export default {
 .ms-test-running {
   color: #6D317C;
 }
-.ms-num{
+
+.ms-num {
   margin-left: 1rem;
   font-size: 15px;
   color: #de9d1c;
-- 
GitLab