@pisell/pisellos 2.3.73 → 2.3.75

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