Commit 6de5ac8f authored by 皮倩雯's avatar 皮倩雯

fix: '周期优化'

parent 386da58d
...@@ -23,12 +23,12 @@ const BaseConfig = (props, ref) => { ...@@ -23,12 +23,12 @@ const BaseConfig = (props, ref) => {
: 3, : 3,
}; };
const weekArr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']; const weekArr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
const [CycleLen, setCycleLen] = useState(2); // xx周期 一次 const [CycleLen, setCycleLen] = useState(1); // xx周期 一次
const [MonthType1, setMonthType1] = useState('首'); // 月选择 首次末 const [MonthType1, setMonthType1] = useState('首'); // 月选择 首次末
const [MonthType2, setMonthType2] = useState('首'); const [MonthType2, setMonthType2] = useState('首');
const [MonthType3, setMonthType3] = useState('首'); const [MonthType3, setMonthType3] = useState('首');
const [MonthDayType1, setMonthDayType1] = useState('1'); // 月选择-日期 const [MonthDayType1, setMonthDayType1] = useState('1'); // 月选择-日期
const [MonthDayType2, setMonthDayType2] = useState('1'); // 月选择-日期 const [MonthDayType2, setMonthDayType2] = useState('31'); // 月选择-日期
const [cities, setCities] = useState('周一'); const [cities, setCities] = useState('周一');
const [secondCity, setSecondCity] = useState(cityData[provinceData[0]][0]); const [secondCity, setSecondCity] = useState(cityData[provinceData[0]][0]);
const [startLen, setstartLen] = useState(1); // 开始日期 const [startLen, setstartLen] = useState(1); // 开始日期
...@@ -98,8 +98,11 @@ const BaseConfig = (props, ref) => { ...@@ -98,8 +98,11 @@ const BaseConfig = (props, ref) => {
}; };
const handleProvinceChange = value => { const handleProvinceChange = value => {
let arr = cityData[detailNumToWeek({ type: 'now', day: startLen })];
if (arr.indexOf(value) > arr.indexOf(secondCity)) {
setSecondCity(arr[arr.length - 1]);
}
setCities(value); setCities(value);
setSecondCity(cityData[value][0]);
}; };
const onSecondCityChange = value => { const onSecondCityChange = value => {
setSecondCity(value); setSecondCity(value);
...@@ -107,20 +110,20 @@ const BaseConfig = (props, ref) => { ...@@ -107,20 +110,20 @@ const BaseConfig = (props, ref) => {
const onChange = e => { const onChange = e => {
if (e.target.value === 'hour') { if (e.target.value === 'hour') {
setCycleLen(2); setCycleLen(1);
} else if (e.target.value === 'day') { } else if (e.target.value === 'day') {
setCycleLen(2); setCycleLen(1);
} else if (e.target.value === 'week') { } else if (e.target.value === 'week') {
setstartLen(1); setstartLen(1);
setCities('周一'); setCities('周一');
setSecondCity('周'); setSecondCity('周');
} else if (e.target.value === 'month') { } else if (e.target.value === 'month') {
setCycleLen(2); setCycleLen(1);
setstartLen(1); setstartLen(1);
setMonthType1('首'); setMonthType1('首');
setMonthType2('首'); setMonthType2('首');
setMonthDayType1('1'); setMonthDayType1('1');
setMonthDayType1('1'); setMonthDayType2('31');
} }
setValue(e.target.value); setValue(e.target.value);
}; };
...@@ -181,7 +184,8 @@ const BaseConfig = (props, ref) => { ...@@ -181,7 +184,8 @@ const BaseConfig = (props, ref) => {
onChange={value => { onChange={value => {
setstartLen(value); setstartLen(value);
setCities(detailNumToWeek({ type: 'now', day: value })); setCities(detailNumToWeek({ type: 'now', day: value }));
setSecondCity(detailNumToWeek({ type: 'now', day: value })); let arr = cityData[provinceData[value - 1]];
setSecondCity(arr[arr.length - 1]);
}} }}
options={[1, 2, 3, 4, 5, 6, 7].map((city, i) => ({ options={[1, 2, 3, 4, 5, 6, 7].map((city, i) => ({
label: weekArr[i], label: weekArr[i],
...@@ -195,48 +199,8 @@ const BaseConfig = (props, ref) => { ...@@ -195,48 +199,8 @@ const BaseConfig = (props, ref) => {
if (value == 'month') { if (value == 'month') {
return ( return (
<div style={{ display: 'flex', width: '400px' }}> <div style={{ display: 'flex', width: '400px' }}>
<Select
value={CycleLen}
style={{
width: 60,
}}
onChange={value => {
setCycleLen(value);
setMonthType1('首');
setMonthType2('首');
setstartLen('1');
setMonthDayType1('1');
setMonthDayType2('1');
}}
options={[1, 2, 3].map(province => ({
label: province,
value: province,
}))}
/>{' '}
<span
style={{
margin: '5px',
}}
>
月一次
</span>
<div> <div>
<span style={{ marginLeft: '44px' }}></span> <span>工作月将从</span>
{/* <Select
style={{
width: 65,
margin: '0 5px',
}}
onChange={(value) => {
setMonthType3(value);
}}
defaultValue={MonthType3}
options={['首', '次', '末'].map((city) => ({
label: city,
value: city,
}))}
/> */}
<Select <Select
key="Select2" key="Select2"
value={startLen} value={startLen}
...@@ -247,10 +211,10 @@ const BaseConfig = (props, ref) => { ...@@ -247,10 +211,10 @@ const BaseConfig = (props, ref) => {
onChange={value => { onChange={value => {
setstartLen(value); setstartLen(value);
if (MonthType1 === '首') { if (MonthType1 === '首') {
setMonthDayType1(value); value > MonthDayType1 && setMonthDayType1(value);
} }
if (MonthType2 === '首') { if (MonthType2 === '首') {
setMonthDayType2(value); value > MonthDayType2 && setMonthDayType2('31');
} }
}} }}
options={[ options={[
...@@ -282,37 +246,66 @@ const BaseConfig = (props, ref) => { ...@@ -282,37 +246,66 @@ const BaseConfig = (props, ref) => {
'26', '26',
'27', '27',
'28', '28',
// '29',
// '30',
// '31',
].map(city => ({ ].map(city => ({
label: city, label: city,
value: city, value: city,
}))} }))}
/> />
<span>号开始</span> <span>日开始,</span>
</div> </div>
<Select
value={CycleLen}
style={{
width: 60,
marginLeft: '3px',
}}
onChange={value => {
setCycleLen(value);
if (value === 1) {
setMonthType1('首');
setMonthType2('首');
if (MonthDayType1 < startLen) {
setMonthDayType1(startLen);
}
if (MonthDayType2 < startLen) {
setMonthDayType2('31');
}
} else if (value === 2) {
if (MonthType2 === '末') {
setMonthType1('首');
setMonthType2('首');
if (MonthDayType1 < startLen) {
setMonthDayType1(startLen);
}
if (MonthDayType2 < startLen) {
setMonthDayType2('31');
}
}
}
}}
options={[1, 2, 3].map(province => ({
label: province,
value: province,
}))}
/>{' '}
<span
style={{
margin: '5px',
}}
>
月一次
</span>
</div> </div>
); );
} }
if (value == 'hour') { if (value == 'hour') {
/* else if(value =='year'){
return <Select
defaultValue='半年一次'
style={{
width: 120,
margin: '0 5px',
}}
options={['半年一次', '一年一次'].map((city) => ({
label: city,
value: city,
}))}
></Select>
}
else if(value =='quarter'){
return <span style={{color:'red'}}>按照1-3月、4-6月、7-9月、10-12月 覆盖计划起止时间,每季度一次</span>
} */
return ( return (
<> <>
<Select <Select
defaultValue={2} defaultValue={1}
value={CycleLen} value={CycleLen}
style={{ style={{
width: 100, width: 100,
...@@ -320,7 +313,7 @@ const BaseConfig = (props, ref) => { ...@@ -320,7 +313,7 @@ const BaseConfig = (props, ref) => {
onChange={value => { onChange={value => {
setCycleLen(value); setCycleLen(value);
}} }}
options={[2, 3, 4, 6, 8, 12].map(province => ({ options={[1, 2, 3, 4, 6, 8, 12].map(province => ({
label: province, label: province,
value: province, value: province,
}))} }))}
...@@ -488,7 +481,7 @@ const BaseConfig = (props, ref) => { ...@@ -488,7 +481,7 @@ const BaseConfig = (props, ref) => {
} else if (value == 'week') { } else if (value == 'week') {
return ( return (
<> <>
<span style={{ marginRight: '5px' }}></span> <span style={{ marginRight: '5px' }}>将会在</span>
<> <>
<Select <Select
// defaultValue={provinceData[0]} // defaultValue={provinceData[0]}
...@@ -497,10 +490,9 @@ const BaseConfig = (props, ref) => { ...@@ -497,10 +490,9 @@ const BaseConfig = (props, ref) => {
width: 90, width: 90,
}} }}
onChange={handleProvinceChange} onChange={handleProvinceChange}
options={provinceData.map(province => ({ options={cityData[detailNumToWeek({ type: 'now', day: startLen })].map(city => ({
label: province, label: city,
value: province, value: city,
disabled: detailSort(province) ? true : false,
}))} }))}
/>{' '} />{' '}
<span <span
...@@ -516,9 +508,11 @@ const BaseConfig = (props, ref) => { ...@@ -516,9 +508,11 @@ const BaseConfig = (props, ref) => {
}} }}
value={secondCity} value={secondCity}
onChange={onSecondCityChange} onChange={onSecondCityChange}
options={cityData[cities].map(city => ({ options={cityData[detailNumToWeek({ type: 'now', day: startLen })].map((city, i) => ({
label: city, label: city,
value: city, value: city,
disabled:
i < cityData[detailNumToWeek({ type: 'now', day: startLen })].indexOf(cities),
}))} }))}
/> />
<span <span
...@@ -526,7 +520,7 @@ const BaseConfig = (props, ref) => { ...@@ -526,7 +520,7 @@ const BaseConfig = (props, ref) => {
margin: '5px', margin: '5px',
}} }}
> >
执行任务 执行任务
</span> </span>
</> </>
</> </>
...@@ -534,7 +528,7 @@ const BaseConfig = (props, ref) => { ...@@ -534,7 +528,7 @@ const BaseConfig = (props, ref) => {
} else if (value == 'month') { } else if (value == 'month') {
return ( return (
<> <>
<span></span> <span>将会在</span>
<Select <Select
style={{ style={{
...@@ -543,7 +537,12 @@ const BaseConfig = (props, ref) => { ...@@ -543,7 +537,12 @@ const BaseConfig = (props, ref) => {
}} }}
onChange={value => { onChange={value => {
setMonthType1(value); setMonthType1(value);
setMonthType2(value); if (['首', '次', '末'].indexOf(value) > ['首', '次', '末'].indexOf(MonthType2)) {
setMonthType2(value);
}
if (value === '首') {
setMonthDayType1(startLen);
}
}} }}
value={MonthType1} value={MonthType1}
options={['首', '次', '末'].slice(0, CycleLen).map(city => ({ options={['首', '次', '末'].slice(0, CycleLen).map(city => ({
...@@ -590,6 +589,9 @@ const BaseConfig = (props, ref) => { ...@@ -590,6 +589,9 @@ const BaseConfig = (props, ref) => {
26, 26,
27, 27,
28, 28,
// 29,
// 30,
// 31,
].map(city => ({ ].map(city => ({
label: city, label: city,
value: city, value: city,
...@@ -601,7 +603,7 @@ const BaseConfig = (props, ref) => { ...@@ -601,7 +603,7 @@ const BaseConfig = (props, ref) => {
margin: '5px', margin: '5px',
}} }}
> >
</span> </span>
<Select <Select
...@@ -657,6 +659,9 @@ const BaseConfig = (props, ref) => { ...@@ -657,6 +659,9 @@ const BaseConfig = (props, ref) => {
26, 26,
27, 27,
28, 28,
// 29,
// 30,
// 31,
].map(city => ({ ].map(city => ({
label: city, label: city,
value: city, value: city,
...@@ -668,7 +673,7 @@ const BaseConfig = (props, ref) => { ...@@ -668,7 +673,7 @@ const BaseConfig = (props, ref) => {
margin: '5px', margin: '5px',
}} }}
> >
执行任务
</span> </span>
</> </>
); );
...@@ -679,6 +684,11 @@ const BaseConfig = (props, ref) => { ...@@ -679,6 +684,11 @@ const BaseConfig = (props, ref) => {
plainOptions={['1号','2号','3号','4号','5号','6号','7号','8号','9号','10号','11号','12号','13号','14号','15号','16号','17号','18号','19号','20号','21号','22号','23号','24号','25号','26号','27号','28号','29号','30号','31号']} plainOptions={['1号','2号','3号','4号','5号','6号','7号','8号','9号','10号','11号','12号','13号','14号','15号','16号','17号','18号','19号','20号','21号','22号','23号','24号','25号','26号','27号','28号','29号','30号','31号']}
></CheckBox> */ ></CheckBox> */
} else if (value == 'hour') { } 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) { 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>
......
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