@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.
Files changed (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,67 +1,84 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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/utils.ts
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ calcCalendarDataByDesignation: () => calcCalendarDataByDesignation,
33
+ calcCalendarDataBySchedule: () => calcCalendarDataBySchedule,
34
+ calcCalendarDataByScheduleResult: () => calcCalendarDataByScheduleResult,
35
+ calcCalendarDataBySchedules: () => calcCalendarDataBySchedules,
36
+ calcCalendarDataByStandard: () => calcCalendarDataByStandard,
37
+ calcCalendarDataByTimeSlots: () => calcCalendarDataByTimeSlots,
38
+ calcMinTimeMaxTimeBySchedules: () => calcMinTimeMaxTimeBySchedules,
39
+ calcScheduleDateRange: () => calcScheduleDateRange,
40
+ formatScheduleData: () => formatScheduleData,
41
+ formatScheduleResult: () => formatScheduleResult,
42
+ getAllSortedDateRanges: () => getAllSortedDateRanges,
43
+ getDaysByStartEnd: () => getDaysByStartEnd,
44
+ isAllDay: () => isAllDay
5
45
  });
6
- exports.formatScheduleResult = exports.formatScheduleData = exports.calcScheduleDateRange = exports.calcMinTimeMaxTimeBySchedules = exports.calcCalendarDataByTimeSlots = exports.calcCalendarDataByStandard = exports.calcCalendarDataBySchedules = exports.calcCalendarDataByScheduleResult = exports.calcCalendarDataBySchedule = exports.calcCalendarDataByDesignation = void 0;
7
- exports.getAllSortedDateRanges = getAllSortedDateRanges;
8
- exports.isAllDay = exports.getDaysByStartEnd = void 0;
9
- var _dayjs = _interopRequireDefault(require("dayjs"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- /**
12
- * 根据日程配置生成日历数据
13
- * @param values
14
- * @param others
15
- * @param type
16
- */
17
- const calcCalendarDataBySchedule = (values, others, type) => {
18
- if (type === 'time-slots') {
46
+ module.exports = __toCommonJS(utils_exports);
47
+ var import_dayjs = __toESM(require("dayjs"));
48
+ var calcCalendarDataBySchedule = (values, others, type) => {
49
+ if (type === "time-slots") {
19
50
  return calcCalendarDataByTimeSlots(values, others);
20
51
  }
21
- if (type === 'designation') {
52
+ if (type === "designation") {
22
53
  return calcCalendarDataByDesignation(values, others);
23
54
  }
24
55
  return calcCalendarDataByStandard(values, others);
25
56
  };
26
-
27
- /**
28
- * 获取开始时间和结束时间之间的所有日期
29
- * @param startDate
30
- * @param endDate
31
- */
32
- exports.calcCalendarDataBySchedule = calcCalendarDataBySchedule;
33
- const getDaysByStartEnd = (startDate, endDate) => {
34
- let start = (0, _dayjs.default)(startDate);
35
- const end = (0, _dayjs.default)(endDate);
57
+ var getDaysByStartEnd = (startDate, endDate) => {
58
+ let start = (0, import_dayjs.default)(startDate);
59
+ const end = (0, import_dayjs.default)(endDate);
36
60
  const daysArray = [];
37
- while (start.isBefore(end, 'day') || start.isSame(end, 'day')) {
38
- daysArray.push(start.format('YYYY-MM-DD'));
39
- start = start.add(1, 'day');
61
+ while (start.isBefore(end, "day") || start.isSame(end, "day")) {
62
+ daysArray.push(start.format("YYYY-MM-DD"));
63
+ start = start.add(1, "day");
40
64
  }
41
65
  return daysArray;
42
66
  };
43
-
44
- /**
45
- * 合并日期和时间
46
- * @param date
47
- * @param time
48
- */
49
- exports.getDaysByStartEnd = getDaysByStartEnd;
50
- const mergeDateTime = (date, time) => {
51
- const dateStr = `${(0, _dayjs.default)(date).format('YYYY-MM-DD')}${time ? (0, _dayjs.default)(time).format(' HH:MM') : ''}`;
52
- return (0, _dayjs.default)(dateStr);
67
+ var mergeDateTime = (date, time) => {
68
+ const dateStr = `${(0, import_dayjs.default)(date).format("YYYY-MM-DD")}${time ? (0, import_dayjs.default)(time).format(" HH:MM") : ""}`;
69
+ return (0, import_dayjs.default)(dateStr);
53
70
  };
54
- const getDataRange = ({
71
+ var getDataRange = ({
55
72
  start,
56
73
  end,
57
74
  type,
58
75
  time_slot
59
76
  }) => {
60
- if (type === 'time-slots') {
77
+ if (type === "time-slots") {
61
78
  let dateRange = [];
62
79
  const dateStr = getDaysByStartEnd(start, end);
63
- dateStr.forEach(str => {
64
- time_slot?.forEach(time => {
80
+ dateStr.forEach((str) => {
81
+ time_slot == null ? void 0 : time_slot.forEach((time) => {
65
82
  dateRange.push({
66
83
  start: `${str} ${time.start_time}`,
67
84
  end: `${str} ${time.end_time}`
@@ -70,35 +87,24 @@ const getDataRange = ({
70
87
  });
71
88
  return dateRange;
72
89
  }
73
- return [{
74
- start: start.format('YYYY-MM-DD HH:mm:ss'),
75
- end: end.format('YYYY-MM-DD HH:mm:ss')
76
- }];
90
+ return [
91
+ {
92
+ start: start.format("YYYY-MM-DD HH:mm:ss"),
93
+ end: end.format("YYYY-MM-DD HH:mm:ss")
94
+ }
95
+ ];
77
96
  };
78
-
79
- /**
80
- * 按天重复配置获取日期
81
- * @param params
82
- */
83
- const getDaysByRepeatDay = (params, isGetRange) => {
84
- const {
85
- start,
86
- end,
87
- deadline,
88
- frequency,
89
- type,
90
- time_slot,
91
- excludedDays
92
- } = params;
93
- const scheduleDiff = end.diff(start, 'second');
94
- const excludedDaysMap = new Map(excludedDays.map(day => [day, true]));
97
+ var getDaysByRepeatDay = (params, isGetRange) => {
98
+ const { start, end, deadline, frequency, type, time_slot, excludedDays } = params;
99
+ const scheduleDiff = end.diff(start, "second");
100
+ const excludedDaysMap = new Map(excludedDays.map((day) => [day, true]));
95
101
  let startTmp = getMaxStart(start);
96
102
  const daysArr = [];
97
- while (startTmp.isBefore(deadline, 'day') || startTmp.isSame(deadline, 'day')) {
98
- const e = startTmp.add(scheduleDiff, 'second');
103
+ while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
104
+ const e = startTmp.add(scheduleDiff, "second");
99
105
  if (isGetRange) {
100
- if (excludedDaysMap.has(startTmp.format('YYYY-MM-DD'))) {
101
- startTmp = startTmp.add(frequency, 'day');
106
+ if (excludedDaysMap.has(startTmp.format("YYYY-MM-DD"))) {
107
+ startTmp = startTmp.add(frequency, "day");
102
108
  continue;
103
109
  }
104
110
  const arr = getDataRange({
@@ -111,16 +117,11 @@ const getDaysByRepeatDay = (params, isGetRange) => {
111
117
  } else {
112
118
  daysArr.push(...getDaysByStartEnd(startTmp, e));
113
119
  }
114
- startTmp = startTmp.add(frequency, 'day');
120
+ startTmp = startTmp.add(frequency, "day");
115
121
  }
116
122
  return Array.from(new Set(daysArr));
117
123
  };
118
-
119
- /**
120
- * 按周重复配置获取日期
121
- * @param params
122
- */
123
- const getDaysByRepeatWeek = (params, isGetRange) => {
124
+ var getDaysByRepeatWeek = (params, isGetRange) => {
124
125
  const {
125
126
  start,
126
127
  end,
@@ -131,28 +132,24 @@ const getDaysByRepeatWeek = (params, isGetRange) => {
131
132
  time_slot,
132
133
  excludedDays
133
134
  } = params;
134
- const scheduleDiff = end.diff(start, 'second');
135
- const excludedDaysMap = new Map(excludedDays.map(day => [day, true]));
135
+ const scheduleDiff = end.diff(start, "second");
136
+ const excludedDaysMap = new Map(excludedDays.map((day) => [day, true]));
136
137
  let startTmp = getMaxStart(start);
137
138
  const daysArr = [];
138
- while (startTmp.isBefore(deadline, 'day') || startTmp.isSame(deadline, 'day')) {
139
+ while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
139
140
  for (let i = 0; i < frequency_date.length; i++) {
140
141
  const item = frequency_date[i];
141
142
  let _start = startTmp.day(item);
142
-
143
- // 如果计算出的日期早于startTmp,则跳到下一周的相同星期几
144
- if (_start.isBefore(startTmp, 'day')) {
145
- _start = _start.add(1, 'week');
143
+ if (_start.isBefore(startTmp, "day")) {
144
+ _start = _start.add(1, "week");
146
145
  }
147
-
148
- // 如果周结束的那一天还超过了deadline,则需要把_end置为deadline
149
- let _end = _start.add(scheduleDiff, 'second');
150
- if (_end.isAfter(deadline, 'day')) {
146
+ let _end = _start.add(scheduleDiff, "second");
147
+ if (_end.isAfter(deadline, "day")) {
151
148
  _end = deadline;
152
149
  }
153
150
  if (isGetRange) {
154
- if (excludedDaysMap.has(_start.format('YYYY-MM-DD'))) {
155
- startTmp = startTmp.day(1).add(frequency, 'day');
151
+ if (excludedDaysMap.has(_start.format("YYYY-MM-DD"))) {
152
+ startTmp = startTmp.day(1).add(frequency, "day");
156
153
  continue;
157
154
  }
158
155
  const arr = getDataRange({
@@ -166,71 +163,32 @@ const getDaysByRepeatWeek = (params, isGetRange) => {
166
163
  daysArr.push(...getDaysByStartEnd(_start, _end));
167
164
  }
168
165
  }
169
- startTmp = startTmp.add(frequency, 'week');
166
+ startTmp = startTmp.add(frequency, "week");
170
167
  }
171
168
  return Array.from(new Set(daysArr));
172
169
  };
173
-
174
- /**
175
- * 日期和排除日期格式化日历所需数据格式
176
- * @param days
177
- * @param color
178
- * @param excludedDays
179
- */
180
- const formatDayColor = ({
170
+ var formatDayColor = ({
181
171
  days,
182
172
  color,
183
173
  excludedDays
184
174
  }) => {
185
175
  const excludedDaysSet = new Set(excludedDays);
186
- return days.map(item => ({
176
+ return days.map((item) => ({
187
177
  date: item,
188
178
  color: [color],
189
179
  isExcluded: excludedDaysSet.has(item)
190
180
  }));
191
181
  };
192
-
193
- /**
194
- * 获取开始结束时间数组的所有日期
195
- * @param arr
196
- */
197
- const getDaysByStartEndArr = (arr = []) => {
182
+ var getDaysByStartEndArr = (arr = []) => {
198
183
  const daysArr = [];
199
- arr.forEach(item => {
184
+ arr.forEach((item) => {
200
185
  if (item && item.start && item.end) {
201
186
  daysArr.push(...getDaysByStartEnd(item.start, item.end));
202
187
  }
203
188
  });
204
189
  return Array.from(new Set(daysArr));
205
190
  };
206
-
207
- /**
208
- * 过滤排除日期
209
- * @param daysArr
210
- * @param excludedArr
211
- */
212
- const filterExcludedDays = (daysArr, excludedArr) => {
213
- const excludeSet = new Set(excludedArr);
214
- if (!excludedArr.length) return daysArr;
215
- return daysArr.filter(item => !excludeSet.has(item));
216
- };
217
-
218
- /**
219
- * 处理日期重复逻辑
220
- * @param repeat_type
221
- * @param start
222
- * @param end
223
- * @param color
224
- * @param endRadio
225
- * @param end_date
226
- * @param excluded_date
227
- * @param included_date
228
- * @param frequency
229
- * @param excludedStatus
230
- * @param includeStatus
231
- * @param frequency_date
232
- */
233
- const processDateRange = ({
191
+ var processDateRange = ({
234
192
  repeat_type,
235
193
  start,
236
194
  end,
@@ -246,83 +204,77 @@ const processDateRange = ({
246
204
  type,
247
205
  time_slot
248
206
  }, isGetRange) => {
249
- /** 时间范围或天 */
250
207
  let days = [];
251
208
  const excludedDays = getDaysByStartEndArr(excluded_date);
252
209
  const includedDays = getDaysByStartEndArr(included_date);
253
-
254
- // 不重复
255
- if (repeat_type === '0') {
210
+ if (repeat_type === "0") {
256
211
  if (isGetRange) {
257
- if (type === 'time-slots') {
258
- days = time_slot?.map(item => ({
212
+ if (type === "time-slots") {
213
+ days = (time_slot == null ? void 0 : time_slot.map((item) => ({
259
214
  start: start.format(`YYYY-MM-DD ${item.start_time}`),
260
215
  end: end.format(`YYYY-MM-DD ${item.end_time}`)
261
- })) || [];
216
+ }))) || [];
262
217
  } else {
263
- days = [{
264
- start: start.format('YYYY-MM-DD HH:mm:ss'),
265
- end: end.format('YYYY-MM-DD HH:mm:ss')
266
- }];
218
+ days = [
219
+ {
220
+ start: start.format("YYYY-MM-DD HH:mm:ss"),
221
+ end: end.format("YYYY-MM-DD HH:mm:ss")
222
+ }
223
+ ];
267
224
  }
268
225
  } else {
269
226
  days = getDaysByStartEnd(start, end);
270
227
  }
271
228
  } else {
272
- let endDate = (0, _dayjs.default)(end_date);
273
-
274
- // 截止时间 如果永不截止取18个月截止
229
+ let endDate = (0, import_dayjs.default)(end_date);
275
230
  if (endRadio === 1) {
276
- endDate = isGetRange ? (0, _dayjs.default)().add(12, 'month') : (0, _dayjs.default)().add(18, 'month');
231
+ endDate = isGetRange ? (0, import_dayjs.default)().add(12, "month") : (0, import_dayjs.default)().add(18, "month");
277
232
  }
278
-
279
- // 按天重复
280
- if (repeat_type === '1') {
281
- days = getDaysByRepeatDay({
282
- start,
283
- end,
284
- deadline: endDate,
285
- frequency,
286
- type,
287
- time_slot,
288
- excludedDays
289
- }, isGetRange);
290
- // 按周重复
291
- } else if (repeat_type === '2') {
292
- days = getDaysByRepeatWeek({
293
- start,
294
- end,
295
- deadline: endDate,
296
- frequency,
297
- frequency_date,
298
- type,
299
- time_slot,
300
- excludedDays
301
- }, isGetRange);
233
+ if (repeat_type === "1") {
234
+ days = getDaysByRepeatDay(
235
+ {
236
+ start,
237
+ end,
238
+ deadline: endDate,
239
+ frequency,
240
+ type,
241
+ time_slot,
242
+ excludedDays
243
+ },
244
+ isGetRange
245
+ );
246
+ } else if (repeat_type === "2") {
247
+ days = getDaysByRepeatWeek(
248
+ {
249
+ start,
250
+ end,
251
+ deadline: endDate,
252
+ frequency,
253
+ frequency_date,
254
+ type,
255
+ time_slot,
256
+ excludedDays
257
+ },
258
+ isGetRange
259
+ );
302
260
  }
303
261
  }
304
262
  if (isGetRange) {
305
- // 如果有包含的天再把包含的天的时间段插入
306
263
  if (includedDays.length) {
307
264
  for (let i = 0; i < includedDays.length; i++) {
308
265
  const includedDay = includedDays[i];
309
- days.push(...getDataRange({
310
- start: (0, _dayjs.default)(includedDay),
311
- end: (0, _dayjs.default)(includedDay),
312
- type: type,
313
- time_slot: time_slot
314
- }));
266
+ days.push(
267
+ ...getDataRange({
268
+ start: (0, import_dayjs.default)(includedDay),
269
+ end: (0, import_dayjs.default)(includedDay),
270
+ type,
271
+ time_slot
272
+ })
273
+ );
315
274
  }
316
275
  }
317
276
  return days;
318
277
  }
319
-
320
- // 开启了排除日期
321
- // if (excludedStatus) {
322
- // days = filterExcludedDays(days, excludedDays);
323
- // }
324
-
325
- // 开启了包含日期
326
278
  if (includeStatus) {
327
279
  days = days.concat(includedDays);
328
280
  }
@@ -332,13 +284,7 @@ const processDateRange = ({
332
284
  excludedDays: excludedStatus ? excludedDays : []
333
285
  });
334
286
  };
335
-
336
- /**
337
- * 根据标准日程计算日历数据
338
- * @param values
339
- * @param others
340
- */
341
- const calcCalendarDataByStandard = (values, others, isGetRange) => {
287
+ var calcCalendarDataByStandard = (values, others, isGetRange) => {
342
288
  const {
343
289
  color,
344
290
  excluded_date,
@@ -352,99 +298,42 @@ const calcCalendarDataByStandard = (values, others, isGetRange) => {
352
298
  start_time,
353
299
  end_time
354
300
  } = values;
355
- const {
356
- endRadio,
357
- isAllDay,
358
- includeStatus,
359
- excludedStatus
360
- } = others;
301
+ const { endRadio, isAllDay: isAllDay2, includeStatus, excludedStatus } = others;
361
302
  if (Array.isArray(designation)) {
362
303
  return [];
363
304
  }
364
-
365
- // 日程开始时间
366
- const start = designation ? mergeDateTime(designation.start_date, isAllDay ? designation.start_time : '') : (0, _dayjs.default)(start_time);
367
-
368
- // 日程结束时间
369
- const end = designation ? mergeDateTime(designation.end_date, isAllDay ? designation.end_time : '') : (0, _dayjs.default)(end_time);
370
-
371
- // // 不重复
372
- // if (repeat_type === "0") {
373
- // return formatDayColor(getDaysByStartEnd(start, end), color);
374
- // }
375
- // // 截止时间 如果永不截止取15个月截止
376
- // const endDate = endRadio === 2 ? dayjs(end_date) : dayjs().add(15, "month");
377
- //
378
- // const excludedDays = getDaysByStartEndArr(excluded_date);
379
- //
380
- // const includedDays = getDaysByStartEndArr(included_date);
381
- //
382
- // // 按天重复
383
- // if (repeat_type === "1") {
384
- // let days = getDaysByRepeatDay({
385
- // start,
386
- // end,
387
- // deadline: endDate,
388
- // frequency,
389
- // });
390
- //
391
- // // 开启了排除日期
392
- // if (excludedStatus) {
393
- // days = filterExcludedDays(days, excludedDays);
394
- // }
395
- //
396
- // // 开启了包含日期
397
- // if (includeStatus) {
398
- // days = days.concat(includedDays);
399
- // }
400
- //
401
- // return formatDayColor(days, color);
402
- // }
403
- //
404
- // // 按周重复
405
- // if (repeat_type === "2") {
406
- // let days = getDaysByRepeatWeek({
407
- // start,
408
- // end,
409
- // deadline: endDate,
410
- // frequency,
411
- // frequency_date,
412
- // });
413
- // }
414
- //
415
- // return [];
416
-
417
- return processDateRange({
418
- repeat_type,
419
- start,
420
- end,
421
- color,
422
- endRadio,
423
- end_date,
424
- excluded_date,
425
- excludedStatus,
426
- frequency,
427
- frequency_date,
428
- included_date,
429
- includeStatus,
430
- time_slot,
431
- type: 'standard'
432
- }, isGetRange);
305
+ const start = designation ? mergeDateTime(
306
+ designation.start_date,
307
+ isAllDay2 ? designation.start_time : ""
308
+ ) : (0, import_dayjs.default)(start_time);
309
+ const end = designation ? mergeDateTime(designation.end_date, isAllDay2 ? designation.end_time : "") : (0, import_dayjs.default)(end_time);
310
+ return processDateRange(
311
+ {
312
+ repeat_type,
313
+ start,
314
+ end,
315
+ color,
316
+ endRadio,
317
+ end_date,
318
+ excluded_date,
319
+ excludedStatus,
320
+ frequency,
321
+ frequency_date,
322
+ included_date,
323
+ includeStatus,
324
+ time_slot,
325
+ type: "standard"
326
+ },
327
+ isGetRange
328
+ );
433
329
  };
434
- exports.calcCalendarDataByStandard = calcCalendarDataByStandard;
435
- const getMaxStart = start_time => {
436
- const valueStart = (0, _dayjs.default)(start_time);
437
- const currentYearStart = (0, _dayjs.default)().startOf('year').set('hour', valueStart.get('hour')).set('minute', valueStart.get('minutes')).set('second', valueStart.get('second'));
330
+ var getMaxStart = (start_time) => {
331
+ const valueStart = (0, import_dayjs.default)(start_time);
332
+ const currentYearStart = (0, import_dayjs.default)().startOf("year").set("hour", valueStart.get("hour")).set("minute", valueStart.get("minutes")).set("second", valueStart.get("second"));
438
333
  const start = valueStart.isBefore(currentYearStart) ? currentYearStart : valueStart;
439
334
  return start;
440
335
  };
441
-
442
- /**
443
- * 根据多时间段计算日历数据
444
- * @param values
445
- * @param others
446
- */
447
- const calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
336
+ var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
448
337
  const {
449
338
  color,
450
339
  excluded_date,
@@ -456,50 +345,37 @@ const calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
456
345
  start_time,
457
346
  time_slot
458
347
  } = values;
459
- const {
460
- endRadio,
461
- excludedStatus,
462
- includeStatus
463
- } = others;
464
- if (!start_time) return [];
465
- const start = (0, _dayjs.default)(start_time);
466
- const end = (0, _dayjs.default)(start_time);
467
- return processDateRange({
468
- repeat_type,
469
- start,
470
- end,
471
- color,
472
- endRadio,
473
- end_date,
474
- excluded_date,
475
- excludedStatus,
476
- frequency,
477
- frequency_date,
478
- included_date,
479
- includeStatus,
480
- time_slot,
481
- type: 'time-slots'
482
- }, isGetRange);
348
+ const { endRadio, excludedStatus, includeStatus } = others;
349
+ if (!start_time)
350
+ return [];
351
+ const start = (0, import_dayjs.default)(start_time);
352
+ const end = (0, import_dayjs.default)(start_time);
353
+ return processDateRange(
354
+ {
355
+ repeat_type,
356
+ start,
357
+ end,
358
+ color,
359
+ endRadio,
360
+ end_date,
361
+ excluded_date,
362
+ excludedStatus,
363
+ frequency,
364
+ frequency_date,
365
+ included_date,
366
+ includeStatus,
367
+ time_slot,
368
+ type: "time-slots"
369
+ },
370
+ isGetRange
371
+ );
483
372
  };
484
-
485
- /**
486
- * 根据指定日期计算日历数据
487
- * @param values
488
- * @param others
489
- */
490
- exports.calcCalendarDataByTimeSlots = calcCalendarDataByTimeSlots;
491
- const calcCalendarDataByDesignation = (values, others, isGetRange) => {
492
- const {
493
- designation,
494
- color
495
- } = values;
373
+ var calcCalendarDataByDesignation = (values, others, isGetRange) => {
374
+ const { designation, color } = values;
496
375
  const days = [];
497
376
  if (Array.isArray(designation)) {
498
- designation.forEach(item => {
499
- // 日程开始时间
377
+ designation.forEach((item) => {
500
378
  const start = mergeDateTime(item.start_date, item.start_time);
501
-
502
- // 日程结束时间
503
379
  const end = mergeDateTime(item.end_date, item.end_time);
504
380
  if (isGetRange) {
505
381
  days.push({
@@ -520,39 +396,27 @@ const calcCalendarDataByDesignation = (values, others, isGetRange) => {
520
396
  excludedDays: []
521
397
  });
522
398
  };
523
- exports.calcCalendarDataByDesignation = calcCalendarDataByDesignation;
524
- const isAllDay = value => {
525
- return (0, _dayjs.default)(value.start_time).format('HH:mm:ss') === '00:00:00' && (0, _dayjs.default)(value.end_time).format('HH:mm:ss') === '23:59:59';
399
+ var isAllDay = (value) => {
400
+ return (0, import_dayjs.default)(value.start_time).format("HH:mm:ss") === "00:00:00" && (0, import_dayjs.default)(value.end_time).format("HH:mm:ss") === "23:59:59";
526
401
  };
527
- exports.isAllDay = isAllDay;
528
- const repeatTypeMap = {
529
- none: '0',
530
- daily: '1',
531
- weekly: '2'
402
+ var repeatTypeMap = {
403
+ none: "0",
404
+ daily: "1",
405
+ weekly: "2"
532
406
  };
533
- const endTypeMap = {
407
+ var endTypeMap = {
534
408
  never: 1,
535
409
  date: 2
536
410
  };
537
-
538
- /**
539
- * 根据接口返回的Schedule计算日历数据
540
- * @param schedule
541
- */
542
- const calcCalendarDataByScheduleResult = schedule => {
543
- const {
411
+ var calcCalendarDataByScheduleResult = (schedule) => {
412
+ const { scheduleFormData, scheduleFormOtherValue } = formatScheduleResult(schedule);
413
+ return calcCalendarDataBySchedule(
544
414
  scheduleFormData,
545
- scheduleFormOtherValue
546
- } = formatScheduleResult(schedule);
547
- return calcCalendarDataBySchedule(scheduleFormData, scheduleFormOtherValue, schedule.type);
415
+ scheduleFormOtherValue,
416
+ schedule.type
417
+ );
548
418
  };
549
-
550
- /**
551
- * 接口返回schedule转换格式
552
- * @param schedule
553
- */
554
- exports.calcCalendarDataByScheduleResult = calcCalendarDataByScheduleResult;
555
- const formatScheduleResult = schedule => {
419
+ var formatScheduleResult = (schedule) => {
556
420
  const {
557
421
  color,
558
422
  name,
@@ -565,13 +429,7 @@ const formatScheduleResult = schedule => {
565
429
  type,
566
430
  time_slot
567
431
  } = schedule;
568
- const {
569
- frequency,
570
- end,
571
- frequency_date,
572
- included_date,
573
- excluded_date
574
- } = repeat_rule || {};
432
+ const { frequency, end, frequency_date, included_date, excluded_date } = repeat_rule || {};
575
433
  return {
576
434
  scheduleFormData: {
577
435
  color,
@@ -585,62 +443,69 @@ const formatScheduleResult = schedule => {
585
443
  excluded_date,
586
444
  included_date,
587
445
  time_slot,
588
- end_date: end?.end_date
446
+ end_date: end == null ? void 0 : end.end_date
589
447
  },
590
448
  scheduleFormOtherValue: {
591
- endRadio: endTypeMap[end?.type || 'never'],
449
+ endRadio: endTypeMap[(end == null ? void 0 : end.type) || "never"],
592
450
  isAllDay: !!is_all,
593
451
  type,
594
- excludedStatus: !!excluded_date?.length,
595
- includeStatus: !!included_date?.length
452
+ excludedStatus: !!(excluded_date == null ? void 0 : excluded_date.length),
453
+ includeStatus: !!(included_date == null ? void 0 : included_date.length)
596
454
  }
597
455
  };
598
456
  };
599
- exports.formatScheduleResult = formatScheduleResult;
600
- const calcScheduleDateRange = schedule => {
601
- const {
602
- scheduleFormData,
603
- scheduleFormOtherValue
604
- } = formatScheduleResult(schedule);
605
- if (schedule.type === 'time-slots') {
606
- return calcCalendarDataByTimeSlots(scheduleFormData, scheduleFormOtherValue, true);
457
+ var calcScheduleDateRange = (schedule) => {
458
+ const { scheduleFormData, scheduleFormOtherValue } = formatScheduleResult(schedule);
459
+ if (schedule.type === "time-slots") {
460
+ return calcCalendarDataByTimeSlots(
461
+ scheduleFormData,
462
+ scheduleFormOtherValue,
463
+ true
464
+ );
607
465
  }
608
- if (schedule.type === 'designation') {
609
- return calcCalendarDataByDesignation(scheduleFormData, scheduleFormOtherValue, true);
466
+ if (schedule.type === "designation") {
467
+ return calcCalendarDataByDesignation(
468
+ scheduleFormData,
469
+ scheduleFormOtherValue,
470
+ true
471
+ );
610
472
  }
611
- return calcCalendarDataByStandard(scheduleFormData, scheduleFormOtherValue, true);
473
+ return calcCalendarDataByStandard(
474
+ scheduleFormData,
475
+ scheduleFormOtherValue,
476
+ true
477
+ );
612
478
  };
613
- exports.calcScheduleDateRange = calcScheduleDateRange;
614
- const calcCalendarDataBySchedules = schedules => {
479
+ var calcCalendarDataBySchedules = (schedules) => {
615
480
  const allSchedules = [];
616
- schedules.forEach(item => {
481
+ schedules.forEach((item) => {
617
482
  allSchedules.push(...calcCalendarDataByScheduleResult(item));
618
483
  });
619
484
  const dateMap = allSchedules.reduce((pre, cur) => {
485
+ var _a, _b;
620
486
  return {
621
487
  ...pre,
622
488
  [cur.date]: {
623
489
  ...cur,
624
- color: [...(pre[cur.date]?.color || []), ...cur.color],
625
- isExcluded: pre[cur.date]?.isExcluded || cur.isExcluded
490
+ color: [...((_a = pre[cur.date]) == null ? void 0 : _a.color) || [], ...cur.color],
491
+ isExcluded: ((_b = pre[cur.date]) == null ? void 0 : _b.isExcluded) || cur.isExcluded
626
492
  }
627
493
  };
628
494
  }, {});
629
495
  return Object.values(dateMap);
630
496
  };
631
- exports.calcCalendarDataBySchedules = calcCalendarDataBySchedules;
632
- const calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
497
+ var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
633
498
  return schedules.reduce((pre, cur) => {
634
- let dateRange = scheduleAllMap?.[cur.id]?.dateRange || calcScheduleDateRange(cur);
499
+ var _a;
500
+ let dateRange = ((_a = scheduleAllMap == null ? void 0 : scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
635
501
  let dateRangeFormat = [];
636
502
  if (selectDate) {
637
503
  const dateRangeTmp = [];
638
504
  const dateRangeFormatTmp = [];
639
505
  for (let i = 0; i < dateRange.length; i++) {
640
506
  const range = dateRange[i];
641
- const start = (0, _dayjs.default)(range.start);
642
- const end = (0, _dayjs.default)(range.end);
643
- // includes 比 dayjs isSame方法会快一些
507
+ const start = (0, import_dayjs.default)(range.start);
508
+ const end = (0, import_dayjs.default)(range.end);
644
509
  const isSameStart = range.start.includes(selectDate);
645
510
  const isSameEnd = range.end.includes(selectDate);
646
511
  if (isSameStart || isSameEnd) {
@@ -648,11 +513,11 @@ const calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) =>
648
513
  if (isSameStart && !isSameEnd) {
649
514
  dateRangeFormatTmp.push({
650
515
  start: range.start,
651
- end: end.format('YYYY-MM-DD 23:59:59')
516
+ end: end.format("YYYY-MM-DD 23:59:59")
652
517
  });
653
518
  } else if (!isSameStart && isSameEnd) {
654
519
  dateRangeFormatTmp.push({
655
- start: start.format('YYYY-MM-DD 00:00:00'),
520
+ start: start.format("YYYY-MM-DD 00:00:00"),
656
521
  end: range.end
657
522
  });
658
523
  } else {
@@ -666,89 +531,82 @@ const calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) =>
666
531
  let minTime = null;
667
532
  let maxTime = null;
668
533
  if (dateRange.length) {
669
- // ({ minTime, maxTime } = getMinTimeRange(dateRange));
670
- minTime = (0, _dayjs.default)(dateRange[0].start);
671
- maxTime = (0, _dayjs.default)(dateRange[dateRange.length - 1].end);
534
+ minTime = (0, import_dayjs.default)(dateRange[0].start);
535
+ maxTime = (0, import_dayjs.default)(dateRange[dateRange.length - 1].end);
672
536
  }
673
537
  return {
674
538
  ...pre,
675
539
  [cur.id]: {
676
540
  minTime,
677
541
  maxTime,
678
- minTimeStr: minTime?.format('YYYY-MM-DD HH:mm:ss') || null,
679
- maxTimeStr: maxTime?.format('YYYY-MM-DD HH:mm:ss') || null,
542
+ minTimeStr: (minTime == null ? void 0 : minTime.format("YYYY-MM-DD HH:mm:ss")) || null,
543
+ maxTimeStr: (maxTime == null ? void 0 : maxTime.format("YYYY-MM-DD HH:mm:ss")) || null,
680
544
  dateRange,
681
545
  dateRangeFormat
682
546
  }
683
547
  };
684
548
  }, {});
685
549
  };
686
-
687
- /**
688
- * @title: 格式化日程数据
689
- * @description:
690
- * @param {Array} relation 资源列表
691
- * @param {string} table_type 关联表类型
692
- * @param {string} item_type 资源类型
693
- * @param {boolean} isExcluded 是否排除
694
- * @return {*}
695
- * @Author: WangHan
696
- * @Date: 2024-09-04 11:54
697
- */
698
- exports.calcMinTimeMaxTimeBySchedules = calcMinTimeMaxTimeBySchedules;
699
- const formatScheduleData = (relation, table_type, item_type, isExcluded) => {
550
+ var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
700
551
  const _relation = relation || [];
701
- // 有关联表类型和资源类型并且排除
702
552
  if (table_type && item_type && isExcluded) {
703
- return _relation.find(item => item?.relation_table_type === table_type && item?.item_type !== item_type);
553
+ return _relation.find(
554
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) !== item_type
555
+ );
704
556
  }
705
-
706
- // 有关联表类型和资源类型
707
557
  if (table_type && item_type) {
708
- return _relation.find(item => item?.relation_table_type === table_type && item?.item_type === item_type);
558
+ return _relation.find(
559
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) === item_type
560
+ );
709
561
  }
710
-
711
- // 有关联表类型
712
562
  if (table_type) {
713
- return _relation.some(item => item?.relation_table_type === table_type);
563
+ return _relation.some(
564
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type
565
+ );
714
566
  }
715
-
716
- // 有关联资源类型
717
567
  if (item_type) {
718
- return _relation.find(item => item?.item_type === item_type);
568
+ return _relation.find((item) => (item == null ? void 0 : item.item_type) === item_type);
719
569
  }
720
570
  };
721
- exports.formatScheduleData = formatScheduleData;
722
571
  function getAllSortedDateRanges(schedules) {
723
- // 收集所有 dateRange
724
572
  const allDateRanges = [];
725
-
726
- // 遍历所有对象,收集 dateRange
727
- Object.values(schedules).forEach(schedule => {
573
+ Object.values(schedules).forEach((schedule) => {
728
574
  if (schedule.dateRange && Array.isArray(schedule.dateRange)) {
729
575
  allDateRanges.push(...schedule.dateRange);
730
576
  }
731
577
  });
732
-
733
- // 如果没有找到任何 dateRange,返回空数组
734
578
  if (allDateRanges.length === 0) {
579
+ console.log("No dateRanges found in schedules:", schedules);
735
580
  return [];
736
581
  }
737
-
738
- // 按照开始时间和时长排序
739
582
  let sortedDateRanges = allDateRanges.sort((a, b) => {
740
- // 首先按开始时间排序
741
- const startTimeCompare = (0, _dayjs.default)(a.start).valueOf() - (0, _dayjs.default)(b.start).valueOf();
742
- if (startTimeCompare !== 0) return startTimeCompare;
743
-
744
- // 如果开始时间相同,按时长排序(结束时间 - 开始时间)
745
- const durationA = (0, _dayjs.default)(a.end).valueOf() - (0, _dayjs.default)(a.start).valueOf();
746
- const durationB = (0, _dayjs.default)(b.end).valueOf() - (0, _dayjs.default)(b.start).valueOf();
583
+ const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
584
+ if (startTimeCompare !== 0)
585
+ return startTimeCompare;
586
+ const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
587
+ const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
747
588
  return durationA - durationB;
748
589
  });
749
-
750
- // 排序完了,还需要做个去重,如果有开始时间结束时间完全一致的,则只保留一个
751
- // 需要使用 dayjs 的 isSame 方法来判断
752
- const uniqueDateRanges = sortedDateRanges.filter((range, index, self) => index === self.findIndex(t => (0, _dayjs.default)(t.start).isSame((0, _dayjs.default)(range.start)) && (0, _dayjs.default)(t.end).isSame((0, _dayjs.default)(range.end))));
590
+ const uniqueDateRanges = sortedDateRanges.filter(
591
+ (range, index, self) => index === self.findIndex(
592
+ (t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end))
593
+ )
594
+ );
753
595
  return uniqueDateRanges;
754
- }
596
+ }
597
+ // Annotate the CommonJS export names for ESM import in node:
598
+ 0 && (module.exports = {
599
+ calcCalendarDataByDesignation,
600
+ calcCalendarDataBySchedule,
601
+ calcCalendarDataByScheduleResult,
602
+ calcCalendarDataBySchedules,
603
+ calcCalendarDataByStandard,
604
+ calcCalendarDataByTimeSlots,
605
+ calcMinTimeMaxTimeBySchedules,
606
+ calcScheduleDateRange,
607
+ formatScheduleData,
608
+ formatScheduleResult,
609
+ getAllSortedDateRanges,
610
+ getDaysByStartEnd,
611
+ isAllDay
612
+ });