From 02b71619de0c3b33e73218575a7226c770d2e2e5 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Wed, 13 Mar 2024 18:04:19 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81=E7=BB=88=E6=96=AD?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=BF=AB=E6=8D=B7=E5=91=BD=E4=BB=A4=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ops/Job/QuickJob.vue | 39 ++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/views/ops/Job/QuickJob.vue b/src/views/ops/Job/QuickJob.vue index b320172af..cc9a7a246 100644 --- a/src/views/ops/Job/QuickJob.vue +++ b/src/views/ops/Job/QuickJob.vue @@ -57,7 +57,7 @@ import Page from '@/layout/components/Page' import AdhocOpenDialog from '@/views/ops/Job/AdhocOpenDialog' import AdhocSaveDialog from '@/views/ops/Job/AdhocSaveDialog' import VariableHelpDialog from '@/views/ops/Job/VariableHelpDialog' -import { createJob, getJob, getTaskDetail } from '@/api/ops' +import { createJob, StopJob, getJob, getTaskDetail } from '@/api/ops' export default { name: 'CommandExecution', @@ -110,6 +110,20 @@ export default { this.execute() } }, + stop: { + type: 'button', + name: this.$t('common.Stop'), + align: 'left', + icon: 'fa fa-stop', + tip: this.$t('ops.StopJob'), + disabled: true, + el: { + type: 'danger' + }, + callback: () => { + this.stop() + } + }, runas: { type: 'input', name: this.$t('ops.runAs'), @@ -343,9 +357,6 @@ export default { switch (event) { case 'end': setTimeout(() => { - clearInterval(this.executionInfo.cancel) - this.toolbar.left.run.icon = 'fa fa-play' - this.toolbar.left.run.disabled = false this.getTaskStatus() }, 500) break @@ -356,6 +367,7 @@ export default { getTaskStatus() { getTaskDetail(this.currentTaskId).then(data => { this.executionInfo.status = data['status'] + this.setBtn() }) }, wrapperError(msg) { @@ -434,7 +446,26 @@ export default { this.$router.replace({ query: { taskId: this.currentTaskId }}) this.setCostTimeInterval() this.writeExecutionOutput() + this.setBtn() }) + }, + stop() { + StopJob({ task_id: this.currentTaskId }).then(() => { + this.xterm.write(this.wrapperError('Task has been canceled')) + this.getTaskStatus() + }).catch((e) => { + console.log(e) + }).finally(() => { + this.setBtn() + }) + }, + setBtn() { + if (this.executionInfo.status !== 'running') { + clearInterval(this.executionInfo.cancel) + this.toolbar.left.run.icon = 'fa fa-play' + } + this.toolbar.left.run.disabled = this.executionInfo.status === 'running' + this.toolbar.left.stop.disabled = this.executionInfo.status !== 'running' } } }