Browse Source

1. 新增立刻执行Quartz定时任务功能

Hccake 6 years ago
parent
commit
3548f7c9e6
2 changed files with 48 additions and 1 deletions
  1. 7 0
      src/api/daemon/sys-job.js
  2. 41 1
      src/views/daemon/job-manage/index.vue

+ 7 - 0
src/api/daemon/sys-job.js

@@ -44,6 +44,13 @@ export function startJobRa(jobId) {
   })
 }
 
+export function runJobRa(jobId) {
+  return request({
+    url: '/job/sys-job/run-job/' + jobId,
+    method: 'post'
+  })
+}
+
 export function shutDownJobRa(jobId) {
   return request({
     url: '/job/sys-job/shutdown-job/' + jobId,

+ 41 - 1
src/views/daemon/job-manage/index.vue

@@ -80,6 +80,7 @@
             icon="el-icon-caret-right"
             @click="handleStartJob(scope.row)">启动
           </el-button>
+
           <el-button
             v-if="permissions.job_sys_job_shutdown_job"
             type="text"
@@ -92,6 +93,12 @@
             icon="el-icon-edit"
             @click="handleUpdate(scope.row,scope.index)">修改
           </el-button>
+          <el-button
+            v-if="permissions.job_sys_job_run_job"
+            type="text"
+            icon="el-icon-s-promotion"
+            @click="handleRunJob(scope.row)">执行
+          </el-button>
           <el-button
             v-if="permissions.job_sys_job_del"
             type="text"
@@ -136,7 +143,8 @@ import {
   shutDownJobRa,
   shutdownJobsRa,
   startJobRa,
-  startJobsRa
+  startJobsRa,
+  runJobRa
 } from '@/api/daemon/sys-job'
 import { tableLogOption, tableOption } from '@/const/crud/daemon/sys-job'
 import { remote } from '@/api/admin/dict'
@@ -261,6 +269,38 @@ export default {
         })
       }
     },
+    /**
+     * 执行定时任务
+     */
+    handleRunJob(row) {
+      this.$confirm(
+        '立刻执行一次任务(任务名称:' + row.jobName + '), 是否继续?',
+        '提示',
+        {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }
+      ).then(() => {
+        runJobRa(row.jobId).then(response => {
+          const code = response.data.code
+          if (code === 0) {
+            this.$notify({
+              title: '成功',
+              message: '执行成功',
+              type: 'success'
+            })
+            this.refreshChange()
+          }
+        }).catch(() => {
+          this.$notify.error({
+            title: '错误',
+            message: '执行失败'
+          })
+        })
+      })
+
+    },
     /**
        * 新增定时任务
        */