定时任务
This commit is contained in:
parent
76c04ec199
commit
09421c59bf
@ -43,6 +43,11 @@
|
|||||||
@success="reloadTable('noRefresh')"
|
@success="reloadTable('noRefresh')"
|
||||||
>
|
>
|
||||||
</editDialog>
|
</editDialog>
|
||||||
|
<jobLog
|
||||||
|
v-if="editLogVisible"
|
||||||
|
:jobId="jobId"
|
||||||
|
v-model:visible="editLogVisible">
|
||||||
|
</jobLog>
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -56,11 +61,17 @@
|
|||||||
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";
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
const router = useRouter();
|
||||||
const editDialog = defineAsyncComponent(() =>
|
const editDialog = defineAsyncComponent(() =>
|
||||||
import('./edit.vue')
|
import('./edit.vue')
|
||||||
)
|
)
|
||||||
|
const jobLog = defineAsyncComponent(() =>
|
||||||
|
import('./log/index.vue')
|
||||||
|
)
|
||||||
const jobId =ref(0)
|
const jobId =ref(0)
|
||||||
const editVisible=ref(false)
|
const editVisible=ref(false)
|
||||||
|
const editLogVisible=ref(false)
|
||||||
const selectionData = ref([])
|
const selectionData = ref([])
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const formParams = reactive({
|
const formParams = reactive({
|
||||||
@ -76,27 +87,7 @@ const selectionData = ref([])
|
|||||||
return h(TableAction, {
|
return h(TableAction, {
|
||||||
style: 'button',
|
style: 'button',
|
||||||
actions: [
|
actions: [
|
||||||
// {
|
|
||||||
// label: '启动',
|
|
||||||
// type: 'warning',
|
|
||||||
// onClick: handelChangeStatus.bind(null, record),
|
|
||||||
// ifShow: () => {
|
|
||||||
// return record.row.status==0 ||record.row.status==2;
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: '暂停',
|
|
||||||
// type: 'warning',
|
|
||||||
// onClick: handelChangeStatus.bind(null, record),
|
|
||||||
// ifShow: () => {
|
|
||||||
// return record.row.status==1;
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: '执行一次',
|
|
||||||
// type: 'warning',
|
|
||||||
// onClick: handelRunOnce.bind(null, record),
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@ -139,7 +130,7 @@ const selectionData = ref([])
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '调度日志',
|
label: '调度日志',
|
||||||
key: 'jogLog'
|
key: 'jobLog'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
select: (key) => {
|
select: (key) => {
|
||||||
@ -147,6 +138,8 @@ const selectionData = ref([])
|
|||||||
handelChangeStatus(record)
|
handelChangeStatus(record)
|
||||||
} else if(key=='runOnce') {
|
} else if(key=='runOnce') {
|
||||||
handelRunOnce(record)
|
handelRunOnce(record)
|
||||||
|
} else if(key=='jobLog'){
|
||||||
|
handleJobLog(record)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -212,6 +205,11 @@ async function handleDelete(record: Recordable) {
|
|||||||
message("删除成功");
|
message("删除成功");
|
||||||
reloadTable()
|
reloadTable()
|
||||||
}
|
}
|
||||||
|
const handleJobLog=(record)=>{
|
||||||
|
// router.push({path:'/monitorJob/log'})
|
||||||
|
editLogVisible.value = true
|
||||||
|
jobId.value=record.row.id
|
||||||
|
}
|
||||||
function onSelectionChange(value){
|
function onSelectionChange(value){
|
||||||
selectionData.value = value
|
selectionData.value = value
|
||||||
}
|
}
|
||||||
|
52
src/views/monitor/job/log/columns.ts
Normal file
52
src/views/monitor/job/log/columns.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { ElTag } from 'element-plus';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '任务名称',
|
||||||
|
prop: 'jobName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '任务组名',
|
||||||
|
prop: 'jobGroup',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '任务触发器',
|
||||||
|
prop: 'jobTrigger',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '任务信息',
|
||||||
|
prop: 'jobMessage',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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 || '-');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行时间',
|
||||||
|
prop: 'startTime',
|
||||||
|
},
|
||||||
|
];
|
117
src/views/monitor/job/log/edit.vue
Normal file
117
src/views/monitor/job/log/edit.vue
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="props.visible"
|
||||||
|
title="日志详情"
|
||||||
|
|
||||||
|
width="700"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:before-close="dialogClose"
|
||||||
|
>
|
||||||
|
<el-descriptions column="2">
|
||||||
|
<el-descriptions-item label="任务名称:">{{formData.jobName}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="任务组名:">{{formData.jobGroup}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="任务触发器:">{{formData.jobTrigger}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="任务信息:">{{formData.jobMessage}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="cron执行表达式:">{{formData.cronExpression}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="任务开始时间:">{{formData.startTime}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="任务结束时间:">{{formData.endTime}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogClose">关闭</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {getJobLogDetail} from "@/api/monitor/job";
|
||||||
|
import {onMounted, reactive, shallowRef} from "vue";
|
||||||
|
|
||||||
|
const formData = reactive({
|
||||||
|
id: "",
|
||||||
|
jobName: "",
|
||||||
|
jobGroup:'',
|
||||||
|
jobTrigger:'',
|
||||||
|
jobMessage:'',
|
||||||
|
cronExpression:'',
|
||||||
|
startTime:'',
|
||||||
|
endTime:''
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["update:visible"]);
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
logId: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const dialogClose = () => {
|
||||||
|
emit("update:visible", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const setFormData = async () => {
|
||||||
|
const data = await getJobLogDetail(props.logId);
|
||||||
|
for (const key in formData) {
|
||||||
|
if (data[key] != null && data[key] != undefined) {
|
||||||
|
//@ts-ignore
|
||||||
|
formData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const getReviceType =(type)=>{
|
||||||
|
let typeText = ''
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
typeText='系统用户'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='会员用户'
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='其他'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return typeText
|
||||||
|
}
|
||||||
|
const getTyepText =(type)=>{
|
||||||
|
let typeText = ''
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
typeText='登录'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='注册'
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='找回密码'
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
typeText='业务'
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
typeText='其他'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return typeText
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.logId) {
|
||||||
|
setFormData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
162
src/views/monitor/job/log/index.vue
Normal file
162
src/views/monitor/job/log/index.vue
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
<template>
|
||||||
|
<el-drawer
|
||||||
|
v-model="props.visible"
|
||||||
|
title="调度日志"
|
||||||
|
direction="rtl"
|
||||||
|
:size="size"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:before-close="dialogClose"
|
||||||
|
>
|
||||||
|
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||||
|
</el-card>
|
||||||
|
<el-card :bordered="false" class="proCard">
|
||||||
|
<BasicTable
|
||||||
|
:columns="columns"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="tableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon class="el-input__icon">
|
||||||
|
<Delete />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</el-card>
|
||||||
|
<editDialog
|
||||||
|
v-if="editVisible"
|
||||||
|
:logId="logId"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
>
|
||||||
|
</editDialog>
|
||||||
|
</el-drawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||||
|
import { ColProps } from 'element-plus';
|
||||||
|
import { schemas } from './querySchemas';
|
||||||
|
import { useForm } from '@/components/Form/index';
|
||||||
|
import { TableAction } from '@/components/Table';
|
||||||
|
import { getJobLogList,jobLogDelete,jobLogBatchDelete } from '@/api/monitor/job';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import {message,confirm} from "@/utils/auth";
|
||||||
|
const editDialog = defineAsyncComponent(() =>
|
||||||
|
import('./edit.vue')
|
||||||
|
)
|
||||||
|
const emit = defineEmits(["update:visible"]);
|
||||||
|
const props = defineProps({
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
jobId: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const editVisible = ref(false)
|
||||||
|
const logId = ref(0)
|
||||||
|
const size = document.body.clientWidth - 500;
|
||||||
|
const selectionData = ref([])
|
||||||
|
const tableRef = ref();
|
||||||
|
const formParams = reactive({
|
||||||
|
jobName:"",
|
||||||
|
status:''
|
||||||
|
});
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 250,
|
||||||
|
label: '操作',
|
||||||
|
prop: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
type: 'warning',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
ifShow: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// auth: ['sys:smsLog:detail'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
||||||
|
ifShow: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||||
|
// auth: ['basic_list'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadDataTable = async (res: any) => {
|
||||||
|
const result = await getJobLogList({ ...formParams, jobId:props.jobId, ...res });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function reloadTable(noRefresh='') {
|
||||||
|
tableRef.value.reload(noRefresh?{}:{pageNo:1});
|
||||||
|
}
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
labelWidth: 100,
|
||||||
|
layout: 'horizontal',
|
||||||
|
colProps: { span: 6 } as ColProps,
|
||||||
|
submitOnReset:true,
|
||||||
|
schemas
|
||||||
|
});
|
||||||
|
function handleSubmit(values: Recordable) {
|
||||||
|
handleReset()
|
||||||
|
for (const key in values) {
|
||||||
|
formParams[key] = values[key]
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset() {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] ='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const dialogClose = () => {
|
||||||
|
emit("update:visible", false);
|
||||||
|
};
|
||||||
|
const handleDetail = async (record: Recordable) => {
|
||||||
|
logId.value=record.row.id
|
||||||
|
await nextTick();
|
||||||
|
editVisible.value=true
|
||||||
|
};
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
let ids = []
|
||||||
|
if(!record){
|
||||||
|
ids = selectionData.value.map(({id}) => id);
|
||||||
|
}
|
||||||
|
await confirm('确定要删除?');
|
||||||
|
record? await jobLogDelete(record.row.id):await jobLogBatchDelete(ids);
|
||||||
|
message("删除成功");
|
||||||
|
reloadTable()
|
||||||
|
}
|
||||||
|
function onSelectionChange(value){
|
||||||
|
selectionData.value = value
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
30
src/views/monitor/job/log/querySchemas.ts
Normal file
30
src/views/monitor/job/log/querySchemas.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { FormSchema } from '@/components/Form/index';
|
||||||
|
export const schemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: 'jobName',
|
||||||
|
component: 'Input',
|
||||||
|
label: '任务名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入数据源名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
component: 'Select',
|
||||||
|
label: '任务状态',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择任务状态',
|
||||||
|
clearable: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '正常',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '失败',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
Loading…
Reference in New Issue
Block a user