|
|
@ -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) { |
|
|
|