Commit 97f58d2c authored by 皮倩雯's avatar 皮倩雯

fix: '方案制定优化'

parent 0a1f20c2
Pipeline #81779 passed with stages
...@@ -525,41 +525,52 @@ const AddModal = props => { ...@@ -525,41 +525,52 @@ const AddModal = props => {
}); });
obj.isSubmit = visibleChecked === true ? '是' : '否'; obj.isSubmit = visibleChecked === true ? '是' : '否';
obj.autoAssign = visibleChecked1 === true ? '是' : '否'; obj.autoAssign = visibleChecked1 === true ? '是' : '否';
let datas = detailTimeData(timeData.current.getdata);
let StartExecLen = 0;
let EndExecLen = 0;
let data = timeData.current.getdata;
let startLen = data.startLen;
if (data.Unit == 'week') {
StartExecLen = getNum(data.cities, data);
EndExecLen = getNum(data.secondCity, data);
}
if (data.Unit == 'month') {
let obg = {
: 0,
: 1,
: 2,
};
StartExecLen = obg[data.MonthType1] * 31 + data.MonthDayType1 * 1 - startLen;
EndExecLen = obg[data.MonthType2] * 31 + data.MonthDayType2 * 1 - startLen;
}
let UnitObj = {
hour: '小时',
day: '日',
week: '周',
month: '月',
};
let lastData = {
CycleLen: data.CycleLen * 1,
Unit: UnitObj[data.Unit],
StartLen: Number(startLen),
StartExecLen: StartExecLen,
EndExecLen: EndExecLen,
};
obj.inOrder = obj.inOrder ? 1 : 0; obj.inOrder = obj.inOrder ? 1 : 0;
if (!obj.time) { if (!obj.time) {
datas.time = false; lastData.time = false;
if (datas.type === '月') { if (data.Unit === 'month') {
datas.excTime = [ lastData.StartExecLen = 0;
{ lastData.EndExecLen = 31 - lastData.StartLen;
mold: 'begin', } else if (data.Unit === 'week') {
day: 1, lastData.StartExecLen = 1;
type: '首', lastData.EndExecLen = 7;
},
{
mold: 'end',
day: 28,
type: '首',
},
];
} else if (datas.type === '周') {
datas.excTime = [
{
mold: 'begin',
day: 1,
type: 'now',
},
{
mold: 'end',
day: 7,
type: 'now',
},
];
} }
} else { } else {
datas.time = true; lastData.time = true;
} }
obj.docycle = JSON.stringify(datas); obj.docycle = JSON.stringify(lastData);
let arr = []; let arr = [];
dataSource.forEach(i => { dataSource.forEach(i => {
arr.push(i.name); arr.push(i.name);
...@@ -623,77 +634,10 @@ const AddModal = props => { ...@@ -623,77 +634,10 @@ const AddModal = props => {
}); });
}; };
const detailTimeData = val => { const getNum = (a, datas) => {
let data = ''; return datas.provinceData.indexOf(a) + 1;
if (val.Unit === 'month') {
data = {
type: '月',
cycle: val.CycleLen,
begin: val.startLen,
excTime: [
{
mold: 'begin',
day: Number(val.MonthDayType1),
type: val.MonthType1,
},
{
mold: 'end',
day: Number(val.MonthDayType2),
type: val.MonthType2,
},
],
};
return data;
} else if (val.Unit === 'week') {
data = {
type: '周',
cycle: val.startLen,
excTime: [
{
mold: 'begin',
day: detailWeekToNum(val.cities),
type: 'now',
},
{
mold: 'end',
day: detailWeekToNum(val.secondCity),
type: val.secondCity.indexOf('下') !== -1 ? 'next' : 'now',
},
],
};
return data;
} else if (val.Unit === 'day') {
data = {
type: '日',
cycle: val.CycleLen,
};
return data;
} else if (val.Unit === 'hour') {
data = {
type: '小时',
cycle: val.CycleLen,
};
return data;
}
}; };
const detailWeekToNum = val => {
if (val.indexOf('周一') !== -1) {
return 1;
} else if (val.indexOf('周二') !== -1) {
return 2;
} else if (val.indexOf('周三') !== -1) {
return 3;
} else if (val.indexOf('周四') !== -1) {
return 4;
} else if (val.indexOf('周五') !== -1) {
return 5;
} else if (val.indexOf('周六') !== -1) {
return 6;
} else if (val.indexOf('周日') !== -1) {
return 7;
}
};
const inputType1 = e => { const inputType1 = e => {
setType1(e.target.value); setType1(e.target.value);
form.setFieldsValue({ businessType: e.target.value }); form.setFieldsValue({ businessType: e.target.value });
......
...@@ -26,9 +26,8 @@ const BaseConfig = (props, ref) => { ...@@ -26,9 +26,8 @@ const BaseConfig = (props, ref) => {
const [CycleLen, setCycleLen] = useState(1); // 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 [MonthDayType1, setMonthDayType1] = useState('1'); // 月选择-日期 const [MonthDayType1, setMonthDayType1] = useState('1'); // 月选择-日期
const [MonthDayType2, setMonthDayType2] = useState('28'); // 月选择-日期 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); // 开始日期
...@@ -40,33 +39,58 @@ const BaseConfig = (props, ref) => { ...@@ -40,33 +39,58 @@ const BaseConfig = (props, ref) => {
if (props.keepTimeData?.time) { if (props.keepTimeData?.time) {
setVisibleChecked(true); setVisibleChecked(true);
} }
let aa = props.keepTimeData; if (props.keepTimeData?.Unit === '月') {
let type = props.keepTimeData.type;
let num = props.keepTimeData.cycle;
if (type === '月') {
setValue('month'); setValue('month');
setCycleLen(num); setCycleLen(props.keepTimeData.CycleLen);
setstartLen(props.keepTimeData.begin); setstartLen(props.keepTimeData.StartLen);
// setMonthType3(props.keepTimeData.begin.type); if (props.keepTimeData.StartExecLen + props.keepTimeData.StartLen < 32) {
setMonthType1(props.keepTimeData.excTime[0].type); setMonthType1('首');
setMonthType2(props.keepTimeData.excTime[1].type); setMonthDayType1(props.keepTimeData.StartExecLen + props.keepTimeData.StartLen);
setMonthDayType1(props.keepTimeData.excTime[0].day); } else if (props.keepTimeData.StartExecLen + props.keepTimeData.StartLen < 63) {
setMonthDayType2(props.keepTimeData.excTime[1].day); setMonthType1('次');
} else if (type === '周') { setMonthDayType1(props.keepTimeData.StartExecLen - 31 + props.keepTimeData.StartLen);
} else if (props.keepTimeData.StartExecLen + props.keepTimeData.StartLen < 94) {
setMonthType1('末');
setMonthDayType1(props.keepTimeData.StartExecLen - 62 + props.keepTimeData.StartLen);
}
// else if (props.keepTimeData.StartExecLen + props.keepTimeData.StartLen < 187) {
// setMonthType1(6);
// setMonthDayType1(props.keepTimeData.StartExecLen - 155 + props.keepTimeData.StartLen);
// } else if (props.keepTimeData.StartExecLen + props.keepTimeData.StartLen < 373) {
// setMonthType1(12);
// setMonthDayType1(props.keepTimeData.StartExecLen - 341 + props.keepTimeData.StartLen);
// }
if (props.keepTimeData.EndExecLen + props.keepTimeData.StartLen < 32) {
setMonthType2('首');
setMonthDayType2(props.keepTimeData.EndExecLen + props.keepTimeData.StartLen);
} else if (props.keepTimeData.EndExecLen + props.keepTimeData.StartLen < 63) {
setMonthType2('次');
setMonthDayType2(props.keepTimeData.EndExecLen - 31 + props.keepTimeData.StartLen);
} else if (props.keepTimeData.EndExecLen + props.keepTimeData.StartLen < 94) {
setMonthType2('末');
setMonthDayType2(props.keepTimeData.EndExecLen - 62 + props.keepTimeData.StartLen);
}
// else if (props.keepTimeData.EndExecLen + props.keepTimeData.StartLen < 187) {
// setMonthType2(6);
// setMonthDayType2(props.keepTimeData.EndExecLen - 155 + props.keepTimeData.StartLen);
// } else if (props.keepTimeData.EndExecLen + props.keepTimeData.StartLen < 373) {
// setMonthType2(12);
// setMonthDayType2(props.keepTimeData.EndExecLen - 341 + props.keepTimeData.StartLen);
// }
} else if (props.keepTimeData?.Unit === '周') {
setCycleLen(props.keepTimeData.CycleLen);
let zix = weekArr[props.keepTimeData.StartLen - 1]; // 执行开始周
setValue('week'); setValue('week');
setstartLen(num); setstartLen(props.keepTimeData.StartLen);
let start = props.keepTimeData.excTime[0]; setCities(cityData[zix][props.keepTimeData.StartExecLen - 1]);
let data = detailNumToWeek(start); setSecondCity(cityData[zix][props.keepTimeData.EndExecLen - 1]);
let end = props.keepTimeData.excTime[1]; } else if (props.keepTimeData?.Unit === '日') {
let data1 = detailNumToWeek(end);
setCities(data);
setSecondCity(data1);
} else if (type === '日') {
setValue('day'); setValue('day');
setCycleLen(num); setCycleLen(props.keepTimeData.CycleLen);
} else if (type === '小时') { } else if (props.keepTimeData?.Unit === '小时') {
setValue('hour'); setValue('hour');
setCycleLen(num); setCycleLen(props.keepTimeData.CycleLen);
} }
} else if (props.keepTimeData === '') { } else if (props.keepTimeData === '') {
if (props.type === 'add') { if (props.type === 'add') {
...@@ -127,7 +151,7 @@ const BaseConfig = (props, ref) => { ...@@ -127,7 +151,7 @@ const BaseConfig = (props, ref) => {
setMonthType1('首'); setMonthType1('首');
setMonthType2('首'); setMonthType2('首');
setMonthDayType1('1'); setMonthDayType1('1');
setMonthDayType2('28'); setMonthDayType2('31');
} }
setValue(e.target.value); setValue(e.target.value);
}; };
...@@ -145,6 +169,7 @@ const BaseConfig = (props, ref) => { ...@@ -145,6 +169,7 @@ const BaseConfig = (props, ref) => {
secondCity, secondCity,
startLen, startLen,
Unit, Unit,
provinceData: cityData[detailNumToWeek({ type: 'now', day: startLen })],
}, },
})); }));
const randerZqsz = value => { const randerZqsz = value => {
...@@ -196,7 +221,49 @@ const BaseConfig = (props, ref) => { ...@@ -196,7 +221,49 @@ const BaseConfig = (props, ref) => {
value: city, value: city,
}))} }))}
/> />
<span>开始</span> <span>开始,</span>
<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].map(province => ({
label: province,
value: province,
}))}
/>
<span
style={{
margin: '5px',
}}
>
周一次
</span>
</div> </div>
); );
} }
...@@ -218,7 +285,7 @@ const BaseConfig = (props, ref) => { ...@@ -218,7 +285,7 @@ const BaseConfig = (props, ref) => {
value > MonthDayType1 && setMonthDayType1(value); value > MonthDayType1 && setMonthDayType1(value);
} }
if (MonthType2 === '首') { if (MonthType2 === '首') {
value > MonthDayType2 && setMonthDayType2('28'); value > MonthDayType2 && setMonthDayType2('31');
} }
}} }}
options={[ options={[
...@@ -250,9 +317,9 @@ const BaseConfig = (props, ref) => { ...@@ -250,9 +317,9 @@ const BaseConfig = (props, ref) => {
'26', '26',
'27', '27',
'28', '28',
// '29', '29',
// '30', '30',
// '31', '31',
].map(city => ({ ].map(city => ({
label: city, label: city,
value: city, value: city,
...@@ -275,7 +342,7 @@ const BaseConfig = (props, ref) => { ...@@ -275,7 +342,7 @@ const BaseConfig = (props, ref) => {
setMonthDayType1(startLen); setMonthDayType1(startLen);
} }
if (MonthDayType2 < startLen) { if (MonthDayType2 < startLen) {
setMonthDayType2('28'); setMonthDayType2('31');
} }
} else if (value === 2) { } else if (value === 2) {
if (MonthType2 === '末') { if (MonthType2 === '末') {
...@@ -285,16 +352,16 @@ const BaseConfig = (props, ref) => { ...@@ -285,16 +352,16 @@ const BaseConfig = (props, ref) => {
setMonthDayType1(startLen); setMonthDayType1(startLen);
} }
if (MonthDayType2 < startLen) { if (MonthDayType2 < startLen) {
setMonthDayType2('28'); setMonthDayType2('31');
} }
} }
} }
}} }}
options={[1, 2, 3, 6, 12].map(province => ({ options={[1, 2, 3].map(province => ({
label: province, label: province,
value: province, value: province,
}))} }))}
/>{' '} />
<span <span
style={{ style={{
margin: '5px', margin: '5px',
...@@ -593,22 +660,16 @@ const BaseConfig = (props, ref) => { ...@@ -593,22 +660,16 @@ const BaseConfig = (props, ref) => {
26, 26,
27, 27,
28, 28,
// 29, 29,
// 30, 30,
// 31, 31,
].map(city => ({ ].map(city => ({
label: city, label: city,
value: city, value: city,
disabled: MonthType1 === '首' && city < startLen ? true : false, disabled: MonthType1 === '首' && city < startLen ? true : false,
}))} }))}
/> />
<span <span>日到</span>
style={{
margin: '5px',
}}
>
日到
</span>
<Select <Select
key="MonthType2" key="MonthType2"
...@@ -663,9 +724,9 @@ const BaseConfig = (props, ref) => { ...@@ -663,9 +724,9 @@ const BaseConfig = (props, ref) => {
26, 26,
27, 27,
28, 28,
// 29, 29,
// 30, 30,
// 31, 31,
].map(city => ({ ].map(city => ({
label: city, label: city,
value: city, value: city,
......
...@@ -421,14 +421,14 @@ const maintenance = () => { ...@@ -421,14 +421,14 @@ const maintenance = () => {
return record; return record;
} else { } else {
let list = JSON.parse(record); let list = JSON.parse(record);
if (list.type === '小时') { if (list.Unit === '小时') {
return <Tag color="#2db7f5">{list.cycle}小时一次</Tag>; return <Tag color="#2db7f5">{list.CycleLen}小时一次</Tag>;
} else if (list.type === '日') { } else if (list.Unit === '日') {
return <Tag color="#08979c">{list.cycle}日一次</Tag>; return <Tag color="#08979c">{list.CycleLen}日一次</Tag>;
} else if (list.type === '周') { } else if (list.Unit === '周') {
return <Tag color="#d3adf7">周一次</Tag>; return <Tag color="#d3adf7">{list.CycleLen}周一次</Tag>;
} else if (list.type === '月') { } else if (list.Unit === '月') {
return <Tag color="#e3799e">{list.cycle}月一次</Tag>; return <Tag color="#e3799e">{list.CycleLen}月一次</Tag>;
} }
} }
} }
......
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