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

fix: '周期优化'

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