Browse Source

fix():bug修改

tags/PMS_V1.0.0_Alpha5
xingjx 1 year ago
parent
commit
5c84ea177c
  1. 18
      src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx
  2. 18
      src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx
  3. 41
      src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/TimePart.jsx

18
src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx

@ -88,7 +88,7 @@ function AddModal(props) {
let effarr = valiArr let effarr = valiArr
effarr.splice(indexDB, 1); effarr.splice(indexDB, 1);
setValiArr(effarr) setValiArr(effarr)
console.log(indexDB, key, arr, effectiveDateList) //console.log(indexDB, key, arr, effectiveDateList)
setEffectiveDateList(_effectiveDateList); setEffectiveDateList(_effectiveDateList);
} }
// //
@ -96,6 +96,12 @@ function AddModal(props) {
research(); research();
close(); close();
} }
function flatten(arr) {
while (arr.some(i => Array.isArray(i))) {
arr = [].concat(...arr);
}
return arr;
}
// //
function fetch(params) { function fetch(params) {
let arr = [] let arr = []
@ -118,19 +124,22 @@ function AddModal(props) {
// // }) // // })
// }) // })
// } // }
if (timestatus.some(ele => ele === false)) { if (flatten(timestatus).some(ele => ele === false)) {
message.error("请填写完整!") message.error("请填写完整!")
return return
} }
let flag = 0
valiArr.map(item => { valiArr.map(item => {
if (item == 0) { if (item == 0) {
message.error("时段之和必须为24小时,且时段不能重叠"); message.error("时段之和必须为24小时,且时段不能重叠");
return flag = 1
} else if (item == 2) { } else if (item == 2) {
message.error('时段范围不能重叠!') message.error('时段范围不能重叠!')
return flag = 1
} }
}) })
if(flag) return
// if (timevalidate == 0) { // if (timevalidate == 0) {
// message.error("24"); // message.error("24");
// return // return
@ -162,7 +171,6 @@ function AddModal(props) {
// //
function submit() { function submit() {
//return //return
console.log(effectiveDateList)
form form
.validateFields() .validateFields()
.then((res) => { .then((res) => {

18
src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx

@ -47,8 +47,14 @@ function EffectiveDate(props) {
}); });
} }
}); });
function flatten(arr) {
while (arr.some(i => Array.isArray(i))) {
arr = [].concat(...arr);
}
return arr;
}
const addTimePart = () => { const addTimePart = () => {
if (effTimePart.some(ele => ele === false)) { if (flatten(effTimePart).some(ele => ele === false)) {
message.error("请先把当前时段填写完整") message.error("请先把当前时段填写完整")
return return
} }
@ -85,12 +91,6 @@ function EffectiveDate(props) {
"minutes" "minutes"
) )
); );
console.log(Math.abs(
moment(timePartList[i].end, "HH:mm:ss").diff(
moment(timePartList[i].start, "HH:mm:ss"),
"minutes"
)
))
} }
arr.push(timePartList[i].end) arr.push(timePartList[i].end)
arr.push(timePartList[i].start) arr.push(timePartList[i].start)
@ -108,7 +108,6 @@ function EffectiveDate(props) {
form form
.validateFields() .validateFields()
.then((values) => { .then((values) => {
//console.log(83, isOneDay(values))
if (isOneDay(values)) { if (isOneDay(values)) {
//message.success(""); //message.success("");
} else { } else {
@ -198,7 +197,6 @@ function EffectiveDate(props) {
)} )}
<Divider /> <Divider />
{timePartList.map((item, tindex) => { {timePartList.map((item, tindex) => {
//console.log(180, timePartList);
return ( return (
<TimePart <TimePart
disable={item.status === "disable"} disable={item.status === "disable"}
@ -210,7 +208,7 @@ function EffectiveDate(props) {
//timePart={timePart} //timePart={timePart}
timePart={(e) => { timePart={(e) => {
carr[index - 1] = e carr[index - 1] = e
console.log(210, timePartList, index, carr[index]) console.log(210, timePartList, index, carr)
timePart(carr) timePart(carr)
}} }}
effTimePart={(e) => { effTimePart={(e) => {

41
src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/TimePart.jsx

@ -13,6 +13,7 @@ import {
message message
} from "antd"; } from "antd";
import moment from "moment"; import moment from "moment";
var timearr = []
function TimePart(props) { function TimePart(props) {
const [form] = Form.useForm(); const [form] = Form.useForm();
const { const {
@ -27,8 +28,9 @@ function TimePart(props) {
} = props; } = props;
useEffect(() => { useEffect(() => {
if (form.getFieldsValue().time_part == undefined) { if (form.getFieldsValue().time_part == undefined) {
timePart(false) timearr[index - 1] = false
effTimePart(false) timePart(timearr)
effTimePart(timearr)
} }
}, [form]) }, [form])
// //
@ -54,8 +56,10 @@ function TimePart(props) {
}).catch(err => { }).catch(err => {
if (err.errorFields.length > 0) {//|| (!err.values.time_before || !err.values.unit) if (err.errorFields.length > 0) {//|| (!err.values.time_before || !err.values.unit)
console.log('不完整') console.log('不完整')
timePart(false) timearr[index - 1] = false
effTimePart(false) timePart(timearr)
//timePart(false)
effTimePart(timearr)
} else { } else {
console.log('完整了', all, countDown(all.end) - countDown(all.start), all.items[0].segment * 60) console.log('完整了', all, countDown(all.end) - countDown(all.start), all.items[0].segment * 60)
if (all.end != '00:00:00' && countDown(all.end) - countDown(all.start) < all.items[0].segment * 60) { if (all.end != '00:00:00' && countDown(all.end) - countDown(all.start) < all.items[0].segment * 60) {
@ -66,8 +70,10 @@ function TimePart(props) {
message.error("输入的'前...分钟'数据要小于时间段时间") message.error("输入的'前...分钟'数据要小于时间段时间")
return return
} }
timePart(true) timearr[index - 1] = true
effTimePart(true) timePart(timearr)
//timePart(true)
effTimePart(timearr)
} }
}) })
all.key = itemKey; all.key = itemKey;
@ -124,17 +130,22 @@ function TimePart(props) {
delete all.segment delete all.segment
} }
delete all.time_part delete all.time_part
timearr[index - 1] = false
timePart(timearr)
if (value.type == 0 && !all.unit) { if (value.type == 0 && !all.unit) {
timePart(false) timePart(timearr)
effTimePart(false) //timePart(false)
effTimePart(timearr)
} }
if (value.type == 1 && !all.unit) { if (value.type == 1 && !all.unit) {
timePart(false) timePart(timearr)
effTimePart(false) //timePart(false)
effTimePart(timearr)
} }
if (value.type == 2 && !all.unit) { if (value.type == 2 && !all.unit) {
timePart(false) timePart(timearr)
effTimePart(false) //timePart(false)
effTimePart(timearr)
} }
onChange(all); onChange(all);
}; };
@ -197,7 +208,11 @@ function TimePart(props) {
</Col> </Col>
<Col span={8}> <Col span={8}>
{index === 1 ? null : ( {index === 1 ? null : (
<Button type="primary" onClick={() => remove(itemKey)}> <Button type="primary" onClick={() => {
timearr.splice(index - 1, 1);
timePart(timearr)
remove(itemKey);
}}>
移除 移除
</Button> </Button>
)} )}

|||||||
100:0
Loading…
Cancel
Save