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 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 = () => {};

View File

@ -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"
>
<FormItem labelname="生效时间段" prop="date_time" id="date_time">
<FormItem
labelname="生效时间段2222222"
prop="date_time"
id="date_time"
>
<DateRangePicker
className="zent-datepicker-plan"
showTime={{