@pisell/pisellos 3.0.23 → 3.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -209,7 +209,18 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
|
|
|
209
209
|
var disabledDate = _objectSpread(_objectSpread({}, date), {}, {
|
|
210
210
|
status: 'unavailable'
|
|
211
211
|
});
|
|
212
|
-
|
|
212
|
+
var hasScheduleConfig = rules.find(function (n) {
|
|
213
|
+
var _n$schedule;
|
|
214
|
+
return (_n$schedule = n.schedule) === null || _n$schedule === void 0 ? void 0 : _n$schedule.length;
|
|
215
|
+
});
|
|
216
|
+
// 如果外面穿了 schedule,但是这个时候scheduleMap为空,则设置为不可用
|
|
217
|
+
// 这种情况为,商品设置了 5.1-5.31 可用,资源设置了 5.1-6.30 可用,session 类商品详情弹窗里里看到的6 月以后的日期都应该是不可用的
|
|
218
|
+
if (Object.keys(scheduleMap).length === 0 && hasScheduleConfig) {
|
|
219
|
+
return _objectSpread(_objectSpread({}, date), {}, {
|
|
220
|
+
color: '',
|
|
221
|
+
status: 'unavailable'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
213
224
|
// 根据日程判断日期是否可用
|
|
214
225
|
if (Object.keys(scheduleMap).length) {
|
|
215
226
|
var schedule = scheduleMap[date.date];
|
|
@@ -716,7 +716,7 @@ export function getAllSortedDateRanges(schedules) {
|
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
// 按照开始时间和时长排序
|
|
719
|
-
|
|
719
|
+
var sortedDateRanges = allDateRanges.sort(function (a, b) {
|
|
720
720
|
// 首先按开始时间排序
|
|
721
721
|
var startTimeCompare = dayjs(a.start).valueOf() - dayjs(b.start).valueOf();
|
|
722
722
|
if (startTimeCompare !== 0) return startTimeCompare;
|
|
@@ -726,4 +726,13 @@ export function getAllSortedDateRanges(schedules) {
|
|
|
726
726
|
var durationB = dayjs(b.end).valueOf() - dayjs(b.start).valueOf();
|
|
727
727
|
return durationA - durationB;
|
|
728
728
|
});
|
|
729
|
+
|
|
730
|
+
// 排序完了,还需要做个去重,如果有开始时间结束时间完全一致的,则只保留一个
|
|
731
|
+
// 需要使用 dayjs 的 isSame 方法来判断
|
|
732
|
+
var uniqueDateRanges = sortedDateRanges.filter(function (range, index, self) {
|
|
733
|
+
return index === self.findIndex(function (t) {
|
|
734
|
+
return dayjs(t.start).isSame(dayjs(range.start)) && dayjs(t.end).isSame(dayjs(range.end));
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
return uniqueDateRanges;
|
|
729
738
|
}
|
|
@@ -155,6 +155,13 @@ var handleAvailableDatesByRules = (dates, rules) => {
|
|
|
155
155
|
newDates = newDates.map((date) => {
|
|
156
156
|
var _a;
|
|
157
157
|
const disabledDate = { ...date, status: "unavailable" };
|
|
158
|
+
const hasScheduleConfig = rules.find((n) => {
|
|
159
|
+
var _a2;
|
|
160
|
+
return (_a2 = n.schedule) == null ? void 0 : _a2.length;
|
|
161
|
+
});
|
|
162
|
+
if (Object.keys(scheduleMap).length === 0 && hasScheduleConfig) {
|
|
163
|
+
return { ...date, color: "", status: "unavailable" };
|
|
164
|
+
}
|
|
158
165
|
if (Object.keys(scheduleMap).length) {
|
|
159
166
|
const schedule = scheduleMap[date.date];
|
|
160
167
|
if (!schedule || (schedule == null ? void 0 : schedule.isExcluded)) {
|
|
@@ -573,7 +573,7 @@ function getAllSortedDateRanges(schedules) {
|
|
|
573
573
|
console.log("No dateRanges found in schedules:", schedules);
|
|
574
574
|
return [];
|
|
575
575
|
}
|
|
576
|
-
|
|
576
|
+
let sortedDateRanges = allDateRanges.sort((a, b) => {
|
|
577
577
|
const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
578
578
|
if (startTimeCompare !== 0)
|
|
579
579
|
return startTimeCompare;
|
|
@@ -581,6 +581,10 @@ function getAllSortedDateRanges(schedules) {
|
|
|
581
581
|
const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
582
582
|
return durationA - durationB;
|
|
583
583
|
});
|
|
584
|
+
const uniqueDateRanges = sortedDateRanges.filter(
|
|
585
|
+
(range, index, self) => index === self.findIndex((t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end)))
|
|
586
|
+
);
|
|
587
|
+
return uniqueDateRanges;
|
|
584
588
|
}
|
|
585
589
|
// Annotate the CommonJS export names for ESM import in node:
|
|
586
590
|
0 && (module.exports = {
|