@pisell/pisellos 0.0.569 → 0.10.2
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/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
|
5
34
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var _isSameOrBefore = _interopRequireDefault(require("dayjs/plugin/isSameOrBefore"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
_dayjs.default.extend(_isSameOrAfter.default);
|
|
12
|
-
_dayjs.default.extend(_isSameOrBefore.default);
|
|
13
|
-
|
|
14
|
-
// 获取时间是否在日程范围内
|
|
15
|
-
const getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
35
|
+
module.exports = __toCommonJS(getDateIsInSchedule_exports);
|
|
36
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
37
|
+
var getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
16
38
|
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
17
39
|
return false;
|
|
18
40
|
}
|
|
19
|
-
const targetDate = (0,
|
|
41
|
+
const targetDate = (0, import_dayjs.default)(dateTime);
|
|
20
42
|
if (!targetDate.isValid()) {
|
|
21
43
|
return false;
|
|
22
44
|
}
|
|
23
|
-
|
|
24
|
-
// 遍历所有日程项
|
|
25
45
|
for (const schedule of scheduleList) {
|
|
26
46
|
if (isTimeInScheduleItem(dateTime, schedule)) {
|
|
27
47
|
return true;
|
|
@@ -29,270 +49,175 @@ const getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
|
29
49
|
}
|
|
30
50
|
return false;
|
|
31
51
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const targetDate = (0, _dayjs.default)(dateTime);
|
|
37
|
-
const targetDateString = dateTime.split(' ')[0]; // YYYY-MM-DD
|
|
38
|
-
const targetTimeString = dateTime.split(' ')[1] || '00:00:00'; // HH:mm:ss
|
|
39
|
-
|
|
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";
|
|
40
56
|
switch (schedule.type) {
|
|
41
|
-
case
|
|
57
|
+
case "standard":
|
|
42
58
|
return isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
43
|
-
case
|
|
59
|
+
case "time-slots":
|
|
44
60
|
return isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
45
|
-
case
|
|
61
|
+
case "designation":
|
|
46
62
|
return isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule);
|
|
47
63
|
default:
|
|
48
64
|
return false;
|
|
49
65
|
}
|
|
50
66
|
};
|
|
51
|
-
|
|
52
|
-
// 处理标准类型日程
|
|
53
|
-
const isInStandardSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
67
|
+
var isInStandardSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
54
68
|
if (!schedule.start_time || !schedule.end_time) {
|
|
55
69
|
return false;
|
|
56
70
|
}
|
|
57
|
-
const startDate = (0,
|
|
58
|
-
const endDate = (0,
|
|
59
|
-
|
|
60
|
-
// 先检查是否在基础时间范围内(不考虑重复),end 为开区间
|
|
71
|
+
const startDate = (0, import_dayjs.default)(schedule.start_time);
|
|
72
|
+
const endDate = (0, import_dayjs.default)(schedule.end_time);
|
|
61
73
|
const isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isBefore(endDate);
|
|
62
|
-
if (schedule.repeat_type ===
|
|
74
|
+
if (schedule.repeat_type === "none") {
|
|
63
75
|
return isInBasicRange;
|
|
64
76
|
}
|
|
65
|
-
|
|
66
|
-
// 处理重复日程
|
|
67
77
|
return isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate);
|
|
68
78
|
};
|
|
69
|
-
|
|
70
|
-
// 处理时间段类型日程
|
|
71
|
-
const isInTimeSlotsSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
79
|
+
var isInTimeSlotsSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
72
80
|
if (!schedule.start_time) {
|
|
73
81
|
return false;
|
|
74
82
|
}
|
|
75
|
-
const scheduleStartDate = (0,
|
|
76
|
-
|
|
77
|
-
// 检查日期是否在日程的有效范围内(包含 daily / weekly 重复规则)
|
|
83
|
+
const scheduleStartDate = (0, import_dayjs.default)(schedule.start_time.split(" ")[0]);
|
|
78
84
|
if (!isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate)) {
|
|
79
85
|
return false;
|
|
80
86
|
}
|
|
81
|
-
|
|
82
|
-
// 检查是否在任一时间段内
|
|
83
87
|
for (const timeSlot of schedule.time_slot) {
|
|
84
88
|
const slotStart = `${targetDateString} ${timeSlot.start_time}:00`;
|
|
85
89
|
const slotEnd = `${targetDateString} ${timeSlot.end_time}:00`;
|
|
86
|
-
const slotStartDate = (0,
|
|
87
|
-
const slotEndDate = (0,
|
|
90
|
+
const slotStartDate = (0, import_dayjs.default)(slotStart);
|
|
91
|
+
const slotEndDate = (0, import_dayjs.default)(slotEnd);
|
|
88
92
|
if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
|
|
89
93
|
return true;
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
return false;
|
|
93
97
|
};
|
|
94
|
-
|
|
95
|
-
// 处理指定类型日程
|
|
96
|
-
const isInDesignationSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
98
|
+
var isInDesignationSchedule = (targetDate, targetDateString, targetTimeString, schedule) => {
|
|
97
99
|
if (!schedule.designation) {
|
|
98
100
|
return false;
|
|
99
101
|
}
|
|
100
|
-
|
|
101
|
-
// @ts-ignore
|
|
102
102
|
for (const designation of schedule.designation) {
|
|
103
103
|
const startDateTime = `${designation.start_date} ${designation.start_time}:00`;
|
|
104
104
|
const endDateTime = `${designation.end_date} ${designation.end_time}:00`;
|
|
105
|
-
const startDate = (0,
|
|
106
|
-
const endDate = (0,
|
|
105
|
+
const startDate = (0, import_dayjs.default)(startDateTime);
|
|
106
|
+
const endDate = (0, import_dayjs.default)(endDateTime);
|
|
107
107
|
if (targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate)) {
|
|
108
108
|
return true;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
return false;
|
|
112
112
|
};
|
|
113
|
-
|
|
114
|
-
// 处理重复日程逻辑
|
|
115
|
-
const isInRepeatingSchedule = (targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) => {
|
|
113
|
+
var isInRepeatingSchedule = (targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) => {
|
|
116
114
|
if (!schedule.repeat_rule) {
|
|
117
115
|
return false;
|
|
118
116
|
}
|
|
119
|
-
const {
|
|
120
|
-
|
|
121
|
-
repeat_type
|
|
122
|
-
} = schedule;
|
|
123
|
-
const targetDateOnly = (0, _dayjs.default)(targetDateString); // 只取日期部分
|
|
124
|
-
|
|
125
|
-
// 首先检查是否在包含日期中(包含日期是额外增加的有效日期)
|
|
117
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
118
|
+
const targetDateOnly = (0, import_dayjs.default)(targetDateString);
|
|
126
119
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
127
120
|
for (const includedDate of repeat_rule.included_date) {
|
|
128
|
-
const includeStartDate = (0,
|
|
129
|
-
const includeEndDate = (0,
|
|
130
|
-
if (targetDateOnly.isSameOrAfter(includeStartDate,
|
|
131
|
-
// 在包含日期中,直接返回true,无需检查其他条件
|
|
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")) {
|
|
132
124
|
return true;
|
|
133
125
|
}
|
|
134
126
|
}
|
|
135
127
|
}
|
|
136
|
-
|
|
137
|
-
// 检查是否在排除日期中
|
|
138
128
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
139
|
-
const excludeStartDate = (0,
|
|
140
|
-
const excludeEndDate = (0,
|
|
141
|
-
|
|
142
|
-
if (targetDateOnly.isSameOrAfter(excludeStartDate, 'day') && targetDateOnly.isSameOrBefore(excludeEndDate, 'day')) {
|
|
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")) {
|
|
143
132
|
return false;
|
|
144
133
|
}
|
|
145
134
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
|
|
149
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
135
|
+
if (repeat_rule.end.type === "date" && repeat_rule.end.end_date) {
|
|
136
|
+
const ruleEndDate = (0, import_dayjs.default)(repeat_rule.end.end_date);
|
|
150
137
|
if (targetDate.isAfter(ruleEndDate)) {
|
|
151
138
|
return false;
|
|
152
139
|
}
|
|
153
140
|
}
|
|
154
|
-
|
|
155
|
-
// 根据重复类型检查
|
|
156
141
|
switch (repeat_type) {
|
|
157
|
-
case
|
|
142
|
+
case "daily":
|
|
158
143
|
return isInDailyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
159
|
-
case
|
|
144
|
+
case "weekly":
|
|
160
145
|
return isInWeeklyRepeat(targetDate, startDate, endDate, repeat_rule);
|
|
161
146
|
default:
|
|
162
147
|
return false;
|
|
163
|
-
// 不支持月和年重复
|
|
164
148
|
}
|
|
165
149
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
169
|
-
const daysDiff = targetDate.diff(startDate, 'day');
|
|
150
|
+
var isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
151
|
+
const daysDiff = targetDate.diff(startDate, "day");
|
|
170
152
|
if (daysDiff < 0) {
|
|
171
153
|
return false;
|
|
172
154
|
}
|
|
173
|
-
|
|
174
|
-
// 检查频率
|
|
175
155
|
if (daysDiff % repeatRule.frequency !== 0) {
|
|
176
156
|
return false;
|
|
177
157
|
}
|
|
178
|
-
|
|
179
|
-
// 检查时间是否在日程的时间范围内
|
|
180
158
|
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
181
159
|
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
182
160
|
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
183
|
-
|
|
184
|
-
// 每日重复:每天都在相同的时间段内有效
|
|
185
|
-
// 例如:01:00:00 - 16:00:00,每天都是这个时间段
|
|
186
161
|
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
187
162
|
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
191
|
-
const targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
|
|
192
|
-
|
|
193
|
-
// 检查是否在指定的星期几内
|
|
163
|
+
var isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
164
|
+
const targetDayOfWeek = targetDate.day();
|
|
194
165
|
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
195
166
|
return false;
|
|
196
167
|
}
|
|
197
|
-
|
|
198
|
-
// 计算周差
|
|
199
|
-
const weeksDiff = targetDate.diff(startDate, 'week');
|
|
168
|
+
const weeksDiff = targetDate.diff(startDate, "week");
|
|
200
169
|
if (weeksDiff < 0) {
|
|
201
170
|
return false;
|
|
202
171
|
}
|
|
203
|
-
|
|
204
|
-
// 检查频率
|
|
205
172
|
if (weeksDiff % repeatRule.frequency !== 0) {
|
|
206
173
|
return false;
|
|
207
174
|
}
|
|
208
|
-
|
|
209
|
-
// 检查时间是否在日程的时间范围内
|
|
210
175
|
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
211
176
|
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
212
177
|
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
213
178
|
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
214
179
|
};
|
|
215
|
-
|
|
216
|
-
// 日程时间段类型
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* 获取当前日期日程时间点
|
|
220
|
-
* @param date 日期 YYYY-MM-DD
|
|
221
|
-
* @param scheduleList 日程列表
|
|
222
|
-
* @returns 当前日期日程时间点 结构,数组 [{
|
|
223
|
-
*
|
|
224
|
-
* // HH:mm
|
|
225
|
-
* end_time: string,
|
|
226
|
-
* // HH:mm
|
|
227
|
-
* start_time: string,
|
|
228
|
-
* // 日期时间
|
|
229
|
-
* // YYYY-MM-DD HH:mm:ss
|
|
230
|
-
* end_at: Dayjs,
|
|
231
|
-
* // YYYY-MM-DD HH:mm:ss
|
|
232
|
-
* start_at: Dayjs,
|
|
233
|
-
*
|
|
234
|
-
* }]
|
|
235
|
-
*/
|
|
236
|
-
const getScheduleStartEndTimePoints = (date, scheduleList) => {
|
|
180
|
+
var getScheduleStartEndTimePoints = (date, scheduleList) => {
|
|
237
181
|
if (!date || !scheduleList || scheduleList.length === 0) {
|
|
238
182
|
return [];
|
|
239
183
|
}
|
|
240
|
-
const targetDate = (0,
|
|
184
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
241
185
|
if (!targetDate.isValid()) {
|
|
242
186
|
return [];
|
|
243
187
|
}
|
|
244
188
|
const timeSlots = [];
|
|
245
|
-
|
|
246
|
-
// 遍历所有日程
|
|
247
189
|
for (const schedule of scheduleList) {
|
|
248
190
|
const slots = extractTimeSlotsFromSchedule(date, schedule);
|
|
249
191
|
timeSlots.push(...slots);
|
|
250
192
|
}
|
|
251
|
-
|
|
252
|
-
// 去重并排序时间段
|
|
253
193
|
return mergeAndSortTimeSlots(timeSlots);
|
|
254
194
|
};
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* 从单个日程中提取指定日期的时间段
|
|
258
|
-
*/
|
|
259
|
-
exports.getScheduleStartEndTimePoints = getScheduleStartEndTimePoints;
|
|
260
|
-
const extractTimeSlotsFromSchedule = (date, schedule) => {
|
|
195
|
+
var extractTimeSlotsFromSchedule = (date, schedule) => {
|
|
261
196
|
switch (schedule.type) {
|
|
262
|
-
case
|
|
197
|
+
case "standard":
|
|
263
198
|
return extractStandardScheduleTimeSlots(date, schedule);
|
|
264
|
-
case
|
|
199
|
+
case "time-slots":
|
|
265
200
|
return extractTimeSlotsScheduleTimeSlots(date, schedule);
|
|
266
|
-
case
|
|
201
|
+
case "designation":
|
|
267
202
|
return extractDesignationScheduleTimeSlots(date, schedule);
|
|
268
203
|
default:
|
|
269
204
|
return [];
|
|
270
205
|
}
|
|
271
206
|
};
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* 提取标准类型日程的时间段
|
|
275
|
-
*/
|
|
276
|
-
const extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
207
|
+
var extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
277
208
|
if (!schedule.start_time || !schedule.end_time) {
|
|
278
209
|
return [];
|
|
279
210
|
}
|
|
280
|
-
const targetDate = (0,
|
|
281
|
-
const startDate = (0,
|
|
282
|
-
const endDate = (0,
|
|
283
|
-
|
|
284
|
-
// 检查日期是否在日程范围内
|
|
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);
|
|
285
214
|
if (!isDateInStandardSchedule(targetDate, schedule, startDate, endDate)) {
|
|
286
215
|
return [];
|
|
287
216
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
// 构造完整的日期时间
|
|
294
|
-
const startAt = (0, _dayjs.default)(`${date} ${startTime}:00`);
|
|
295
|
-
const endAt = (0, _dayjs.default)(`${date} ${endTime}:00`);
|
|
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`);
|
|
296
221
|
return [{
|
|
297
222
|
start_time: startTime,
|
|
298
223
|
end_time: endTime,
|
|
@@ -300,30 +225,22 @@ const extractStandardScheduleTimeSlots = (date, schedule) => {
|
|
|
300
225
|
end_at: endAt
|
|
301
226
|
}];
|
|
302
227
|
};
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* 提取时间段类型日程的时间段
|
|
306
|
-
*/
|
|
307
|
-
const extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
228
|
+
var extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
308
229
|
if (!schedule.start_time || !schedule.time_slot || schedule.time_slot.length === 0) {
|
|
309
230
|
return [];
|
|
310
231
|
}
|
|
311
|
-
const targetDate = (0,
|
|
312
|
-
const scheduleStartDate = (0,
|
|
313
|
-
|
|
314
|
-
// 检查日期是否在日程的有效范围内(考虑重复规则)
|
|
232
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
233
|
+
const scheduleStartDate = (0, import_dayjs.default)(schedule.start_time.split(" ")[0]);
|
|
315
234
|
if (!isDateInTimeSlotsSchedule(targetDate, schedule, scheduleStartDate)) {
|
|
316
235
|
return [];
|
|
317
236
|
}
|
|
318
237
|
const slots = [];
|
|
319
|
-
|
|
320
|
-
// 提取所有时间段
|
|
321
238
|
for (const timeSlot of schedule.time_slot) {
|
|
322
239
|
if (!timeSlot.start_time || !timeSlot.end_time) {
|
|
323
240
|
continue;
|
|
324
241
|
}
|
|
325
|
-
const startAt = (0,
|
|
326
|
-
const endAt = (0,
|
|
242
|
+
const startAt = (0, import_dayjs.default)(`${date} ${timeSlot.start_time}:00`);
|
|
243
|
+
const endAt = (0, import_dayjs.default)(`${date} ${timeSlot.end_time}:00`);
|
|
327
244
|
slots.push({
|
|
328
245
|
start_time: timeSlot.start_time,
|
|
329
246
|
end_time: timeSlot.end_time,
|
|
@@ -333,90 +250,63 @@ const extractTimeSlotsScheduleTimeSlots = (date, schedule) => {
|
|
|
333
250
|
}
|
|
334
251
|
return slots;
|
|
335
252
|
};
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
*/
|
|
340
|
-
const isDateInTimeSlotsSchedule = (targetDate, schedule, scheduleStartDate) => {
|
|
341
|
-
// 不重复的日程
|
|
342
|
-
if (schedule.repeat_type === 'none') {
|
|
343
|
-
// 只在 start_time 的日期有效
|
|
344
|
-
return targetDate.isSame(scheduleStartDate, 'day');
|
|
253
|
+
var isDateInTimeSlotsSchedule = (targetDate, schedule, scheduleStartDate) => {
|
|
254
|
+
if (schedule.repeat_type === "none") {
|
|
255
|
+
return targetDate.isSame(scheduleStartDate, "day");
|
|
345
256
|
}
|
|
346
|
-
|
|
347
|
-
// 重复的日程,需要检查重复规则
|
|
348
257
|
if (!schedule.repeat_rule) {
|
|
349
258
|
return false;
|
|
350
259
|
}
|
|
351
|
-
const {
|
|
352
|
-
repeat_rule,
|
|
353
|
-
repeat_type
|
|
354
|
-
} = schedule;
|
|
355
|
-
|
|
356
|
-
// 检查是否在包含日期中(优先级最高)
|
|
260
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
357
261
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
358
262
|
for (const includedDate of repeat_rule.included_date) {
|
|
359
|
-
const includeStartDate = (0,
|
|
360
|
-
const includeEndDate = (0,
|
|
361
|
-
if (targetDate.isSameOrAfter(includeStartDate,
|
|
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")) {
|
|
362
266
|
return true;
|
|
363
267
|
}
|
|
364
268
|
}
|
|
365
269
|
}
|
|
366
|
-
|
|
367
|
-
// 检查是否在排除日期中
|
|
368
270
|
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
369
271
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
370
|
-
const excludeStartDate = (0,
|
|
371
|
-
const excludeEndDate = (0,
|
|
372
|
-
if (targetDate.isSameOrAfter(excludeStartDate,
|
|
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")) {
|
|
373
275
|
return false;
|
|
374
276
|
}
|
|
375
277
|
}
|
|
376
278
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
381
|
-
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
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")) {
|
|
382
282
|
return false;
|
|
383
283
|
}
|
|
384
284
|
}
|
|
385
|
-
|
|
386
|
-
// 检查是否在开始日期之前
|
|
387
|
-
if (targetDate.isBefore(scheduleStartDate, 'day')) {
|
|
285
|
+
if (targetDate.isBefore(scheduleStartDate, "day")) {
|
|
388
286
|
return false;
|
|
389
287
|
}
|
|
390
|
-
|
|
391
|
-
// 根据重复类型检查
|
|
392
288
|
switch (repeat_type) {
|
|
393
|
-
case
|
|
289
|
+
case "daily":
|
|
394
290
|
return isDateInDailyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
395
|
-
case
|
|
291
|
+
case "weekly":
|
|
396
292
|
return isDateInWeeklyRepeat(targetDate, scheduleStartDate, repeat_rule);
|
|
397
293
|
default:
|
|
398
294
|
return false;
|
|
399
295
|
}
|
|
400
296
|
};
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* 提取指定日期类型日程的时间段
|
|
404
|
-
*/
|
|
405
|
-
const extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
297
|
+
var extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
406
298
|
if (!schedule.designation) {
|
|
407
299
|
return [];
|
|
408
300
|
}
|
|
409
|
-
const targetDate = (0,
|
|
301
|
+
const targetDate = (0, import_dayjs.default)(date);
|
|
410
302
|
const designations = Array.isArray(schedule.designation) ? schedule.designation : [schedule.designation];
|
|
411
303
|
const slots = [];
|
|
412
304
|
for (const designation of designations) {
|
|
413
|
-
const startDate = (0,
|
|
414
|
-
const endDate = (0,
|
|
415
|
-
|
|
416
|
-
// 检查日期是否在指定范围内(考虑重复规则)
|
|
305
|
+
const startDate = (0, import_dayjs.default)(designation.start_date);
|
|
306
|
+
const endDate = (0, import_dayjs.default)(designation.end_date);
|
|
417
307
|
if (isDateInDesignationSchedule(targetDate, schedule, designation, startDate, endDate)) {
|
|
418
|
-
const startAt = (0,
|
|
419
|
-
const endAt = (0,
|
|
308
|
+
const startAt = (0, import_dayjs.default)(`${date} ${designation.start_time}:00`);
|
|
309
|
+
const endAt = (0, import_dayjs.default)(`${date} ${designation.end_time}:00`);
|
|
420
310
|
slots.push({
|
|
421
311
|
start_time: designation.start_time,
|
|
422
312
|
end_time: designation.end_time,
|
|
@@ -427,196 +317,125 @@ const extractDesignationScheduleTimeSlots = (date, schedule) => {
|
|
|
427
317
|
}
|
|
428
318
|
return slots;
|
|
429
319
|
};
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
*/
|
|
434
|
-
const isDateInDesignationSchedule = (targetDate, schedule, designation, startDate, endDate) => {
|
|
435
|
-
// 不重复的日程
|
|
436
|
-
if (schedule.repeat_type === 'none') {
|
|
437
|
-
// 检查日期是否在指定的日期范围内
|
|
438
|
-
return targetDate.isSameOrAfter(startDate, 'day') && targetDate.isSameOrBefore(endDate, 'day');
|
|
320
|
+
var isDateInDesignationSchedule = (targetDate, schedule, designation, startDate, endDate) => {
|
|
321
|
+
if (schedule.repeat_type === "none") {
|
|
322
|
+
return targetDate.isSameOrAfter(startDate, "day") && targetDate.isSameOrBefore(endDate, "day");
|
|
439
323
|
}
|
|
440
|
-
|
|
441
|
-
// 重复的日程,需要检查重复规则
|
|
442
324
|
if (!schedule.repeat_rule) {
|
|
443
325
|
return false;
|
|
444
326
|
}
|
|
445
|
-
const {
|
|
446
|
-
repeat_rule,
|
|
447
|
-
repeat_type
|
|
448
|
-
} = schedule;
|
|
449
|
-
|
|
450
|
-
// 检查是否在包含日期中(优先级最高)
|
|
327
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
451
328
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
452
329
|
for (const includedDate of repeat_rule.included_date) {
|
|
453
|
-
const includeStartDate = (0,
|
|
454
|
-
const includeEndDate = (0,
|
|
455
|
-
if (targetDate.isSameOrAfter(includeStartDate,
|
|
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")) {
|
|
456
333
|
return true;
|
|
457
334
|
}
|
|
458
335
|
}
|
|
459
336
|
}
|
|
460
|
-
|
|
461
|
-
// 检查是否在排除日期中
|
|
462
337
|
if (repeat_rule.excluded_date && repeat_rule.excluded_date.length > 0) {
|
|
463
338
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
464
|
-
const excludeStartDate = (0,
|
|
465
|
-
const excludeEndDate = (0,
|
|
466
|
-
if (targetDate.isSameOrAfter(excludeStartDate,
|
|
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")) {
|
|
467
342
|
return false;
|
|
468
343
|
}
|
|
469
344
|
}
|
|
470
345
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
475
|
-
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
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")) {
|
|
476
349
|
return false;
|
|
477
350
|
}
|
|
478
351
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if (!targetDate.isSameOrAfter(startDate, 'day') || !targetDate.isSameOrBefore(endDate, 'day')) {
|
|
482
|
-
// 对于重复日程,如果不在基本范围内,还需要检查是否符合重复规则
|
|
483
|
-
// 只要在 startDate 之后,并且符合重复规则即可
|
|
484
|
-
if (targetDate.isBefore(startDate, 'day')) {
|
|
352
|
+
if (!targetDate.isSameOrAfter(startDate, "day") || !targetDate.isSameOrBefore(endDate, "day")) {
|
|
353
|
+
if (targetDate.isBefore(startDate, "day")) {
|
|
485
354
|
return false;
|
|
486
355
|
}
|
|
487
356
|
}
|
|
488
|
-
|
|
489
|
-
// 根据重复类型检查
|
|
490
357
|
switch (repeat_type) {
|
|
491
|
-
case
|
|
358
|
+
case "daily":
|
|
492
359
|
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
493
|
-
case
|
|
360
|
+
case "weekly":
|
|
494
361
|
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
495
362
|
default:
|
|
496
363
|
return false;
|
|
497
364
|
}
|
|
498
365
|
};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
// 不重复的日程
|
|
507
|
-
if (schedule.repeat_type === 'none') {
|
|
508
|
-
// 检查日期是否在范围内
|
|
509
|
-
const scheduleStartDate = startDate.format('YYYY-MM-DD');
|
|
510
|
-
const scheduleEndDate = endDate.format('YYYY-MM-DD');
|
|
511
|
-
return targetDate.isSameOrAfter(scheduleStartDate, 'day') && targetDate.isSameOrBefore(scheduleEndDate, 'day');
|
|
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");
|
|
512
372
|
}
|
|
513
|
-
|
|
514
|
-
// 重复的日程,需要检查重复规则
|
|
515
373
|
if (!schedule.repeat_rule) {
|
|
516
374
|
return false;
|
|
517
375
|
}
|
|
518
|
-
const {
|
|
519
|
-
repeat_rule,
|
|
520
|
-
repeat_type
|
|
521
|
-
} = schedule;
|
|
522
|
-
|
|
523
|
-
// 检查是否在包含日期中
|
|
376
|
+
const { repeat_rule, repeat_type } = schedule;
|
|
524
377
|
if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
|
|
525
378
|
for (const includedDate of repeat_rule.included_date) {
|
|
526
|
-
const includeStartDate = (0,
|
|
527
|
-
const includeEndDate = (0,
|
|
528
|
-
if (targetDate.isSameOrAfter(includeStartDate,
|
|
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")) {
|
|
529
382
|
return true;
|
|
530
383
|
}
|
|
531
384
|
}
|
|
532
385
|
}
|
|
533
|
-
|
|
534
|
-
// 检查是否在排除日期中
|
|
535
386
|
for (const excludedDate of repeat_rule.excluded_date) {
|
|
536
|
-
const excludeStartDate = (0,
|
|
537
|
-
const excludeEndDate = (0,
|
|
538
|
-
if (targetDate.isSameOrAfter(excludeStartDate,
|
|
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")) {
|
|
539
390
|
return false;
|
|
540
391
|
}
|
|
541
392
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
const ruleEndDate = (0, _dayjs.default)(repeat_rule.end.end_date);
|
|
546
|
-
if (targetDate.isAfter(ruleEndDate, 'day')) {
|
|
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")) {
|
|
547
396
|
return false;
|
|
548
397
|
}
|
|
549
398
|
}
|
|
550
|
-
|
|
551
|
-
// 检查是否在开始日期之前
|
|
552
|
-
if (targetDate.isBefore(startDate, 'day')) {
|
|
399
|
+
if (targetDate.isBefore(startDate, "day")) {
|
|
553
400
|
return false;
|
|
554
401
|
}
|
|
555
|
-
|
|
556
|
-
// 根据重复类型检查
|
|
557
402
|
switch (repeat_type) {
|
|
558
|
-
case
|
|
403
|
+
case "daily":
|
|
559
404
|
return isDateInDailyRepeat(targetDate, startDate, repeat_rule);
|
|
560
|
-
case
|
|
405
|
+
case "weekly":
|
|
561
406
|
return isDateInWeeklyRepeat(targetDate, startDate, repeat_rule);
|
|
562
407
|
default:
|
|
563
408
|
return false;
|
|
564
409
|
}
|
|
565
410
|
};
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
* 检查日期是否符合每日重复规则
|
|
569
|
-
*/
|
|
570
|
-
const isDateInDailyRepeat = (targetDate, startDate, repeatRule) => {
|
|
571
|
-
const daysDiff = targetDate.diff(startDate, 'day');
|
|
411
|
+
var isDateInDailyRepeat = (targetDate, startDate, repeatRule) => {
|
|
412
|
+
const daysDiff = targetDate.diff(startDate, "day");
|
|
572
413
|
if (daysDiff < 0) {
|
|
573
414
|
return false;
|
|
574
415
|
}
|
|
575
|
-
|
|
576
|
-
// 检查频率
|
|
577
416
|
return daysDiff % repeatRule.frequency === 0;
|
|
578
417
|
};
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
* 检查日期是否符合每周重复规则
|
|
582
|
-
*/
|
|
583
|
-
const isDateInWeeklyRepeat = (targetDate, startDate, repeatRule) => {
|
|
584
|
-
const targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
|
|
585
|
-
|
|
586
|
-
// 检查是否在指定的星期几内
|
|
418
|
+
var isDateInWeeklyRepeat = (targetDate, startDate, repeatRule) => {
|
|
419
|
+
const targetDayOfWeek = targetDate.day();
|
|
587
420
|
if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
|
|
588
421
|
return false;
|
|
589
422
|
}
|
|
590
|
-
|
|
591
|
-
// 计算周差
|
|
592
|
-
const weeksDiff = targetDate.diff(startDate, 'week');
|
|
423
|
+
const weeksDiff = targetDate.diff(startDate, "week");
|
|
593
424
|
if (weeksDiff < 0) {
|
|
594
425
|
return false;
|
|
595
426
|
}
|
|
596
|
-
|
|
597
|
-
// 检查频率
|
|
598
427
|
return weeksDiff % repeatRule.frequency === 0;
|
|
599
428
|
};
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* 对时间段去重并排序
|
|
603
|
-
* 只移除开始时间和结束时间完全相同的重复时间段
|
|
604
|
-
*/
|
|
605
|
-
const mergeAndSortTimeSlots = slots => {
|
|
429
|
+
var mergeAndSortTimeSlots = (slots) => {
|
|
606
430
|
if (slots.length === 0) {
|
|
607
431
|
return [];
|
|
608
432
|
}
|
|
609
|
-
|
|
610
|
-
// 按开始时间排序
|
|
611
433
|
const sorted = [...slots].sort((a, b) => {
|
|
612
434
|
return a.start_at.valueOf() - b.start_at.valueOf();
|
|
613
435
|
});
|
|
614
|
-
|
|
615
|
-
// 去重:移除开始和结束时间完全相同的时间段
|
|
616
436
|
const unique = [];
|
|
617
|
-
const seenKeys = new Set();
|
|
437
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
618
438
|
for (const slot of sorted) {
|
|
619
|
-
// 使用开始时间和结束时间作为唯一键
|
|
620
439
|
const key = `${slot.start_time}-${slot.end_time}`;
|
|
621
440
|
if (!seenKeys.has(key)) {
|
|
622
441
|
seenKeys.add(key);
|
|
@@ -624,4 +443,9 @@ const mergeAndSortTimeSlots = slots => {
|
|
|
624
443
|
}
|
|
625
444
|
}
|
|
626
445
|
return unique;
|
|
627
|
-
};
|
|
446
|
+
};
|
|
447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
448
|
+
0 && (module.exports = {
|
|
449
|
+
getDateIsInSchedule,
|
|
450
|
+
getScheduleStartEndTimePoints
|
|
451
|
+
});
|