Commit cde70839 authored by 涂伟's avatar 涂伟

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

parent 49caf071
Pipeline #89239 passed with stages
...@@ -517,6 +517,7 @@ const AddModal = props => { ...@@ -517,6 +517,7 @@ const AddModal = props => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
console.log(obj, 'objobjobjobj');
let mappingFields = formAdd.getFieldValue('parmars'); let mappingFields = formAdd.getFieldValue('parmars');
mappingFields && mappingFields &&
mappingFields.forEach(i => { mappingFields.forEach(i => {
...@@ -530,6 +531,7 @@ const AddModal = props => { ...@@ -530,6 +531,7 @@ const AddModal = props => {
let StartExecLen = 0; let StartExecLen = 0;
let EndExecLen = 0; let EndExecLen = 0;
let data = timeData.current.getdata; let data = timeData.current.getdata;
console.log(data, 'datadatadata');
let startLen = data.startLen; let startLen = data.startLen;
if (data.Unit == 'week') { if (data.Unit == 'week') {
StartExecLen = getNum(data.cities, data); StartExecLen = getNum(data.cities, data);
...@@ -546,6 +548,10 @@ const AddModal = props => { ...@@ -546,6 +548,10 @@ const AddModal = props => {
StartExecLen = obg[data.MonthType1] * 31 + data.MonthDayType1 * 1 - startLen; StartExecLen = obg[data.MonthType1] * 31 + data.MonthDayType1 * 1 - startLen;
EndExecLen = obg[data.MonthType2] * 31 + data.MonthDayType2 * 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 = { let UnitObj = {
hour: '小时', hour: '小时',
day: '日', day: '日',
...@@ -569,11 +575,15 @@ const AddModal = props => { ...@@ -569,11 +575,15 @@ const AddModal = props => {
} else if (data.Unit === 'week') { } else if (data.Unit === 'week') {
lastData.StartExecLen = 1; lastData.StartExecLen = 1;
lastData.EndExecLen = 7; lastData.EndExecLen = 7;
} else if (data.Unit === 'hour') {
lastData.StartExecLen = 0;
lastData.EndExecLen = 1;
} }
} else { } else {
lastData.time = true; lastData.time = true;
} }
obj.docycle = JSON.stringify(lastData); obj.docycle = JSON.stringify(lastData);
console.log(obj.docycle,'ssssssssssss');
let arr = []; let arr = [];
dataSource.forEach(i => { dataSource.forEach(i => {
arr.push(i.name); arr.push(i.name);
......
...@@ -37,6 +37,9 @@ const BaseConfig = (props, ref) => { ...@@ -37,6 +37,9 @@ const BaseConfig = (props, ref) => {
const [Unit, setValue] = useState(); const [Unit, setValue] = useState();
const [visibleChecked, setVisibleChecked] = useState(false); const [visibleChecked, setVisibleChecked] = useState(false);
const [onlineTasks, setOnlineTasks] = useState(0); const [onlineTasks, setOnlineTasks] = useState(0);
const [HourType, setHourType] = useState('今');
const [HourDayType1, setHourDayType1] = useState('0'); // 时选择-日期
const [HourDayType2, setHourDayType2] = useState('1'); // 时选择-日期
const handleInputChange = (value) => { const handleInputChange = (value) => {
setOnlineTasks(value); setOnlineTasks(value);
...@@ -96,8 +99,18 @@ const BaseConfig = (props, ref) => { ...@@ -96,8 +99,18 @@ const BaseConfig = (props, ref) => {
setValue('day'); setValue('day');
setCycleLen(props.keepTimeData.CycleLen); setCycleLen(props.keepTimeData.CycleLen);
} else if (props.keepTimeData?.Unit === '小时') { } else if (props.keepTimeData?.Unit === '小时') {
console.log(props.keepTimeData,'props.keepTimeDataprops.keepTimeDataprops.keepTimeData');
setValue('hour'); setValue('hour');
setCycleLen(props.keepTimeData.CycleLen); 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 === '') { } else if (props.keepTimeData === '') {
if (props.type === 'add') { if (props.type === 'add') {
...@@ -146,6 +159,10 @@ const BaseConfig = (props, ref) => { ...@@ -146,6 +159,10 @@ const BaseConfig = (props, ref) => {
const onChange = e => { const onChange = e => {
if (e.target.value === 'hour') { if (e.target.value === 'hour') {
setCycleLen(1); setCycleLen(1);
setHourDayType1(0);
setHourDayType2(1);
setHourType('今');
setstartLen(0);
} else if (e.target.value === 'day') { } else if (e.target.value === 'day') {
setCycleLen(1); setCycleLen(1);
} else if (e.target.value === 'week') { } else if (e.target.value === 'week') {
...@@ -177,6 +194,9 @@ const BaseConfig = (props, ref) => { ...@@ -177,6 +194,9 @@ const BaseConfig = (props, ref) => {
startLen, startLen,
Unit, Unit,
provinceData: cityData[detailNumToWeek({ type: 'now', day: startLen })], provinceData: cityData[detailNumToWeek({ type: 'now', day: startLen })],
HourDayType1,
HourDayType2,
HourType,
}, },
})); }));
const randerZqsz = value => { const randerZqsz = value => {
...@@ -348,30 +368,128 @@ const BaseConfig = (props, ref) => { ...@@ -348,30 +368,128 @@ const BaseConfig = (props, ref) => {
); );
} }
if (value == 'hour') { 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 ( 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 <Select
defaultValue={1} defaultValue={1}
value={CycleLen} value={CycleLen}
style={{ style={{
width: 100, width: 60,
}} }}
onChange={value => { onChange={(value) => {
setCycleLen(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, label: province,
value: province, value: province,
}))} }))}
/>{' '} />{' '}
<span <span
style={{ style={{
margin: '5px', margin: '5px 2px',
}} }}
> >
小时一次 小时一次
</span> </span>
</> </>
</div>
); );
} }
return <></>; return <></>;
...@@ -721,40 +839,141 @@ const BaseConfig = (props, ref) => { ...@@ -721,40 +839,141 @@ const BaseConfig = (props, ref) => {
</> </>
); );
} else if (value == 'hour') { } else if (value == 'hour') {
if (CycleLen == 1) { // if (CycleLen == 1) {
return ( // return (
<span style={{ color: 'red' }}>*每天 0-1时 1-2时 2-3时 3-4时 4-5时 执行以此类推..</span> // <span style={{ color: 'red' }}>*每天 0-1时 1-2时 2-3时 3-4时 4-5时 执行以此类推..</span>
); // );
} // }
if (CycleLen == 2) { // if (CycleLen == 2) {
return ( // return (
<span style={{ color: 'red' }}>*每天 0-2时 2-4时 4-6时 6-8时 8-10时 执行以此类推..</span> // <span style={{ color: 'red' }}>*每天 0-2时 2-4时 4-6时 6-8时 8-10时 执行以此类推..</span>
); // );
} // }
if (CycleLen == 3) { // 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 ( return (
<span style={{ color: 'red' }}> <>
*每天 0-3时 3-6时 6-9时 9-12时 12-15时 执行以此类推.. <span
style={{
margin: '5px 2px',
}}
>
将会在
</span> </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 ( 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> </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 { } else {
return; return;
} }
...@@ -810,7 +1029,7 @@ const BaseConfig = (props, ref) => { ...@@ -810,7 +1029,7 @@ const BaseConfig = (props, ref) => {
{randerZqsz(Unit)} {randerZqsz(Unit)}
</Form.Item> </Form.Item>
</Col> </Col>
{(Unit === 'week' || Unit === 'month') && ( {(Unit === 'week' || Unit === 'month' || Unit === 'hour') && (
<Col span={24}> <Col span={24}>
<Form.Item labelCol={{ span: 5 }} name="time" label="制定执行时间"> <Form.Item labelCol={{ span: 5 }} name="time" label="制定执行时间">
<Switch <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