@pisell/pisellos 2.2.51 → 2.2.53
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.
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +747 -0
- package/dist/modules/Schedule/index.d.ts +2 -2
- package/dist/modules/Schedule/index.js +2 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +451 -0
- package/lib/modules/Schedule/index.d.ts +2 -2
- package/lib/modules/Schedule/index.js +2 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { ScheduleItem } from "./types";
|
|
3
|
+
export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
|
|
4
|
+
export type ScheduleTimeSlot = {
|
|
5
|
+
/** 开始时间 HH:mm */
|
|
6
|
+
start_time: string;
|
|
7
|
+
/** 结束时间 HH:mm */
|
|
8
|
+
end_time: string;
|
|
9
|
+
/** 开始日期时间 YYYY-MM-DD HH:mm:ss */
|
|
10
|
+
start_at: dayjs.Dayjs;
|
|
11
|
+
/** 结束日期时间 YYYY-MM-DD HH:mm:ss */
|
|
12
|
+
end_at: dayjs.Dayjs;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 获取当前日期日程时间点
|
|
16
|
+
* @param date 日期 YYYY-MM-DD
|
|
17
|
+
* @param scheduleList 日程列表
|
|
18
|
+
* @returns 当前日期日程时间点 结构,数组 [{
|
|
19
|
+
*
|
|
20
|
+
* // HH:mm
|
|
21
|
+
* end_time: string,
|
|
22
|
+
* // HH:mm
|
|
23
|
+
* start_time: string,
|
|
24
|
+
* // 日期时间
|
|
25
|
+
* // YYYY-MM-DD HH:mm:ss
|
|
26
|
+
* end_at: Dayjs,
|
|
27
|
+
* // YYYY-MM-DD HH:mm:ss
|
|
28
|
+
* start_at: Dayjs,
|
|
29
|
+
*
|
|
30
|
+
* }]
|
|
31
|
+
*/
|
|
32
|
+
export declare const getScheduleStartEndTimePoints: (date: string, scheduleList: ScheduleItem[]) => ScheduleTimeSlot[];
|
|
@@ -0,0 +1,747 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
import dayjs from "dayjs";
|
|
9
|
+
// 获取时间是否在日程范围内
|
|
10
|
+
export var getDateIsInSchedule = function getDateIsInSchedule(dateTime, scheduleList) {
|
|
11
|
+
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
var targetDate = dayjs(dateTime);
|
|
15
|
+
if (!targetDate.isValid()) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 遍历所有日程项
|
|
20
|
+
var _iterator = _createForOfIteratorHelper(scheduleList),
|
|
21
|
+
_step;
|
|
22
|
+
try {
|
|
23
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
24
|
+
var schedule = _step.value;
|
|
25
|
+
if (isTimeInScheduleItem(dateTime, schedule)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
_iterator.e(err);
|
|
31
|
+
} finally {
|
|
32
|
+
_iterator.f();
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// 判断时间是否在单个日程项范围内
|
|
38
|
+
var isTimeInScheduleItem = function isTimeInScheduleItem(dateTime, schedule) {
|
|
39
|
+
var targetDate = dayjs(dateTime);
|
|
40
|
+
var targetDateString = dateTime.split(' ')[0]; // YYYY-MM-DD
|
|
41
|
+
var targetTimeString = dateTime.split(' ')[1] || '00:00:00'; // HH:mm:ss
|
|
42
|
+
|
|
43
|
+
switch (schedule.type) {
|
|
44
|
+
case 'standard':
|
|
45
|
+
return isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
46
|
+
case 'time-slots':
|
|
47
|
+
return isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
48
|
+
case 'designation':
|
|
49
|
+
return isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
50
|
+
default:
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// 处理标准类型日程
|
|
56
|
+
var isInStandardSchedule = function isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule) {
|
|
57
|
+
if (!schedule.start_time || !schedule.end_time) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
var startDate = dayjs(schedule.start_time);
|
|
61
|
+
var endDate = dayjs(schedule.end_time);
|
|
62
|
+
|
|
63
|
+
// 先检查是否在基础时间范围内(不考虑重复)
|
|
64
|
+
var isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate);
|
|
65
|
+
if (schedule.repeat_type === 'none') {
|
|
66
|
+
return isInBasicRange;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 处理重复日程
|
|
70
|
+
return isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 处理时间段类型日程
|
|
74
|
+
var isInTimeSlotsSchedule = function isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule) {
|
|
75
|
+
if (!schedule.start_time) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
var scheduleDate = schedule.start_time.split(' ')[0];
|
|
79
|
+
|
|
80
|
+
// 检查日期是否匹配
|
|
81
|
+
if (targetDateString !== scheduleDate) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 检查是否在任一时间段内
|
|
86
|
+
var _iterator2 = _createForOfIteratorHelper(schedule.time_slot),
|
|
87
|
+
_step2;
|
|
88
|
+
try {
|
|
89
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
90
|
+
var timeSlot = _step2.value;
|
|
91
|
+
var slotStart = "".concat(scheduleDate, " ").concat(timeSlot.start_time, ":00");
|
|
92
|
+
var slotEnd = "".concat(scheduleDate, " ").concat(timeSlot.end_time, ":00");
|
|
93
|
+
var slotStartDate = dayjs(slotStart);
|
|
94
|
+
var slotEndDate = dayjs(slotEnd);
|
|
95
|
+
if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_iterator2.e(err);
|
|
101
|
+
} finally {
|
|
102
|
+
_iterator2.f();
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// 处理指定类型日程
|
|
108
|
+
var isInDesignationSchedule = function isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule) {
|
|
109
|
+
if (!schedule.designation) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
var _iterator3 = _createForOfIteratorHelper(schedule.designation),
|
|
115
|
+
_step3;
|
|
116
|
+
try {
|
|
117
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
118
|
+
var designation = _step3.value;
|
|
119
|
+
var startDateTime = "".concat(designation.start_date, " ").concat(designation.start_time, ":00");
|
|
120
|
+
var endDateTime = "".concat(designation.end_date, " ").concat(designation.end_time, ":00");
|
|
121
|
+
var startDate = dayjs(startDateTime);
|
|
122
|
+
var endDate = dayjs(endDateTime);
|
|
123
|
+
if (targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
_iterator3.e(err);
|
|
129
|
+
} finally {
|
|
130
|
+
_iterator3.f();
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// 处理重复日程逻辑
|
|
136
|
+
var isInRepeatingSchedule = function isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) {
|
|
137
|
+
if (!schedule.repeat_rule) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
var repeat_rule = schedule.repeat_rule,
|
|
141
|
+
repeat_type = schedule.repeat_type;
|
|
142
|
+
var targetDateOnly = dayjs(targetDateString); // 只取日期部分
|
|
143
|
+
|
|
144
|
+
// 首先检查是否在包含日期中(包含日期是额外增加的有效日期)
|
|
145
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
146
|
+
var _iterator4 = _createForOfIteratorHelper(repeat_rule.included_date),
|
|
147
|
+
_step4;
|
|
148
|
+
try {
|
|
149
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
150
|
+
var includedDate = _step4.value;
|
|
151
|
+
var includeStartDate = dayjs(includedDate.start);
|
|
152
|
+
var includeEndDate = dayjs(includedDate.end);
|
|
153
|
+
if (targetDateOnly.isSameOrAfter(includeStartDate, 'day') && targetDateOnly.isSameOrBefore(includeEndDate, 'day')) {
|
|
154
|
+
// 在包含日期中,直接返回true,无需检查其他条件
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
_iterator4.e(err);
|
|
160
|
+
} finally {
|
|
161
|
+
_iterator4.f();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 检查是否在排除日期中
|
|
166
|
+
var _iterator5 = _createForOfIteratorHelper(repeat_rule.excluded_date),
|
|
167
|
+
_step5;
|
|
168
|
+
try {
|
|
169
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
170
|
+
var excludedDate = _step5.value;
|
|
171
|
+
var excludeStartDate = dayjs(excludedDate.start);
|
|
172
|
+
var excludeEndDate = dayjs(excludedDate.end);
|
|
173
|
+
// 检查目标日期是否在排除范围内(包含边界)
|
|
174
|
+
if (targetDateOnly.isSameOrAfter(excludeStartDate, 'day') && targetDateOnly.isSameOrBefore(excludeEndDate, 'day')) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 检查重复规则的结束条件
|
|
180
|
+
} catch (err) {
|
|
181
|
+
_iterator5.e(err);
|
|
182
|
+
} finally {
|
|
183
|
+
_iterator5.f();
|
|
184
|
+
}
|
|
185
|
+
if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
|
|
186
|
+
var ruleEndDate = dayjs(repeat_rule.end.end_date);
|
|
187
|
+
if (targetDate.isAfter(ruleEndDate)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 根据重复类型检查
|
|
193
|
+
switch (repeat_type) {
|
|
194
|
+
case 'daily':
|
|
195
|
+
return isInDailyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
196
|
+
case 'weekly':
|
|
197
|
+
return isInWeeklyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
198
|
+
default:
|
|
199
|
+
return false;
|
|
200
|
+
// 不支持月和年重复
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// 每日重复逻辑
|
|
205
|
+
var isInDailyRepeat = function isInDailyRepeat(targetDate, startDate, endDate, repeatRule) {
|
|
206
|
+
var daysDiff = targetDate.diff(startDate, 'day');
|
|
207
|
+
if (daysDiff < 0) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 检查频率
|
|
212
|
+
if (daysDiff % repeatRule.frequency !== 0) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 检查时间是否在日程的时间范围内
|
|
217
|
+
var targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
218
|
+
var startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
219
|
+
var endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
220
|
+
|
|
221
|
+
// 每日重复:每天都在相同的时间段内有效
|
|
222
|
+
// 例如:01:00:00 - 16:00:00,每天都是这个时间段
|
|
223
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// 每周重复逻辑
|
|
227
|
+
var isInWeeklyRepeat = function isInWeeklyRepeat(targetDate, startDate, endDate, repeatRule) {
|
|
228
|
+
var targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
|
|
229
|
+
|
|
230
|
+
// 检查是否在指定的星期几内
|
|
231
|
+
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 计算周差
|
|
236
|
+
var weeksDiff = targetDate.diff(startDate, 'week');
|
|
237
|
+
if (weeksDiff < 0) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 检查频率
|
|
242
|
+
if (weeksDiff % repeatRule.frequency !== 0) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// 检查时间是否在日程的时间范围内
|
|
247
|
+
var targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
248
|
+
var startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
249
|
+
var endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
250
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// 日程时间段类型
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 获取当前日期日程时间点
|
|
257
|
+
* @param date 日期 YYYY-MM-DD
|
|
258
|
+
* @param scheduleList 日程列表
|
|
259
|
+
* @returns 当前日期日程时间点 结构,数组 [{
|
|
260
|
+
*
|
|
261
|
+
* // HH:mm
|
|
262
|
+
* end_time: string,
|
|
263
|
+
* // HH:mm
|
|
264
|
+
* start_time: string,
|
|
265
|
+
* // 日期时间
|
|
266
|
+
* // YYYY-MM-DD HH:mm:ss
|
|
267
|
+
* end_at: Dayjs,
|
|
268
|
+
* // YYYY-MM-DD HH:mm:ss
|
|
269
|
+
* start_at: Dayjs,
|
|
270
|
+
*
|
|
271
|
+
* }]
|
|
272
|
+
*/
|
|
273
|
+
export var getScheduleStartEndTimePoints = function getScheduleStartEndTimePoints(date, scheduleList) {
|
|
274
|
+
if (!date || !scheduleList || scheduleList.length === 0) {
|
|
275
|
+
return [];
|
|
276
|
+
}
|
|
277
|
+
var targetDate = dayjs(date);
|
|
278
|
+
if (!targetDate.isValid()) {
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
var timeSlots = [];
|
|
282
|
+
|
|
283
|
+
// 遍历所有日程
|
|
284
|
+
var _iterator6 = _createForOfIteratorHelper(scheduleList),
|
|
285
|
+
_step6;
|
|
286
|
+
try {
|
|
287
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
288
|
+
var schedule = _step6.value;
|
|
289
|
+
var slots = extractTimeSlotsFromSchedule(date, schedule);
|
|
290
|
+
timeSlots.push.apply(timeSlots, slots);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 去重并排序时间段
|
|
294
|
+
} catch (err) {
|
|
295
|
+
_iterator6.e(err);
|
|
296
|
+
} finally {
|
|
297
|
+
_iterator6.f();
|
|
298
|
+
}
|
|
299
|
+
return mergeAndSortTimeSlots(timeSlots);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 从单个日程中提取指定日期的时间段
|
|
304
|
+
*/
|
|
305
|
+
var extractTimeSlotsFromSchedule = function extractTimeSlotsFromSchedule(date, schedule) {
|
|
306
|
+
switch (schedule.type) {
|
|
307
|
+
case 'standard':
|
|
308
|
+
return extractStandardScheduleTimeSlots(date, schedule);
|
|
309
|
+
case 'time-slots':
|
|
310
|
+
return extractTimeSlotsScheduleTimeSlots(date, schedule);
|
|
311
|
+
case 'designation':
|
|
312
|
+
return extractDesignationScheduleTimeSlots(date, schedule);
|
|
313
|
+
default:
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 提取标准类型日程的时间段
|
|
320
|
+
*/
|
|
321
|
+
var extractStandardScheduleTimeSlots = function extractStandardScheduleTimeSlots(date, schedule) {
|
|
322
|
+
if (!schedule.start_time || !schedule.end_time) {
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
var targetDate = dayjs(date);
|
|
326
|
+
var startDate = dayjs(schedule.start_time);
|
|
327
|
+
var endDate = dayjs(schedule.end_time);
|
|
328
|
+
|
|
329
|
+
// 检查日期是否在日程范围内
|
|
330
|
+
if (!isDateInStandardSchedule(targetDate, schedule, startDate, endDate)) {
|
|
331
|
+
return [];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// 提取时间部分
|
|
335
|
+
var startTime = startDate.format('HH:mm');
|
|
336
|
+
var endTime = endDate.format('HH:mm');
|
|
337
|
+
|
|
338
|
+
// 构造完整的日期时间
|
|
339
|
+
var startAt = dayjs("".concat(date, " ").concat(startTime, ":00"));
|
|
340
|
+
var endAt = dayjs("".concat(date, " ").concat(endTime, ":00"));
|
|
341
|
+
return [{
|
|
342
|
+
start_time: startTime,
|
|
343
|
+
end_time: endTime,
|
|
344
|
+
start_at: startAt,
|
|
345
|
+
end_at: endAt
|
|
346
|
+
}];
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* 提取时间段类型日程的时间段
|
|
351
|
+
*/
|
|
352
|
+
var extractTimeSlotsScheduleTimeSlots = function extractTimeSlotsScheduleTimeSlots(date, schedule) {
|
|
353
|
+
if (!schedule.start_time || !schedule.time_slot || schedule.time_slot.length === 0) {
|
|
354
|
+
return [];
|
|
355
|
+
}
|
|
356
|
+
var targetDate = dayjs(date);
|
|
357
|
+
var scheduleStartDate = dayjs(schedule.start_time.split(' ')[0]);
|
|
358
|
+
|
|
359
|
+
// 检查日期是否在日程的有效范围内(考虑重复规则)
|
|
360
|
+
if (!isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate)) {
|
|
361
|
+
return [];
|
|
362
|
+
}
|
|
363
|
+
var slots = [];
|
|
364
|
+
|
|
365
|
+
// 提取所有时间段
|
|
366
|
+
var _iterator7 = _createForOfIteratorHelper(schedule.time_slot),
|
|
367
|
+
_step7;
|
|
368
|
+
try {
|
|
369
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
370
|
+
var timeSlot = _step7.value;
|
|
371
|
+
if (!timeSlot.start_time || !timeSlot.end_time) {
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
var startAt = dayjs("".concat(date, " ").concat(timeSlot.start_time, ":00"));
|
|
375
|
+
var endAt = dayjs("".concat(date, " ").concat(timeSlot.end_time, ":00"));
|
|
376
|
+
slots.push({
|
|
377
|
+
start_time: timeSlot.start_time,
|
|
378
|
+
end_time: timeSlot.end_time,
|
|
379
|
+
start_at: startAt,
|
|
380
|
+
end_at: endAt
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
} catch (err) {
|
|
384
|
+
_iterator7.e(err);
|
|
385
|
+
} finally {
|
|
386
|
+
_iterator7.f();
|
|
387
|
+
}
|
|
388
|
+
return slots;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* 检查日期是否在时间段类型日程范围内
|
|
393
|
+
*/
|
|
394
|
+
var isDateInTimeSlotsSchedule = function isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate) {
|
|
395
|
+
// 不重复的日程
|
|
396
|
+
if (schedule.repeat_type === 'none') {
|
|
397
|
+
// 只在 start_time 的日期有效
|
|
398
|
+
return targetDate.isSame(scheduleStartDate, 'day');
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// 重复的日程,需要检查重复规则
|
|
402
|
+
if (!schedule.repeat_rule) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
var repeat_rule = schedule.repeat_rule,
|
|
406
|
+
repeat_type = schedule.repeat_type;
|
|
407
|
+
|
|
408
|
+
// 检查是否在包含日期中(优先级最高)
|
|
409
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
410
|
+
var _iterator8 = _createForOfIteratorHelper(repeat_rule.included_date),
|
|
411
|
+
_step8;
|
|
412
|
+
try {
|
|
413
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
414
|
+
var includedDate = _step8.value;
|
|
415
|
+
var includeStartDate = dayjs(includedDate.start);
|
|
416
|
+
var includeEndDate = dayjs(includedDate.end);
|
|
417
|
+
if (targetDate.isSameOrAfter(includeStartDate, 'day') && targetDate.isSameOrBefore(includeEndDate, 'day')) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
} catch (err) {
|
|
422
|
+
_iterator8.e(err);
|
|
423
|
+
} finally {
|
|
424
|
+
_iterator8.f();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// 检查是否在排除日期中
|
|
429
|
+
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
430
|
+
var _iterator9 = _createForOfIteratorHelper(repeat_rule.excluded_date),
|
|
431
|
+
_step9;
|
|
432
|
+
try {
|
|
433
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
434
|
+
var excludedDate = _step9.value;
|
|
435
|
+
var excludeStartDate = dayjs(excludedDate.start);
|
|
436
|
+
var excludeEndDate = dayjs(excludedDate.end);
|
|
437
|
+
if (targetDate.isSameOrAfter(excludeStartDate, 'day') && targetDate.isSameOrBefore(excludeEndDate, 'day')) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
} catch (err) {
|
|
442
|
+
_iterator9.e(err);
|
|
443
|
+
} finally {
|
|
444
|
+
_iterator9.f();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// 检查重复规则的结束条件
|
|
449
|
+
if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
|
|
450
|
+
var ruleEndDate = dayjs(repeat_rule.end.end_date);
|
|
451
|
+
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// 检查是否在开始日期之前
|
|
457
|
+
if (targetDate.isBefore(scheduleStartDate, 'day')) {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// 根据重复类型检查
|
|
462
|
+
switch (repeat_type) {
|
|
463
|
+
case 'daily':
|
|
464
|
+
return isDateInDailyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
465
|
+
case 'weekly':
|
|
466
|
+
return isDateInWeeklyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
467
|
+
default:
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* 提取指定日期类型日程的时间段
|
|
474
|
+
*/
|
|
475
|
+
var extractDesignationScheduleTimeSlots = function extractDesignationScheduleTimeSlots(date, schedule) {
|
|
476
|
+
if (!schedule.designation) {
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
var targetDate = dayjs(date);
|
|
480
|
+
var designations = Array.isArray(schedule.designation) ? schedule.designation : [schedule.designation];
|
|
481
|
+
var slots = [];
|
|
482
|
+
var _iterator10 = _createForOfIteratorHelper(designations),
|
|
483
|
+
_step10;
|
|
484
|
+
try {
|
|
485
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
486
|
+
var designation = _step10.value;
|
|
487
|
+
var startDate = dayjs(designation.start_date);
|
|
488
|
+
var endDate = dayjs(designation.end_date);
|
|
489
|
+
|
|
490
|
+
// 检查日期是否在指定范围内(考虑重复规则)
|
|
491
|
+
if (isDateInDesignationSchedule(targetDate, schedule, designation, startDate, endDate)) {
|
|
492
|
+
var startAt = dayjs("".concat(date, " ").concat(designation.start_time, ":00"));
|
|
493
|
+
var endAt = dayjs("".concat(date, " ").concat(designation.end_time, ":00"));
|
|
494
|
+
slots.push({
|
|
495
|
+
start_time: designation.start_time,
|
|
496
|
+
end_time: designation.end_time,
|
|
497
|
+
start_at: startAt,
|
|
498
|
+
end_at: endAt
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
_iterator10.e(err);
|
|
504
|
+
} finally {
|
|
505
|
+
_iterator10.f();
|
|
506
|
+
}
|
|
507
|
+
return slots;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* 检查日期是否在指定日期类型日程范围内
|
|
512
|
+
*/
|
|
513
|
+
var isDateInDesignationSchedule = function isDateInDesignationSchedule(targetDate, schedule, designation, startDate, endDate) {
|
|
514
|
+
// 不重复的日程
|
|
515
|
+
if (schedule.repeat_type === 'none') {
|
|
516
|
+
// 检查日期是否在指定的日期范围内
|
|
517
|
+
return targetDate.isSameOrAfter(startDate, 'day') && targetDate.isSameOrBefore(endDate, 'day');
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// 重复的日程,需要检查重复规则
|
|
521
|
+
if (!schedule.repeat_rule) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
var repeat_rule = schedule.repeat_rule,
|
|
525
|
+
repeat_type = schedule.repeat_type;
|
|
526
|
+
|
|
527
|
+
// 检查是否在包含日期中(优先级最高)
|
|
528
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
529
|
+
var _iterator11 = _createForOfIteratorHelper(repeat_rule.included_date),
|
|
530
|
+
_step11;
|
|
531
|
+
try {
|
|
532
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
533
|
+
var includedDate = _step11.value;
|
|
534
|
+
var includeStartDate = dayjs(includedDate.start);
|
|
535
|
+
var includeEndDate = dayjs(includedDate.end);
|
|
536
|
+
if (targetDate.isSameOrAfter(includeStartDate, 'day') && targetDate.isSameOrBefore(includeEndDate, 'day')) {
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
} catch (err) {
|
|
541
|
+
_iterator11.e(err);
|
|
542
|
+
} finally {
|
|
543
|
+
_iterator11.f();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// 检查是否在排除日期中
|
|
548
|
+
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
549
|
+
var _iterator12 = _createForOfIteratorHelper(repeat_rule.excluded_date),
|
|
550
|
+
_step12;
|
|
551
|
+
try {
|
|
552
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
553
|
+
var excludedDate = _step12.value;
|
|
554
|
+
var excludeStartDate = dayjs(excludedDate.start);
|
|
555
|
+
var excludeEndDate = dayjs(excludedDate.end);
|
|
556
|
+
if (targetDate.isSameOrAfter(excludeStartDate, 'day') && targetDate.isSameOrBefore(excludeEndDate, 'day')) {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
} catch (err) {
|
|
561
|
+
_iterator12.e(err);
|
|
562
|
+
} finally {
|
|
563
|
+
_iterator12.f();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// 检查重复规则的结束条件
|
|
568
|
+
if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
|
|
569
|
+
var ruleEndDate = dayjs(repeat_rule.end.end_date);
|
|
570
|
+
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// 检查是否在基本日期范围内
|
|
576
|
+
if (!targetDate.isSameOrAfter(startDate, 'day') || !targetDate.isSameOrBefore(endDate, 'day')) {
|
|
577
|
+
// 对于重复日程,如果不在基本范围内,还需要检查是否符合重复规则
|
|
578
|
+
// 只要在 startDate 之后,并且符合重复规则即可
|
|
579
|
+
if (targetDate.isBefore(startDate, 'day')) {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// 根据重复类型检查
|
|
585
|
+
switch (repeat_type) {
|
|
586
|
+
case 'daily':
|
|
587
|
+
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
588
|
+
case 'weekly':
|
|
589
|
+
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
590
|
+
default:
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* 检查日期是否在标准日程范围内
|
|
597
|
+
*/
|
|
598
|
+
var isDateInStandardSchedule = function isDateInStandardSchedule(targetDate, schedule, startDate, endDate) {
|
|
599
|
+
var targetDateString = targetDate.format('YYYY-MM-DD');
|
|
600
|
+
|
|
601
|
+
// 不重复的日程
|
|
602
|
+
if (schedule.repeat_type === 'none') {
|
|
603
|
+
// 检查日期是否在范围内
|
|
604
|
+
var scheduleStartDate = startDate.format('YYYY-MM-DD');
|
|
605
|
+
var scheduleEndDate = endDate.format('YYYY-MM-DD');
|
|
606
|
+
return targetDate.isSameOrAfter(scheduleStartDate, 'day') && targetDate.isSameOrBefore(scheduleEndDate, 'day');
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// 重复的日程,需要检查重复规则
|
|
610
|
+
if (!schedule.repeat_rule) {
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
var repeat_rule = schedule.repeat_rule,
|
|
614
|
+
repeat_type = schedule.repeat_type;
|
|
615
|
+
|
|
616
|
+
// 检查是否在包含日期中
|
|
617
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
618
|
+
var _iterator13 = _createForOfIteratorHelper(repeat_rule.included_date),
|
|
619
|
+
_step13;
|
|
620
|
+
try {
|
|
621
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
622
|
+
var includedDate = _step13.value;
|
|
623
|
+
var includeStartDate = dayjs(includedDate.start);
|
|
624
|
+
var includeEndDate = dayjs(includedDate.end);
|
|
625
|
+
if (targetDate.isSameOrAfter(includeStartDate, 'day') && targetDate.isSameOrBefore(includeEndDate, 'day')) {
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
} catch (err) {
|
|
630
|
+
_iterator13.e(err);
|
|
631
|
+
} finally {
|
|
632
|
+
_iterator13.f();
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// 检查是否在排除日期中
|
|
637
|
+
var _iterator14 = _createForOfIteratorHelper(repeat_rule.excluded_date),
|
|
638
|
+
_step14;
|
|
639
|
+
try {
|
|
640
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
641
|
+
var excludedDate = _step14.value;
|
|
642
|
+
var excludeStartDate = dayjs(excludedDate.start);
|
|
643
|
+
var excludeEndDate = dayjs(excludedDate.end);
|
|
644
|
+
if (targetDate.isSameOrAfter(excludeStartDate, 'day') && targetDate.isSameOrBefore(excludeEndDate, 'day')) {
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// 检查重复规则的结束条件
|
|
650
|
+
} catch (err) {
|
|
651
|
+
_iterator14.e(err);
|
|
652
|
+
} finally {
|
|
653
|
+
_iterator14.f();
|
|
654
|
+
}
|
|
655
|
+
if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
|
|
656
|
+
var ruleEndDate = dayjs(repeat_rule.end.end_date);
|
|
657
|
+
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// 检查是否在开始日期之前
|
|
663
|
+
if (targetDate.isBefore(startDate, 'day')) {
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// 根据重复类型检查
|
|
668
|
+
switch (repeat_type) {
|
|
669
|
+
case 'daily':
|
|
670
|
+
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
671
|
+
case 'weekly':
|
|
672
|
+
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
673
|
+
default:
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* 检查日期是否符合每日重复规则
|
|
680
|
+
*/
|
|
681
|
+
var isDateInDailyRepeat = function isDateInDailyRepeat(targetDate, startDate, repeatRule) {
|
|
682
|
+
var daysDiff = targetDate.diff(startDate, 'day');
|
|
683
|
+
if (daysDiff < 0) {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// 检查频率
|
|
688
|
+
return daysDiff % repeatRule.frequency === 0;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* 检查日期是否符合每周重复规则
|
|
693
|
+
*/
|
|
694
|
+
var isDateInWeeklyRepeat = function isDateInWeeklyRepeat(targetDate, startDate, repeatRule) {
|
|
695
|
+
var targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
|
|
696
|
+
|
|
697
|
+
// 检查是否在指定的星期几内
|
|
698
|
+
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// 计算周差
|
|
703
|
+
var weeksDiff = targetDate.diff(startDate, 'week');
|
|
704
|
+
if (weeksDiff < 0) {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// 检查频率
|
|
709
|
+
return weeksDiff % repeatRule.frequency === 0;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* 对时间段去重并排序
|
|
714
|
+
* 只移除开始时间和结束时间完全相同的重复时间段
|
|
715
|
+
*/
|
|
716
|
+
var mergeAndSortTimeSlots = function mergeAndSortTimeSlots(slots) {
|
|
717
|
+
if (slots.length === 0) {
|
|
718
|
+
return [];
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// 按开始时间排序
|
|
722
|
+
var sorted = _toConsumableArray(slots).sort(function (a, b) {
|
|
723
|
+
return a.start_at.valueOf() - b.start_at.valueOf();
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
// 去重:移除开始和结束时间完全相同的时间段
|
|
727
|
+
var unique = [];
|
|
728
|
+
var seenKeys = new Set();
|
|
729
|
+
var _iterator15 = _createForOfIteratorHelper(sorted),
|
|
730
|
+
_step15;
|
|
731
|
+
try {
|
|
732
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
733
|
+
var slot = _step15.value;
|
|
734
|
+
// 使用开始时间和结束时间作为唯一键
|
|
735
|
+
var key = "".concat(slot.start_time, "-").concat(slot.end_time);
|
|
736
|
+
if (!seenKeys.has(key)) {
|
|
737
|
+
seenKeys.add(key);
|
|
738
|
+
unique.push(slot);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
} catch (err) {
|
|
742
|
+
_iterator15.e(err);
|
|
743
|
+
} finally {
|
|
744
|
+
_iterator15.f();
|
|
745
|
+
}
|
|
746
|
+
return unique;
|
|
747
|
+
};
|
|
@@ -33,7 +33,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
33
33
|
isInScheduleByDate({ date, schedule, }: {
|
|
34
34
|
date: string;
|
|
35
35
|
schedule: any;
|
|
36
|
-
}): boolean
|
|
36
|
+
}): boolean;
|
|
37
37
|
/**
|
|
38
38
|
* 传入一个时间, 判断改时间是否在schedule 内
|
|
39
39
|
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
@@ -42,5 +42,5 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
42
42
|
static isInScheduleByDate({ date, schedule, }: {
|
|
43
43
|
date: string;
|
|
44
44
|
schedule: any;
|
|
45
|
-
}): boolean
|
|
45
|
+
}): boolean;
|
|
46
46
|
}
|
|
@@ -27,6 +27,7 @@ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
|
27
27
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
28
28
|
import { generateMonthDates, disableAllDates, disableDatesBeforeOneDay } from "../Date/utils";
|
|
29
29
|
import { calcScheduleDateRange } from "./utils";
|
|
30
|
+
import { getDateIsInSchedule } from "./getDateIsInSchedule";
|
|
30
31
|
dayjs.extend(isSameOrBefore);
|
|
31
32
|
dayjs.extend(isSameOrAfter);
|
|
32
33
|
export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -270,6 +271,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
270
271
|
var _schedule$repeat_rule, _schedule$repeat_rule2;
|
|
271
272
|
var date = _ref3.date,
|
|
272
273
|
schedule = _ref3.schedule;
|
|
274
|
+
return getDateIsInSchedule(date, [schedule]);
|
|
273
275
|
if (schedule.start_time && schedule.end_time) {
|
|
274
276
|
var isBeforeStartTime = dayjs(date).isBefore(dayjs(schedule.start_time));
|
|
275
277
|
var isAfterEndTime = dayjs(date).isAfter(dayjs(schedule.end_time));
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { ScheduleItem } from "./types";
|
|
3
|
+
export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
|
|
4
|
+
export type ScheduleTimeSlot = {
|
|
5
|
+
/** 开始时间 HH:mm */
|
|
6
|
+
start_time: string;
|
|
7
|
+
/** 结束时间 HH:mm */
|
|
8
|
+
end_time: string;
|
|
9
|
+
/** 开始日期时间 YYYY-MM-DD HH:mm:ss */
|
|
10
|
+
start_at: dayjs.Dayjs;
|
|
11
|
+
/** 结束日期时间 YYYY-MM-DD HH:mm:ss */
|
|
12
|
+
end_at: dayjs.Dayjs;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 获取当前日期日程时间点
|
|
16
|
+
* @param date 日期 YYYY-MM-DD
|
|
17
|
+
* @param scheduleList 日程列表
|
|
18
|
+
* @returns 当前日期日程时间点 结构,数组 [{
|
|
19
|
+
*
|
|
20
|
+
* // HH:mm
|
|
21
|
+
* end_time: string,
|
|
22
|
+
* // HH:mm
|
|
23
|
+
* start_time: string,
|
|
24
|
+
* // 日期时间
|
|
25
|
+
* // YYYY-MM-DD HH:mm:ss
|
|
26
|
+
* end_at: Dayjs,
|
|
27
|
+
* // YYYY-MM-DD HH:mm:ss
|
|
28
|
+
* start_at: Dayjs,
|
|
29
|
+
*
|
|
30
|
+
* }]
|
|
31
|
+
*/
|
|
32
|
+
export declare const getScheduleStartEndTimePoints: (date: string, scheduleList: ScheduleItem[]) => ScheduleTimeSlot[];
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/Schedule/getDateIsInSchedule.ts
|
|
30
|
+
var getDateIsInSchedule_exports = {};
|
|
31
|
+
__export(getDateIsInSchedule_exports, {
|
|
32
|
+
getDateIsInSchedule: () => getDateIsInSchedule,
|
|
33
|
+
getScheduleStartEndTimePoints: () => getScheduleStartEndTimePoints
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(getDateIsInSchedule_exports);
|
|
36
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
37
|
+
var getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
38
|
+
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const targetDate = (0, import_dayjs.default)(dateTime);
|
|
42
|
+
if (!targetDate.isValid()) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
for (const schedule of scheduleList) {
|
|
46
|
+
if (isTimeInScheduleItem(dateTime, schedule)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
var isTimeInScheduleItem = (dateTime, schedule) => {
|
|
53
|
+
const targetDate = (0, import_dayjs.default)(dateTime);
|
|
54
|
+
const targetDateString = dateTime.split(" ")[0];
|
|
55
|
+
const targetTimeString = dateTime.split(" ")[1] || "00:00:00";
|
|
56
|
+
switch (schedule.type) {
|
|
57
|
+
case "standard":
|
|
58
|
+
return isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
59
|
+
case "time-slots":
|
|
60
|
+
return isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
61
|
+
case "designation":
|
|
62
|
+
return isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
63
|
+
default:
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var isInStandardSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
68
|
+
if (!schedule.start_time || !schedule.end_time) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const startDate = (0, import_dayjs.default)(schedule.start_time);
|
|
72
|
+
const endDate = (0, import_dayjs.default)(schedule.end_time);
|
|
73
|
+
const isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate);
|
|
74
|
+
if (schedule.repeat_type === "none") {
|
|
75
|
+
return isInBasicRange;
|
|
76
|
+
}
|
|
77
|
+
return isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate);
|
|
78
|
+
};
|
|
79
|
+
var isInTimeSlotsSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
80
|
+
if (!schedule.start_time) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const scheduleDate = schedule.start_time.split(" ")[0];
|
|
84
|
+
if (targetDateString !== scheduleDate) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
for (const timeSlot of schedule.time_slot) {
|
|
88
|
+
const slotStart = `${scheduleDate} ${timeSlot.start_time}:00`;
|
|
89
|
+
const slotEnd = `${scheduleDate} ${timeSlot.end_time}:00`;
|
|
90
|
+
const slotStartDate = (0, import_dayjs.default)(slotStart);
|
|
91
|
+
const slotEndDate = (0, import_dayjs.default)(slotEnd);
|
|
92
|
+
if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
};
|
|
98
|
+
var isInDesignationSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
99
|
+
if (!schedule.designation) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
for (const designation of schedule.designation) {
|
|
103
|
+
const startDateTime = `${designation.start_date} ${designation.start_time}:00`;
|
|
104
|
+
const endDateTime = `${designation.end_date} ${designation.end_time}:00`;
|
|
105
|
+
const startDate = (0, import_dayjs.default)(startDateTime);
|
|
106
|
+
const endDate = (0, import_dayjs.default)(endDateTime);
|
|
107
|
+
if (targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate)) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
113
|
+
var isInRepeatingSchedule = (targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) => {
|
|
114
|
+
if (!schedule.repeat_rule) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
118
|
+
const targetDateOnly = (0, import_dayjs.default)(targetDateString);
|
|
119
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
120
|
+
for (const includedDate of repeat_rule.included_date) {
|
|
121
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
122
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
123
|
+
if (targetDateOnly.isSameOrAfter(includeStartDate, "day") && targetDateOnly.isSameOrBefore(includeEndDate, "day")) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const excludedDate of repeat_rule.excluded_date) {
|
|
129
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
130
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
131
|
+
if (targetDateOnly.isSameOrAfter(excludeStartDate, "day") && targetDateOnly.isSameOrBefore(excludeEndDate, "day")) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
136
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
137
|
+
if (targetDate.isAfter(ruleEndDate)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
switch (repeat_type) {
|
|
142
|
+
case "daily":
|
|
143
|
+
return isInDailyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
144
|
+
case "weekly":
|
|
145
|
+
return isInWeeklyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
146
|
+
default:
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
151
|
+
const daysDiff = targetDate.diff(startDate, "day");
|
|
152
|
+
if (daysDiff < 0) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
if (daysDiff % repeatRule.frequency !== 0) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
159
|
+
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
160
|
+
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
161
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
162
|
+
};
|
|
163
|
+
var isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
164
|
+
const targetDayOfWeek = targetDate.day();
|
|
165
|
+
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const weeksDiff = targetDate.diff(startDate, "week");
|
|
169
|
+
if (weeksDiff < 0) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
if (weeksDiff % repeatRule.frequency !== 0) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
176
|
+
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
177
|
+
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
178
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
179
|
+
};
|
|
180
|
+
var getScheduleStartEndTimePoints = (date, scheduleList) => {
|
|
181
|
+
if (!date || !scheduleList || scheduleList.length === 0) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
185
|
+
if (!targetDate.isValid()) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
const timeSlots = [];
|
|
189
|
+
for (const schedule of scheduleList) {
|
|
190
|
+
const slots = extractTimeSlotsFromSchedule(date, schedule);
|
|
191
|
+
timeSlots.push(...slots);
|
|
192
|
+
}
|
|
193
|
+
return mergeAndSortTimeSlots(timeSlots);
|
|
194
|
+
};
|
|
195
|
+
var extractTimeSlotsFromSchedule = (date, schedule) => {
|
|
196
|
+
switch (schedule.type) {
|
|
197
|
+
case "standard":
|
|
198
|
+
return extractStandardScheduleTimeSlots(date, schedule);
|
|
199
|
+
case "time-slots":
|
|
200
|
+
return extractTimeSlotsScheduleTimeSlots(date, schedule);
|
|
201
|
+
case "designation":
|
|
202
|
+
return extractDesignationScheduleTimeSlots(date, schedule);
|
|
203
|
+
default:
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
208
|
+
if (!schedule.start_time || !schedule.end_time) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
212
|
+
const startDate = (0, import_dayjs.default)(schedule.start_time);
|
|
213
|
+
const endDate = (0, import_dayjs.default)(schedule.end_time);
|
|
214
|
+
if (!isDateInStandardSchedule(targetDate, schedule, startDate, endDate)) {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
const startTime = startDate.format("HH:mm");
|
|
218
|
+
const endTime = endDate.format("HH:mm");
|
|
219
|
+
const startAt = (0, import_dayjs.default)(`${date} ${startTime}:00`);
|
|
220
|
+
const endAt = (0, import_dayjs.default)(`${date} ${endTime}:00`);
|
|
221
|
+
return [{
|
|
222
|
+
start_time: startTime,
|
|
223
|
+
end_time: endTime,
|
|
224
|
+
start_at: startAt,
|
|
225
|
+
end_at: endAt
|
|
226
|
+
}];
|
|
227
|
+
};
|
|
228
|
+
var extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
229
|
+
if (!schedule.start_time || !schedule.time_slot || schedule.time_slot.length === 0) {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
233
|
+
const scheduleStartDate = (0, import_dayjs.default)(schedule.start_time.split(" ")[0]);
|
|
234
|
+
if (!isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate)) {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
const slots = [];
|
|
238
|
+
for (const timeSlot of schedule.time_slot) {
|
|
239
|
+
if (!timeSlot.start_time || !timeSlot.end_time) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const startAt = (0, import_dayjs.default)(`${date} ${timeSlot.start_time}:00`);
|
|
243
|
+
const endAt = (0, import_dayjs.default)(`${date} ${timeSlot.end_time}:00`);
|
|
244
|
+
slots.push({
|
|
245
|
+
start_time: timeSlot.start_time,
|
|
246
|
+
end_time: timeSlot.end_time,
|
|
247
|
+
start_at: startAt,
|
|
248
|
+
end_at: endAt
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return slots;
|
|
252
|
+
};
|
|
253
|
+
var isDateInTimeSlotsSchedule = (targetDate, schedule, scheduleStartDate) => {
|
|
254
|
+
if (schedule.repeat_type === "none") {
|
|
255
|
+
return targetDate.isSame(scheduleStartDate, "day");
|
|
256
|
+
}
|
|
257
|
+
if (!schedule.repeat_rule) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
261
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
262
|
+
for (const includedDate of repeat_rule.included_date) {
|
|
263
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
264
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
265
|
+
if (targetDate.isSameOrAfter(includeStartDate, "day") && targetDate.isSameOrBefore(includeEndDate, "day")) {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
271
|
+
for (const excludedDate of repeat_rule.excluded_date) {
|
|
272
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
273
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
274
|
+
if (targetDate.isSameOrAfter(excludeStartDate, "day") && targetDate.isSameOrBefore(excludeEndDate, "day")) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
280
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
281
|
+
if (targetDate.isAfter(ruleEndDate, "day")) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (targetDate.isBefore(scheduleStartDate, "day")) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
switch (repeat_type) {
|
|
289
|
+
case "daily":
|
|
290
|
+
return isDateInDailyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
291
|
+
case "weekly":
|
|
292
|
+
return isDateInWeeklyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
293
|
+
default:
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
298
|
+
if (!schedule.designation) {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
302
|
+
const designations = Array.isArray(schedule.designation) ? schedule.designation : [schedule.designation];
|
|
303
|
+
const slots = [];
|
|
304
|
+
for (const designation of designations) {
|
|
305
|
+
const startDate = (0, import_dayjs.default)(designation.start_date);
|
|
306
|
+
const endDate = (0, import_dayjs.default)(designation.end_date);
|
|
307
|
+
if (isDateInDesignationSchedule(targetDate, schedule, designation, startDate, endDate)) {
|
|
308
|
+
const startAt = (0, import_dayjs.default)(`${date} ${designation.start_time}:00`);
|
|
309
|
+
const endAt = (0, import_dayjs.default)(`${date} ${designation.end_time}:00`);
|
|
310
|
+
slots.push({
|
|
311
|
+
start_time: designation.start_time,
|
|
312
|
+
end_time: designation.end_time,
|
|
313
|
+
start_at: startAt,
|
|
314
|
+
end_at: endAt
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return slots;
|
|
319
|
+
};
|
|
320
|
+
var isDateInDesignationSchedule = (targetDate, schedule, designation, startDate, endDate) => {
|
|
321
|
+
if (schedule.repeat_type === "none") {
|
|
322
|
+
return targetDate.isSameOrAfter(startDate, "day") && targetDate.isSameOrBefore(endDate, "day");
|
|
323
|
+
}
|
|
324
|
+
if (!schedule.repeat_rule) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
328
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
329
|
+
for (const includedDate of repeat_rule.included_date) {
|
|
330
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
331
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
332
|
+
if (targetDate.isSameOrAfter(includeStartDate, "day") && targetDate.isSameOrBefore(includeEndDate, "day")) {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
338
|
+
for (const excludedDate of repeat_rule.excluded_date) {
|
|
339
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
340
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
341
|
+
if (targetDate.isSameOrAfter(excludeStartDate, "day") && targetDate.isSameOrBefore(excludeEndDate, "day")) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
347
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
348
|
+
if (targetDate.isAfter(ruleEndDate, "day")) {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (!targetDate.isSameOrAfter(startDate, "day") || !targetDate.isSameOrBefore(endDate, "day")) {
|
|
353
|
+
if (targetDate.isBefore(startDate, "day")) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
switch (repeat_type) {
|
|
358
|
+
case "daily":
|
|
359
|
+
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
360
|
+
case "weekly":
|
|
361
|
+
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
362
|
+
default:
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var isDateInStandardSchedule = (targetDate, schedule, startDate, endDate) => {
|
|
367
|
+
const targetDateString = targetDate.format("YYYY-MM-DD");
|
|
368
|
+
if (schedule.repeat_type === "none") {
|
|
369
|
+
const scheduleStartDate = startDate.format("YYYY-MM-DD");
|
|
370
|
+
const scheduleEndDate = endDate.format("YYYY-MM-DD");
|
|
371
|
+
return targetDate.isSameOrAfter(scheduleStartDate, "day") && targetDate.isSameOrBefore(scheduleEndDate, "day");
|
|
372
|
+
}
|
|
373
|
+
if (!schedule.repeat_rule) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
377
|
+
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
378
|
+
for (const includedDate of repeat_rule.included_date) {
|
|
379
|
+
const includeStartDate = (0, import_dayjs.default)(includedDate.start);
|
|
380
|
+
const includeEndDate = (0, import_dayjs.default)(includedDate.end);
|
|
381
|
+
if (targetDate.isSameOrAfter(includeStartDate, "day") && targetDate.isSameOrBefore(includeEndDate, "day")) {
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
for (const excludedDate of repeat_rule.excluded_date) {
|
|
387
|
+
const excludeStartDate = (0, import_dayjs.default)(excludedDate.start);
|
|
388
|
+
const excludeEndDate = (0, import_dayjs.default)(excludedDate.end);
|
|
389
|
+
if (targetDate.isSameOrAfter(excludeStartDate, "day") && targetDate.isSameOrBefore(excludeEndDate, "day")) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
394
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
395
|
+
if (targetDate.isAfter(ruleEndDate, "day")) {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (targetDate.isBefore(startDate, "day")) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
switch (repeat_type) {
|
|
403
|
+
case "daily":
|
|
404
|
+
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
405
|
+
case "weekly":
|
|
406
|
+
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
407
|
+
default:
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
var isDateInDailyRepeat = (targetDate, startDate, repeatRule) => {
|
|
412
|
+
const daysDiff = targetDate.diff(startDate, "day");
|
|
413
|
+
if (daysDiff < 0) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
return daysDiff % repeatRule.frequency === 0;
|
|
417
|
+
};
|
|
418
|
+
var isDateInWeeklyRepeat = (targetDate, startDate, repeatRule) => {
|
|
419
|
+
const targetDayOfWeek = targetDate.day();
|
|
420
|
+
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
const weeksDiff = targetDate.diff(startDate, "week");
|
|
424
|
+
if (weeksDiff < 0) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return weeksDiff % repeatRule.frequency === 0;
|
|
428
|
+
};
|
|
429
|
+
var mergeAndSortTimeSlots = (slots) => {
|
|
430
|
+
if (slots.length === 0) {
|
|
431
|
+
return [];
|
|
432
|
+
}
|
|
433
|
+
const sorted = [...slots].sort((a, b) => {
|
|
434
|
+
return a.start_at.valueOf() - b.start_at.valueOf();
|
|
435
|
+
});
|
|
436
|
+
const unique = [];
|
|
437
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
438
|
+
for (const slot of sorted) {
|
|
439
|
+
const key = `${slot.start_time}-${slot.end_time}`;
|
|
440
|
+
if (!seenKeys.has(key)) {
|
|
441
|
+
seenKeys.add(key);
|
|
442
|
+
unique.push(slot);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return unique;
|
|
446
|
+
};
|
|
447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
448
|
+
0 && (module.exports = {
|
|
449
|
+
getDateIsInSchedule,
|
|
450
|
+
getScheduleStartEndTimePoints
|
|
451
|
+
});
|
|
@@ -33,7 +33,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
33
33
|
isInScheduleByDate({ date, schedule, }: {
|
|
34
34
|
date: string;
|
|
35
35
|
schedule: any;
|
|
36
|
-
}): boolean
|
|
36
|
+
}): boolean;
|
|
37
37
|
/**
|
|
38
38
|
* 传入一个时间, 判断改时间是否在schedule 内
|
|
39
39
|
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
@@ -42,5 +42,5 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
42
42
|
static isInScheduleByDate({ date, schedule, }: {
|
|
43
43
|
date: string;
|
|
44
44
|
schedule: any;
|
|
45
|
-
}): boolean
|
|
45
|
+
}): boolean;
|
|
46
46
|
}
|
|
@@ -39,6 +39,7 @@ var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
|
39
39
|
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
40
40
|
var import_utils = require("../Date/utils");
|
|
41
41
|
var import_utils2 = require("./utils");
|
|
42
|
+
var import_getDateIsInSchedule = require("./getDateIsInSchedule");
|
|
42
43
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
43
44
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
44
45
|
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
@@ -180,6 +181,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
180
181
|
schedule
|
|
181
182
|
}) {
|
|
182
183
|
var _a, _b, _c, _d;
|
|
184
|
+
return (0, import_getDateIsInSchedule.getDateIsInSchedule)(date, [schedule]);
|
|
183
185
|
if (schedule.start_time && schedule.end_time) {
|
|
184
186
|
const isBeforeStartTime = (0, import_dayjs.default)(date).isBefore(
|
|
185
187
|
(0, import_dayjs.default)(schedule.start_time)
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|