4 changed files with 243 additions and 4 deletions
@ -0,0 +1,62 @@ |
|||||||
|
<template> |
||||||
|
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #toolbar> |
||||||
|
<a-button type="warning" v-auth="['infra:job:export']" :preIcon="IconEnum.EXPORT" @click="handleExport"> |
||||||
|
{{ t('action.export') }} |
||||||
|
</a-button> |
||||||
|
</template> |
||||||
|
<template #bodyCell="{ column, record }"> |
||||||
|
<template v-if="column.key === 'action'"> |
||||||
|
<TableAction :actions="[{ icon: IconEnum.EDIT, label: t('action.detail'), onClick: handleDetail.bind(null, record) }]" /> |
||||||
|
</template> |
||||||
|
</template> |
||||||
|
</BasicTable> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup name="InfraJobLog"> |
||||||
|
import { useRoute } from 'vue-router' |
||||||
|
import { useI18n } from '@/hooks/web/useI18n' |
||||||
|
import { useMessage } from '@/hooks/web/useMessage' |
||||||
|
import { IconEnum } from '@/enums/appEnum' |
||||||
|
import { BasicTable, useTable, TableAction } from '@/components/Table' |
||||||
|
import { JobLogExportReqVO, exportJobLog, getJobLogPage } from '@/api/infra/jobLog' |
||||||
|
import { columns, searchFormSchema } from './jobLog.data' |
||||||
|
|
||||||
|
const { t } = useI18n() |
||||||
|
const { query } = useRoute() |
||||||
|
const { createConfirm, createMessage } = useMessage() |
||||||
|
|
||||||
|
const [registerTable, { getForm }] = useTable({ |
||||||
|
title: '定时任务日志列表', |
||||||
|
api: getJobLogPage, |
||||||
|
searchInfo: { id: query.id as unknown as number }, |
||||||
|
columns, |
||||||
|
formConfig: { labelWidth: 120, schemas: searchFormSchema }, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
showIndexColumn: false, |
||||||
|
actionColumn: { |
||||||
|
width: 140, |
||||||
|
title: t('common.action'), |
||||||
|
dataIndex: 'action', |
||||||
|
fixed: 'right' |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
function handleDetail() { |
||||||
|
console.info('detail') |
||||||
|
} |
||||||
|
|
||||||
|
async function handleExport() { |
||||||
|
createConfirm({ |
||||||
|
title: t('common.exportTitle'), |
||||||
|
iconType: 'warning', |
||||||
|
content: t('common.exportMessage'), |
||||||
|
async onOk() { |
||||||
|
await exportJobLog(getForm().getFieldsValue() as JobLogExportReqVO) |
||||||
|
createMessage.success(t('common.exportSuccessText')) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
</script> |
@ -0,0 +1,146 @@ |
|||||||
|
import { BasicColumn, FormSchema, useRender } from '@/components/Table' |
||||||
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: '日志编号', |
||||||
|
dataIndex: 'id', |
||||||
|
width: 100 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '任务编号', |
||||||
|
dataIndex: 'jobId', |
||||||
|
width: 180 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '处理器的名字', |
||||||
|
dataIndex: 'handlerName', |
||||||
|
width: 180 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '处理器的参数', |
||||||
|
dataIndex: 'handlerParam', |
||||||
|
width: 180 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '第几次执行', |
||||||
|
dataIndex: 'executeIndex', |
||||||
|
width: 100 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '执行时间', |
||||||
|
dataIndex: 'beginTime', |
||||||
|
width: 180, |
||||||
|
customRender: ({ record }) => { |
||||||
|
return useRender.renderDate(record.beginTime) + ' ~ ' + useRender.renderDate(record.endTime) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '执行时长', |
||||||
|
dataIndex: 'duration', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderText(text, ' 毫秒') |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '任务状态', |
||||||
|
dataIndex: 'status', |
||||||
|
width: 180, |
||||||
|
customRender: ({ record }) => { |
||||||
|
return useRender.renderDict(record.beginTime, DICT_TYPE.INFRA_JOB_LOG_STATUS) |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
label: '处理器的名字', |
||||||
|
field: 'handlerName', |
||||||
|
component: 'Input', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '开始执行时间', |
||||||
|
field: 'beginTime', |
||||||
|
component: 'DatePicker', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '结束执行时间', |
||||||
|
field: 'endTime', |
||||||
|
component: 'DatePicker', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '任务状态', |
||||||
|
field: 'status', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.INFRA_JOB_STATUS) |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '处理器的名字', |
||||||
|
field: 'handlerName', |
||||||
|
component: 'Input', |
||||||
|
colProps: { span: 8 } |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
label: '任务编号', |
||||||
|
field: 'id', |
||||||
|
show: false, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '任务名称', |
||||||
|
field: 'name', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '处理器的名字', |
||||||
|
field: 'handlerName', |
||||||
|
required: true, |
||||||
|
dynamicDisabled: ({ values }) => !!values.id, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '处理器的参数', |
||||||
|
field: 'handlerParam', |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'CRON 表达式', |
||||||
|
field: 'cronExpression', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '重试次数', |
||||||
|
field: 'retryCount', |
||||||
|
required: true, |
||||||
|
helpMessage: '设置为 0 时,不进行重试', |
||||||
|
defaultValue: 0, |
||||||
|
component: 'InputNumber' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '重试间隔', |
||||||
|
field: 'retryInterval', |
||||||
|
required: true, |
||||||
|
helpMessage: '单位:毫秒。设置为 0 时,无需间隔', |
||||||
|
defaultValue: 0, |
||||||
|
component: 'InputNumber', |
||||||
|
suffix: '毫秒' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '监控超时时间', |
||||||
|
field: 'monitorTimeout', |
||||||
|
component: 'Input', |
||||||
|
suffix: '毫秒' |
||||||
|
} |
||||||
|
] |
Reference in new issue