Commit cde70839 authored by 涂伟's avatar 涂伟

fix: '维保配置新增小时配置逻辑'

parent 49caf071
Pipeline #89239 passed with stages
......@@ -517,6 +517,7 @@ const AddModal = props => {
form.validateFields().then(validate => {
if (validate) {
let obj = form.getFieldsValue();
console.log(obj, 'objobjobjobj');
let mappingFields = formAdd.getFieldValue('parmars');
mappingFields &&
mappingFields.forEach(i => {
......@@ -530,6 +531,7 @@ const AddModal = props => {
let StartExecLen = 0;
let EndExecLen = 0;
let data = timeData.current.getdata;
console.log(data, 'datadatadata');
let startLen = data.startLen;
if (data.Unit == 'week') {
StartExecLen = getNum(data.cities, data);
......@@ -546,6 +548,10 @@ const AddModal = props => {
StartExecLen = obg[data.MonthType1] * 31 + data.MonthDayType1 * 1 - startLen;
EndExecLen = obg[data.MonthType2] * 31 + data.MonthDayType2 * 1 - startLen;
}
if (data.Unit == 'hour') {
StartExecLen = data.HourDayType1
EndExecLen = data.HourType === '今' ? data.HourDayType2 : 24 + data.HourDayType2;
}
let UnitObj = {
hour: '小时',
day: '日',
......@@ -569,11 +575,15 @@ const AddModal = props => {
} else if (data.Unit === 'week') {
lastData.StartExecLen = 1;
lastData.EndExecLen = 7;
} else if (data.Unit === 'hour') {
lastData.StartExecLen = 0;
lastData.EndExecLen = 1;
}
} else {
lastData.time = true;
}
obj.docycle = JSON.stringify(lastData);
console.log(obj.docycle,'ssssssssssss');
let arr = [];
dataSource.forEach(i => {
arr.push(i.name);
......
......@@ -37,6 +37,9 @@ const BaseConfig = (props, ref) => {
const [Unit, setValue] = useState();
const [visibleChecked, setVisibleChecked] = useState(false);
const [onlineTasks, setOnlineTasks] = useState(0);
const [HourType, setHourType] = useState('今');
const [HourDayType1, setHourDayType1] = useState('0'); // 时选择-日期
const [HourDayType2, setHourDayType2] = useState('1'); // 时选择-日期
const handleInputChange = (value) => {
setOnlineTasks(value);
......@@ -96,8 +99,18 @@ const BaseConfig = (props, ref) => {
setValue('day');
setCycleLen(props.keepTimeData.CycleLen);
} else if (props.keepTimeData?.Unit === '小时') {
console.log(props.keepTimeData,'props.keepTimeDataprops.keepTimeDataprops.keepTimeData');
setValue('hour');
setCycleLen(props.keepTimeData.CycleLen);
setHourDayType1(props.keepTimeData.StartExecLen)
setstartLen(props.keepTimeData.StartExecLen)
if((props.keepTimeData.StartExecLen + props.keepTimeData.CycleLen)>23) {
setHourType('明')
setHourDayType2((props.keepTimeData.StartExecLen + props.keepTimeData.CycleLen) - 24)
} else {
setHourType('今')
setHourDayType2(props.keepTimeData.EndExecLen)
}
}
} else if (props.keepTimeData === '') {
if (props.type === 'add') {
......@@ -146,6 +159,10 @@ const BaseConfig = (props, ref) => {
const onChange = e => {
if (e.target.value === 'hour') {
setCycleLen(1);
setHourDayType1(0);
setHourDayType2(1);
setHourType('今');
setstartLen(0);
} else if (e.target.value === 'day') {
setCycleLen(1);
} else if (e.target.value === 'week') {
......@@ -177,6 +194,9 @@ const BaseConfig = (props, ref) => {
startLen,
Unit,
provinceData: cityData[detailNumToWeek({ type: 'now', day: startLen })],
HourDayType1,
HourDayType2,
HourType,
},
}));
const randerZqsz = value => {
......@@ -348,30 +368,128 @@ const BaseConfig = (props, ref) => {
);
}
if (value == 'hour') {
// return (
// <>
// <Select
// defaultValue={1}
// value={CycleLen}
// style={{
// width: 100,
// }}
// onChange={value => {
// setCycleLen(value);
// }}
// options={[1, 2, 3, 4, 6, 8, 12].map(province => ({
// label: province,
// value: province,
// }))}
// />{' '}
// <span
// style={{
// margin: '5px',
// }}
// >
// 小时一次
// </span>
// </>
// );
return (
<div style={{ display: 'flex', width: '400px' }}>
<div>
<span style={{}}>工作将从 </span>
<Select
// key={'Select3'}
defaultValue={startLen}
style={{
width: 58,
margin: '0 5px 2px',
}}
onChange={(value) => {
setHourDayType1(value)
setstartLen(value);
// if (CycleLen == 0.5) return
// setMonthDayType1(value)
// setMonthDayType2(value == 1 ? 31 : value - 1)
if ((Number(value) + CycleLen) < 24) {
// setMonthType2('首')
setHourType('今')
setHourDayType2(Number(value) + CycleLen)
} else {
setHourType('明')
setHourDayType2(Number(value) + CycleLen - 24)
}
// }
}}
options={[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
].map((city) => ({
label: city,
value: city,
}))}
></Select>
<span>时开始,</span>
</div>
<>
<Select
defaultValue={1}
value={CycleLen}
style={{
width: 100,
width: 60,
}}
onChange={value => {
setCycleLen(value);
onChange={(value) => {
setCycleLen(value)
setHourDayType2(Number(HourDayType1) + value)
if ((Number(HourDayType1) + value) < 24) {
// setMonthType2('首')
setHourType('今')
setHourDayType2(Number(HourDayType1) + value)
} else {
setHourType('明')
setHourDayType2(Number(HourDayType1) + value - 24)
}
}}
options={[1, 2, 3, 4, 6, 8, 12].map(province => ({
options={[1, 2, 3, 4, 6, 8, 12, 24].map((province) => ({
label: province,
value: province,
}))}
/>{' '}
<span
style={{
margin: '5px',
margin: '5px 2px',
}}
>
小时一次
</span>
</>
</div>
);
}
return <></>;
......@@ -721,40 +839,141 @@ const BaseConfig = (props, ref) => {
</>
);
} else if (value == 'hour') {
if (CycleLen == 1) {
return (
<span style={{ color: 'red' }}>*每天 0-1时 1-2时 2-3时 3-4时 4-5时 执行以此类推..</span>
);
}
if (CycleLen == 2) {
return (
<span style={{ color: 'red' }}>*每天 0-2时 2-4时 4-6时 6-8时 8-10时 执行以此类推..</span>
);
}
if (CycleLen == 3) {
// if (CycleLen == 1) {
// return (
// <span style={{ color: 'red' }}>*每天 0-1时 1-2时 2-3时 3-4时 4-5时 执行以此类推..</span>
// );
// }
// if (CycleLen == 2) {
// return (
// <span style={{ color: 'red' }}>*每天 0-2时 2-4时 4-6时 6-8时 8-10时 执行以此类推..</span>
// );
// }
// if (CycleLen == 3) {
// return (
// <span style={{ color: 'red' }}>
// *每天 0-3时 3-6时 6-9时 9-12时 12-15时 执行以此类推..
// </span>
// );
// }
// if (CycleLen == 4) {
// return (
// <span style={{ color: 'red' }}>
// *每天 0-4时 4-8时 8-12时 12-16时 16-20时 执行以此类推..
// </span>
// );
// }
// if (CycleLen == 6) {
// return <span style={{ color: 'red' }}>*每天 0-6时 6-12时 12-1时 18-24时 执行</span>;
// }
// if (CycleLen == 8) {
// return <span style={{ color: 'red' }}>*每天 0-8时 8-16时 16-24时 执行</span>;
// }
// if (CycleLen == 12) {
// return <span style={{ color: 'red' }}>*每天 0-12时 12-24时 执行</span>;
// }
return (
<span style={{ color: 'red' }}>
*每天 0-3时 3-6时 6-9时 9-12时 12-15时 执行以此类推..
<>
<span
style={{
margin: '5px 2px',
}}
>
将会在
</span>
);
<span
style={{
margin: '5px 2px',
}}
>
今天
</span>
<Select
style={{
width: 58,
margin: '0 5px 2px',
}}
onChange={(value) => {
setHourDayType1(value);
}}
value={HourDayType1}
options={[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23
].map((city) => ({
label: city,
value: city,
// disabled: city < startLen
}))}
></Select>
<span
style={{
margin: '5px 2px',
}}
>
时到
</span>
<Select
key={''}
style={{
width: 58,
margin: '0 5px 2px',
}}
value={HourType}
onChange={(value) => setHourType(value)}
options={['今', '明'].map((city) => ({
label: city,
value: city,
}))
// .slice(0, Math.min(CycleLen + (startLen > 0 ? 1 : 0), 3))
// .map((city) => ({
// label: city,
// value: city,
// disabled: Mobj[city] < Mobj[MonthType1] ? true : false,
// }))
}
if (CycleLen == 4) {
></Select >
<span
style={{
margin: '5px 2px',
}}
>
</span>
<Select
key={'hour'}
style={{
width: 58,
margin: '0 5px 2px',
}}
onChange={(value) => {
setHourDayType2(value);
}}
value={HourDayType2}
options={[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24
].map((city) => {
return (
<span style={{ color: 'red' }}>
*每天 0-4时 4-8时 8-12时 12-16时 16-20时 执行以此类推..
{
label: city,
value: city,
// disabled:
// ((city + (obg[MonthType2])) - (MonthDayType1 + (obg[MonthType1])) > 30)
})
})}
></Select>
<span
style={{
margin: '5px 2px',
}}
>
时 执行任务
</span>
</>
);
}
if (CycleLen == 6) {
return <span style={{ color: 'red' }}>*每天 0-6时 6-12时 12-1时 18-24时 执行</span>;
}
if (CycleLen == 8) {
return <span style={{ color: 'red' }}>*每天 0-8时 8-16时 16-24时 执行</span>;
}
if (CycleLen == 12) {
return <span style={{ color: 'red' }}>*每天 0-12时 12-24时 执行</span>;
}
} else {
return;
}
......@@ -810,7 +1029,7 @@ const BaseConfig = (props, ref) => {
{randerZqsz(Unit)}
</Form.Item>
</Col>
{(Unit === 'week' || Unit === 'month') && (
{(Unit === 'week' || Unit === 'month' || Unit === 'hour') && (
<Col span={24}>
<Form.Item labelCol={{ span: 5 }} name="time" label="制定执行时间">
<Switch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment