@pisell/pisellos 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +20 -1
- package/dist/modules/AccountList/index.js +243 -75
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +5 -5
- package/dist/modules/Cart/index.js +33 -19
- package/dist/modules/Cart/types.d.ts +21 -7
- package/dist/modules/Cart/utils.d.ts +29 -5
- package/dist/modules/Cart/utils.js +72 -26
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -55
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +74 -23
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +10 -5
- package/dist/modules/Order/index.js +32 -16
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Product/index.d.ts +4 -1
- package/dist/modules/Product/index.js +22 -0
- package/dist/modules/Product/types.d.ts +7 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -4
- package/dist/modules/Rules/index.js +11 -11
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/index.d.ts +8 -3
- package/dist/modules/Schedule/index.js +45 -5
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +8 -8
- package/dist/modules/Schedule/utils.d.ts +9 -3
- package/dist/modules/Schedule/utils.js +77 -48
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +5 -5
- package/dist/modules/Summary/index.js +7 -7
- package/dist/modules/Summary/types.d.ts +2 -2
- package/dist/modules/Summary/utils.d.ts +4 -4
- package/dist/modules/Summary/utils.js +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +71 -16
- package/dist/solution/BookingByStep/index.js +643 -227
- package/dist/solution/BookingByStep/types.d.ts +2 -2
- package/dist/solution/BookingByStep/types.js +9 -9
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -5
- package/dist/solution/BookingByStep/utils/resources.js +37 -19
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +20 -1
- package/lib/modules/AccountList/index.js +122 -13
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +5 -5
- package/lib/modules/Cart/index.js +28 -6
- package/lib/modules/Cart/types.d.ts +21 -7
- package/lib/modules/Cart/utils.d.ts +29 -5
- package/lib/modules/Cart/utils.js +47 -3
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +6 -6
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +37 -6
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +10 -5
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +4 -1
- package/lib/modules/Product/index.js +16 -0
- package/lib/modules/Product/types.d.ts +7 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +4 -4
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.d.ts +8 -3
- package/lib/modules/Schedule/index.js +33 -2
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +8 -8
- package/lib/modules/Schedule/utils.d.ts +9 -3
- package/lib/modules/Schedule/utils.js +32 -4
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +5 -5
- package/lib/modules/Summary/types.d.ts +2 -2
- package/lib/modules/Summary/utils.d.ts +4 -4
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +71 -16
- package/lib/solution/BookingByStep/index.js +396 -48
- package/lib/solution/BookingByStep/types.d.ts +2 -2
- package/lib/solution/BookingByStep/types.js +36 -9
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -5
- package/lib/solution/BookingByStep/utils/resources.js +128 -58
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
11
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
-
import dayjs from
|
|
13
|
+
import dayjs from 'dayjs';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* 根据日程配置生成日历数据
|
|
@@ -19,10 +19,10 @@ import dayjs from "dayjs";
|
|
|
19
19
|
* @param type
|
|
20
20
|
*/
|
|
21
21
|
export var calcCalendarDataBySchedule = function calcCalendarDataBySchedule(values, others, type) {
|
|
22
|
-
if (type ===
|
|
22
|
+
if (type === 'time-slots') {
|
|
23
23
|
return calcCalendarDataByTimeSlots(values, others);
|
|
24
24
|
}
|
|
25
|
-
if (type ===
|
|
25
|
+
if (type === 'designation') {
|
|
26
26
|
return calcCalendarDataByDesignation(values, others);
|
|
27
27
|
}
|
|
28
28
|
return calcCalendarDataByStandard(values, others);
|
|
@@ -37,9 +37,9 @@ export var getDaysByStartEnd = function getDaysByStartEnd(startDate, endDate) {
|
|
|
37
37
|
var start = dayjs(startDate);
|
|
38
38
|
var end = dayjs(endDate);
|
|
39
39
|
var daysArray = [];
|
|
40
|
-
while (start.isBefore(end,
|
|
41
|
-
daysArray.push(start.format(
|
|
42
|
-
start = start.add(1,
|
|
40
|
+
while (start.isBefore(end, 'day') || start.isSame(end, 'day')) {
|
|
41
|
+
daysArray.push(start.format('YYYY-MM-DD'));
|
|
42
|
+
start = start.add(1, 'day');
|
|
43
43
|
}
|
|
44
44
|
return daysArray;
|
|
45
45
|
};
|
|
@@ -50,7 +50,7 @@ export var getDaysByStartEnd = function getDaysByStartEnd(startDate, endDate) {
|
|
|
50
50
|
* @param time
|
|
51
51
|
*/
|
|
52
52
|
var mergeDateTime = function mergeDateTime(date, time) {
|
|
53
|
-
var dateStr = "".concat(dayjs(date).format(
|
|
53
|
+
var dateStr = "".concat(dayjs(date).format('YYYY-MM-DD')).concat(time ? dayjs(time).format(' HH:MM') : '');
|
|
54
54
|
return dayjs(dateStr);
|
|
55
55
|
};
|
|
56
56
|
var getDataRange = function getDataRange(_ref) {
|
|
@@ -58,7 +58,7 @@ var getDataRange = function getDataRange(_ref) {
|
|
|
58
58
|
end = _ref.end,
|
|
59
59
|
type = _ref.type,
|
|
60
60
|
time_slot = _ref.time_slot;
|
|
61
|
-
if (type ===
|
|
61
|
+
if (type === 'time-slots') {
|
|
62
62
|
var dateRange = [];
|
|
63
63
|
var dateStr = getDaysByStartEnd(start, end);
|
|
64
64
|
dateStr.forEach(function (str) {
|
|
@@ -72,8 +72,8 @@ var getDataRange = function getDataRange(_ref) {
|
|
|
72
72
|
return dateRange;
|
|
73
73
|
}
|
|
74
74
|
return [{
|
|
75
|
-
start: start.format(
|
|
76
|
-
end: end.format(
|
|
75
|
+
start: start.format('YYYY-MM-DD HH:mm:ss'),
|
|
76
|
+
end: end.format('YYYY-MM-DD HH:mm:ss')
|
|
77
77
|
}];
|
|
78
78
|
};
|
|
79
79
|
|
|
@@ -89,17 +89,17 @@ var getDaysByRepeatDay = function getDaysByRepeatDay(params, isGetRange) {
|
|
|
89
89
|
type = params.type,
|
|
90
90
|
time_slot = params.time_slot,
|
|
91
91
|
excludedDays = params.excludedDays;
|
|
92
|
-
var scheduleDiff = end.diff(start,
|
|
92
|
+
var scheduleDiff = end.diff(start, 'second');
|
|
93
93
|
var excludedDaysMap = new Map(excludedDays.map(function (day) {
|
|
94
94
|
return [day, true];
|
|
95
95
|
}));
|
|
96
96
|
var startTmp = getMaxStart(start);
|
|
97
97
|
var daysArr = [];
|
|
98
|
-
while (startTmp.isBefore(deadline,
|
|
99
|
-
var e = startTmp.add(scheduleDiff,
|
|
98
|
+
while (startTmp.isBefore(deadline, 'day') || startTmp.isSame(deadline, 'day')) {
|
|
99
|
+
var e = startTmp.add(scheduleDiff, 'second');
|
|
100
100
|
if (isGetRange) {
|
|
101
|
-
if (excludedDaysMap.has(startTmp.format(
|
|
102
|
-
startTmp = startTmp.add(frequency,
|
|
101
|
+
if (excludedDaysMap.has(startTmp.format('YYYY-MM-DD'))) {
|
|
102
|
+
startTmp = startTmp.add(frequency, 'day');
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
105
|
var arr = getDataRange({
|
|
@@ -112,7 +112,7 @@ var getDaysByRepeatDay = function getDaysByRepeatDay(params, isGetRange) {
|
|
|
112
112
|
} else {
|
|
113
113
|
daysArr.push.apply(daysArr, _toConsumableArray(getDaysByStartEnd(startTmp, e)));
|
|
114
114
|
}
|
|
115
|
-
startTmp = startTmp.add(frequency,
|
|
115
|
+
startTmp = startTmp.add(frequency, 'day');
|
|
116
116
|
}
|
|
117
117
|
return Array.from(new Set(daysArr));
|
|
118
118
|
};
|
|
@@ -130,20 +130,20 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
|
|
|
130
130
|
type = params.type,
|
|
131
131
|
time_slot = params.time_slot,
|
|
132
132
|
excludedDays = params.excludedDays;
|
|
133
|
-
var scheduleDiff = end.diff(start,
|
|
133
|
+
var scheduleDiff = end.diff(start, 'second');
|
|
134
134
|
var excludedDaysMap = new Map(excludedDays.map(function (day) {
|
|
135
135
|
return [day, true];
|
|
136
136
|
}));
|
|
137
137
|
var startTmp = getMaxStart(start);
|
|
138
138
|
var daysArr = [];
|
|
139
|
-
while (startTmp.isBefore(deadline,
|
|
139
|
+
while (startTmp.isBefore(deadline, 'day') || startTmp.isSame(deadline, 'day')) {
|
|
140
140
|
for (var i = 0; i < frequency_date.length; i++) {
|
|
141
141
|
var item = frequency_date[i];
|
|
142
142
|
var _start = startTmp.day(item);
|
|
143
|
-
var _end = _start.add(scheduleDiff,
|
|
143
|
+
var _end = _start.add(scheduleDiff, 'second');
|
|
144
144
|
if (isGetRange) {
|
|
145
|
-
if (excludedDaysMap.has(_start.format(
|
|
146
|
-
startTmp = startTmp.day(1).add(frequency,
|
|
145
|
+
if (excludedDaysMap.has(_start.format('YYYY-MM-DD'))) {
|
|
146
|
+
startTmp = startTmp.day(1).add(frequency, 'week');
|
|
147
147
|
continue;
|
|
148
148
|
}
|
|
149
149
|
var arr = getDataRange({
|
|
@@ -157,7 +157,7 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
|
|
|
157
157
|
daysArr.push.apply(daysArr, _toConsumableArray(getDaysByStartEnd(_start, _end)));
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
startTmp = startTmp.day(1).add(frequency,
|
|
160
|
+
startTmp = startTmp.day(1).add(frequency, 'week');
|
|
161
161
|
}
|
|
162
162
|
return Array.from(new Set(daysArr));
|
|
163
163
|
};
|
|
@@ -246,9 +246,9 @@ var processDateRange = function processDateRange(_ref3, isGetRange) {
|
|
|
246
246
|
var includedDays = getDaysByStartEndArr(included_date);
|
|
247
247
|
|
|
248
248
|
// 不重复
|
|
249
|
-
if (repeat_type ===
|
|
249
|
+
if (repeat_type === '0') {
|
|
250
250
|
if (isGetRange) {
|
|
251
|
-
if (type ===
|
|
251
|
+
if (type === 'time-slots') {
|
|
252
252
|
days = (time_slot === null || time_slot === void 0 ? void 0 : time_slot.map(function (item) {
|
|
253
253
|
return {
|
|
254
254
|
start: start.format("YYYY-MM-DD ".concat(item.start_time)),
|
|
@@ -257,8 +257,8 @@ var processDateRange = function processDateRange(_ref3, isGetRange) {
|
|
|
257
257
|
})) || [];
|
|
258
258
|
} else {
|
|
259
259
|
days = [{
|
|
260
|
-
start: start.format(
|
|
261
|
-
end: end.format(
|
|
260
|
+
start: start.format('YYYY-MM-DD HH:mm:ss'),
|
|
261
|
+
end: end.format('YYYY-MM-DD HH:mm:ss')
|
|
262
262
|
}];
|
|
263
263
|
}
|
|
264
264
|
} else {
|
|
@@ -269,11 +269,11 @@ var processDateRange = function processDateRange(_ref3, isGetRange) {
|
|
|
269
269
|
|
|
270
270
|
// 截止时间 如果永不截止取18个月截止
|
|
271
271
|
if (endRadio === 1) {
|
|
272
|
-
endDate = isGetRange ? dayjs().add(12,
|
|
272
|
+
endDate = isGetRange ? dayjs().add(12, 'month') : dayjs().add(18, 'month');
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
// 按天重复
|
|
276
|
-
if (repeat_type ===
|
|
276
|
+
if (repeat_type === '1') {
|
|
277
277
|
days = getDaysByRepeatDay({
|
|
278
278
|
start: start,
|
|
279
279
|
end: end,
|
|
@@ -284,7 +284,7 @@ var processDateRange = function processDateRange(_ref3, isGetRange) {
|
|
|
284
284
|
excludedDays: excludedDays
|
|
285
285
|
}, isGetRange);
|
|
286
286
|
// 按周重复
|
|
287
|
-
} else if (repeat_type ===
|
|
287
|
+
} else if (repeat_type === '2') {
|
|
288
288
|
days = getDaysByRepeatWeek({
|
|
289
289
|
start: start,
|
|
290
290
|
end: end,
|
|
@@ -358,10 +358,10 @@ export var calcCalendarDataByStandard = function calcCalendarDataByStandard(valu
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// 日程开始时间
|
|
361
|
-
var start = designation ? mergeDateTime(designation.start_date, isAllDay ? designation.start_time :
|
|
361
|
+
var start = designation ? mergeDateTime(designation.start_date, isAllDay ? designation.start_time : '') : dayjs(start_time);
|
|
362
362
|
|
|
363
363
|
// 日程结束时间
|
|
364
|
-
var end = designation ? mergeDateTime(designation.end_date, isAllDay ? designation.end_time :
|
|
364
|
+
var end = designation ? mergeDateTime(designation.end_date, isAllDay ? designation.end_time : '') : dayjs(end_time);
|
|
365
365
|
|
|
366
366
|
// // 不重复
|
|
367
367
|
// if (repeat_type === "0") {
|
|
@@ -423,12 +423,12 @@ export var calcCalendarDataByStandard = function calcCalendarDataByStandard(valu
|
|
|
423
423
|
included_date: included_date,
|
|
424
424
|
includeStatus: includeStatus,
|
|
425
425
|
time_slot: time_slot,
|
|
426
|
-
type:
|
|
426
|
+
type: 'standard'
|
|
427
427
|
}, isGetRange);
|
|
428
428
|
};
|
|
429
429
|
var getMaxStart = function getMaxStart(start_time) {
|
|
430
430
|
var valueStart = dayjs(start_time);
|
|
431
|
-
var currentYearStart = dayjs().startOf(
|
|
431
|
+
var currentYearStart = dayjs().startOf('year').set('hour', valueStart.get('hour')).set('minute', valueStart.get('minutes')).set('second', valueStart.get('second'));
|
|
432
432
|
var start = valueStart.isBefore(currentYearStart) ? currentYearStart : valueStart;
|
|
433
433
|
return start;
|
|
434
434
|
};
|
|
@@ -470,7 +470,7 @@ export var calcCalendarDataByTimeSlots = function calcCalendarDataByTimeSlots(va
|
|
|
470
470
|
included_date: included_date,
|
|
471
471
|
includeStatus: includeStatus,
|
|
472
472
|
time_slot: time_slot,
|
|
473
|
-
type:
|
|
473
|
+
type: 'time-slots'
|
|
474
474
|
}, isGetRange);
|
|
475
475
|
};
|
|
476
476
|
|
|
@@ -510,12 +510,12 @@ export var calcCalendarDataByDesignation = function calcCalendarDataByDesignatio
|
|
|
510
510
|
});
|
|
511
511
|
};
|
|
512
512
|
export var isAllDay = function isAllDay(value) {
|
|
513
|
-
return dayjs(value.start_time).format(
|
|
513
|
+
return dayjs(value.start_time).format('HH:mm:ss') === '00:00:00' && dayjs(value.end_time).format('HH:mm:ss') === '23:59:59';
|
|
514
514
|
};
|
|
515
515
|
var repeatTypeMap = {
|
|
516
|
-
none:
|
|
517
|
-
daily:
|
|
518
|
-
weekly:
|
|
516
|
+
none: '0',
|
|
517
|
+
daily: '1',
|
|
518
|
+
weekly: '2'
|
|
519
519
|
};
|
|
520
520
|
var endTypeMap = {
|
|
521
521
|
never: 1,
|
|
@@ -570,7 +570,7 @@ export var formatScheduleResult = function formatScheduleResult(schedule) {
|
|
|
570
570
|
end_date: end === null || end === void 0 ? void 0 : end.end_date
|
|
571
571
|
},
|
|
572
572
|
scheduleFormOtherValue: {
|
|
573
|
-
endRadio: endTypeMap[(end === null || end === void 0 ? void 0 : end.type) ||
|
|
573
|
+
endRadio: endTypeMap[(end === null || end === void 0 ? void 0 : end.type) || 'never'],
|
|
574
574
|
isAllDay: !!is_all,
|
|
575
575
|
type: type,
|
|
576
576
|
excludedStatus: !!(excluded_date !== null && excluded_date !== void 0 && excluded_date.length),
|
|
@@ -582,10 +582,10 @@ export var calcScheduleDateRange = function calcScheduleDateRange(schedule) {
|
|
|
582
582
|
var _formatScheduleResult2 = formatScheduleResult(schedule),
|
|
583
583
|
scheduleFormData = _formatScheduleResult2.scheduleFormData,
|
|
584
584
|
scheduleFormOtherValue = _formatScheduleResult2.scheduleFormOtherValue;
|
|
585
|
-
if (schedule.type ===
|
|
585
|
+
if (schedule.type === 'time-slots') {
|
|
586
586
|
return calcCalendarDataByTimeSlots(scheduleFormData, scheduleFormOtherValue, true);
|
|
587
587
|
}
|
|
588
|
-
if (schedule.type ===
|
|
588
|
+
if (schedule.type === 'designation') {
|
|
589
589
|
return calcCalendarDataByDesignation(scheduleFormData, scheduleFormOtherValue, true);
|
|
590
590
|
}
|
|
591
591
|
return calcCalendarDataByStandard(scheduleFormData, scheduleFormOtherValue, true);
|
|
@@ -607,7 +607,7 @@ export var calcCalendarDataBySchedules = function calcCalendarDataBySchedules(sc
|
|
|
607
607
|
export var calcMinTimeMaxTimeBySchedules = function calcMinTimeMaxTimeBySchedules(schedules, scheduleAllMap, selectDate) {
|
|
608
608
|
return schedules.reduce(function (pre, cur) {
|
|
609
609
|
var _scheduleAllMap$cur$i, _minTime, _maxTime;
|
|
610
|
-
var dateRange = ((_scheduleAllMap$cur$i = scheduleAllMap[cur.id]) === null || _scheduleAllMap$cur$i === void 0 ? void 0 : _scheduleAllMap$cur$i.dateRange) || calcScheduleDateRange(cur);
|
|
610
|
+
var dateRange = (scheduleAllMap === null || scheduleAllMap === void 0 || (_scheduleAllMap$cur$i = scheduleAllMap[cur.id]) === null || _scheduleAllMap$cur$i === void 0 ? void 0 : _scheduleAllMap$cur$i.dateRange) || calcScheduleDateRange(cur);
|
|
611
611
|
var dateRangeFormat = [];
|
|
612
612
|
if (selectDate) {
|
|
613
613
|
var dateRangeTmp = [];
|
|
@@ -624,11 +624,11 @@ export var calcMinTimeMaxTimeBySchedules = function calcMinTimeMaxTimeBySchedule
|
|
|
624
624
|
if (isSameStart && !isSameEnd) {
|
|
625
625
|
dateRangeFormatTmp.push({
|
|
626
626
|
start: range.start,
|
|
627
|
-
end: end.format(
|
|
627
|
+
end: end.format('YYYY-MM-DD 23:59:59')
|
|
628
628
|
});
|
|
629
629
|
} else if (!isSameStart && isSameEnd) {
|
|
630
630
|
dateRangeFormatTmp.push({
|
|
631
|
-
start: start.format(
|
|
631
|
+
start: start.format('YYYY-MM-DD 00:00:00'),
|
|
632
632
|
end: range.end
|
|
633
633
|
});
|
|
634
634
|
} else {
|
|
@@ -649,8 +649,8 @@ export var calcMinTimeMaxTimeBySchedules = function calcMinTimeMaxTimeBySchedule
|
|
|
649
649
|
return _objectSpread(_objectSpread({}, pre), {}, _defineProperty({}, cur.id, {
|
|
650
650
|
minTime: minTime,
|
|
651
651
|
maxTime: maxTime,
|
|
652
|
-
minTimeStr: ((_minTime = minTime) === null || _minTime === void 0 ? void 0 : _minTime.format(
|
|
653
|
-
maxTimeStr: ((_maxTime = maxTime) === null || _maxTime === void 0 ? void 0 : _maxTime.format(
|
|
652
|
+
minTimeStr: ((_minTime = minTime) === null || _minTime === void 0 ? void 0 : _minTime.format('YYYY-MM-DD HH:mm:ss')) || null,
|
|
653
|
+
maxTimeStr: ((_maxTime = maxTime) === null || _maxTime === void 0 ? void 0 : _maxTime.format('YYYY-MM-DD HH:mm:ss')) || null,
|
|
654
654
|
dateRange: dateRange,
|
|
655
655
|
dateRangeFormat: dateRangeFormat
|
|
656
656
|
}));
|
|
@@ -659,7 +659,7 @@ export var calcMinTimeMaxTimeBySchedules = function calcMinTimeMaxTimeBySchedule
|
|
|
659
659
|
|
|
660
660
|
/**
|
|
661
661
|
* @title: 格式化日程数据
|
|
662
|
-
* @description:
|
|
662
|
+
* @description:
|
|
663
663
|
* @param {Array} relation 资源列表
|
|
664
664
|
* @param {string} table_type 关联表类型
|
|
665
665
|
* @param {string} item_type 资源类型
|
|
@@ -697,4 +697,33 @@ export var formatScheduleData = function formatScheduleData(relation, table_type
|
|
|
697
697
|
return (item === null || item === void 0 ? void 0 : item.item_type) === item_type;
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
|
-
};
|
|
700
|
+
};
|
|
701
|
+
export function getAllSortedDateRanges(schedules) {
|
|
702
|
+
// 收集所有 dateRange
|
|
703
|
+
var allDateRanges = [];
|
|
704
|
+
|
|
705
|
+
// 遍历所有对象,收集 dateRange
|
|
706
|
+
Object.values(schedules).forEach(function (schedule) {
|
|
707
|
+
if (schedule.dateRange && Array.isArray(schedule.dateRange)) {
|
|
708
|
+
allDateRanges.push.apply(allDateRanges, _toConsumableArray(schedule.dateRange));
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// 如果没有找到任何 dateRange,返回空数组
|
|
713
|
+
if (allDateRanges.length === 0) {
|
|
714
|
+
console.log('No dateRanges found in schedules:', schedules);
|
|
715
|
+
return [];
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// 按照开始时间和时长排序
|
|
719
|
+
return allDateRanges.sort(function (a, b) {
|
|
720
|
+
// 首先按开始时间排序
|
|
721
|
+
var startTimeCompare = dayjs(a.start).valueOf() - dayjs(b.start).valueOf();
|
|
722
|
+
if (startTimeCompare !== 0) return startTimeCompare;
|
|
723
|
+
|
|
724
|
+
// 如果开始时间相同,按时长排序(结束时间 - 开始时间)
|
|
725
|
+
var durationA = dayjs(a.end).valueOf() - dayjs(a.start).valueOf();
|
|
726
|
+
var durationB = dayjs(b.end).valueOf() - dayjs(b.start).valueOf();
|
|
727
|
+
return durationA - durationB;
|
|
728
|
+
});
|
|
729
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { IStep, IStepModuleAPI } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { IStep, IStepModuleAPI } from './tyeps';
|
|
4
4
|
export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -19,5 +19,16 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
19
19
|
prevStep(): void;
|
|
20
20
|
nextStep(): void;
|
|
21
21
|
gotoStep(stepIndex: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* 添加步骤
|
|
24
|
+
* @param step 步骤
|
|
25
|
+
* @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
|
|
26
|
+
*/
|
|
27
|
+
addStep(step: IStep, key?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* 删除步骤
|
|
30
|
+
* @param key 步骤的 key
|
|
31
|
+
*/
|
|
32
|
+
removeStep(key: string): void;
|
|
22
33
|
storeChange(): void;
|
|
23
34
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
2
8
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
10
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -23,8 +29,8 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
23
29
|
var _this;
|
|
24
30
|
_classCallCheck(this, StepModule);
|
|
25
31
|
_this = _super.call(this, name, version);
|
|
26
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
27
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'step');
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
28
34
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
29
35
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
30
36
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
@@ -118,6 +124,52 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
118
124
|
value: function gotoStep(stepIndex) {
|
|
119
125
|
this.setCurrentStep(stepIndex);
|
|
120
126
|
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 添加步骤
|
|
130
|
+
* @param step 步骤
|
|
131
|
+
* @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
|
|
132
|
+
*/
|
|
133
|
+
}, {
|
|
134
|
+
key: "addStep",
|
|
135
|
+
value: function addStep(step, key) {
|
|
136
|
+
var stepList = this.store.stepList;
|
|
137
|
+
|
|
138
|
+
// 前置检测step在stepList中是否存在
|
|
139
|
+
var index = stepList.findIndex(function (n) {
|
|
140
|
+
return n.key === step.key;
|
|
141
|
+
});
|
|
142
|
+
if (index !== -1) {
|
|
143
|
+
console.log('[StepModule] 步骤已存在,添加失败');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (key) {
|
|
147
|
+
var _index = this.store.stepList.findIndex(function (n) {
|
|
148
|
+
return n.key === key;
|
|
149
|
+
});
|
|
150
|
+
if (_index !== -1) {
|
|
151
|
+
stepList.splice(_index + 1, 0, step);
|
|
152
|
+
} else {
|
|
153
|
+
stepList = [].concat(_toConsumableArray(stepList), [step]);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
stepList.splice(this.store.currentStepIndex + 1, 0, step);
|
|
157
|
+
}
|
|
158
|
+
this.store.stepList = _toConsumableArray(stepList);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 删除步骤
|
|
163
|
+
* @param key 步骤的 key
|
|
164
|
+
*/
|
|
165
|
+
}, {
|
|
166
|
+
key: "removeStep",
|
|
167
|
+
value: function removeStep(key) {
|
|
168
|
+
var newStepList = this.store.stepList.filter(function (n) {
|
|
169
|
+
return n.key !== key;
|
|
170
|
+
});
|
|
171
|
+
this.store.stepList = _toConsumableArray(newStepList);
|
|
172
|
+
}
|
|
121
173
|
}, {
|
|
122
174
|
key: "storeChange",
|
|
123
175
|
value: function storeChange() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { CartItem } from
|
|
4
|
-
import { ISummaryState, ISummaryModuleAPI } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { CartItem } from '../Cart/types';
|
|
4
|
+
import { ISummaryState, ISummaryModuleAPI } from './types';
|
|
5
5
|
export declare class SummaryModule extends BaseModule implements Module, ISummaryModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
@@ -13,7 +13,7 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
13
13
|
private fatherModule;
|
|
14
14
|
constructor(name?: string, version?: string);
|
|
15
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
|
-
getSummary(cartItems: CartItem[]): Promise<ISummaryState[
|
|
16
|
+
getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
|
|
17
17
|
/**
|
|
18
18
|
* 获取协议
|
|
19
19
|
* @param protocolId 协议ID
|
|
@@ -24,8 +24,8 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
24
24
|
var _this;
|
|
25
25
|
_classCallCheck(this, SummaryModule);
|
|
26
26
|
_this = _super.call(this, name, version);
|
|
27
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
28
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'summary');
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
29
29
|
_defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
|
|
30
30
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
31
31
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
@@ -44,8 +44,8 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
44
44
|
case 0:
|
|
45
45
|
this.core = core;
|
|
46
46
|
this.store = options.store;
|
|
47
|
-
this.shopStore = this.core.getPlugin(
|
|
48
|
-
this.request = this.core.getPlugin(
|
|
47
|
+
this.shopStore = this.core.getPlugin('shopStore');
|
|
48
|
+
this.request = this.core.getPlugin('request');
|
|
49
49
|
if (options.initialState) {
|
|
50
50
|
this.store.summary = options.initialState.summary;
|
|
51
51
|
}
|
|
@@ -60,7 +60,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
60
60
|
_context.next = 9;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
|
-
throw new Error(
|
|
63
|
+
throw new Error('SummaryModule 需要 shopStore 插件支持');
|
|
64
64
|
case 9:
|
|
65
65
|
case "end":
|
|
66
66
|
return _context.stop();
|
|
@@ -81,7 +81,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
81
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
82
82
|
while (1) switch (_context2.prev = _context2.next) {
|
|
83
83
|
case 0:
|
|
84
|
-
shopInfo = ((_this$shopStore$get = this.shopStore.get(
|
|
84
|
+
shopInfo = ((_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
|
|
85
85
|
summary = calculatePriceDetails(shopInfo, cartItems);
|
|
86
86
|
this.store.summary = summary;
|
|
87
87
|
return _context2.abrupt("return", this.store.summary);
|
|
@@ -128,7 +128,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
128
128
|
cacheId: this.cacheId,
|
|
129
129
|
fatherModule: this.fatherModule,
|
|
130
130
|
store: this.store,
|
|
131
|
-
cacheKey: [
|
|
131
|
+
cacheKey: ['summary']
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartItem } from
|
|
1
|
+
import { CartItem } from '../Cart/types';
|
|
2
2
|
export interface ISummaryState {
|
|
3
3
|
summary: {
|
|
4
4
|
/** 商品总价 */
|
|
@@ -30,5 +30,5 @@ export interface IProtocol {
|
|
|
30
30
|
id: string;
|
|
31
31
|
}
|
|
32
32
|
export interface ISummaryModuleAPI {
|
|
33
|
-
getSummary(cartItems: CartItem[]): Promise<ISummaryState[
|
|
33
|
+
getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
|
|
34
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Decimal from
|
|
2
|
-
import { CartItem } from
|
|
3
|
-
import { ISummaryState } from
|
|
4
|
-
export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState[
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { CartItem } from '../Cart/types';
|
|
3
|
+
import { ISummaryState } from './types';
|
|
4
|
+
export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState['summary'];
|
|
5
5
|
/**
|
|
6
6
|
* 计算商品小计(不含其他费用)
|
|
7
7
|
* @param items - 购物车商品数组
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Decimal from
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
2
|
export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items) {
|
|
3
3
|
var subtotal = new Decimal(calculateSubtotal(items));
|
|
4
4
|
var totalTaxFee = new Decimal(calculateTaxFee(shopInfo, items));
|
|
@@ -25,7 +25,7 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
|
|
|
25
25
|
*/
|
|
26
26
|
export var calculateSubtotal = function calculateSubtotal(items) {
|
|
27
27
|
if (!(items !== null && items !== void 0 && items.length)) {
|
|
28
|
-
return
|
|
28
|
+
return '0.00';
|
|
29
29
|
}
|
|
30
30
|
var subtotal = items.reduce(function (sum, item) {
|
|
31
31
|
var cartItemTotalPrice = new Decimal(item.total || 0);
|
|
@@ -44,7 +44,7 @@ export var calculateSubtotal = function calculateSubtotal(items) {
|
|
|
44
44
|
*/
|
|
45
45
|
export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
|
|
46
46
|
if (!(items !== null && items !== void 0 && items.length)) {
|
|
47
|
-
return
|
|
47
|
+
return '0.00';
|
|
48
48
|
}
|
|
49
49
|
var _ref = shopInfo || {},
|
|
50
50
|
is_price_include_tax = _ref.is_price_include_tax,
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './request';
|
|
2
|
+
export * from './window';
|
|
3
|
+
export * from './shopStore';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* RequestPlugin 接口定义
|
|
4
4
|
*/
|
|
@@ -40,13 +40,13 @@ export interface RequestPlugin extends Plugin {
|
|
|
40
40
|
*/
|
|
41
41
|
export interface RequestOptions {
|
|
42
42
|
url?: string;
|
|
43
|
-
method?:
|
|
43
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
44
44
|
headers?: Record<string, string>;
|
|
45
45
|
data?: any;
|
|
46
46
|
body?: any;
|
|
47
47
|
params?: Record<string, string | number | boolean>;
|
|
48
48
|
timeout?: number;
|
|
49
|
-
responseType?:
|
|
49
|
+
responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
|
|
50
50
|
withCredentials?: boolean;
|
|
51
51
|
useCache?: boolean;
|
|
52
52
|
}
|