feat: 定时任务 HttpJob 增加超时时间设置
This commit is contained in:
parent
80d7156f72
commit
7e773f11f2
1
Web/src/types/views.d.ts
vendored
1
Web/src/types/views.d.ts
vendored
@ -355,6 +355,7 @@ interface HttpJobMessage {
|
|||||||
requestUri?: string | null;
|
requestUri?: string | null;
|
||||||
httpMethod?: string | null;
|
httpMethod?: string | null;
|
||||||
body?: string | null;
|
body?: string | null;
|
||||||
|
timeout?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改记录相关字段定义
|
// 修改记录相关字段定义
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
<el-input v-model="state.httpJobMessage.requestUri" placeholder="请求地址" clearable />
|
<el-input v-model="state.httpJobMessage.requestUri" placeholder="请求地址" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</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-form-item label="请求方法">
|
||||||
<el-radio-group v-model="state.httpJobMessage.httpMethod">
|
<el-radio-group v-model="state.httpJobMessage.httpMethod">
|
||||||
<el-radio :value="httpMethodDef.get">Get</el-radio>
|
<el-radio :value="httpMethodDef.get">Get</el-radio>
|
||||||
@ -79,6 +79,19 @@
|
|||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</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-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="isHttpCreateType">
|
||||||
<el-form-item label="请求报文体">
|
<el-form-item label="请求报文体">
|
||||||
<el-input v-model="state.httpJobMessage.body" placeholder="请求报文体" clearable type="textarea" :autosize="{ minRows: 3, maxRows: 6 }" />
|
<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"}',
|
post: '{"Method":"POST"}',
|
||||||
put: '{"Method":"PUT"}',
|
put: '{"Method":"PUT"}',
|
||||||
delete: '{"Method":"DELETE"}',
|
delete: '{"Method":"DELETE"}',
|
||||||
};
|
} as EmptyObjectType;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: String,
|
title: String,
|
||||||
@ -184,7 +197,7 @@ const openDialog = (row: any) => {
|
|||||||
ruleFormRef.value?.resetFields();
|
ruleFormRef.value?.resetFields();
|
||||||
|
|
||||||
// Http请求
|
// Http请求
|
||||||
if (row.id && state.ruleForm.createType === JobCreateTypeEnum.NUMBER_2) {
|
if (state.ruleForm.createType === JobCreateTypeEnum.NUMBER_2) {
|
||||||
state.httpJobMessage = getHttpJobMessage(state.ruleForm.properties);
|
state.httpJobMessage = getHttpJobMessage(state.ruleForm.properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +239,7 @@ const submit = () => {
|
|||||||
RequestUri: state.httpJobMessage.requestUri,
|
RequestUri: state.httpJobMessage.requestUri,
|
||||||
HttpMethod: JSON.parse(state.httpJobMessage.httpMethod + ''),
|
HttpMethod: JSON.parse(state.httpJobMessage.httpMethod + ''),
|
||||||
Body: state.httpJobMessage.body,
|
Body: state.httpJobMessage.body,
|
||||||
|
Timeout: state.httpJobMessage.timeout == 0 ? -1 : state.httpJobMessage.timeout, // 0 用户填写0,转换为 -1,HttpClient 不支持设置超时时间为 0
|
||||||
ClientName: 'HttpJob',
|
ClientName: 'HttpJob',
|
||||||
EnsureSuccessStatusCode: true,
|
EnsureSuccessStatusCode: true,
|
||||||
});
|
});
|
||||||
@ -244,7 +258,11 @@ const submit = () => {
|
|||||||
|
|
||||||
// 根据任务属性获取 HttpJobMessage
|
// 根据任务属性获取 HttpJobMessage
|
||||||
const getHttpJobMessage = (properties: string | undefined | null): 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 propData = JSON.parse(properties);
|
||||||
const httpJobMessageNet = JSON.parse(propData['HttpJob']); // 后端大写开头的 HttpJobMessage
|
const httpJobMessageNet = JSON.parse(propData['HttpJob']); // 后端大写开头的 HttpJobMessage
|
||||||
@ -253,6 +271,7 @@ const getHttpJobMessage = (properties: string | undefined | null): HttpJobMessag
|
|||||||
requestUri: httpJobMessageNet.RequestUri,
|
requestUri: httpJobMessageNet.RequestUri,
|
||||||
httpMethod: JSON.stringify(httpJobMessageNet.HttpMethod),
|
httpMethod: JSON.stringify(httpJobMessageNet.HttpMethod),
|
||||||
body: httpJobMessageNet.Body,
|
body: httpJobMessageNet.Body,
|
||||||
|
timeout: httpJobMessageNet.Timeout,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -174,6 +174,9 @@
|
|||||||
<el-descriptions-item label="请求报文体" label-align="right" label-class-name="job-index-descriptions-label-style">
|
<el-descriptions-item label="请求报文体" label-align="right" label-class-name="job-index-descriptions-label-style">
|
||||||
{{ getHttpJobMessage((row as JobDetailOutput).jobDetail?.properties).body }}
|
{{ getHttpJobMessage((row as JobDetailOutput).jobDetail?.properties).body }}
|
||||||
</el-descriptions-item>
|
</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-descriptions>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
@ -503,14 +506,7 @@ const openJobDashboard = () => {
|
|||||||
|
|
||||||
// 根据任务属性获取 HttpJobMessage
|
// 根据任务属性获取 HttpJobMessage
|
||||||
const getHttpJobMessage = (properties: string | undefined | null): HttpJobMessage => {
|
const getHttpJobMessage = (properties: string | undefined | null): HttpJobMessage => {
|
||||||
if (properties === undefined || properties === null || properties === '') return {};
|
return editJobDetailRef.value?.getHttpJobMessage(properties)!;
|
||||||
const propData = JSON.parse(properties);
|
|
||||||
const httpJobMessageNet = JSON.parse(propData['HttpJob']); // 后端大写开头的 HttpJobMessage
|
|
||||||
return {
|
|
||||||
requestUri: httpJobMessageNet.RequestUri,
|
|
||||||
httpMethod: JSON.stringify(httpJobMessageNet.HttpMethod),
|
|
||||||
body: httpJobMessageNet.Body,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取请求方法的对应描述
|
// 获取请求方法的对应描述
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user