From 8e3504b57fef7b1eda8b75ca8aca67bee3b200dc Mon Sep 17 00:00:00 2001
From: 钟日健 <5689795+arsn@user.noreply.gitee.com>
Date: Fri, 18 Mar 2022 10:19:44 +0800
Subject: [PATCH] 定时任务新增立即执行,恢复,暂停
---
deploy/deploy.yml | 2
src/views/system/quartz.vue | 282 ++++++++++++++++++++++++++++++++++------------
src/api/system/quartz.js | 21 +++
3 files changed, 231 insertions(+), 74 deletions(-)
diff --git a/deploy/deploy.yml b/deploy/deploy.yml
index a1a6d41..cd678be 100644
--- a/deploy/deploy.yml
+++ b/deploy/deploy.yml
@@ -25,7 +25,7 @@
- name: aliyun #提前在项目下配置访问阿里云的账号密码
containers:
# - image: $REGISTRY/$ALIYUNHUB_NAMESPACE/zhba-vue:SNAPSHOT-$BUILD_NUMBER
- - image: registry.cn-hangzhou.aliyuncs.com/arsn/zhba-vue:SNAPSHOT-6
+ - image: registry.cn-hangzhou.aliyuncs.com/arsn/zhba-vue:SNAPSHOT-7
imagePullPolicy: Always
name: app
ports:
diff --git a/src/api/system/quartz.js b/src/api/system/quartz.js
index 87d294d..a77facf 100644
--- a/src/api/system/quartz.js
+++ b/src/api/system/quartz.js
@@ -27,6 +27,27 @@
data: row
})
}
+export const activateQuartz = (row) => {
+ return request({
+ url: '/api/scheduled/activateQuartz',
+ method: 'post',
+ data: row
+ })
+}
+export const runQuartz = (row) => {
+ return request({
+ url: '/api/scheduled/runQuartz',
+ method: 'post',
+ data: row
+ })
+}
+export const stopQuartz = (row) => {
+ return request({
+ url: '/api/scheduled/stopQuartz',
+ method: 'post',
+ data: row
+ })
+}
export const remove = (ids) => {
return request({
diff --git a/src/views/system/quartz.vue b/src/views/system/quartz.vue
index ef46262..67c3130 100644
--- a/src/views/system/quartz.vue
+++ b/src/views/system/quartz.vue
@@ -44,6 +44,33 @@
>导出
</el-button>
</template>
+
+ <template slot-scope="{ type, size, row }" slot="menu">
+ <el-button
+ :size="size"
+ :type="type"
+ icon="el-icon-video-play"
+ v-if="permission.quartz_run"
+ @click="runQuartz(row)"
+ >立即执行
+ </el-button>
+ <el-button
+ :type="type"
+ :size="size"
+ v-if="permission.quartz_stop"
+ icon="el-icon-video-pause"
+ @click="stopQuartz(row)"
+ >暂停任务
+ </el-button>
+ <el-button
+ :type="type"
+ :size="size"
+ v-if="permission.quartz_activate"
+ icon="el-icon-refresh-left"
+ @click="activateQuartz(row)"
+ >恢复任务
+ </el-button>
+ </template>
</avue-crud>
</basic-container>
</template>
@@ -53,8 +80,11 @@
getList,
add,
update,
- remove
-} from "@/api/clock/clock";
+ remove,
+ stopQuartz,
+ runQuartz,
+ activateQuartz
+} from "@/api/system/quartz";
import { mapGetters } from "vuex";
import { getToken } from "@/util/auth";
import Qs from "qs";
@@ -80,109 +110,108 @@
searchSize: "mini",
searchMenuSpan: 6,
height: 583,
- menuWidth: 280,
+ menuWidth: 420,
border: true,
align: "center",
selection: true,
column: [
{
- label: "日期",
- prop: "releaseTimeRange",
- type: "datetime",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd",
- searchRange: true,
- hide: true,
- addDisplay: false,
- editDisplay: false,
- viewDisplay: false,
- search: true,
- searchSpan: 5,
- rules: [
- {
- required: true,
- message: "请输入申请时间",
- trigger: "blur"
- }
- ]
- },
- {
- label: "姓名",
- prop: "realName",
+ label: "任务名称",
+ prop: "name",
search: true,
searchSpan: 4,
labelWidth: 145,
- minWidth: 160,
+ width: 220,
span:12,
rules: [
{
required: true,
- message: "请输入姓名",
+ message: "请输入任务名称",
trigger: "click"
}
],
overHidden: true
},
-
{
- label: "打卡时间",
- prop: "clockTime",
- format: "yyyy-MM-dd HH:mm:ss",
- valueFormat: "yyyy-MM-dd HH:mm:ss",
- span: 12,
+ label: "方法名",
+ prop: "methodName",
+ search: true,
+ searchSpan: 4,
labelWidth: 145,
- disabled: false,
+ width: 110,
+ span:12,
rules: [
{
required: true,
- message: "请输入打卡时间",
- trigger: "blur"
- }
- ]
- },
- {
- label: "打卡类型",
- prop: "clockType",
- span: 12,
- labelWidth: 145,
- disabled: false,
- type: "select",
- dataType: "number",
- search:true,
- searchSpan:4,
- dicData:[
- {
- label:"上班",
- value:1
- },
- {
- label:"下班",
- value:2
+ message: "请输入方法名",
+ trigger: "click"
}
],
+ overHidden: true
+ },
+ {
+ label: "bean名称",
+ prop: "beanName",
+ search: true,
+ searchSpan: 4,
+ labelWidth: 145,
+ width: 110,
+ span:12,
rules: [
{
required: true,
- message: "请输入打卡类型",
- trigger: "blur"
+ message: "请输入bean名称",
+ trigger: "click"
}
- ]
+ ],
+ overHidden: true
+ },
+ {
+ label: "表达式",
+ prop: "cronExpression",
+ search: true,
+ searchSpan: 4,
+ labelWidth: 145,
+ width: 110,
+ span:12,
+ rules: [
+ {
+ required: true,
+ message: "请输入表达式",
+ trigger: "click"
+ }
+ ],
+ overHidden: true
+ },
+ {
+ label: "参数",
+ prop: "params",
+ labelWidth: 145,
+ width: 110,
+ span:12,
+ overHidden: true
},
{
label: "状态",
- prop: "attendanceType",
+ prop: "status",
span: 12,
labelWidth: 145,
disabled: false,
search:true,
searchSpan:4,
type: "select",
- dicUrl:
- "/api/blade-system/dict-biz/dictionary?code=attendanceType",
- props: {
- label: "dictValue",
- value: "dictKey"
- },
+ width:80,
+ display:false,
+ dicData:[
+ {
+ label:"正常",
+ value: 1
+ },
+ {
+ label:"暂停",
+ value: 2
+ }
+ ],
dataType: "number",
rules: [
{
@@ -191,7 +220,51 @@
trigger: "blur"
}
]
+ },
+ {
+ label: "创建时间",
+ prop: "createTime",
+ format: "yyyy-MM-dd HH:mm:ss",
+ valueFormat: "yyyy-MM-dd HH:mm:ss",
+ span: 12,
+ labelWidth: 145,
+ disabled: false,
+ width:140,
+ display:false,
+ rules: [
+ {
+ required: true,
+ message: "请输入创建时间",
+ trigger: "blur"
+ }
+ ]
},
+ {
+ label: "近一次执行时间",
+ prop: "activeTime",
+ format: "yyyy-MM-dd HH:mm:ss",
+ valueFormat: "yyyy-MM-dd HH:mm:ss",
+ span: 12,
+ labelWidth: 145,
+ disabled: false,
+ width:140,
+ display:false,
+ rules: [
+ {
+ required: true,
+ message: "请输入近一次执行时间",
+ trigger: "blur"
+ }
+ ]
+ },
+ {
+ label: "任务说明",
+ span: 24,
+ type: "textarea",
+ labelWidth: 145,
+ prop: "remark"
+ }
+
],
...this.$store.state.control.clearOtherBut
}
@@ -203,10 +276,10 @@
...mapGetters(["userInfo", "permission"]),
permissionList() {
return {
- addBtn: this.vaildData(this.permission.clock_add, false),
- viewBtn: this.vaildData(this.permission.clock_view, false),
- delBtn: this.vaildData(this.permission.clock_delete, false),
- editBtn: this.vaildData(this.permission.clock_edit, false)
+ addBtn: this.vaildData(this.permission.quartz_add, false),
+ viewBtn: this.vaildData(null, false),
+ delBtn: this.vaildData(this.permission.quartz_delete, false),
+ editBtn: this.vaildData(this.permission.quartz_edit, false)
};
},
ids() {
@@ -232,6 +305,7 @@
this.onLoad(this.page, this.query);
},
rowSave(form, done, loading) {
+ form['status'] = 1;
add(form).then(res => {
if (res.data.success) {
this.$message({
@@ -285,7 +359,6 @@
}
)
.then(() => {
- console.log(row);
return remove(row.id);
})
.then(() => {
@@ -296,6 +369,69 @@
});
});
},
+ //任务恢复
+ activateQuartz(row) {
+ this.$confirm(
+ "确定恢复当前任务?",
+ {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ }
+ )
+ .then(() => {
+ return activateQuartz(row);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ });
+ },
+ //立即执行任务,不会改变任务状态,只执行一次
+ runQuartz(row) {
+ this.$confirm(
+ "确定立即执行当前任务?",
+ {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ }
+ )
+ .then(() => {
+ return runQuartz(row);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ });
+ },
+ //停止任务
+ stopQuartz(row) {
+ this.$confirm(
+ "确定停止当前任务?",
+ {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ }
+ )
+ .then(() => {
+ return stopQuartz(row);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ });
+ },
selectionChange(list) {
this.selectionList = list;
},
--
Gitblit v1.9.3