签入版本
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import { h } from 'vue';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
fixed: 'left',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '任务名称',
|
||||
dataIndex: 'jobName',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '任务组名',
|
||||
dataIndex: 'jobGroup',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '任务触发器',
|
||||
dataIndex: 'jobTrigger',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '任务日志信息',
|
||||
dataIndex: 'jobMessage',
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
title: '执行表达式',
|
||||
dataIndex: 'cronExpression',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '执行状态',
|
||||
dataIndex: 'status',
|
||||
width: 100,
|
||||
customRender({ record }) {
|
||||
let typeText = '';
|
||||
switch (record.status) {
|
||||
case 0:
|
||||
typeText = '未发布';
|
||||
break;
|
||||
case 1:
|
||||
typeText = '运行中';
|
||||
break;
|
||||
case 2:
|
||||
typeText = '暂停';
|
||||
break;
|
||||
case 3:
|
||||
typeText = '删除';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return h('span', typeText || '-');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '任务开始时间',
|
||||
dataIndex: 'startTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '任务结束时间',
|
||||
dataIndex: 'startTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '任务执行时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '任务执行耗时',
|
||||
dataIndex: 'consumeTime',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="props.visible" title="日志详情" width="800px" @cancel="dialogClose">
|
||||
<a-descriptions :column="2" bordered :labelStyle="{ width: '160px' }">
|
||||
<a-descriptions-item label="任务名称:">{{ formData.jobName }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务组名:">{{ formData.jobGroup }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务触发器:">{{ formData.jobTrigger }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务日志信息:">{{ formData.jobMessage }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务执行表达式:">{{
|
||||
formData.cronExpression
|
||||
}}</a-descriptions-item>
|
||||
<a-descriptions-item label="请求状态">
|
||||
<a-tag :color="formData.status ? 'danger' : 'success'">{{
|
||||
formData.status ? '异常' : '正常'
|
||||
}}</a-tag>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="任务开始时间:">{{ formData.startTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务结束时间:">{{ formData.endTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务执行时间:">{{ formData.createTime }}</a-descriptions-item>
|
||||
<a-descriptions-item label="任务执行耗时:">{{ formData.consumeTime }}ms</a-descriptions-item>
|
||||
<a-descriptions-item label="执行异常信息:" :span="3">{{
|
||||
formData.exceptionInfo
|
||||
}}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<a-button @click="dialogClose">关闭</a-button>
|
||||
</span>
|
||||
</template>
|
||||
</a-modal>
|
||||
</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: '',
|
||||
status: '',
|
||||
cronExpression: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
createTime: '',
|
||||
consumeTime: '',
|
||||
exceptionInfo: '',
|
||||
});
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 钩子函数
|
||||
*/
|
||||
onMounted(() => {
|
||||
if (props.logId) {
|
||||
setFormData();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="props.visible" title="调度日志" :width="size" @close="dialogClose" :closable="false">
|
||||
<template #extra>
|
||||
<CloseOutlined style="font-size: 16px;color:rgba(0, 0, 0, 0.45);cursor: pointer;" @click="dialogClose" />
|
||||
</template>
|
||||
<a-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset" />
|
||||
</a-card>
|
||||
<a-card :bordered="false" class="proCard">
|
||||
<BasicTable
|
||||
:columns="columns"
|
||||
:request="loadDataTable"
|
||||
:row-key="(row) => row.id"
|
||||
ref="tableRef"
|
||||
:row-selection="{ onChange: onSelectionChange }"
|
||||
>
|
||||
<template #tableTitle>
|
||||
<a-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
删除
|
||||
</a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="handleDetail(record.id)">
|
||||
<template #icon><EyeOutlined /></template>
|
||||
详情
|
||||
</a-button>
|
||||
<a-button type="primary" danger @click="handleDelete(record.id)">
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
删除
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</a-card>
|
||||
<editDialog v-if="editVisible" :logId="logId" v-model:visible="editVisible" />
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, h, nextTick, defineAsyncComponent } from 'vue';
|
||||
import { schemas } from './querySchemas';
|
||||
import { useForm } from '@/components/Form/index';
|
||||
import { EyeOutlined, DeleteOutlined,CloseOutlined } from '@ant-design/icons-vue';
|
||||
import { getJobLogList, jobLogDelete, jobLogBatchDelete } from '@/api/monitor/job';
|
||||
import { columns } from './columns';
|
||||
import { Modal, message } from 'ant-design-vue';
|
||||
|
||||
/**
|
||||
* 导入组件
|
||||
*/
|
||||
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
|
||||
const emit = defineEmits(['update:visible']);
|
||||
const editVisible = ref(false);
|
||||
const logId = ref(0);
|
||||
const size = document.body.clientWidth - 500;
|
||||
const selectionData = ref([]);
|
||||
const tableRef = ref();
|
||||
|
||||
/**
|
||||
* 定义接收的参数
|
||||
*/
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false,
|
||||
},
|
||||
jobId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 定义查询参数
|
||||
*/
|
||||
const formParams = reactive({
|
||||
jobName: '',
|
||||
status: '',
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载数据列表
|
||||
* @param res 参数
|
||||
*/
|
||||
const loadDataTable = async (res: any) => {
|
||||
const result = await getJobLogList({ ...formParams, jobId: props.jobId, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 刷新数据列表
|
||||
* @param noRefresh 参数
|
||||
*/
|
||||
function reloadTable(noRefresh = '') {
|
||||
tableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
const [register, {}] = useForm({
|
||||
rowProps: { gutter: [16, 0] },
|
||||
colProps: {
|
||||
xs: 24,
|
||||
sm: 24,
|
||||
md: 12,
|
||||
lg: 8,
|
||||
xl: 6,
|
||||
},
|
||||
labelCol: { span: 6, offset: 0 },
|
||||
schemas,
|
||||
});
|
||||
|
||||
/**
|
||||
* 执行提交表单
|
||||
*/
|
||||
function handleSubmit(values: Recordable) {
|
||||
for (const key in formParams) {
|
||||
formParams[key] = '';
|
||||
}
|
||||
for (const key in values) {
|
||||
formParams[key] = values[key];
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行重置
|
||||
*/
|
||||
function handleReset() {
|
||||
for (const key in formParams) {
|
||||
formParams[key] = '';
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭窗体
|
||||
*/
|
||||
const dialogClose = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行查询详情
|
||||
*/
|
||||
const handleDetail = async (id) => {
|
||||
logId.value = id;
|
||||
await nextTick();
|
||||
editVisible.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行删除
|
||||
*/
|
||||
async function handleDelete(id) {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除?',
|
||||
onOk: async () => {
|
||||
id ? await jobLogDelete(id) : await jobLogBatchDelete(selectionData.value);
|
||||
message.success('删除成功');
|
||||
reloadTable();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 选项发生变化
|
||||
*/
|
||||
function onSelectionChange(value) {
|
||||
selectionData.value = value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { FormSchema } from '@/components/Form/index';
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
name: 'jobName',
|
||||
component: 'Input',
|
||||
label: '任务名称',
|
||||
componentProps: {
|
||||
placeholder: '请输入数据源名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
component: 'Select',
|
||||
label: '任务状态',
|
||||
componentProps: {
|
||||
placeholder: '请选择任务状态',
|
||||
clearable: true,
|
||||
options: [
|
||||
{
|
||||
label: '正常',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '失败',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user