@pisell/pisellos 2.3.74 → 2.3.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +6 -10
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +75 -91
- package/dist/modules/Order/types.d.ts +3 -1
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Rules/index.js +1 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.js +97 -129
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.js +2 -4
- package/dist/server/modules/products/index.js +24 -42
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BaseSales/index.js +100 -72
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.js +0 -2
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +134 -134
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -0
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +122 -127
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +70 -76
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +1733 -2121
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.d.ts +3 -1
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils.js +814 -647
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +81 -118
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +589 -770
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.js +3050 -2665
- package/lib/server/modules/floor-plan/index.js +118 -134
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +142 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.js +784 -1002
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.js +583 -471
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +220 -186
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1220 -1412
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.js +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +328 -324
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,84 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 ===
|
|
21
|
+
if (type === 'designation') {
|
|
53
22
|
return calcCalendarDataByDesignation(values, others);
|
|
54
23
|
}
|
|
55
24
|
return calcCalendarDataByStandard(values, others);
|
|
56
25
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,
|
|
62
|
-
daysArray.push(start.format(
|
|
63
|
-
start = start.add(1,
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
54
|
+
const getDataRange = ({
|
|
72
55
|
start,
|
|
73
56
|
end,
|
|
74
57
|
type,
|
|
75
58
|
time_slot
|
|
76
59
|
}) => {
|
|
77
|
-
if (type ===
|
|
60
|
+
if (type === 'time-slots') {
|
|
78
61
|
let dateRange = [];
|
|
79
62
|
const dateStr = getDaysByStartEnd(start, end);
|
|
80
|
-
dateStr.forEach(
|
|
81
|
-
time_slot
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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,
|
|
104
|
-
const e = startTmp.add(scheduleDiff,
|
|
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(
|
|
107
|
-
startTmp = startTmp.add(frequency,
|
|
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,
|
|
114
|
+
startTmp = startTmp.add(frequency, 'day');
|
|
121
115
|
}
|
|
122
116
|
return Array.from(new Set(daysArr));
|
|
123
117
|
};
|
|
124
|
-
|
|
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,
|
|
136
|
-
const excludedDaysMap = new Map(excludedDays.map(
|
|
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,
|
|
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
|
-
|
|
144
|
-
|
|
142
|
+
|
|
143
|
+
// 如果计算出的日期早于startTmp,则跳到下一周的相同星期几
|
|
144
|
+
if (_start.isBefore(startTmp, 'day')) {
|
|
145
|
+
_start = _start.add(1, 'week');
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
|
|
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(
|
|
152
|
-
startTmp = startTmp.day(1).add(frequency,
|
|
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,
|
|
169
|
+
startTmp = startTmp.add(frequency, 'week');
|
|
167
170
|
}
|
|
168
171
|
return Array.from(new Set(daysArr));
|
|
169
172
|
};
|
|
170
|
-
|
|
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(
|
|
186
|
+
return days.map(item => ({
|
|
177
187
|
date: item,
|
|
178
188
|
color: [color],
|
|
179
189
|
isExcluded: excludedDaysSet.has(item)
|
|
180
190
|
}));
|
|
181
191
|
};
|
|
182
|
-
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 获取开始结束时间数组的所有日期
|
|
195
|
+
* @param arr
|
|
196
|
+
*/
|
|
197
|
+
const getDaysByStartEndArr = (arr = []) => {
|
|
183
198
|
const daysArr = [];
|
|
184
|
-
arr.forEach(
|
|
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
|
-
|
|
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
|
-
|
|
253
|
+
|
|
254
|
+
// 不重复
|
|
255
|
+
if (repeat_type === '0') {
|
|
211
256
|
if (isGetRange) {
|
|
212
|
-
if (type ===
|
|
213
|
-
days =
|
|
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
|
-
|
|
221
|
-
|
|
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,
|
|
272
|
+
let endDate = (0, _dayjs.default)(end_date);
|
|
273
|
+
|
|
274
|
+
// 截止时间 如果永不截止取18个月截止
|
|
230
275
|
if (endRadio === 1) {
|
|
231
|
-
endDate = isGetRange ? (0,
|
|
276
|
+
endDate = isGetRange ? (0, _dayjs.default)().add(12, 'month') : (0, _dayjs.default)().add(18, 'month');
|
|
232
277
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} else if (repeat_type ===
|
|
247
|
-
days = getDaysByRepeatWeek(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
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 {
|
|
355
|
+
const {
|
|
356
|
+
endRadio,
|
|
357
|
+
isAllDay,
|
|
358
|
+
includeStatus,
|
|
359
|
+
excludedStatus
|
|
360
|
+
} = others;
|
|
302
361
|
if (Array.isArray(designation)) {
|
|
303
362
|
return [];
|
|
304
363
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
const
|
|
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
|
-
|
|
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 {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
374
|
-
|
|
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(
|
|
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
|
-
|
|
400
|
-
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
527
|
+
exports.isAllDay = isAllDay;
|
|
528
|
+
const repeatTypeMap = {
|
|
529
|
+
none: '0',
|
|
530
|
+
daily: '1',
|
|
531
|
+
weekly: '2'
|
|
406
532
|
};
|
|
407
|
-
|
|
533
|
+
const endTypeMap = {
|
|
408
534
|
never: 1,
|
|
409
535
|
date: 2
|
|
410
536
|
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* 根据接口返回的Schedule计算日历数据
|
|
540
|
+
* @param schedule
|
|
541
|
+
*/
|
|
542
|
+
const calcCalendarDataByScheduleResult = schedule => {
|
|
543
|
+
const {
|
|
414
544
|
scheduleFormData,
|
|
415
|
-
scheduleFormOtherValue
|
|
416
|
-
|
|
417
|
-
);
|
|
545
|
+
scheduleFormOtherValue
|
|
546
|
+
} = formatScheduleResult(schedule);
|
|
547
|
+
return calcCalendarDataBySchedule(scheduleFormData, scheduleFormOtherValue, schedule.type);
|
|
418
548
|
};
|
|
419
|
-
|
|
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 {
|
|
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
|
|
588
|
+
end_date: end?.end_date
|
|
447
589
|
},
|
|
448
590
|
scheduleFormOtherValue: {
|
|
449
|
-
endRadio: endTypeMap[
|
|
591
|
+
endRadio: endTypeMap[end?.type || 'never'],
|
|
450
592
|
isAllDay: !!is_all,
|
|
451
593
|
type,
|
|
452
|
-
excludedStatus: !!
|
|
453
|
-
includeStatus: !!
|
|
594
|
+
excludedStatus: !!excluded_date?.length,
|
|
595
|
+
includeStatus: !!included_date?.length
|
|
454
596
|
}
|
|
455
597
|
};
|
|
456
598
|
};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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 ===
|
|
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
|
-
|
|
613
|
+
exports.calcScheduleDateRange = calcScheduleDateRange;
|
|
614
|
+
const calcCalendarDataBySchedules = schedules => {
|
|
480
615
|
const allSchedules = [];
|
|
481
|
-
schedules.forEach(
|
|
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: [...(
|
|
491
|
-
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
|
-
|
|
631
|
+
exports.calcCalendarDataBySchedules = calcCalendarDataBySchedules;
|
|
632
|
+
const calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
|
|
498
633
|
return schedules.reduce((pre, cur) => {
|
|
499
|
-
|
|
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,
|
|
508
|
-
const end = (0,
|
|
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(
|
|
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(
|
|
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 = (
|
|
535
|
-
|
|
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:
|
|
543
|
-
maxTimeStr:
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
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
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
+
}
|