@pisell/pisellos 3.0.8 → 3.0.10
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.
|
@@ -50,10 +50,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
50
50
|
category_ids?: number[];
|
|
51
51
|
}): Promise<any>;
|
|
52
52
|
loadAllSchedule(): Promise<void>;
|
|
53
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
53
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel }: {
|
|
54
54
|
startDate: string;
|
|
55
55
|
endDate: string;
|
|
56
56
|
custom_page_id?: number;
|
|
57
|
+
channel?: string;
|
|
57
58
|
}): Promise<ITime[]>;
|
|
58
59
|
storeProduct(productData: ProductData): Promise<void>;
|
|
59
60
|
addAccount(account: Account | IHolder, extra?: {
|
|
@@ -314,11 +314,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
314
314
|
value: function () {
|
|
315
315
|
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
316
316
|
var _res$data$date_list;
|
|
317
|
-
var startDate, endDate, custom_page_id, dates, res;
|
|
317
|
+
var startDate, endDate, custom_page_id, channel, dates, res;
|
|
318
318
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
319
319
|
while (1) switch (_context5.prev = _context5.next) {
|
|
320
320
|
case 0:
|
|
321
|
-
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
321
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
|
|
322
322
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
323
323
|
if (dayjs(startDate).isBefore(dayjs(), 'day')) {
|
|
324
324
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
@@ -337,7 +337,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
337
337
|
return this.request.get("/schedule/product/availability", {
|
|
338
338
|
start_date: startDate,
|
|
339
339
|
end_date: endDate,
|
|
340
|
-
custom_page_id: custom_page_id
|
|
340
|
+
custom_page_id: custom_page_id,
|
|
341
|
+
channel: channel
|
|
341
342
|
});
|
|
342
343
|
case 8:
|
|
343
344
|
res = _context5.sent;
|
|
@@ -350,13 +351,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
350
351
|
return _context5.abrupt("return", dates);
|
|
351
352
|
case 12:
|
|
352
353
|
res.data.date_list.forEach(function (n) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
dates[index].status = 'available';
|
|
359
|
-
}
|
|
354
|
+
var index = dates.findIndex(function (m) {
|
|
355
|
+
return m.date === n.date;
|
|
356
|
+
});
|
|
357
|
+
if (index !== -1) {
|
|
358
|
+
dates[index].status = 'available';
|
|
360
359
|
}
|
|
361
360
|
});
|
|
362
361
|
dates = disableDatesBeforeOneDay(dates);
|
|
@@ -1195,7 +1194,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1195
1194
|
});
|
|
1196
1195
|
n.renderList = n.renderList.filter(function (m) {
|
|
1197
1196
|
var recordCount = capacityMap[m.id] || 0;
|
|
1198
|
-
var
|
|
1197
|
+
var canUseArr = m.times.map(function (item) {
|
|
1199
1198
|
var res = getIsUsableByTimeItem({
|
|
1200
1199
|
timeSlice: {
|
|
1201
1200
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1213,7 +1212,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1213
1212
|
}
|
|
1214
1213
|
return res.usable;
|
|
1215
1214
|
});
|
|
1216
|
-
|
|
1215
|
+
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1216
|
+
return !canUseArr.some(function (n) {
|
|
1217
|
+
return n === false;
|
|
1218
|
+
});
|
|
1217
1219
|
});
|
|
1218
1220
|
});
|
|
1219
1221
|
} else {
|
|
@@ -1581,7 +1583,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1581
1583
|
}, {
|
|
1582
1584
|
key: "getTimeSlotByAllResources",
|
|
1583
1585
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1584
|
-
var
|
|
1586
|
+
var _dateRange,
|
|
1587
|
+
_this9 = this,
|
|
1585
1588
|
_cartItems$,
|
|
1586
1589
|
_cartItems$2;
|
|
1587
1590
|
var dateRange = this.store.date.getDateRange();
|
|
@@ -1590,8 +1593,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1590
1593
|
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1591
1594
|
// if (cartItems?.[0].start_date) return [];
|
|
1592
1595
|
var resourceIds = [];
|
|
1596
|
+
var resourcesTypeId = undefined;
|
|
1593
1597
|
cartItems.forEach(function (item) {
|
|
1594
|
-
var _item$_productOrigin9;
|
|
1598
|
+
var _item$_productOrigin9, _item$_productOrigin10;
|
|
1595
1599
|
(_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
|
|
1596
1600
|
if (n.code === resources_code) {
|
|
1597
1601
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -1603,7 +1607,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1607
|
if (item.resource_id) {
|
|
1604
1608
|
resourceIds.push(item.resource_id);
|
|
1605
1609
|
}
|
|
1610
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.find(function (n) {
|
|
1611
|
+
return n.code === resources_code;
|
|
1612
|
+
})) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.id;
|
|
1606
1613
|
});
|
|
1614
|
+
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1615
|
+
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
1616
|
+
// resources.push(...dateRange[0].resource);
|
|
1617
|
+
dateRange[0].resource.forEach(function (n) {
|
|
1618
|
+
if (n.form_id === resourcesTypeId) {
|
|
1619
|
+
resources.push(n);
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1607
1623
|
var resourcesMap = getResourcesMap(resources);
|
|
1608
1624
|
var duration = 0;
|
|
1609
1625
|
// duration = 不同账号的最长时间
|
|
@@ -1611,8 +1627,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1611
1627
|
var checkDuration = function checkDuration(cartItems) {
|
|
1612
1628
|
var accountDuration = 0;
|
|
1613
1629
|
cartItems.forEach(function (item) {
|
|
1614
|
-
var _item$_productOrigin$3, _item$
|
|
1615
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1630
|
+
var _item$_productOrigin$3, _item$_productOrigin11;
|
|
1631
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1616
1632
|
});
|
|
1617
1633
|
if (accountDuration > duration) {
|
|
1618
1634
|
duration = accountDuration;
|
|
@@ -1681,9 +1697,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1681
1697
|
accountItems.forEach(function (item, index) {
|
|
1682
1698
|
var newResources = cloneDeep(item._origin.resources);
|
|
1683
1699
|
newResources.forEach(function (resource) {
|
|
1684
|
-
var _item$_productOrigin$4, _item$
|
|
1700
|
+
var _item$_productOrigin$4, _item$_productOrigin12, _ref11, _item$_productOrigin13;
|
|
1685
1701
|
resource.startTime = currentStartTime;
|
|
1686
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
1702
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1687
1703
|
delete resource.times;
|
|
1688
1704
|
});
|
|
1689
1705
|
_this10.store.cart.updateItem({
|
|
@@ -1827,7 +1843,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1827
1843
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
1828
1844
|
resourcesUseableMap[m.id] = res.usable;
|
|
1829
1845
|
}
|
|
1830
|
-
// 如果资源可用,且是独占资源,remainingCapacity 始终为 1
|
|
1831
1846
|
if (res.usable && res.remainingCapacity >= count) {
|
|
1832
1847
|
count = res.remainingCapacity;
|
|
1833
1848
|
}
|
|
@@ -50,10 +50,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
50
50
|
category_ids?: number[];
|
|
51
51
|
}): Promise<any>;
|
|
52
52
|
loadAllSchedule(): Promise<void>;
|
|
53
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
53
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel }: {
|
|
54
54
|
startDate: string;
|
|
55
55
|
endDate: string;
|
|
56
56
|
custom_page_id?: number;
|
|
57
|
+
channel?: string;
|
|
57
58
|
}): Promise<ITime[]>;
|
|
58
59
|
storeProduct(productData: ProductData): Promise<void>;
|
|
59
60
|
addAccount(account: Account | IHolder, extra?: {
|
|
@@ -208,7 +208,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
208
208
|
async loadScheduleAvailableDate({
|
|
209
209
|
startDate,
|
|
210
210
|
endDate,
|
|
211
|
-
custom_page_id
|
|
211
|
+
custom_page_id,
|
|
212
|
+
channel
|
|
212
213
|
}) {
|
|
213
214
|
var _a;
|
|
214
215
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
@@ -224,7 +225,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
224
225
|
{
|
|
225
226
|
start_date: startDate,
|
|
226
227
|
end_date: endDate,
|
|
227
|
-
custom_page_id
|
|
228
|
+
custom_page_id,
|
|
229
|
+
channel
|
|
228
230
|
}
|
|
229
231
|
);
|
|
230
232
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
@@ -232,11 +234,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
232
234
|
return dates;
|
|
233
235
|
}
|
|
234
236
|
res.data.date_list.forEach((n) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
dates[index].status = "available";
|
|
239
|
-
}
|
|
237
|
+
const index = dates.findIndex((m) => m.date === n.date);
|
|
238
|
+
if (index !== -1) {
|
|
239
|
+
dates[index].status = "available";
|
|
240
240
|
}
|
|
241
241
|
});
|
|
242
242
|
dates = (0, import_utils3.disableDatesBeforeOneDay)(dates);
|
|
@@ -646,7 +646,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
646
646
|
});
|
|
647
647
|
n.renderList = n.renderList.filter((m) => {
|
|
648
648
|
const recordCount = capacityMap[m.id] || 0;
|
|
649
|
-
const
|
|
649
|
+
const canUseArr = m.times.map((item) => {
|
|
650
650
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
651
651
|
timeSlice: {
|
|
652
652
|
start_time: startTime.format("HH:mm"),
|
|
@@ -664,7 +664,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
664
664
|
}
|
|
665
665
|
return res.usable;
|
|
666
666
|
});
|
|
667
|
-
return
|
|
667
|
+
return !canUseArr.some((n2) => n2 === false);
|
|
668
668
|
});
|
|
669
669
|
});
|
|
670
670
|
} else {
|
|
@@ -992,13 +992,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
992
992
|
}
|
|
993
993
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
994
994
|
getTimeSlotByAllResources(resources_code) {
|
|
995
|
-
var _a, _b, _c, _d;
|
|
995
|
+
var _a, _b, _c, _d, _e, _f;
|
|
996
996
|
let dateRange = this.store.date.getDateRange();
|
|
997
997
|
const resources = [];
|
|
998
998
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
999
999
|
const resourceIds = [];
|
|
1000
|
+
let resourcesTypeId = void 0;
|
|
1000
1001
|
cartItems.forEach((item) => {
|
|
1001
|
-
var _a2, _b2, _c2;
|
|
1002
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
1002
1003
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1003
1004
|
if (n.code === resources_code) {
|
|
1004
1005
|
resources.push(...n.renderList || []);
|
|
@@ -1007,7 +1008,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1007
1008
|
if (item.resource_id) {
|
|
1008
1009
|
resourceIds.push(item.resource_id);
|
|
1009
1010
|
}
|
|
1011
|
+
resourcesTypeId = (_g = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find((n) => n.code === resources_code)) == null ? void 0 : _g.id;
|
|
1010
1012
|
});
|
|
1013
|
+
if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
|
|
1014
|
+
dateRange[0].resource.forEach((n) => {
|
|
1015
|
+
if (n.form_id === resourcesTypeId) {
|
|
1016
|
+
resources.push(n);
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1011
1020
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
1012
1021
|
let duration = 0;
|
|
1013
1022
|
const accountList = this.store.accountList.getAccounts();
|
|
@@ -1029,7 +1038,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1029
1038
|
} else {
|
|
1030
1039
|
checkDuration(cartItems);
|
|
1031
1040
|
}
|
|
1032
|
-
if (!((
|
|
1041
|
+
if (!((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) && !((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1033
1042
|
return [];
|
|
1034
1043
|
}
|
|
1035
1044
|
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
@@ -1041,7 +1050,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1041
1050
|
weekNum: 0
|
|
1042
1051
|
},
|
|
1043
1052
|
{
|
|
1044
|
-
date: ((
|
|
1053
|
+
date: ((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.end_date) || ((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.start_date) || "",
|
|
1045
1054
|
status: "available",
|
|
1046
1055
|
week: "",
|
|
1047
1056
|
weekNum: 0
|