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

fix: '方案制定优化'

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