feat: 定时任务 HttpJob 增加超时时间设置

This commit is contained in:
写意 2025-04-18 16:23:09 +08:00
parent 80d7156f72
commit 7e773f11f2
3 changed files with 28 additions and 12 deletions

View File

@ -355,6 +355,7 @@ interface HttpJobMessage {
requestUri?: string | null;
httpMethod?: string | null;
body?: string | null;
timeout?: number | null;
}
// 修改记录相关字段定义

View File

@ -69,7 +69,7 @@
<el-input v-model="state.httpJobMessage.requestUri" placeholder="请求地址" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="isHttpCreateType">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="isHttpCreateType">
<el-form-item label="请求方法">
<el-radio-group v-model="state.httpJobMessage.httpMethod">
<el-radio :value="httpMethodDef.get">Get</el-radio>
@ -79,6 +79,19 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="isHttpCreateType">
<el-form-item>
<template v-slot:label>
<div>
超时时间(ms)
<el-tooltip raw-content content="设为 -1 表示无限等待,留空默认值是 100,000 毫秒100 秒)" placement="top">
<SvgIcon name="fa fa-question-circle-o" :size="16" style="vertical-align: middle" />
</el-tooltip>
</div>
</template>
<el-input-number v-model="state.httpJobMessage.timeout" placeholder="超时时间(ms)" :min="-1" :step="1000" class="w100" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="isHttpCreateType">
<el-form-item label="请求报文体">
<el-input v-model="state.httpJobMessage.body" placeholder="请求报文体" clearable type="textarea" :autosize="{ minRows: 3, maxRows: 6 }" />
@ -117,7 +130,7 @@ const httpMethodDef = {
post: '{"Method":"POST"}',
put: '{"Method":"PUT"}',
delete: '{"Method":"DELETE"}',
};
} as EmptyObjectType;
const props = defineProps({
title: String,
@ -184,7 +197,7 @@ const openDialog = (row: any) => {
ruleFormRef.value?.resetFields();
// Http
if (row.id && state.ruleForm.createType === JobCreateTypeEnum.NUMBER_2) {
if (state.ruleForm.createType === JobCreateTypeEnum.NUMBER_2) {
state.httpJobMessage = getHttpJobMessage(state.ruleForm.properties);
}
@ -226,6 +239,7 @@ const submit = () => {
RequestUri: state.httpJobMessage.requestUri,
HttpMethod: JSON.parse(state.httpJobMessage.httpMethod + ''),
Body: state.httpJobMessage.body,
Timeout: state.httpJobMessage.timeout == 0 ? -1 : state.httpJobMessage.timeout, // 0 0 -1HttpClient 0
ClientName: 'HttpJob',
EnsureSuccessStatusCode: true,
});
@ -244,7 +258,11 @@ const submit = () => {
// HttpJobMessage
const getHttpJobMessage = (properties: string | undefined | null): HttpJobMessage => {
if (properties === undefined || properties === null || properties === '') return {};
if (properties === undefined || properties === null || properties === '')
return {
httpMethod: httpMethodDef.get,
timeout: 100000,
};
const propData = JSON.parse(properties);
const httpJobMessageNet = JSON.parse(propData['HttpJob']); // HttpJobMessage
@ -253,6 +271,7 @@ const getHttpJobMessage = (properties: string | undefined | null): HttpJobMessag
requestUri: httpJobMessageNet.RequestUri,
httpMethod: JSON.stringify(httpJobMessageNet.HttpMethod),
body: httpJobMessageNet.Body,
timeout: httpJobMessageNet.Timeout,
};
};

View File

@ -174,6 +174,9 @@
<el-descriptions-item label="请求报文体" label-align="right" label-class-name="job-index-descriptions-label-style">
{{ getHttpJobMessage((row as JobDetailOutput).jobDetail?.properties).body }}
</el-descriptions-item>
<el-descriptions-item label="超时时间" label-align="right" label-class-name="job-index-descriptions-label-style">
{{ getHttpJobMessage((row as JobDetailOutput).jobDetail?.properties).timeout }}
</el-descriptions-item>
</el-descriptions>
</el-popover>
</div>
@ -503,14 +506,7 @@ const openJobDashboard = () => {
// HttpJobMessage
const getHttpJobMessage = (properties: string | undefined | null): HttpJobMessage => {
if (properties === undefined || properties === null || properties === '') return {};
const propData = JSON.parse(properties);
const httpJobMessageNet = JSON.parse(propData['HttpJob']); // HttpJobMessage
return {
requestUri: httpJobMessageNet.RequestUri,
httpMethod: JSON.stringify(httpJobMessageNet.HttpMethod),
body: httpJobMessageNet.Body,
};
return editJobDetailRef.value?.getHttpJobMessage(properties)!;
};
//