diff --git a/src/components/UseCouponAddEdit/index.jsx b/src/components/UseCouponAddEdit/index.jsx index cd993ad0..1a1180fb 100644 --- a/src/components/UseCouponAddEdit/index.jsx +++ b/src/components/UseCouponAddEdit/index.jsx @@ -804,11 +804,13 @@ const UseCouponAddEdit = forwardRef((props, ref) => { ); }; const onDisabledTime = (date) => { - const min = new Date(); + let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate")); + const min = new Date(step1.begin_time); const hour = min.getHours(); const minute = min.getMinutes(); const second = min.getSeconds(); const isSame = isSameDay(date, min); + return isSame ? { disabledHours: () => initArray(hour), @@ -822,30 +824,28 @@ const UseCouponAddEdit = forwardRef((props, ref) => { : {}; }; const onDisabledRange = (date, type) => { - let deDateTime = sessionStorage.getItem("datetime"); - let disabled = false; - if (deDateTime) { - let step1 = JSON.parse(deDateTime); - let str = moment(date).format("YYYY-MM-DD HH:mm:ss"); - if (type === "start") { - disabled = - moment(str).isBefore(step1[0]) || moment(str).isAfter(step1[1]); - } - if (type === "end") { - disabled = - moment(str).add(1, "days").isBefore(step1[0]) || - moment(str).isAfter(step1[1]); - } - } else { - if (type === "end") { - disabled = - moment(date.getTime()).add(1, "days") <= new Date().getTime(); - } - if (type === "start") { - disabled = date.getTime() <= new Date().getTime(); + let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate")); + let isdisabled = false; + let str = moment(date).format("YYYY-MM-DD HH:mm:ss"); + const isDay = moment(step1.end_time).format("HH:mm:ss"); + if (type == "start") { + if (isDay < "23:59:59") { + isdisabled = + moment(str).isBefore(step1.begin_time) || + moment(str).subtract(1, "days").isAfter(step1.end_time); + } else { + isdisabled = + moment(str).isBefore(step1.begin_time) || + moment(str).isAfter(step1.end_time); } } - return disabled; + + if (type == "end") { + isdisabled = + moment(str).add(1, "days").isBefore(step1.begin_time) || + moment(str).isAfter(step1.end_time); + } + return isdisabled; }; const onPageChange = () => {}; const onCountChange = () => {}; diff --git a/src/components/UseExchangeAddEdit/index.jsx b/src/components/UseExchangeAddEdit/index.jsx index a8bdf355..da59fba8 100644 --- a/src/components/UseExchangeAddEdit/index.jsx +++ b/src/components/UseExchangeAddEdit/index.jsx @@ -312,12 +312,14 @@ const UseExchangeAddEdit = forwardRef((props, ref) => { }); }; - const onDisabledTime = (date) => { - const min = new Date(); + const onDisabledTime = (date, type) => { + let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate")); + const min = new Date(step1.begin_time); const hour = min.getHours(); const minute = min.getMinutes(); const second = min.getSeconds(); const isSame = isSameDay(date, min); + return isSame ? { disabledHours: () => initArray(hour), @@ -332,30 +334,28 @@ const UseExchangeAddEdit = forwardRef((props, ref) => { }; const onDisabledRange = (date, type) => { - let deDateTime = sessionStorage.getItem("datetime"); - let disabled = false; - if (deDateTime) { - let step1 = JSON.parse(deDateTime); - let str = moment(date).format("YYYY-MM-DD HH:mm:ss"); - if (type === "start") { - disabled = - moment(str).isBefore(step1[0]) || moment(str).isAfter(step1[1]); - } - if (type === "end") { - disabled = - moment(str).add(1, "days").isBefore(step1[0]) || - moment(str).isAfter(step1[1]); - } - } else { - if (type === "end") { - disabled = - moment(date.getTime()).add(1, "days") <= new Date().getTime(); - } - if (type === "start") { - disabled = date.getTime() <= new Date().getTime(); + let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate")); + let isdisabled = false; + let str = moment(date).format("YYYY-MM-DD HH:mm:ss"); + const isDay = moment(step1.end_time).format("HH:mm:ss"); + if (type == "start") { + if (isDay < "23:59:59") { + isdisabled = + moment(str).isBefore(step1.begin_time) || + moment(str).subtract(1, "days").isAfter(step1.end_time); + } else { + isdisabled = + moment(str).isBefore(step1.begin_time) || + moment(str).isAfter(step1.end_time); } } - return disabled; + + if (type == "end") { + isdisabled = + moment(str).add(1, "days").isBefore(step1.begin_time) || + moment(str).isAfter(step1.end_time); + } + return isdisabled; }; const onRankChange = (e) => { @@ -620,7 +620,11 @@ const UseExchangeAddEdit = forwardRef((props, ref) => { ref={codeRuleEl} className="addform" > - +