任务新增执行SQL脚本&优化列表显示
This commit is contained in:
parent
5441962c37
commit
17c871d88f
@ -4,7 +4,7 @@ export function queryTasks(data) {
|
||||
return request({
|
||||
url: '/system/tasks/list',
|
||||
method: 'get',
|
||||
data
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
@ -16,9 +16,9 @@ export function getTasks(id) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 获取所有任务
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export function getAllTasks() {
|
||||
return request({
|
||||
@ -29,8 +29,8 @@ export function getAllTasks() {
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
* @param {*} data
|
||||
* @returns
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function createTasks(data) {
|
||||
return request({
|
||||
@ -42,8 +42,8 @@ export function createTasks(data) {
|
||||
|
||||
/**
|
||||
* 更新任务
|
||||
* @param {*} data
|
||||
* @returns
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function updateTasks(data) {
|
||||
return request({
|
||||
@ -55,8 +55,8 @@ export function updateTasks(data) {
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
* @param {*} id
|
||||
* @returns
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function deleteTasks(id) {
|
||||
return request({
|
||||
@ -67,8 +67,8 @@ export function deleteTasks(id) {
|
||||
|
||||
/**
|
||||
* 启动任务
|
||||
* @param {*} id
|
||||
* @returns
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function startTasks(id) {
|
||||
return request({
|
||||
@ -79,8 +79,8 @@ export function startTasks(id) {
|
||||
|
||||
/**
|
||||
* 停止任务
|
||||
* @param {*} id
|
||||
* @returns
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function stopTasks(id) {
|
||||
return request({
|
||||
@ -91,8 +91,8 @@ export function stopTasks(id) {
|
||||
|
||||
/**
|
||||
* 运行一次
|
||||
* @param {*} id
|
||||
* @returns
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function runTasks(id) {
|
||||
return request({
|
||||
@ -102,7 +102,7 @@ export function runTasks(id) {
|
||||
}
|
||||
/**
|
||||
* 导出
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export function exportTasks() {
|
||||
return request({
|
||||
@ -111,5 +111,4 @@ export function exportTasks() {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export default { queryTasks, getTasks, getAllTasks, createTasks, updateTasks, deleteTasks, startTasks, stopTasks, runTasks, exportTasks }
|
||||
|
||||
@ -1,24 +1,26 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-row v-if="searchToggle" :gutter="20">
|
||||
<el-col>
|
||||
<el-form :inline="true" @submit.prevent>
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model="queryParams.queryText"
|
||||
placeholder="请输入计划任务名称"
|
||||
clearable
|
||||
prefix-icon="el-icon-search"
|
||||
@keyup.enter="handleQuery"
|
||||
@clear="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleQuery">{{ $t('btn.search') }}</el-button>
|
||||
<el-button icon="refresh" @click="handleReset">{{ $t('btn.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form :model="queryParams" inline @submit.prevent ref="queryRef" v-show="searchToggle">
|
||||
<el-form-item prop="taskType">
|
||||
<el-select clearable v-model="queryParams.taskType" placeholder="请选择任务类型">
|
||||
<el-option v-for="item in options.taskTypeOptions" :key="item.dictValue" :label="item.dictLabel" :value="parseInt(item.dictValue)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="queryText">
|
||||
<el-input
|
||||
v-model="queryParams.queryText"
|
||||
placeholder="请输入计划任务名称"
|
||||
clearable
|
||||
prefix-icon="el-icon-search"
|
||||
@keyup.enter="handleQuery"
|
||||
@clear="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleQuery">{{ $t('btn.search') }}</el-button>
|
||||
<el-button icon="refresh" @click="handleReset">{{ $t('btn.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row class="mb8" :gutter="20">
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['monitor:job:add']" plain type="primary" icon="plus" @click="handleCreate">
|
||||
@ -35,26 +37,55 @@
|
||||
{{ $t('btn.log') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch="searchToggle" @queryTable="handleQuery"></right-toolbar>
|
||||
<right-toolbar :showSearch="searchToggle" :columns="columns" @queryTable="handleQuery"></right-toolbar>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-table ref="tasks" v-loading="loading" :data="dataTasks" border="" row-key="id" @sort-change="handleSortable">
|
||||
<el-table-column type="index" :index="handleIndexCalc" label="#" align="center" />
|
||||
<el-table-column prop="id" label="id" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('id')" />
|
||||
<el-table-column prop="name" label="任务名称" width="100" />
|
||||
<el-table-column prop="jobGroup" :show-overflow-tooltip="true" align="center" label="任务分组" width="80" />
|
||||
<el-table-column prop="assemblyName" align="center" label="程序集名称" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="className" align="center" label="任务类名" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="runTimes" align="center" label="运行次数" width="80" />
|
||||
<el-table-column prop="intervalSecond" align="center" label="执行间隔(s)" width="90" />
|
||||
<el-table-column prop="cron" align="center" label="运行表达式" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="taskType" label="任务类型" align="center" v-if="columns.showColumn('taskType')">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="options.taskTypeOptions" :value="scope.row.taskType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="triggerType" label="触发器类型" align="center" v-if="columns.showColumn('triggerType')">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="options.triggerTypeOptions" :value="scope.row.triggerType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column sortable prop="isStart" align="center" label="任务状态" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :value="scope.row.isStart" :options="isStartOptions"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="lastRunTime" align="center" label="最后运行时间" :show-overflow-tooltip="true" /> -->
|
||||
<el-table-column prop="remark" align="center" label="备注" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
|
||||
<el-table-column
|
||||
prop="jobGroup"
|
||||
:show-overflow-tooltip="true"
|
||||
align="center"
|
||||
label="任务分组"
|
||||
width="80"
|
||||
v-if="columns.showColumn('jobGroup')" />
|
||||
<el-table-column
|
||||
prop="assemblyName"
|
||||
align="center"
|
||||
label="程序集名称"
|
||||
v-if="columns.showColumn('assemblyName')"
|
||||
:show-overflow-tooltip="true" />
|
||||
<el-table-column prop="className" align="center" label="任务类名" v-if="columns.showColumn('className')" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="runTimes" align="center" label="运行次数" width="80" />
|
||||
<el-table-column prop="intervalSecond" align="center" label="执行间隔(s)" v-if="columns.showColumn('intervalSecond')" width="90" />
|
||||
<el-table-column prop="cron" align="center" label="运行表达式" v-if="columns.showColumn('cron')" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="remark" align="center" label="备注" v-if="columns.showColumn('remark')" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="jobParams" label="任务参数" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('jobParams')" />
|
||||
<el-table-column
|
||||
prop="lastRunTime"
|
||||
label="最后运行时间"
|
||||
align="center"
|
||||
:show-overflow-tooltip="true"
|
||||
v-if="columns.showColumn('lastRunTime')" />
|
||||
|
||||
<el-table-column label="操作" width="250" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-link size="small" class="ml10" icon="view" v-hasPermi="['monitor:job:query']" @click="handleDetails(scope.row)">
|
||||
{{ $t('btn.details') }}
|
||||
@ -126,7 +157,7 @@
|
||||
<pagination v-model:total="total" v-model:page="queryParams.PageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-row>
|
||||
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-dialog :title="title" v-model="open" width="600px" draggable append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :lg="24" v-if="form.id">
|
||||
@ -142,13 +173,17 @@
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="触发器类型" prop="triggerType">
|
||||
<el-select v-model="form.triggerType" placeholder="请选择触发器类型" style="width: 100%">
|
||||
<el-option v-for="item in triggerTypeOptions" :key="item.value" :label="item.label" :value="parseInt(item.value)" />
|
||||
<el-option
|
||||
v-for="item in options.triggerTypeOptions"
|
||||
:key="item.dictValue"
|
||||
:label="item.dictLabel"
|
||||
:value="parseInt(item.dictValue)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="任务分组" maxlength="200" prop="jobGroup">
|
||||
<el-select v-model="form.jobGroup" placeholder="请选择">
|
||||
<el-select v-model="form.jobGroup" placeholder="请选择任务分组">
|
||||
<el-option v-for="dict in jobGroupOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@ -158,6 +193,7 @@
|
||||
<el-radio-group v-model="form.taskType">
|
||||
<el-radio :label="1">执行程序集</el-radio>
|
||||
<el-radio :label="2">执行url</el-radio>
|
||||
<el-radio :label="3">执行SQL语句</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -169,7 +205,12 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<template v-else>
|
||||
<el-col :lg="24" v-if="form.taskType == 3">
|
||||
<el-form-item label="SQL语句" prop="sqlText">
|
||||
<el-input :rows="5" type="textarea" v-model="form.sqlText" placeholder="请输入SQL语句,批量执行SQL请换行"> </el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<template v-if="form.taskType == 1">
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="程序集名称" maxlength="200" prop="assemblyName">
|
||||
<el-input v-model="form.assemblyName" placeholder="请输入程序集名称" />
|
||||
@ -186,7 +227,7 @@
|
||||
<el-form-item label="传入参数" prop="jobParams">
|
||||
<template #label>
|
||||
<span>
|
||||
<el-tooltip content="eg:{ token: abc123}" placement="top">
|
||||
<el-tooltip content="eg:{ token: abc123} or token=abc123&uid=1000" placement="top">
|
||||
<el-icon :size="15">
|
||||
<questionFilled />
|
||||
</el-icon>
|
||||
@ -262,7 +303,7 @@
|
||||
<el-drawer :title="logTitle" v-model="drawer">
|
||||
<el-form :inline="true" @submit.prevent>
|
||||
<el-form-item>
|
||||
<el-date-picker v-model="logForm.beginTime" clearable type="date" />
|
||||
<el-date-picker v-model="logForm.beginTime" placeholder="请选择时间" :shortcuts="dateOptions" clearable type="date" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleJobLog">{{ $t('btn.search') }}</el-button>
|
||||
@ -272,7 +313,7 @@
|
||||
<el-timeline>
|
||||
<el-timeline-item :timestamp="item.createTime" placement="top" v-for="(item, i) in jobLogList" :key="i">
|
||||
<h4>{{ item.jobMessage }}</h4>
|
||||
<p>{{ item.exception }}</p>
|
||||
<p style="color: red">{{ item.exception }}</p>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-empty v-if="jobLogList.length <= 0"></el-empty>
|
||||
@ -283,7 +324,6 @@
|
||||
<script setup name="job">
|
||||
import { queryTasks, getTasks, createTasks, updateTasks, deleteTasks, startTasks, stopTasks, runTasks, exportTasks } from '@/api/monitor/job'
|
||||
import { listJobLog } from '@/api/monitor/jobLog'
|
||||
// import Vue3CronCore from '@/components/vue3-cron-core/Index.vue'
|
||||
import Crontab from '@/components/Crontab'
|
||||
|
||||
const router = useRouter()
|
||||
@ -302,21 +342,44 @@ const searchToggle = ref(true)
|
||||
// 合计条数
|
||||
const total = ref(0)
|
||||
// 遮罩层
|
||||
const loading = ref(true)
|
||||
const loading = ref(false)
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
queryText: undefined,
|
||||
PageNum: 1,
|
||||
pageSize: 10,
|
||||
orderby: 'createTime',
|
||||
sort: 'descending'
|
||||
orderby: '',
|
||||
sort: '',
|
||||
taskType: undefined
|
||||
})
|
||||
const columns = ref([
|
||||
// { visible: true, prop: 'name', label: '名称' },
|
||||
{ visible: true, prop: 'taskType', label: '任务类型' },
|
||||
{ visible: true, prop: 'triggerType', label: '触发器类型' },
|
||||
{ visible: true, prop: 'jobGroup', label: '任务分组' },
|
||||
{ visible: true, prop: 'assemblyName', label: '程序集名称' },
|
||||
{ visible: true, prop: 'className', label: '类名' },
|
||||
{ visible: false, prop: 'remark', label: '备注' },
|
||||
{ visible: false, prop: 'id', label: '任务id' },
|
||||
{ visible: false, prop: 'cron', label: 'cron表达式' },
|
||||
// { visible: true, prop: 'runTimes', label: '运行次数' },
|
||||
// { visible: false, prop: 'beginTime', label: '开始时间' },
|
||||
// { visible: false, prop: 'endTime', label: '结束时间' },
|
||||
{ visible: false, prop: 'intervalSecond', label: '执行每隔(s)' },
|
||||
// { visible: false, prop: 'isStart', label: '是否启动' },
|
||||
{ visible: false, prop: 'jobParams', label: '任务参数' },
|
||||
{ visible: true, prop: 'lastRunTime', label: '最后运行时间' }
|
||||
// { visible: false, prop: 'apiUrl', label: '网络请求地址' },
|
||||
// { visible: false, prop: 'sqlText', label: 'sql脚本' }
|
||||
])
|
||||
// 计划任务列表
|
||||
const dataTasks = ref([])
|
||||
// 任务日志列表
|
||||
const jobLogList = ref([])
|
||||
const logTitle = ref('')
|
||||
const formRef = ref(null)
|
||||
const queryRef = ref(null)
|
||||
|
||||
// 任务状态字典
|
||||
const isStartOptions = ref([
|
||||
{ dictLabel: '运行中', dictValue: 'true', listClass: 'success' },
|
||||
@ -324,17 +387,7 @@ const isStartOptions = ref([
|
||||
])
|
||||
// 任务组名字典
|
||||
const jobGroupOptions = ref([])
|
||||
// 触发器类型
|
||||
const triggerTypeOptions = ref([
|
||||
{
|
||||
label: '[普通]',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: '[表达式]',
|
||||
value: 1
|
||||
}
|
||||
])
|
||||
|
||||
const state = reactive({
|
||||
form: {},
|
||||
// 表单校验
|
||||
@ -348,18 +401,26 @@ const state = reactive({
|
||||
cron: [{ required: true, message: 'cron表达式不能为空', trigger: 'change' }],
|
||||
beginTime: [{ required: false, message: '请选择开始日期', trigger: 'blur' }],
|
||||
endTime: [{ required: false, message: '请选择结束日期', trigger: 'blur' }],
|
||||
intervalSecond: [{ message: '请设置执行间隔', type: 'number', trigger: 'blur' }]
|
||||
intervalSecond: [{ message: '请设置执行间隔', type: 'number', trigger: 'blur' }],
|
||||
sqlText: [{ required: true, message: '请输入sql语句', trigger: 'blur' }]
|
||||
},
|
||||
options: {
|
||||
// 触发器类型
|
||||
triggerTypeOptions: [
|
||||
{ dictLabel: '普通', dictValue: '0' },
|
||||
{ dictLabel: '表达式', dictValue: '1' }
|
||||
],
|
||||
taskTypeOptions: [
|
||||
{ dictLabel: '程序集', dictValue: '1' },
|
||||
{ dictLabel: 'api请求', dictValue: '2' },
|
||||
{ dictLabel: 'sql脚本', dictValue: '3' }
|
||||
]
|
||||
}
|
||||
})
|
||||
// 按钮是否可见
|
||||
const btnVisible = ref(true)
|
||||
const { rules, form } = toRefs(state)
|
||||
// 时间的选择
|
||||
// const pickerOptions = reactive({
|
||||
// disabledDate(time) {
|
||||
// return time.getTime() < Date.now() - 8.64e7
|
||||
// },
|
||||
// })
|
||||
const { rules, form, options } = toRefs(state)
|
||||
|
||||
/** 查询计划任务列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
@ -374,7 +435,7 @@ function handleQuery() {
|
||||
}
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
queryParams.queryText = ''
|
||||
proxy.resetForm('queryRef')
|
||||
getList()
|
||||
}
|
||||
/** 新增按钮操作 */
|
||||
|
||||
@ -22,7 +22,8 @@
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"></el-date-picker>
|
||||
end-placeholder="结束日期"
|
||||
:shortcuts="dateOptions"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user