@pisell/pisellos 3.0.24 → 3.0.26

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.
@@ -716,7 +716,7 @@ export function getAllSortedDateRanges(schedules) {
716
716
  }
717
717
 
718
718
  // 按照开始时间和时长排序
719
- return allDateRanges.sort(function (a, b) {
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
  }
@@ -216,6 +216,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
216
216
  });
217
217
  if (schedule_ids_data.length) {
218
218
  schedule_ids = schedule_ids_data;
219
+ } else if (schedule_date) {
220
+ // 后端说如果 schedule_ids 如果为空,需要给[0]
221
+ schedule_ids = [0];
219
222
  }
220
223
  }
221
224
  _context2.next = 4;
@@ -573,7 +573,7 @@ function getAllSortedDateRanges(schedules) {
573
573
  console.log("No dateRanges found in schedules:", schedules);
574
574
  return [];
575
575
  }
576
- return allDateRanges.sort((a, b) => {
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 = {
@@ -165,6 +165,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
165
165
  const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
166
166
  if (schedule_ids_data.length) {
167
167
  schedule_ids = schedule_ids_data;
168
+ } else if (schedule_date) {
169
+ schedule_ids = [0];
168
170
  }
169
171
  }
170
172
  const productsData = await this.request.post(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.24",
4
+ "version": "3.0.26",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",