From 5c84ea177c9f13cb94760aae7caba4866facef54 Mon Sep 17 00:00:00 2001 From: xingjx Date: Wed, 10 Jan 2024 22:32:39 +0800 Subject: [PATCH] =?UTF-8?q?fix():bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OutSegmentMgm/ChargeRulesMgm/AddModal.jsx | 18 +++++++--- .../OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx | 18 +++++----- .../OutSegmentMgm/ChargeRulesMgm/TimePart.jsx | 41 +++++++++++++++------- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx index 7419ea0..73da2f1 100644 --- a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx +++ b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx @@ -88,7 +88,7 @@ function AddModal(props) { let effarr = valiArr effarr.splice(indexDB, 1); setValiArr(effarr) - console.log(indexDB, key, arr, effectiveDateList) + //console.log(indexDB, key, arr, effectiveDateList) setEffectiveDateList(_effectiveDateList); } //提交成功后函数 @@ -96,6 +96,12 @@ function AddModal(props) { research(); close(); } + function flatten(arr) { + while (arr.some(i => Array.isArray(i))) { + arr = [].concat(...arr); + } + return arr; + } //提交接口 function fetch(params) { let arr = [] @@ -118,19 +124,22 @@ function AddModal(props) { // // }) // }) // } - if (timestatus.some(ele => ele === false)) { + + if (flatten(timestatus).some(ele => ele === false)) { message.error("请填写完整!") return } + let flag = 0 valiArr.map(item => { if (item == 0) { message.error("时段之和必须为24小时,且时段不能重叠"); - return + flag = 1 } else if (item == 2) { message.error('时段范围不能重叠!') - return + flag = 1 } }) + if(flag) return // if (timevalidate == 0) { // message.error("时段之和必须为24小时,且时段不能重叠"); // return @@ -162,7 +171,6 @@ function AddModal(props) { //提交按钮 function submit() { //return - console.log(effectiveDateList) form .validateFields() .then((res) => { diff --git a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx index ecb62f6..3a253f1 100644 --- a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx +++ b/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 = () => { - if (effTimePart.some(ele => ele === false)) { + if (flatten(effTimePart).some(ele => ele === false)) { message.error("请先把当前时段填写完整") return } @@ -85,12 +91,6 @@ function EffectiveDate(props) { "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].start) @@ -108,7 +108,6 @@ function EffectiveDate(props) { form .validateFields() .then((values) => { - //console.log(83, isOneDay(values)) if (isOneDay(values)) { //message.success("时段检验通过"); } else { @@ -198,7 +197,6 @@ function EffectiveDate(props) { )} {timePartList.map((item, tindex) => { - //console.log(180, timePartList); return ( { carr[index - 1] = e - console.log(210, timePartList, index, carr[index]) + console.log(210, timePartList, index, carr) timePart(carr) }} effTimePart={(e) => { diff --git a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/TimePart.jsx b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/TimePart.jsx index fc9213f..c6aae39 100644 --- a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/TimePart.jsx +++ b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/TimePart.jsx @@ -13,6 +13,7 @@ import { message } from "antd"; import moment from "moment"; +var timearr = [] function TimePart(props) { const [form] = Form.useForm(); const { @@ -27,8 +28,9 @@ function TimePart(props) { } = props; useEffect(() => { if (form.getFieldsValue().time_part == undefined) { - timePart(false) - effTimePart(false) + timearr[index - 1] = false + timePart(timearr) + effTimePart(timearr) } }, [form]) //计算分钟数 @@ -54,8 +56,10 @@ function TimePart(props) { }).catch(err => { if (err.errorFields.length > 0) {//|| (!err.values.time_before || !err.values.unit) console.log('不完整') - timePart(false) - effTimePart(false) + timearr[index - 1] = false + timePart(timearr) + //timePart(false) + effTimePart(timearr) } else { 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) { @@ -66,8 +70,10 @@ function TimePart(props) { message.error("输入的'前...分钟'数据要小于时间段时间") return } - timePart(true) - effTimePart(true) + timearr[index - 1] = true + timePart(timearr) + //timePart(true) + effTimePart(timearr) } }) all.key = itemKey; @@ -124,17 +130,22 @@ function TimePart(props) { delete all.segment } delete all.time_part + timearr[index - 1] = false + timePart(timearr) if (value.type == 0 && !all.unit) { - timePart(false) - effTimePart(false) + timePart(timearr) + //timePart(false) + effTimePart(timearr) } if (value.type == 1 && !all.unit) { - timePart(false) - effTimePart(false) + timePart(timearr) + //timePart(false) + effTimePart(timearr) } if (value.type == 2 && !all.unit) { - timePart(false) - effTimePart(false) + timePart(timearr) + //timePart(false) + effTimePart(timearr) } onChange(all); }; @@ -197,7 +208,11 @@ function TimePart(props) { {index === 1 ? null : ( - )}