diff --git a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx index 90bd2ce..cba6c57 100644 --- a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx +++ b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/AddModal.jsx @@ -30,8 +30,9 @@ function AddModal(props) { const isEdit = status === "edit"; const [getOperationName, setGetOperationName] = useState([]) const [getNewOperationName, setNewGetOperationName] = useState([]) - const [timestatus, setTimestatus] = useState(true) + const [timestatus, setTimestatus] = useState([true]) const [timevalidate, setTimevalidate] = useState(true) + const [valiArr, setValiArr] = useState([]) const operationName = () => { ajax.getAllOperator().then(res => { let arr = res.data @@ -65,7 +66,7 @@ function AddModal(props) { // effectiveDateList?.map((e)=>{ // arr.push(e.date) // }) - setTimestatus(false) + //setTimestatus(false) const randomNum = Math.floor(Math.random() * 1000); const item = { key: randomNum.toString() + Date.now().toString().substring(0, 6), @@ -75,9 +76,19 @@ function AddModal(props) { } function removeEffectiveDate(key) { + let indexDB = '' + effectiveDateList + .map((item, index) => { if (item.key == key && item) { indexDB = index } }) const _effectiveDateList = effectiveDateList .map((item) => item.key !== key && item) .filter((item) => item.key !== undefined); + let arr = timestatus + arr.splice(indexDB, 1); + setTimestatus(arr) + let effarr = valiArr + effarr.splice(indexDB, 1); + setValiArr(effarr) + console.log(indexDB, key, arr, effectiveDateList) setEffectiveDateList(_effectiveDateList); } //提交成功后函数 @@ -111,14 +122,23 @@ function AddModal(props) { message.error("请填写完整!") return } - if (timevalidate == 0) { - message.error("时段之和必须为24小时,且时段不能重叠"); - return - } else if (timevalidate == 2) { - message.error('时段范围不能重叠!') - return - } - //return + valiArr.map(item => { + if (item == 0) { + message.error("时段之和必须为24小时,且时段不能重叠"); + return + } else if (item == 2) { + message.error('时段范围不能重叠!') + return + } + }) + // if (timevalidate == 0) { + // message.error("时段之和必须为24小时,且时段不能重叠"); + // return + // } else if (timevalidate == 2) { + // message.error('时段范围不能重叠!') + // return + // } + return if (status === "add") { ajax.addChargeRule(params).then((res) => { if (res.status === 20000) { @@ -333,8 +353,8 @@ function AddModal(props) { index={index + 1} itemKey={item.key} remove={removeEffectiveDate} - timePart={(e) => { console.log(78787, e); setTimestatus(e) }}//时段内数据是否完整 - validate={(e) => { setTimevalidate(e) }}//时段填写是否符合要求 + timePart={(e) => { console.log(78787, effectiveDateList, e); setTimestatus(e) }}//时段内数据是否完整 + validate={(e, arr) => { setTimevalidate(e); console.log(arr); setValiArr(arr) }}//时段填写是否符合要求 onChange={(value, key) => { const _effectiveDateList = effectiveDateList.map((item) => { if (item.key === key) { diff --git a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx index ed2a815..ecb62f6 100644 --- a/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx +++ b/src/pages/OutRoadMgm/OutSegmentMgm/ChargeRulesMgm/EffectiveDate.jsx @@ -14,6 +14,7 @@ import { import TimePart from "./TimePart"; import moment from "moment"; var carr = [] +var effarr = [] function EffectiveDate(props) { const { remove = () => { }, @@ -47,7 +48,7 @@ function EffectiveDate(props) { } }); const addTimePart = () => { - if (!effTimePart) { + if (effTimePart.some(ele => ele === false)) { message.error("请先把当前时段填写完整") return } @@ -119,7 +120,9 @@ function EffectiveDate(props) { }); } useEffect(() => { - validate(isOneDay()) + let arr = [] + arr[index - 1] = isOneDay() + validate(isOneDay(), arr) }, [timePartList]) const valueChange = (value, all) => { console.log(value, all) @@ -138,8 +141,8 @@ function EffectiveDate(props) { form={form} onValuesChange={valueChange} initialValues={{ - ...record, unit_fee_type_group: [], + ...record, date: moment(record.date), }} disabled={disable} @@ -156,7 +159,9 @@ function EffectiveDate(props) {