fix(性能测试): 点击再次执行时查询时间状态检测

This commit is contained in:
Captain.B 2020-08-28 17:24:24 +08:00
parent 8298781148
commit c29dd93243
1 changed files with 13 additions and 4 deletions

View File

@ -142,6 +142,10 @@ export default {
} }
}, },
initReportTimeInfo() { initReportTimeInfo() {
if (this.status === 'Starting') {
this.clearData();
return;
}
if (this.reportId) { if (this.reportId) {
this.result = this.$get("/performance/report/content/report_time/" + this.reportId) this.result = this.$get("/performance/report/content/report_time/" + this.reportId)
.then(res => { .then(res => {
@ -155,7 +159,7 @@ export default {
} }
}).catch(() => { }).catch(() => {
this.clearData(); this.clearData();
}) });
} }
}, },
initWebSocket() { initWebSocket() {
@ -226,10 +230,15 @@ export default {
onMessage(e) { onMessage(e) {
this.$set(this.report, "refresh", e.data); // this.$set(this.report, "refresh", e.data); //
this.$set(this.report, "status", 'Running'); this.$set(this.report, "status", 'Running');
this.status = 'Running';
this.initReportTimeInfo(); this.initReportTimeInfo();
window.console.log('receive a message:', e.data); window.console.log('receive a message:', e.data);
}, },
onClose(e) { onClose(e) {
if (e.code === 1005) {
// socketreport
return;
}
this.$set(this.report, "refresh", Math.random()); // this.$set(this.report, "refresh", Math.random()); //
this.$set(this.report, "status", 'Completed'); this.$set(this.report, "status", 'Completed');
this.initReportTimeInfo(); this.initReportTimeInfo();
@ -262,9 +271,6 @@ export default {
}); });
}, },
beforeDestroy() {
this.websocket.close() //websocket
},
watch: { watch: {
'$route'(to) { '$route'(to) {
if (to.name === "perReportView") { if (to.name === "perReportView") {
@ -295,6 +301,9 @@ export default {
}); });
} }
} else {
console.log("close socket.");
this.websocket.close() //websocket
} }
} }
} }