fix: 修复兑换码、优惠券时间问题

This commit is contained in:
zhangds 2022-11-09 17:56:30 +08:00
parent aebc2afc9a
commit eca3d58c60
2 changed files with 52 additions and 48 deletions

View File

@ -804,11 +804,13 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
); );
}; };
const onDisabledTime = (date) => { 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 hour = min.getHours();
const minute = min.getMinutes(); const minute = min.getMinutes();
const second = min.getSeconds(); const second = min.getSeconds();
const isSame = isSameDay(date, min); const isSame = isSameDay(date, min);
return isSame return isSame
? { ? {
disabledHours: () => initArray(hour), disabledHours: () => initArray(hour),
@ -822,30 +824,28 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
: {}; : {};
}; };
const onDisabledRange = (date, type) => { const onDisabledRange = (date, type) => {
let deDateTime = sessionStorage.getItem("datetime"); let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"));
let disabled = false; let isdisabled = false;
if (deDateTime) {
let step1 = JSON.parse(deDateTime);
let str = moment(date).format("YYYY-MM-DD HH:mm:ss"); let str = moment(date).format("YYYY-MM-DD HH:mm:ss");
if (type === "start") { const isDay = moment(step1.end_time).format("HH:mm:ss");
disabled = if (type == "start") {
moment(str).isBefore(step1[0]) || moment(str).isAfter(step1[1]); if (isDay < "23:59:59") {
} isdisabled =
if (type === "end") { moment(str).isBefore(step1.begin_time) ||
disabled = moment(str).subtract(1, "days").isAfter(step1.end_time);
moment(str).add(1, "days").isBefore(step1[0]) ||
moment(str).isAfter(step1[1]);
}
} else { } else {
if (type === "end") { isdisabled =
disabled = moment(str).isBefore(step1.begin_time) ||
moment(date.getTime()).add(1, "days") <= new Date().getTime(); moment(str).isAfter(step1.end_time);
}
if (type === "start") {
disabled = date.getTime() <= new Date().getTime();
} }
} }
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 onPageChange = () => {};
const onCountChange = () => {}; const onCountChange = () => {};

View File

@ -312,12 +312,14 @@ const UseExchangeAddEdit = forwardRef((props, ref) => {
}); });
}; };
const onDisabledTime = (date) => { const onDisabledTime = (date, type) => {
const min = new Date(); let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"));
const min = new Date(step1.begin_time);
const hour = min.getHours(); const hour = min.getHours();
const minute = min.getMinutes(); const minute = min.getMinutes();
const second = min.getSeconds(); const second = min.getSeconds();
const isSame = isSameDay(date, min); const isSame = isSameDay(date, min);
return isSame return isSame
? { ? {
disabledHours: () => initArray(hour), disabledHours: () => initArray(hour),
@ -332,30 +334,28 @@ const UseExchangeAddEdit = forwardRef((props, ref) => {
}; };
const onDisabledRange = (date, type) => { const onDisabledRange = (date, type) => {
let deDateTime = sessionStorage.getItem("datetime"); let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"));
let disabled = false; let isdisabled = false;
if (deDateTime) {
let step1 = JSON.parse(deDateTime);
let str = moment(date).format("YYYY-MM-DD HH:mm:ss"); let str = moment(date).format("YYYY-MM-DD HH:mm:ss");
if (type === "start") { const isDay = moment(step1.end_time).format("HH:mm:ss");
disabled = if (type == "start") {
moment(str).isBefore(step1[0]) || moment(str).isAfter(step1[1]); if (isDay < "23:59:59") {
} isdisabled =
if (type === "end") { moment(str).isBefore(step1.begin_time) ||
disabled = moment(str).subtract(1, "days").isAfter(step1.end_time);
moment(str).add(1, "days").isBefore(step1[0]) ||
moment(str).isAfter(step1[1]);
}
} else { } else {
if (type === "end") { isdisabled =
disabled = moment(str).isBefore(step1.begin_time) ||
moment(date.getTime()).add(1, "days") <= new Date().getTime(); moment(str).isAfter(step1.end_time);
}
if (type === "start") {
disabled = date.getTime() <= new Date().getTime();
} }
} }
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) => { const onRankChange = (e) => {
@ -620,7 +620,11 @@ const UseExchangeAddEdit = forwardRef((props, ref) => {
ref={codeRuleEl} ref={codeRuleEl}
className="addform" className="addform"
> >
<FormItem labelname="生效时间段" prop="date_time" id="date_time"> <FormItem
labelname="生效时间段2222222"
prop="date_time"
id="date_time"
>
<DateRangePicker <DateRangePicker
className="zent-datepicker-plan" className="zent-datepicker-plan"
showTime={{ showTime={{