@pisell/pisellos 0.0.30 → 0.0.31
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.
|
@@ -848,9 +848,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
848
848
|
var dateRange = this.store.date.getDateRange();
|
|
849
849
|
if (timeSlots) {
|
|
850
850
|
// 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
851
|
+
// const duration = resourceProductData.product.duration.value;
|
|
852
|
+
// const start_time = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
853
|
+
// const end_time = dayjs(`${dateRange[0].date} ${start_time}`)
|
|
854
|
+
// .add(duration, resourceProductData.product.duration.type)
|
|
855
|
+
// .format("HH:mm");
|
|
854
856
|
// 根据 start_time 和 end_time 去匹配资源
|
|
855
857
|
var targetResource = null;
|
|
856
858
|
var _iterator = _createForOfIteratorHelper(resources),
|
|
@@ -860,11 +862,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
860
862
|
var n = _step.value;
|
|
861
863
|
var canUseTime = n.times.find(function (item) {
|
|
862
864
|
return getIsUsableByTimeItem({
|
|
863
|
-
timeSlice:
|
|
864
|
-
time:
|
|
865
|
-
start_time: start_time,
|
|
866
|
-
end_time: end_time
|
|
867
|
-
},
|
|
865
|
+
timeSlice: timeSlots,
|
|
866
|
+
time: item,
|
|
868
867
|
resource: n,
|
|
869
868
|
currentCount: 1
|
|
870
869
|
});
|
|
@@ -887,7 +886,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
887
886
|
};
|
|
888
887
|
} else {
|
|
889
888
|
// 如果没有传递 timeSlots,证明是第一个资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
890
|
-
var
|
|
889
|
+
var duration = resourceProductData.product.duration.value;
|
|
891
890
|
var resourcesMap = getResourcesMap(resources);
|
|
892
891
|
var resourceIds = resources.map(function (n) {
|
|
893
892
|
return n.id;
|
|
@@ -895,7 +894,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
895
894
|
var _timeSlots = getTimeSlicesByResources({
|
|
896
895
|
resourceIds: resourceIds,
|
|
897
896
|
resourcesMap: resourcesMap,
|
|
898
|
-
duration:
|
|
897
|
+
duration: duration,
|
|
899
898
|
currentDate: dateRange[0].date,
|
|
900
899
|
split: 10
|
|
901
900
|
});
|
|
@@ -950,9 +949,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
950
949
|
});
|
|
951
950
|
|
|
952
951
|
// 如果有选择时间了,则代表不是第一种资源了,则需要根据开始时间去匹配
|
|
952
|
+
// 每个商品
|
|
953
953
|
if (timeSlots) {
|
|
954
|
-
|
|
955
|
-
|
|
954
|
+
// const start_time = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
955
|
+
// const end_time = dayjs(`${dateRange[0].date} ${timeSlots.start_time}`)
|
|
956
|
+
// .add(duration, durationType as dayjs.ManipulateType)
|
|
957
|
+
// .format("HH:mm");
|
|
956
958
|
// 根据 start_time 和 end_time 去匹配资源
|
|
957
959
|
var targetResource = null;
|
|
958
960
|
var _iterator2 = _createForOfIteratorHelper(resources),
|
|
@@ -963,11 +965,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
963
965
|
var recordCount = countMap[n.id] || 0;
|
|
964
966
|
var canUseTime = n.times.find(function (item) {
|
|
965
967
|
return getIsUsableByTimeItem({
|
|
966
|
-
timeSlice:
|
|
967
|
-
time:
|
|
968
|
-
start_time: start_time,
|
|
969
|
-
end_time: end_time
|
|
970
|
-
},
|
|
968
|
+
timeSlice: timeSlots,
|
|
969
|
+
time: item,
|
|
971
970
|
resource: n,
|
|
972
971
|
currentCount: recordCount + 1
|
|
973
972
|
});
|
|
@@ -1029,14 +1028,30 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1029
1028
|
var cartItems = _this7.store.cart.getCartByAccount(account.getId());
|
|
1030
1029
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1031
1030
|
var allCartItems = _this7.store.cart.getItems();
|
|
1032
|
-
|
|
1031
|
+
var recordTimeSlots = cloneDeep(timeSlots);
|
|
1032
|
+
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1033
|
+
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
1034
|
+
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
1035
|
+
|
|
1036
|
+
cartItems.forEach(function (item, index) {
|
|
1033
1037
|
if (timeSlots) {
|
|
1034
1038
|
var _item$_origin$resourc2;
|
|
1039
|
+
if (index !== 0 && recordTimeSlots) {
|
|
1040
|
+
var _item$_productOrigin$, _item$_productOrigin2, _ref8, _item$_productOrigin3, _item$_productOrigin$2, _item$_productOrigin4, _ref9, _item$_productOrigin5;
|
|
1041
|
+
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.duration) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref8 = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes");
|
|
1042
|
+
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref9 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref9 !== void 0 ? _ref9 : "minutes");
|
|
1043
|
+
recordTimeSlots = {
|
|
1044
|
+
start_time: start_at.format("HH:mm"),
|
|
1045
|
+
end_time: end_at.format("HH:mm"),
|
|
1046
|
+
start_at: start_at,
|
|
1047
|
+
end_at: end_at
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1035
1050
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1036
1051
|
var res = _this7.autoSelectAccountResources({
|
|
1037
1052
|
holder_id: item.holder_id,
|
|
1038
1053
|
resources_code: resources_code,
|
|
1039
|
-
timeSlots:
|
|
1054
|
+
timeSlots: recordTimeSlots,
|
|
1040
1055
|
countMap: selectResourcesMap
|
|
1041
1056
|
});
|
|
1042
1057
|
// 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
@@ -1112,8 +1127,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1112
1127
|
var cartItems = this.store.cart.getItems();
|
|
1113
1128
|
var resourceIds = [];
|
|
1114
1129
|
cartItems.forEach(function (item) {
|
|
1115
|
-
var _item$
|
|
1116
|
-
(_item$
|
|
1130
|
+
var _item$_productOrigin6;
|
|
1131
|
+
(_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.product_resource) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.resources) === null || _item$_productOrigin6 === void 0 || _item$_productOrigin6.forEach(function (n) {
|
|
1117
1132
|
if (n.code === resources_code) {
|
|
1118
1133
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1119
1134
|
}
|
|
@@ -1132,8 +1147,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1132
1147
|
var accountDuration = 0;
|
|
1133
1148
|
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1134
1149
|
cartItems.forEach(function (item) {
|
|
1135
|
-
var _item$_productOrigin
|
|
1136
|
-
accountDuration += (_item$_productOrigin$ = (_item$
|
|
1150
|
+
var _item$_productOrigin$3, _item$_productOrigin7;
|
|
1151
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1137
1152
|
});
|
|
1138
1153
|
if (accountDuration > duration) {
|
|
1139
1154
|
duration = accountDuration;
|
|
@@ -1173,9 +1188,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1173
1188
|
accountItems.forEach(function (item, index) {
|
|
1174
1189
|
var newResources = cloneDeep(item._origin.resources);
|
|
1175
1190
|
newResources.forEach(function (resource) {
|
|
1176
|
-
var _item$_productOrigin$
|
|
1191
|
+
var _item$_productOrigin$4, _item$_productOrigin8, _ref10, _item$_productOrigin9;
|
|
1177
1192
|
resource.startTime = currentStartTime;
|
|
1178
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$
|
|
1193
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref10 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.type) !== null && _ref10 !== void 0 ? _ref10 : "minutes").format("YYYY-MM-DD HH:mm");
|
|
1179
1194
|
delete resource.times;
|
|
1180
1195
|
});
|
|
1181
1196
|
_this9.store.cart.updateItem({
|
|
@@ -432,15 +432,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
432
432
|
}) {
|
|
433
433
|
const dateRange = this.store.date.getDateRange();
|
|
434
434
|
if (timeSlots) {
|
|
435
|
-
const duration = resourceProductData.product.duration.value;
|
|
436
|
-
const start_time = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
437
|
-
const end_time = (0, import_dayjs.default)(`${dateRange[0].date} ${start_time}`).add(duration, resourceProductData.product.duration.type).format("HH:mm");
|
|
438
435
|
let targetResource = null;
|
|
439
436
|
for (const n of resources) {
|
|
440
437
|
const canUseTime = n.times.find(
|
|
441
438
|
(item) => (0, import_resources.getIsUsableByTimeItem)({
|
|
442
|
-
timeSlice:
|
|
443
|
-
time:
|
|
439
|
+
timeSlice: timeSlots,
|
|
440
|
+
time: item,
|
|
444
441
|
resource: n,
|
|
445
442
|
currentCount: 1
|
|
446
443
|
})
|
|
@@ -504,15 +501,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
504
501
|
});
|
|
505
502
|
});
|
|
506
503
|
if (timeSlots) {
|
|
507
|
-
const start_time = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
508
|
-
const end_time = (0, import_dayjs.default)(`${dateRange[0].date} ${start_time}`).add(duration, durationType).format("HH:mm");
|
|
509
504
|
let targetResource = null;
|
|
510
505
|
for (const n of resources) {
|
|
511
506
|
const recordCount = countMap[n.id] || 0;
|
|
512
507
|
const canUseTime = n.times.find(
|
|
513
508
|
(item) => (0, import_resources.getIsUsableByTimeItem)({
|
|
514
|
-
timeSlice:
|
|
515
|
-
time:
|
|
509
|
+
timeSlice: timeSlots,
|
|
510
|
+
time: item,
|
|
516
511
|
resource: n,
|
|
517
512
|
currentCount: recordCount + 1
|
|
518
513
|
})
|
|
@@ -558,16 +553,27 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
558
553
|
this.store.accountList.getAccounts().forEach((account) => {
|
|
559
554
|
const cartItems = this.store.cart.getCartByAccount(account.getId());
|
|
560
555
|
const allCartItems = this.store.cart.getItems();
|
|
561
|
-
|
|
562
|
-
|
|
556
|
+
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
557
|
+
cartItems.forEach((item, index) => {
|
|
558
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
563
559
|
if (timeSlots) {
|
|
560
|
+
if (index !== 0 && recordTimeSlots) {
|
|
561
|
+
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0, ((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes");
|
|
562
|
+
let end_at = start_at.add(((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) ?? 0, ((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.type) ?? "minutes");
|
|
563
|
+
recordTimeSlots = {
|
|
564
|
+
start_time: start_at.format("HH:mm"),
|
|
565
|
+
end_time: end_at.format("HH:mm"),
|
|
566
|
+
start_at,
|
|
567
|
+
end_at
|
|
568
|
+
};
|
|
569
|
+
}
|
|
564
570
|
const res = this.autoSelectAccountResources({
|
|
565
571
|
holder_id: item.holder_id,
|
|
566
572
|
resources_code,
|
|
567
|
-
timeSlots,
|
|
573
|
+
timeSlots: recordTimeSlots,
|
|
568
574
|
countMap: selectResourcesMap
|
|
569
575
|
});
|
|
570
|
-
if ((
|
|
576
|
+
if ((_i = item._origin.resources) == null ? void 0 : _i.some((n) => {
|
|
571
577
|
var _a2;
|
|
572
578
|
return n.form_id === ((_a2 = res == null ? void 0 : res.selectedResource) == null ? void 0 : _a2.form_id);
|
|
573
579
|
})) {
|
|
@@ -597,9 +603,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
597
603
|
}
|
|
598
604
|
} else {
|
|
599
605
|
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
|
|
600
|
-
const targetRenderList = (
|
|
606
|
+
const targetRenderList = (_j = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _j.renderList;
|
|
601
607
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
602
|
-
if ((
|
|
608
|
+
if ((_k = item._origin.resources) == null ? void 0 : _k.some((n) => n.form_id === targetRenderList[0].form_id)) {
|
|
603
609
|
return;
|
|
604
610
|
}
|
|
605
611
|
const targetResource = targetRenderList[0];
|