新增加任务
This commit is contained in:
parent
fe00e0b775
commit
a7a90a96ac
587
src/views/monitor/job/index.vue
Normal file
587
src/views/monitor/job/index.vue
Normal file
@ -0,0 +1,587 @@
|
||||
<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">搜索</el-button>
|
||||
<el-button icon="refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<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">新增</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button v-hasPermi="['monitor:job:edit']" plain type="success" icon="el-icon-edit" @click="handleRun(null)" :disabled="single">运行一次</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['monitor:job:delete']" plain type="danger" icon="el-icon-remove" @click="handleDelete(null)" :disabled="single">删除</el-button>
|
||||
</el-col>-->
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="download" @click="handleExport" v-hasPermi="['monitor:job:export']">导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button plain v-hasPermi="['monitor:job:query']" type="info" icon="operation" @click="handleJobLog()">日志
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch="searchToggle" @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="name" :show-overflow-tooltip="true" label="任务名称" width="80" />
|
||||
<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 sortable prop="isStart" align="center" label="任务状态" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.isStart ? 'success' : 'danger'">{{ scope.row.isStart ? "运行中":"已停止" }}</el-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="230" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button type="text" icon="view" v-hasPermi="['monitor:job:query']"
|
||||
@click="handleJobLog(scope.row.id, scope.row.name)">
|
||||
日志
|
||||
<!-- <router-link :to="{path: 'job/log', query: {jobId: scope.row.id}}">日志</router-link> -->
|
||||
</el-button>
|
||||
<el-button type="text" v-if="scope.row.isStart" v-hasPermi="['monitor:job:run']" icon="remove" title="运行"
|
||||
@click="handleRun(scope.row)">运行</el-button>
|
||||
<el-button type="text" v-if="scope.row.isStart" v-hasPermi="['monitor:job:stop']" icon="video-pause" style="color:red"
|
||||
title="停止" @click="handleStop(scope.row)">停止</el-button>
|
||||
|
||||
<el-button type="text" v-if="!scope.row.isStart" v-hasPermi="['monitor:job:start']" icon="video-play" title="启动"
|
||||
@click="handleStart(scope.row)">启动</el-button>
|
||||
<el-button type="text" v-if="!scope.row.isStart" v-hasPermi="['monitor:job:edit']" icon="edit" style="color:gray"
|
||||
title="编辑" @click="handleUpdate(scope.row)">编辑</el-button>
|
||||
<el-button type="text" v-if="!scope.row.isStart" v-hasPermi="['monitor:job:delete']" icon="delete" style="color:red"
|
||||
title="删除" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<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-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :lg="24" v-if="this.form.id">
|
||||
<el-form-item label="任务ID">
|
||||
<div>{{form.id}}</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="任务名称" maxlength="200" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入任务名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<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-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-option v-for="dict in jobGroupOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="任务类型" prop="taskType">
|
||||
<el-radio-group v-model="form.taskType">
|
||||
<el-radio :label="1">执行程序集</el-radio>
|
||||
<el-radio :label="2">执行url</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="24" v-if="form.taskType == 2">
|
||||
<el-form-item label="apiUrl" prop="apiUrl">
|
||||
<el-input v-model="form.apiUrl" placeholder="远程调用接口url">
|
||||
<!-- <template #default="prepend">Http://</template> -->
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<template v-else>
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="程序集名称" maxlength="200" prop="assemblyName">
|
||||
<el-input v-model="form.assemblyName" placeholder="请输入程序集名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="任务类名" maxlength="200" prop="className">
|
||||
<el-input v-model="form.className" placeholder="请输入任务类名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="传入参数" prop="jobParams">
|
||||
<template #label>
|
||||
<span>
|
||||
<el-tooltip content="eg:{ token: abc123}" placement="top">
|
||||
<el-icon :size="15">
|
||||
<questionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
传入参数
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-input v-model="form.jobParams" placeholder="传入参数" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="24" v-show="form.triggerType == 1">
|
||||
<el-form-item label="间隔(Cron)" prop="cron">
|
||||
<el-input v-model="form.cron" placeholder="请输入cron执行表达式">
|
||||
<!-- <template #append>
|
||||
<el-button type="primary" @click="handleShowCron">
|
||||
生成表达式
|
||||
<el-icon><time/></el-icon>
|
||||
</el-button>
|
||||
</template> -->
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="开始日期" prop="beginTime">
|
||||
<template #label>
|
||||
<span>
|
||||
<el-tooltip content="如果不写开始时间和结束时间,任务将以当前时间开始执行,到9999年结束" placement="top">
|
||||
<el-icon :size="15">
|
||||
<questionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
开始日期
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-date-picker v-model="form.beginTime" style="width:100%" type="date" :picker-options="pickerOptions" placeholder="选择开始日期" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="结束日期" prop="endTime">
|
||||
<el-date-picker v-model="form.endTime" style="width:100%" type="date" placeholder="选择结束日期" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="24">
|
||||
<el-form-item v-show="form.triggerType == 0" label="执行间隔(秒)" prop="intervalSecond">
|
||||
<el-input-number v-model="form.intervalSecond" :max="9999999999" step-strictly controls-position="right" :min="1" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" v-model="form.remark" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="text" @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- <el-dialog title="Cron表达式生成器" v-model="openCron" destroy-on-close>
|
||||
<crontab @hide="openCron=false" @fill="crontabFill" :expression="expression"></crontab>
|
||||
</el-dialog> -->
|
||||
|
||||
<el-drawer :title="logTitle" v-model="drawer">
|
||||
<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>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-empty v-if="jobLogList.length <= 0"></el-empty>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryTasks,
|
||||
getTasks,
|
||||
createTasks,
|
||||
updateTasks,
|
||||
deleteTasks,
|
||||
startTasks,
|
||||
stopTasks,
|
||||
runTasks,
|
||||
exportTasks,
|
||||
} from '@/api/monitor/job'
|
||||
import { listJobLog } from '@/api/monitor/jobLog'
|
||||
// import Crontab from '@/components/Crontab'
|
||||
|
||||
export default {
|
||||
name: 'job',
|
||||
// components: { Crontab },
|
||||
data() {
|
||||
var cronValidate = (rule, value, callback) => {
|
||||
if (this.form.triggerType === 1) {
|
||||
if (value === '' || value === undefined) {
|
||||
callback(new Error('运行时间表达式不能为空!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
var beginTimeValidate = (rule, value, callback) => {
|
||||
if (this.form.triggerType === 0) {
|
||||
if (value === '' || value === undefined) {
|
||||
callback(new Error('选择开始日期!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
var endTimeValidate = (rule, value, callback) => {
|
||||
if (this.form.triggerType === 0) {
|
||||
if (value === '' || value === undefined) {
|
||||
callback(new Error('选择结束日期!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
var intervalSecondValidate = (rule, value, callback) => {
|
||||
if (this.form.triggerType === 0) {
|
||||
if (value === '' || value === undefined) {
|
||||
callback(new Error('请设置执行间隔!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
// 是否显示Cron表达式弹出层
|
||||
openCron: false,
|
||||
// 传入的表达式
|
||||
expression: '',
|
||||
drawer: false,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 表单
|
||||
form: {},
|
||||
// 表单标题
|
||||
title: '',
|
||||
// 显示搜索
|
||||
searchToggle: true,
|
||||
// 表格高度
|
||||
tableHeight: window.innerHeight,
|
||||
// 合计条数
|
||||
total: 0,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
queryText: undefined,
|
||||
PageNum: 1,
|
||||
pageSize: 10,
|
||||
orderby: 'createTime',
|
||||
sort: 'descending',
|
||||
},
|
||||
// 计划任务列表
|
||||
dataTasks: [],
|
||||
// 任务日志列表
|
||||
jobLogList: [],
|
||||
logTitle: '',
|
||||
// 任务状态字典
|
||||
isStartOptions: [
|
||||
{ dictLabel: '运行中', dictValue: 'true' },
|
||||
{ dictLabel: '已停止', dictValue: 'false', listClass: 'danger' },
|
||||
],
|
||||
// 任务组名字典
|
||||
jobGroupOptions: [],
|
||||
// 触发器类型
|
||||
triggerTypeOptions: [
|
||||
{
|
||||
label: '[普通]',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '[表达式]',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '任务名称不能为空', trigger: 'blur' },
|
||||
],
|
||||
jobGroup: [
|
||||
{ required: true, message: '任务分组不能为空', trigger: 'blur' },
|
||||
],
|
||||
assemblyName: [
|
||||
{ required: true, message: '程序集名称不能为空', trigger: 'blur' },
|
||||
],
|
||||
className: [
|
||||
{ required: true, message: '任务类名不能为空', trigger: 'blur' },
|
||||
],
|
||||
triggerType: [
|
||||
{ required: true, message: '请选择触发器类型', trigger: 'blur' },
|
||||
],
|
||||
apiUrl: [
|
||||
{ required: true, message: '请输入apiUrl地址', trigger: 'blur' },
|
||||
],
|
||||
cron: [{ validator: cronValidate, trigger: 'blur' }],
|
||||
beginTime: [{ validator: beginTimeValidate, trigger: 'blur' }],
|
||||
endTime: [{ validator: endTimeValidate, trigger: 'blur' }],
|
||||
intervalSecond: [
|
||||
{
|
||||
validator: intervalSecondValidate,
|
||||
type: 'number',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
// 时间的选择
|
||||
pickerOptions: {
|
||||
disabledDate(time) {
|
||||
return time.getTime() < Date.now() - 8.64e7
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getDicts('sys_job_group').then((response) => {
|
||||
this.jobGroupOptions = response.data
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
'form.triggerType': {
|
||||
handler(val) {
|
||||
console.log(val)
|
||||
if (val == 0) {
|
||||
this.form.cron = undefined
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
/** 查询计划任务列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
queryTasks(this.queryParams).then((response) => {
|
||||
this.dataTasks = response.data.result
|
||||
this.total = response.data.totalNum
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
handleQuery() {
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
handleReset() {
|
||||
this.queryParams.queryText = ''
|
||||
this.getList()
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleCreate() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = '添加计划任务'
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
|
||||
getTasks(row.id).then((res) => {
|
||||
this.form = res.data
|
||||
this.open = true
|
||||
this.title = '修改计划任务'
|
||||
})
|
||||
},
|
||||
/** 任务日志列表查询 */
|
||||
handleJobLog(id, title) {
|
||||
if (id == undefined) {
|
||||
this.$router.push({ path: 'job/log' })
|
||||
} else {
|
||||
this.drawer = true
|
||||
this.jobLogList = []
|
||||
this.logTitle = title
|
||||
listJobLog({ JobId: id }).then((response) => {
|
||||
this.jobLogList = response.data.result
|
||||
})
|
||||
}
|
||||
},
|
||||
/** cron表达式按钮操作 */
|
||||
handleShowCron() {
|
||||
this.expression = this.form.cron
|
||||
this.openCron = true
|
||||
},
|
||||
/** 确定后回传值 */
|
||||
crontabFill(value) {
|
||||
console.log(value)
|
||||
this.form.cron = value
|
||||
},
|
||||
// 启动按钮
|
||||
handleStart(row) {
|
||||
startTasks(row.id).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.$modal.msgSuccess(response.msg)
|
||||
this.open = false
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
// 停止按钮
|
||||
handleStop(row) {
|
||||
stopTasks(row.id).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.$modal.msgSuccess(response.msg)
|
||||
this.open = false
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const jobInfo = row
|
||||
|
||||
this.$confirm(
|
||||
'是否确认删除名称为"' + jobInfo.name + '"的计划任务?',
|
||||
'警告',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
deleteTasks(jobInfo.id).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(function () {})
|
||||
},
|
||||
/* 立即执行一次 */
|
||||
handleRun(row) {
|
||||
const jobInfo = row
|
||||
|
||||
this.$confirm('确认要立即执行一次"' + jobInfo.name + '"任务吗?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then((res) => {
|
||||
runTasks(jobInfo.id).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess('执行成功')
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.id !== undefined) {
|
||||
updateTasks(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
createTasks(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 排序操作
|
||||
handleSortable(val) {
|
||||
this.queryParams.orderby = val.prop
|
||||
this.queryParams.sort = val.order
|
||||
this.getList()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
jobGroup: undefined,
|
||||
assemblyName: 'ZR.Tasks',
|
||||
className: undefined,
|
||||
jobParams: undefined,
|
||||
triggerType: 1,
|
||||
beginTime: undefined,
|
||||
endTime: undefined,
|
||||
intervalSecond: 1,
|
||||
cron: undefined,
|
||||
taskType: 1,
|
||||
}
|
||||
this.resetForm('form')
|
||||
},
|
||||
// 自动计算分页 Id
|
||||
handleIndexCalc(index) {
|
||||
return (
|
||||
(this.queryParams.PageNum - 1) * this.queryParams.pageSize + index + 1
|
||||
)
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.$confirm('是否确认导出所有任务?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
return exportTasks()
|
||||
})
|
||||
.then((response) => {
|
||||
this.download(response.data.path)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
257
src/views/monitor/job/log.vue
Normal file
257
src/views/monitor/job/log.vue
Normal file
@ -0,0 +1,257 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="任务名称" prop="jobName">
|
||||
<el-input v-model="queryParams.jobName" placeholder="请输入任务名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="任务组名" prop="jobGroup">
|
||||
<el-select v-model="queryParams.jobGroup" placeholder="请任务组名" clearable style="width: 240px">
|
||||
<el-option v-for="dict in jobGroupOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="执行状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择执行状态" clearable style="width: 240px">
|
||||
<el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="执行时间">
|
||||
<el-date-picker v-model="dateRange" style="width: 240px" value-format="YYYY-MM-DD" type="daterange" range-separator="-"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['PRIV_JOBLOG_DELETE']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="delete" @click="handleClean" :disabled="total <= 0"
|
||||
v-hasPermi="['PRIV_JOBLOG_REMOVE']">清空</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="download" @click="handleExport" v-hasPermi="['PRIV_JOBLOG_EXPORT']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="jobLogList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="日志编号" width="80" align="center" prop="jobLogId" />
|
||||
<el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="任务组名" align="center" prop="jobGroup" :formatter="jobGroupFormat" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="日志信息" align="center" prop="jobMessage" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="执行状态" align="center" prop="status" :formatter="statusFormat" />
|
||||
<el-table-column label="作业用时" align="center" prop="elapsed">
|
||||
<template #default="scope">
|
||||
<span :style="scope.row.elapsed < 1000 ? 'color:green':scope.row.elapsed <3000 ?'color:orange':'color:red'">{{ scope.row.elapsed /1000 }}
|
||||
ms</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="执行时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button type="text" icon="view" @click="handleView(scope.row)">详细</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 调度日志详细 -->
|
||||
<el-dialog title="调度日志详细" v-model="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" label-width="100px" >
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="日志序号:">{{ form.jobLogId }}</el-form-item>
|
||||
<el-form-item label="任务名称:">{{ form.jobName }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="任务分组:">{{ form.jobGroup }}</el-form-item>
|
||||
<el-form-item label="执行时间:">{{ form.createTime }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="调用方法:">{{ form.invokeTarget }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="日志信息:">{{ form.jobMessage }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="执行状态:">
|
||||
<div v-if="form.status == 0">正常</div>
|
||||
<div v-else-if="form.status == 1">失败</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" v-if="form.status == 1">>
|
||||
<el-form-item label="异常信息:">{{ form.exception }}</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="text" @click="open = false">关 闭</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listJobLog,
|
||||
delJobLog,
|
||||
exportJobLog,
|
||||
cleanJobLog,
|
||||
} from '@/api/monitor/jobLog'
|
||||
|
||||
export default {
|
||||
name: 'job/log',
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 调度日志表格数据
|
||||
jobLogList: [],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 日期范围
|
||||
dateRange: [],
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 执行状态字典
|
||||
statusOptions: [],
|
||||
// 任务组名字典
|
||||
jobGroupOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
jobName: undefined,
|
||||
jobGroup: undefined,
|
||||
status: undefined,
|
||||
jobId: undefined,
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.queryParams.jobId = this.$route.query.jobId
|
||||
this.getList()
|
||||
this.getDicts('sys_job_status').then((response) => {
|
||||
this.statusOptions = response.data
|
||||
})
|
||||
this.getDicts('sys_job_group').then((response) => {
|
||||
this.jobGroupOptions = response.data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
/** 查询调度日志列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(
|
||||
(response) => {
|
||||
this.jobLogList = response.data.result
|
||||
this.total = response.data.totalNum
|
||||
this.loading = false
|
||||
}
|
||||
)
|
||||
},
|
||||
// 执行状态字典翻译
|
||||
statusFormat(row, column) {
|
||||
return this.selectDictLabel(this.statusOptions, row.status)
|
||||
},
|
||||
// 任务组名字典翻译
|
||||
jobGroupFormat(row, column) {
|
||||
return this.selectDictLabel(this.jobGroupOptions, row.jobGroup)
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = []
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.jobLogId)
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 详细按钮操作 */
|
||||
handleView(row) {
|
||||
this.open = true
|
||||
this.form = row
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const jobLogIds = this.ids
|
||||
this.$confirm(
|
||||
'是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?',
|
||||
'警告',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return delJobLog(jobLogIds)
|
||||
})
|
||||
.then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
})
|
||||
},
|
||||
/** 清空按钮操作 */
|
||||
handleClean() {
|
||||
this.$confirm('是否确认清空所有调度日志数据项?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(function () {
|
||||
return cleanJobLog()
|
||||
})
|
||||
.then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('清空成功')
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams
|
||||
this.$confirm('是否确认导出所有调度日志数据项?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(function () {
|
||||
return exportJobLog(queryParams)
|
||||
})
|
||||
.then((response) => {
|
||||
this.download(response.data.path)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user