定时任务
This commit is contained in:
parent
09421c59bf
commit
184ca551ce
@ -74,6 +74,16 @@ export function getJobRunOnce(id) {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @description: 设置状态
|
||||||
|
*/
|
||||||
|
export function setJobStatus(data:any) {
|
||||||
|
return http.request({
|
||||||
|
url: '/job/status',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 暂停任务
|
* @description: 暂停任务
|
||||||
*/
|
*/
|
||||||
|
@ -23,26 +23,31 @@ export const columns = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '状态',
|
label: '状态',
|
||||||
prop: 'status',
|
isSlot:true,
|
||||||
render(record) {
|
value:'status'
|
||||||
let typeText = ''
|
|
||||||
switch (record.row.status) {
|
|
||||||
case 0:
|
|
||||||
typeText='未发布'
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
typeText='运行中'
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
typeText='暂停'
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
typeText='删除'
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return h('span', typeText || '-');
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// label: '状态',
|
||||||
|
// prop: 'status',
|
||||||
|
// render(record) {
|
||||||
|
// let typeText = ''
|
||||||
|
// switch (record.row.status) {
|
||||||
|
// case 0:
|
||||||
|
// typeText='未发布'
|
||||||
|
// break;
|
||||||
|
// case 1:
|
||||||
|
// typeText='运行中'
|
||||||
|
// break;
|
||||||
|
// case 2:
|
||||||
|
// typeText='暂停'
|
||||||
|
// break;
|
||||||
|
// case 3:
|
||||||
|
// typeText='删除'
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// return h('span', typeText || '-');
|
||||||
|
// },
|
||||||
|
// },
|
||||||
];
|
];
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
@selection-change="onSelectionChange"
|
@selection-change="onSelectionChange"
|
||||||
>
|
>
|
||||||
<template #tableTitle>
|
<template #tableTitle>
|
||||||
<el-button type="primary" @click="handleAdd">
|
<el-button type="primary" @click="handleAdd" v-perm="['sys:job:add']">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<el-icon class="el-input__icon">
|
<el-icon class="el-input__icon">
|
||||||
<PlusOutlined />
|
<PlusOutlined />
|
||||||
@ -21,7 +21,7 @@
|
|||||||
</template>
|
</template>
|
||||||
添加任务
|
添加任务
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length" v-perm="['sys:job:batchDelete']">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<el-icon class="el-input__icon">
|
<el-icon class="el-input__icon">
|
||||||
<Delete />
|
<Delete />
|
||||||
@ -30,9 +30,9 @@
|
|||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<!-- <template #status="{ scope }">
|
<template #status="{ scope }">
|
||||||
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="handelChangeStatus(scope.row)" />
|
<el-switch v-model="scope.row.realStatus" @change="handelSetStatus(scope.row)" />
|
||||||
</template> -->
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
@ -57,7 +57,7 @@
|
|||||||
import { schemas } from './querySchemas';
|
import { schemas } from './querySchemas';
|
||||||
import { useForm } from '@/components/Form/index';
|
import { useForm } from '@/components/Form/index';
|
||||||
import { TableAction } from '@/components/Table';
|
import { TableAction } from '@/components/Table';
|
||||||
import { getJobList,jobDelete,jobBatchDelete,getJobRunOnce,getJobPause,getJobResume } from '@/api/monitor/job';
|
import { getJobList,jobDelete,jobBatchDelete,getJobRunOnce,setJobStatus,getJobPause,getJobResume } from '@/api/monitor/job';
|
||||||
import { columns } from './columns';
|
import { columns } from './columns';
|
||||||
import { PlusOutlined } from '@vicons/antd';
|
import { PlusOutlined } from '@vicons/antd';
|
||||||
import {message,confirm} from "@/utils/auth";
|
import {message,confirm} from "@/utils/auth";
|
||||||
@ -87,56 +87,57 @@ const selectionData = ref([])
|
|||||||
return h(TableAction, {
|
return h(TableAction, {
|
||||||
style: 'button',
|
style: 'button',
|
||||||
actions: [
|
actions: [
|
||||||
|
|
||||||
{
|
|
||||||
label: '编辑',
|
|
||||||
type: 'warning',
|
|
||||||
onClick: handleEdit.bind(null, record),
|
|
||||||
ifShow: () => {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
// auth: ['basic_list'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '删除',
|
|
||||||
type: 'danger',
|
|
||||||
onClick: handleDelete.bind(null, record),
|
|
||||||
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
|
||||||
ifShow: () => {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
|
||||||
// auth: ['basic_list'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
dropDownActions: [
|
|
||||||
{
|
{
|
||||||
label: '启动',
|
label: '启动',
|
||||||
key: 'resume',
|
type: 'success',
|
||||||
|
onClick: handelChangeStatus.bind(null, record),
|
||||||
|
auth:['sys:job:resume'],
|
||||||
ifShow: () => {
|
ifShow: () => {
|
||||||
return record.row.status==0 ||record.row.status==2;
|
return record.row.status==0 ||record.row.status==2;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '暂停',
|
label: '暂停',
|
||||||
key: 'pause',
|
type: 'warning',
|
||||||
|
onClick: handelChangeStatus.bind(null, record),
|
||||||
|
auth:['sys:job:pause'],
|
||||||
ifShow: () => {
|
ifShow: () => {
|
||||||
return record.row.status==1;
|
return record.row.status==1;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
type: 'warning',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
disabled:record.row.status==1,
|
||||||
|
auth: ['sys:job:update'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||||
|
auth: ['sys:job:update'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dropDownActions: [
|
||||||
{
|
{
|
||||||
label: '执行一次',
|
label: '执行一次',
|
||||||
key: 'runOnce'
|
key: 'runOnce',
|
||||||
|
disabled:true,
|
||||||
|
auth: ['sys:job:runOnce'],
|
||||||
|
ifShow: () => {
|
||||||
|
return record.row.status==2;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '调度日志',
|
label: '调度日志',
|
||||||
key: 'jobLog'
|
key: 'jobLog',
|
||||||
|
auth:['sys:job:jobLog']
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
select: (key) => {
|
select: (key) => {
|
||||||
if(key=='resume' || key=='pause') {
|
if(key=='runOnce') {
|
||||||
handelChangeStatus(record)
|
|
||||||
} else if(key=='runOnce') {
|
|
||||||
handelRunOnce(record)
|
handelRunOnce(record)
|
||||||
} else if(key=='jobLog'){
|
} else if(key=='jobLog'){
|
||||||
handleJobLog(record)
|
handleJobLog(record)
|
||||||
@ -148,6 +149,13 @@ const selectionData = ref([])
|
|||||||
|
|
||||||
const loadDataTable = async (res: any) => {
|
const loadDataTable = async (res: any) => {
|
||||||
const result = await getJobList({ ...formParams, ...res });
|
const result = await getJobList({ ...formParams, ...res });
|
||||||
|
result.records.map(item=>{
|
||||||
|
if(item.status==0) {
|
||||||
|
item.realStatus = false
|
||||||
|
} else {
|
||||||
|
item.realStatus = true
|
||||||
|
}
|
||||||
|
})
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -179,7 +187,11 @@ const selectionData = ref([])
|
|||||||
await nextTick();
|
await nextTick();
|
||||||
editVisible.value=true
|
editVisible.value=true
|
||||||
};
|
};
|
||||||
|
const handelSetStatus = async(row)=>{
|
||||||
|
await setJobStatus({id:row.id,status:row.realStatus?1:0})
|
||||||
|
message("设置成功");
|
||||||
|
reloadTable('noRefresh')
|
||||||
|
}
|
||||||
const handleEdit = async (record: Recordable) => {
|
const handleEdit = async (record: Recordable) => {
|
||||||
jobId.value=record.row.id
|
jobId.value=record.row.id
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
Loading…
Reference in New Issue
Block a user