@pisell/pisellos 3.0.13 → 3.0.15
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/Step/index.d.ts +16 -0
- package/dist/modules/Step/index.js +54 -5
- package/dist/modules/Step/tyeps.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +7 -2
- package/dist/solution/BookingByStep/index.js +172 -60
- package/lib/modules/Step/index.d.ts +16 -0
- package/lib/modules/Step/index.js +44 -5
- package/lib/modules/Step/tyeps.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +7 -2
- package/lib/solution/BookingByStep/index.js +113 -29
- package/package.json +1 -1
|
@@ -16,8 +16,18 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
16
16
|
getStepList(): IStep[];
|
|
17
17
|
getCurrentStep(): IStep;
|
|
18
18
|
getCurrentStepIndex(): number;
|
|
19
|
+
/**
|
|
20
|
+
* 上一个步骤
|
|
21
|
+
*/
|
|
19
22
|
prevStep(): void;
|
|
23
|
+
/**
|
|
24
|
+
* 下一个步骤
|
|
25
|
+
*/
|
|
20
26
|
nextStep(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 跳转到指定步骤
|
|
29
|
+
* @param stepIndex 步骤的 index
|
|
30
|
+
*/
|
|
21
31
|
gotoStep(stepIndex: number): void;
|
|
22
32
|
/**
|
|
23
33
|
* 添加步骤
|
|
@@ -30,5 +40,11 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
30
40
|
* @param key 步骤的 key
|
|
31
41
|
*/
|
|
32
42
|
removeStep(key: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* 更新步骤
|
|
45
|
+
* @param key 步骤的 key
|
|
46
|
+
* @param step 步骤
|
|
47
|
+
*/
|
|
48
|
+
updateStep(key: string, step: IStep): void;
|
|
33
49
|
storeChange(): void;
|
|
34
50
|
}
|
|
@@ -84,7 +84,8 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
84
84
|
}, {
|
|
85
85
|
key: "setCurrentStep",
|
|
86
86
|
value: function setCurrentStep(stepIndex) {
|
|
87
|
-
|
|
87
|
+
var _this$store$stepList;
|
|
88
|
+
if (stepIndex < 0 || stepIndex >= ((_this$store$stepList = this.store.stepList) === null || _this$store$stepList === void 0 ? void 0 : _this$store$stepList.length)) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
this.store.currentStepIndex = stepIndex;
|
|
@@ -105,20 +106,45 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
105
106
|
value: function getCurrentStepIndex() {
|
|
106
107
|
return this.store.currentStepIndex;
|
|
107
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 上一个步骤
|
|
112
|
+
*/
|
|
108
113
|
}, {
|
|
109
114
|
key: "prevStep",
|
|
110
115
|
value: function prevStep() {
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
// 如果上一个步骤是跳过,则继续往前找,直到找到一个不是跳过的步骤
|
|
117
|
+
var prevStepIndex = this.store.currentStepIndex - 1;
|
|
118
|
+
while ((_this$store$stepList$ = this.store.stepList[prevStepIndex]) !== null && _this$store$stepList$ !== void 0 && _this$store$stepList$.isSkip) {
|
|
119
|
+
var _this$store$stepList$;
|
|
120
|
+
prevStepIndex--;
|
|
121
|
+
}
|
|
122
|
+
if (prevStepIndex >= 0) {
|
|
123
|
+
this.setCurrentStep(prevStepIndex);
|
|
113
124
|
}
|
|
114
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 下一个步骤
|
|
129
|
+
*/
|
|
115
130
|
}, {
|
|
116
131
|
key: "nextStep",
|
|
117
132
|
value: function nextStep() {
|
|
118
|
-
|
|
119
|
-
|
|
133
|
+
// 如果下一个步骤是跳过,则继续往后找,直到找到一个不是跳过的步骤
|
|
134
|
+
var nextStepIndex = this.store.currentStepIndex + 1;
|
|
135
|
+
while ((_this$store$stepList$2 = this.store.stepList[nextStepIndex]) !== null && _this$store$stepList$2 !== void 0 && _this$store$stepList$2.isSkip) {
|
|
136
|
+
var _this$store$stepList$2;
|
|
137
|
+
nextStepIndex++;
|
|
138
|
+
}
|
|
139
|
+
if (nextStepIndex < this.store.stepList.length) {
|
|
140
|
+
this.setCurrentStep(nextStepIndex);
|
|
120
141
|
}
|
|
121
142
|
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 跳转到指定步骤
|
|
146
|
+
* @param stepIndex 步骤的 index
|
|
147
|
+
*/
|
|
122
148
|
}, {
|
|
123
149
|
key: "gotoStep",
|
|
124
150
|
value: function gotoStep(stepIndex) {
|
|
@@ -170,6 +196,29 @@ export var StepModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
170
196
|
});
|
|
171
197
|
this.store.stepList = _toConsumableArray(newStepList);
|
|
172
198
|
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 更新步骤
|
|
202
|
+
* @param key 步骤的 key
|
|
203
|
+
* @param step 步骤
|
|
204
|
+
*/
|
|
205
|
+
}, {
|
|
206
|
+
key: "updateStep",
|
|
207
|
+
value: function updateStep(key, step) {
|
|
208
|
+
var _this$store$stepList2, _this$store$currentSt;
|
|
209
|
+
var newStepList = (_this$store$stepList2 = this.store.stepList) === null || _this$store$stepList2 === void 0 ? void 0 : _this$store$stepList2.map(function (n) {
|
|
210
|
+
if (n.key === key) {
|
|
211
|
+
return step;
|
|
212
|
+
}
|
|
213
|
+
return n;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// 如果更新的是当前步骤,则更新当前步骤
|
|
217
|
+
if (key === ((_this$store$currentSt = this.store.currentStep) === null || _this$store$currentSt === void 0 ? void 0 : _this$store$currentSt.key)) {
|
|
218
|
+
this.store.currentStep = step;
|
|
219
|
+
}
|
|
220
|
+
this.store.stepList = _toConsumableArray(newStepList || []);
|
|
221
|
+
}
|
|
173
222
|
}, {
|
|
174
223
|
key: "storeChange",
|
|
175
224
|
value: function storeChange() {
|
|
@@ -38,6 +38,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
38
38
|
* 删除step
|
|
39
39
|
*/
|
|
40
40
|
removeStep(key: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* 更新step
|
|
43
|
+
*/
|
|
44
|
+
updateStep(key: string, step: IStep): void;
|
|
41
45
|
loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
|
|
42
46
|
category_ids?: number[];
|
|
43
47
|
product_ids?: number[];
|
|
@@ -51,7 +55,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
51
55
|
category_ids?: number[];
|
|
52
56
|
}): Promise<any>;
|
|
53
57
|
loadAllSchedule(): Promise<void>;
|
|
54
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel }: {
|
|
58
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: {
|
|
55
59
|
startDate: string;
|
|
56
60
|
endDate: string;
|
|
57
61
|
custom_page_id?: number;
|
|
@@ -156,7 +160,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
156
160
|
resources: any[];
|
|
157
161
|
currentResourceId: number;
|
|
158
162
|
}): TimeSliceItem[];
|
|
159
|
-
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, capacity, }: {
|
|
163
|
+
autoSelectAccountResources({ cartItem, holder_id, resources_code, timeSlots, countMap, capacity, }: {
|
|
164
|
+
cartItem: CartItem;
|
|
160
165
|
holder_id: string;
|
|
161
166
|
resources_code: string | number;
|
|
162
167
|
timeSlots?: TimeSliceItem;
|
|
@@ -182,6 +182,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
182
182
|
value: function removeStep(key) {
|
|
183
183
|
this.store.step.removeStep(key);
|
|
184
184
|
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 更新step
|
|
188
|
+
*/
|
|
189
|
+
}, {
|
|
190
|
+
key: "updateStep",
|
|
191
|
+
value: function updateStep(key, step) {
|
|
192
|
+
this.store.step.updateStep(key, step);
|
|
193
|
+
}
|
|
194
|
+
|
|
185
195
|
// 获取购物车里 temp.xxx的方法
|
|
186
196
|
// async getStoreCart(key?: string) {
|
|
187
197
|
// return this.store.cart.getTemp(key);
|
|
@@ -296,7 +306,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
306
|
while (1) switch (_context4.prev = _context4.next) {
|
|
297
307
|
case 0:
|
|
298
308
|
_context4.next = 2;
|
|
299
|
-
return this.request.get("/schedule");
|
|
309
|
+
return this.request.get("/schedule?num=999");
|
|
300
310
|
case 2:
|
|
301
311
|
scheduleList = _context4.sent;
|
|
302
312
|
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
@@ -1044,7 +1054,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1044
1054
|
// 检查主资源ID是否匹配
|
|
1045
1055
|
if (targetRes.id === m.id) return true;
|
|
1046
1056
|
// 检查组合资源的情况
|
|
1047
|
-
if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 &&
|
|
1057
|
+
if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
|
|
1058
|
+
// 如果现在选择的是组合资源,需要判断
|
|
1059
|
+
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
1060
|
+
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
1061
|
+
|
|
1062
|
+
targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
|
|
1063
|
+
return m.metadata.combined_resource.resource_ids.includes(n);
|
|
1064
|
+
}))) return true;
|
|
1048
1065
|
if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
|
|
1049
1066
|
return false;
|
|
1050
1067
|
});
|
|
@@ -1196,7 +1213,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1213
|
});
|
|
1197
1214
|
n.renderList = n.renderList.filter(function (m) {
|
|
1198
1215
|
var recordCount = capacityMap[m.id] || 0;
|
|
1199
|
-
|
|
1216
|
+
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1217
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1218
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1219
|
+
var mTimes = m.times.filter(function (n) {
|
|
1220
|
+
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
1221
|
+
});
|
|
1222
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1223
|
+
if (mTimes.length === 0) {
|
|
1224
|
+
return false;
|
|
1225
|
+
}
|
|
1226
|
+
var canUseArr = mTimes.map(function (item) {
|
|
1200
1227
|
var res = getIsUsableByTimeItem({
|
|
1201
1228
|
timeSlice: {
|
|
1202
1229
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1225,10 +1252,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1225
1252
|
} else {
|
|
1226
1253
|
productResources.forEach(function (item) {
|
|
1227
1254
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1255
|
+
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1228
1256
|
item.renderList = item.renderList.filter(function (n) {
|
|
1257
|
+
var _cartItem$_productOri3;
|
|
1229
1258
|
var recordCount = n.capacity || 0;
|
|
1230
1259
|
if (n.onlyComputed) return false;
|
|
1231
|
-
|
|
1260
|
+
// 查一下这个资源基于商品的可用时间片
|
|
1261
|
+
var timeSlots = getTimeSlicesByResource({
|
|
1262
|
+
resource: n,
|
|
1263
|
+
duration: ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.value) || 0,
|
|
1264
|
+
split: 10,
|
|
1265
|
+
currentDate: dateRange[0].date
|
|
1266
|
+
});
|
|
1267
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1232
1268
|
});
|
|
1233
1269
|
});
|
|
1234
1270
|
}
|
|
@@ -1324,7 +1360,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1324
1360
|
}, {
|
|
1325
1361
|
key: "autoSelectAccountResources",
|
|
1326
1362
|
value: function autoSelectAccountResources(_ref8) {
|
|
1327
|
-
var
|
|
1363
|
+
var _cartItem$_productOri4, _allProductResources$;
|
|
1364
|
+
var cartItem = _ref8.cartItem,
|
|
1365
|
+
holder_id = _ref8.holder_id,
|
|
1328
1366
|
resources_code = _ref8.resources_code,
|
|
1329
1367
|
timeSlots = _ref8.timeSlots,
|
|
1330
1368
|
countMap = _ref8.countMap,
|
|
@@ -1347,15 +1385,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1347
1385
|
// 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
|
|
1348
1386
|
// let durationType = accountCartItems[0]?._productOrigin?.duration?.type ?? "minutes";
|
|
1349
1387
|
// 取出账号下所对应类型的所有的可用资源
|
|
1350
|
-
|
|
1351
|
-
accountCartItems.forEach(
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1388
|
+
// let resourcesCartItems: any[] = [];
|
|
1389
|
+
// accountCartItems.forEach((item) => {
|
|
1390
|
+
// item._productOrigin?.product_resource?.resources?.forEach((n) => {
|
|
1391
|
+
// if (n.code === resources_code) {
|
|
1392
|
+
// resourcesCartItems.push(...(n.renderList || []));
|
|
1393
|
+
// }
|
|
1394
|
+
// });
|
|
1395
|
+
// });
|
|
1396
|
+
var AllResources = [];
|
|
1397
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1398
|
+
dateRange.forEach(function (n) {
|
|
1399
|
+
if (n.resource) AllResources.push.apply(AllResources, _toConsumableArray(n.resource));
|
|
1357
1400
|
});
|
|
1358
|
-
}
|
|
1401
|
+
}
|
|
1402
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1403
|
+
if (!AllResources.length) {
|
|
1404
|
+
var dateList = this.store.date.getDateList();
|
|
1405
|
+
dateList.forEach(function (n) {
|
|
1406
|
+
if (n.resource) AllResources.push.apply(AllResources, _toConsumableArray(n.resource));
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1410
|
+
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1411
|
+
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1412
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.product_resource) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.resources) || [], selectedResources, 1);
|
|
1413
|
+
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1414
|
+
return n.code === resources_code;
|
|
1415
|
+
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
1359
1416
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1360
1417
|
resources.sort(function (a, b) {
|
|
1361
1418
|
var _a$metadata2, _b$metadata2;
|
|
@@ -1365,7 +1422,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1365
1422
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1366
1423
|
return 0;
|
|
1367
1424
|
});
|
|
1368
|
-
var resourcesUseableMap = {
|
|
1425
|
+
var resourcesUseableMap = _toConsumableArray(selectedResources).reduce(function (acc, n) {
|
|
1426
|
+
acc[n] = false;
|
|
1427
|
+
return acc;
|
|
1428
|
+
}, {});
|
|
1369
1429
|
|
|
1370
1430
|
// 如果有选择时间了,则代表不是第一种资源了,则需要根据开始时间去匹配
|
|
1371
1431
|
// 每个商品
|
|
@@ -1380,29 +1440,47 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1380
1440
|
_step2;
|
|
1381
1441
|
try {
|
|
1382
1442
|
var _loop = function _loop() {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1443
|
+
var n = _step2.value;
|
|
1444
|
+
// 如果资源是独占的,并且 countMap 里选择过这个资源,则直接跳过
|
|
1445
|
+
// if (n.resourceType === 'single' && countMap[n.id]) {
|
|
1446
|
+
// resourcesUseableMap[n.id] = false;
|
|
1447
|
+
// continue
|
|
1448
|
+
// }
|
|
1449
|
+
var recordCount = countMap[n.id] || 0;
|
|
1450
|
+
// n.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1451
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1452
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1453
|
+
var mTimes = n.times.filter(function (n) {
|
|
1454
|
+
return !dayjs(n.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(n.end_at).isBefore(dayjs(timeSlots.end_at));
|
|
1392
1455
|
});
|
|
1393
|
-
//
|
|
1394
|
-
if (
|
|
1395
|
-
|
|
1456
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1457
|
+
if (mTimes.length === 0) {
|
|
1458
|
+
return 0; // continue
|
|
1396
1459
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1460
|
+
var canUseTime = mTimes.find(function (item) {
|
|
1461
|
+
var res = getIsUsableByTimeItem({
|
|
1462
|
+
timeSlice: timeSlots,
|
|
1463
|
+
time: item,
|
|
1464
|
+
resource: n,
|
|
1465
|
+
currentCount: recordCount + (capacity || 0),
|
|
1466
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1467
|
+
});
|
|
1468
|
+
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1469
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1470
|
+
resourcesUseableMap[n.id] = res.usable;
|
|
1471
|
+
}
|
|
1472
|
+
return res.usable;
|
|
1473
|
+
});
|
|
1474
|
+
if (canUseTime && !n.onlyComputed) {
|
|
1475
|
+
targetResource = n;
|
|
1476
|
+
return 1; // break
|
|
1477
|
+
}
|
|
1478
|
+
},
|
|
1479
|
+
_ret;
|
|
1404
1480
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1405
|
-
|
|
1481
|
+
_ret = _loop();
|
|
1482
|
+
if (_ret === 0) continue;
|
|
1483
|
+
if (_ret === 1) break;
|
|
1406
1484
|
}
|
|
1407
1485
|
} catch (err) {
|
|
1408
1486
|
_iterator2.e(err);
|
|
@@ -1413,13 +1491,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1413
1491
|
selectedResource: targetResource
|
|
1414
1492
|
};
|
|
1415
1493
|
} else {
|
|
1416
|
-
var
|
|
1494
|
+
var _resourcesMap = getResourcesMap(resources);
|
|
1417
1495
|
var resourceIds = resources.map(function (n) {
|
|
1418
1496
|
return n.id;
|
|
1419
1497
|
});
|
|
1420
1498
|
var _timeSlots = getTimeSlicesByResources({
|
|
1421
1499
|
resourceIds: resourceIds,
|
|
1422
|
-
resourcesMap:
|
|
1500
|
+
resourcesMap: _resourcesMap,
|
|
1423
1501
|
duration: duration,
|
|
1424
1502
|
currentDate: dateRange[0].date,
|
|
1425
1503
|
split: 10,
|
|
@@ -1462,9 +1540,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1462
1540
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
1463
1541
|
|
|
1464
1542
|
cartItems.forEach(function (item, index) {
|
|
1465
|
-
var _item$
|
|
1543
|
+
var _item$_productOrigin2;
|
|
1466
1544
|
var formatCapacity = formatDefaultCapacitys({
|
|
1467
|
-
capacity: (_item$
|
|
1545
|
+
capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
|
|
1468
1546
|
product_bundle: item._origin.product.product_bundle
|
|
1469
1547
|
});
|
|
1470
1548
|
var currentCapacity = getSumCapacity({
|
|
@@ -1481,9 +1559,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1481
1559
|
}
|
|
1482
1560
|
if (recordTimeSlots) {
|
|
1483
1561
|
if (index !== 0 && recordTimeSlots) {
|
|
1484
|
-
var _item$_productOrigin$, _item$
|
|
1485
|
-
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$
|
|
1486
|
-
var end_at = start_at.add((_item$_productOrigin$2 = (_item$
|
|
1562
|
+
var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
|
|
1563
|
+
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1564
|
+
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1487
1565
|
recordTimeSlots = {
|
|
1488
1566
|
start_time: start_at.format('HH:mm'),
|
|
1489
1567
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1493,6 +1571,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1493
1571
|
}
|
|
1494
1572
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1495
1573
|
var res = _this8.autoSelectAccountResources({
|
|
1574
|
+
cartItem: item,
|
|
1496
1575
|
holder_id: item.holder_id,
|
|
1497
1576
|
resources_code: resources_code,
|
|
1498
1577
|
timeSlots: recordTimeSlots,
|
|
@@ -1515,7 +1594,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1515
1594
|
_id: item._id,
|
|
1516
1595
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1517
1596
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1518
|
-
|
|
1597
|
+
var _res$selectedResource;
|
|
1598
|
+
return existingRes.form_id !== ((_res$selectedResource = res.selectedResource) === null || _res$selectedResource === void 0 ? void 0 : _res$selectedResource.form_id);
|
|
1519
1599
|
})), [res.selectedResource])
|
|
1520
1600
|
});
|
|
1521
1601
|
} else {
|
|
@@ -1523,31 +1603,38 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1523
1603
|
errorList.push(item._id);
|
|
1524
1604
|
}
|
|
1525
1605
|
} else {
|
|
1526
|
-
var _item$
|
|
1606
|
+
var _item$_productOrigin7, _productResources$fin;
|
|
1527
1607
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1528
1608
|
var allCartItems = cloneDeep(_this8.store.cart.getItems());
|
|
1529
1609
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1530
1610
|
var selectedResources = [];
|
|
1531
|
-
var _resources = cloneDeep(((_item$
|
|
1611
|
+
var _resources = cloneDeep(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.resources) || []);
|
|
1532
1612
|
var currentResourcesRenderList = [];
|
|
1533
1613
|
_resources.forEach(function (n) {
|
|
1534
1614
|
var _n$renderList;
|
|
1535
1615
|
if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
|
|
1536
1616
|
// 过滤掉 capacity 小于 currentCapacity 的资源
|
|
1537
1617
|
n.renderList = n.renderList.filter(function (m) {
|
|
1618
|
+
var _item$duration;
|
|
1538
1619
|
var recordCount = m.capacity || 0;
|
|
1539
|
-
|
|
1620
|
+
var timeSlots = getTimeSlicesByResource({
|
|
1621
|
+
resource: m,
|
|
1622
|
+
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
|
|
1623
|
+
split: 10,
|
|
1624
|
+
currentDate: dateRange[0].date
|
|
1625
|
+
});
|
|
1626
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1540
1627
|
});
|
|
1541
1628
|
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1542
1629
|
}
|
|
1543
1630
|
});
|
|
1544
|
-
var
|
|
1631
|
+
var _resourcesMap2 = getResourcesMap(currentResourcesRenderList);
|
|
1545
1632
|
if (item.holder_id) {
|
|
1546
|
-
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id,
|
|
1633
|
+
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, _resourcesMap2);
|
|
1547
1634
|
} else {
|
|
1548
|
-
selectedResources = getOthersCartSelectedResources(allCartItems, item._id,
|
|
1635
|
+
selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap2);
|
|
1549
1636
|
}
|
|
1550
|
-
var productResources = getResourcesByProduct(
|
|
1637
|
+
var productResources = getResourcesByProduct(_resourcesMap2, cloneDeep(_resources), selectedResources, currentCapacity);
|
|
1551
1638
|
productResources.forEach(function (item) {
|
|
1552
1639
|
item.renderList = item.renderList.filter(function (n) {
|
|
1553
1640
|
var recordCount = n.capacity || 0;
|
|
@@ -1615,8 +1702,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1615
1702
|
var resourceIds = [];
|
|
1616
1703
|
var resourcesTypeId = undefined;
|
|
1617
1704
|
cartItems.forEach(function (item) {
|
|
1618
|
-
var _item$
|
|
1619
|
-
(_item$
|
|
1705
|
+
var _item$_productOrigin8, _item$_productOrigin9;
|
|
1706
|
+
(_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.resources) === null || _item$_productOrigin8 === void 0 || _item$_productOrigin8.forEach(function (n) {
|
|
1620
1707
|
if (n.code === resources_code) {
|
|
1621
1708
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1622
1709
|
}
|
|
@@ -1627,9 +1714,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1627
1714
|
if (item.resource_id) {
|
|
1628
1715
|
resourceIds.push(item.resource_id);
|
|
1629
1716
|
}
|
|
1630
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
1717
|
+
resourcesTypeId = item === null || item === void 0 || (_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 = _item$_productOrigin9.find(function (n) {
|
|
1631
1718
|
return n.code === resources_code;
|
|
1632
|
-
})) === null || _item$
|
|
1719
|
+
})) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.id;
|
|
1633
1720
|
});
|
|
1634
1721
|
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1635
1722
|
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
@@ -1649,8 +1736,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1649
1736
|
var checkDuration = function checkDuration(cartItems) {
|
|
1650
1737
|
var accountDuration = 0;
|
|
1651
1738
|
cartItems.forEach(function (item) {
|
|
1652
|
-
var _item$_productOrigin$3, _item$
|
|
1653
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1739
|
+
var _item$_productOrigin$3, _item$_productOrigin10;
|
|
1740
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1654
1741
|
});
|
|
1655
1742
|
if (accountDuration > duration) {
|
|
1656
1743
|
duration = accountDuration;
|
|
@@ -1719,9 +1806,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1719
1806
|
accountItems.forEach(function (item, index) {
|
|
1720
1807
|
var newResources = cloneDeep(item._origin.resources);
|
|
1721
1808
|
newResources.forEach(function (resource) {
|
|
1722
|
-
var _item$_productOrigin$4, _item$
|
|
1809
|
+
var _item$_productOrigin$4, _item$_productOrigin11, _ref11, _item$_productOrigin12;
|
|
1723
1810
|
resource.startTime = currentStartTime;
|
|
1724
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
1811
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_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$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1725
1812
|
delete resource.times;
|
|
1726
1813
|
});
|
|
1727
1814
|
_this10.store.cart.updateItem({
|
|
@@ -1762,6 +1849,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1762
1849
|
});
|
|
1763
1850
|
});
|
|
1764
1851
|
var newScheduleArr = Object.values(newSchedule);
|
|
1852
|
+
// newScheduleArr 需要做个排序,按日期从小到大
|
|
1853
|
+
newScheduleArr.sort(function (a, b) {
|
|
1854
|
+
return dayjs(a.date).diff(dayjs(b.date));
|
|
1855
|
+
});
|
|
1765
1856
|
return newScheduleArr;
|
|
1766
1857
|
}
|
|
1767
1858
|
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
@@ -1841,14 +1932,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1841
1932
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1842
1933
|
return 0;
|
|
1843
1934
|
});
|
|
1844
|
-
|
|
1935
|
+
|
|
1845
1936
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
1846
1937
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
1938
|
+
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
1939
|
+
var resourcesUseableMap = {};
|
|
1847
1940
|
var count = 0;
|
|
1848
1941
|
// 遍历所有资源
|
|
1849
1942
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
1850
1943
|
// 遍历所有资源的上工时间片
|
|
1851
|
-
|
|
1944
|
+
var currentResourcesCount = 0;
|
|
1945
|
+
var currentResourcesTimeSlotCanUsedArr = [];
|
|
1946
|
+
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1947
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1948
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1949
|
+
var mTimes = m.times.filter(function (n) {
|
|
1950
|
+
return !dayjs(n.start_at).isAfter(dayjs(item.start)) && !dayjs(n.end_at).isBefore(dayjs(item.end));
|
|
1951
|
+
});
|
|
1952
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1953
|
+
if (mTimes.length === 0) {
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
mTimes.forEach(function (childTiem) {
|
|
1852
1957
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
1853
1958
|
var res = getIsUsableByTimeItem({
|
|
1854
1959
|
timeSlice: {
|
|
@@ -1867,9 +1972,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1867
1972
|
resourcesUseableMap[m.id] = res.usable;
|
|
1868
1973
|
}
|
|
1869
1974
|
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1870
|
-
|
|
1975
|
+
currentResourcesCount = res.remainingCapacity;
|
|
1871
1976
|
}
|
|
1977
|
+
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1872
1978
|
});
|
|
1979
|
+
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
1980
|
+
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
1981
|
+
return n === false;
|
|
1982
|
+
}) && currentResourcesCount >= count) {
|
|
1983
|
+
count = currentResourcesCount;
|
|
1984
|
+
}
|
|
1873
1985
|
});
|
|
1874
1986
|
var startDayJs = dayjs(item.start);
|
|
1875
1987
|
var endDayJs = dayjs(item.end);
|
|
@@ -16,8 +16,18 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
16
16
|
getStepList(): IStep[];
|
|
17
17
|
getCurrentStep(): IStep;
|
|
18
18
|
getCurrentStepIndex(): number;
|
|
19
|
+
/**
|
|
20
|
+
* 上一个步骤
|
|
21
|
+
*/
|
|
19
22
|
prevStep(): void;
|
|
23
|
+
/**
|
|
24
|
+
* 下一个步骤
|
|
25
|
+
*/
|
|
20
26
|
nextStep(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 跳转到指定步骤
|
|
29
|
+
* @param stepIndex 步骤的 index
|
|
30
|
+
*/
|
|
21
31
|
gotoStep(stepIndex: number): void;
|
|
22
32
|
/**
|
|
23
33
|
* 添加步骤
|
|
@@ -30,5 +40,11 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
30
40
|
* @param key 步骤的 key
|
|
31
41
|
*/
|
|
32
42
|
removeStep(key: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* 更新步骤
|
|
45
|
+
* @param key 步骤的 key
|
|
46
|
+
* @param step 步骤
|
|
47
|
+
*/
|
|
48
|
+
updateStep(key: string, step: IStep): void;
|
|
33
49
|
storeChange(): void;
|
|
34
50
|
}
|
|
@@ -55,7 +55,8 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
55
55
|
this.store.stepList = stepList;
|
|
56
56
|
}
|
|
57
57
|
setCurrentStep(stepIndex) {
|
|
58
|
-
|
|
58
|
+
var _a;
|
|
59
|
+
if (stepIndex < 0 || stepIndex >= ((_a = this.store.stepList) == null ? void 0 : _a.length)) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
62
|
this.store.currentStepIndex = stepIndex;
|
|
@@ -70,16 +71,36 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
70
71
|
getCurrentStepIndex() {
|
|
71
72
|
return this.store.currentStepIndex;
|
|
72
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* 上一个步骤
|
|
76
|
+
*/
|
|
73
77
|
prevStep() {
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
let prevStepIndex = this.store.currentStepIndex - 1;
|
|
80
|
+
while ((_a = this.store.stepList[prevStepIndex]) == null ? void 0 : _a.isSkip) {
|
|
81
|
+
prevStepIndex--;
|
|
82
|
+
}
|
|
83
|
+
if (prevStepIndex >= 0) {
|
|
84
|
+
this.setCurrentStep(prevStepIndex);
|
|
76
85
|
}
|
|
77
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* 下一个步骤
|
|
89
|
+
*/
|
|
78
90
|
nextStep() {
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
var _a;
|
|
92
|
+
let nextStepIndex = this.store.currentStepIndex + 1;
|
|
93
|
+
while ((_a = this.store.stepList[nextStepIndex]) == null ? void 0 : _a.isSkip) {
|
|
94
|
+
nextStepIndex++;
|
|
95
|
+
}
|
|
96
|
+
if (nextStepIndex < this.store.stepList.length) {
|
|
97
|
+
this.setCurrentStep(nextStepIndex);
|
|
81
98
|
}
|
|
82
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* 跳转到指定步骤
|
|
102
|
+
* @param stepIndex 步骤的 index
|
|
103
|
+
*/
|
|
83
104
|
gotoStep(stepIndex) {
|
|
84
105
|
this.setCurrentStep(stepIndex);
|
|
85
106
|
}
|
|
@@ -115,6 +136,24 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
115
136
|
const newStepList = this.store.stepList.filter((n) => n.key !== key);
|
|
116
137
|
this.store.stepList = [...newStepList];
|
|
117
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* 更新步骤
|
|
141
|
+
* @param key 步骤的 key
|
|
142
|
+
* @param step 步骤
|
|
143
|
+
*/
|
|
144
|
+
updateStep(key, step) {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
const newStepList = (_a = this.store.stepList) == null ? void 0 : _a.map((n) => {
|
|
147
|
+
if (n.key === key) {
|
|
148
|
+
return step;
|
|
149
|
+
}
|
|
150
|
+
return n;
|
|
151
|
+
});
|
|
152
|
+
if (key === ((_b = this.store.currentStep) == null ? void 0 : _b.key)) {
|
|
153
|
+
this.store.currentStep = step;
|
|
154
|
+
}
|
|
155
|
+
this.store.stepList = [...newStepList || []];
|
|
156
|
+
}
|
|
118
157
|
storeChange() {
|
|
119
158
|
if (this.openCache) {
|
|
120
159
|
this.checkSaveCache({
|
|
@@ -38,6 +38,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
38
38
|
* 删除step
|
|
39
39
|
*/
|
|
40
40
|
removeStep(key: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* 更新step
|
|
43
|
+
*/
|
|
44
|
+
updateStep(key: string, step: IStep): void;
|
|
41
45
|
loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
|
|
42
46
|
category_ids?: number[];
|
|
43
47
|
product_ids?: number[];
|
|
@@ -51,7 +55,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
51
55
|
category_ids?: number[];
|
|
52
56
|
}): Promise<any>;
|
|
53
57
|
loadAllSchedule(): Promise<void>;
|
|
54
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel }: {
|
|
58
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: {
|
|
55
59
|
startDate: string;
|
|
56
60
|
endDate: string;
|
|
57
61
|
custom_page_id?: number;
|
|
@@ -156,7 +160,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
156
160
|
resources: any[];
|
|
157
161
|
currentResourceId: number;
|
|
158
162
|
}): TimeSliceItem[];
|
|
159
|
-
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, capacity, }: {
|
|
163
|
+
autoSelectAccountResources({ cartItem, holder_id, resources_code, timeSlots, countMap, capacity, }: {
|
|
164
|
+
cartItem: CartItem;
|
|
160
165
|
holder_id: string;
|
|
161
166
|
resources_code: string | number;
|
|
162
167
|
timeSlots?: TimeSliceItem;
|
|
@@ -142,6 +142,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
142
142
|
removeStep(key) {
|
|
143
143
|
this.store.step.removeStep(key);
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* 更新step
|
|
147
|
+
*/
|
|
148
|
+
updateStep(key, step) {
|
|
149
|
+
this.store.step.updateStep(key, step);
|
|
150
|
+
}
|
|
145
151
|
// 获取购物车里 temp.xxx的方法
|
|
146
152
|
// async getStoreCart(key?: string) {
|
|
147
153
|
// return this.store.cart.getTemp(key);
|
|
@@ -203,7 +209,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
203
209
|
// 加载当前店铺下所有 schedule
|
|
204
210
|
async loadAllSchedule() {
|
|
205
211
|
var _a;
|
|
206
|
-
const scheduleList = await this.request.get(`/schedule`);
|
|
212
|
+
const scheduleList = await this.request.get(`/schedule?num=999`);
|
|
207
213
|
this.store.schedule.setScheduleList(((_a = scheduleList.data) == null ? void 0 : _a.list) || []);
|
|
208
214
|
}
|
|
209
215
|
// ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
@@ -505,7 +511,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
505
511
|
var _a3, _b;
|
|
506
512
|
if (targetRes.id === m.id)
|
|
507
513
|
return true;
|
|
508
|
-
if (((_a3 = targetRes.metadata.combined_resource) == null ? void 0 : _a3.status) === 1 &&
|
|
514
|
+
if (((_a3 = targetRes.metadata.combined_resource) == null ? void 0 : _a3.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
515
|
+
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
516
|
+
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
517
|
+
(targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some((n) => {
|
|
518
|
+
return m.metadata.combined_resource.resource_ids.includes(n);
|
|
519
|
+
})))
|
|
509
520
|
return true;
|
|
510
521
|
if (((_b = m.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
|
|
511
522
|
return true;
|
|
@@ -648,7 +659,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
648
659
|
});
|
|
649
660
|
n.renderList = n.renderList.filter((m) => {
|
|
650
661
|
const recordCount = capacityMap[m.id] || 0;
|
|
651
|
-
const
|
|
662
|
+
const mTimes = m.times.filter((n2) => {
|
|
663
|
+
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
664
|
+
});
|
|
665
|
+
if (mTimes.length === 0) {
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
const canUseArr = mTimes.map((item) => {
|
|
652
669
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
653
670
|
timeSlice: {
|
|
654
671
|
start_time: startTime.format("HH:mm"),
|
|
@@ -674,10 +691,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
674
691
|
} else {
|
|
675
692
|
productResources.forEach((item) => {
|
|
676
693
|
item.renderList = item.renderList.filter((n) => {
|
|
694
|
+
var _a2, _b2;
|
|
677
695
|
const recordCount = n.capacity || 0;
|
|
678
696
|
if (n.onlyComputed)
|
|
679
697
|
return false;
|
|
680
|
-
|
|
698
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
699
|
+
resource: n,
|
|
700
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
|
|
701
|
+
split: 10,
|
|
702
|
+
currentDate: dateRange[0].date
|
|
703
|
+
});
|
|
704
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
681
705
|
});
|
|
682
706
|
});
|
|
683
707
|
}
|
|
@@ -772,12 +796,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
772
796
|
}
|
|
773
797
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
774
798
|
autoSelectAccountResources({
|
|
799
|
+
cartItem,
|
|
775
800
|
holder_id,
|
|
776
801
|
resources_code,
|
|
777
802
|
timeSlots,
|
|
778
803
|
countMap,
|
|
779
804
|
capacity
|
|
780
805
|
}) {
|
|
806
|
+
var _a, _b, _c;
|
|
781
807
|
const dateRange = this.store.date.getDateRange();
|
|
782
808
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
783
809
|
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
@@ -785,34 +811,62 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
785
811
|
accountCartItems = cartItems;
|
|
786
812
|
}
|
|
787
813
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
788
|
-
var
|
|
789
|
-
return acc + (((
|
|
814
|
+
var _a2, _b2;
|
|
815
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0);
|
|
790
816
|
}, 0);
|
|
791
|
-
let
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
resources.push(...n.renderList || []);
|
|
797
|
-
}
|
|
817
|
+
let AllResources = [];
|
|
818
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
819
|
+
dateRange.forEach((n) => {
|
|
820
|
+
if (n.resource)
|
|
821
|
+
AllResources.push(...n.resource);
|
|
798
822
|
});
|
|
799
|
-
}
|
|
823
|
+
}
|
|
824
|
+
if (!AllResources.length) {
|
|
825
|
+
const dateList = this.store.date.getDateList();
|
|
826
|
+
dateList.forEach((n) => {
|
|
827
|
+
if (n.resource)
|
|
828
|
+
AllResources.push(...n.resource);
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(AllResources));
|
|
832
|
+
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
833
|
+
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
834
|
+
allCartItems,
|
|
835
|
+
holder_id,
|
|
836
|
+
resourcesMap
|
|
837
|
+
);
|
|
838
|
+
let allProductResources = (0, import_resources.getResourcesByProduct)(
|
|
839
|
+
resourcesMap,
|
|
840
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
841
|
+
selectedResources,
|
|
842
|
+
1
|
|
843
|
+
);
|
|
844
|
+
const resources = ((_c = allProductResources.find((n) => n.code === resources_code)) == null ? void 0 : _c.renderList) || [];
|
|
800
845
|
resources.sort((a, b) => {
|
|
801
|
-
var
|
|
802
|
-
const aIsCombined = ((
|
|
803
|
-
const bIsCombined = ((_d = (
|
|
846
|
+
var _a2, _b2, _c2, _d;
|
|
847
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
848
|
+
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
804
849
|
if (aIsCombined && !bIsCombined)
|
|
805
850
|
return 1;
|
|
806
851
|
if (!aIsCombined && bIsCombined)
|
|
807
852
|
return -1;
|
|
808
853
|
return 0;
|
|
809
854
|
});
|
|
810
|
-
const resourcesUseableMap = {
|
|
855
|
+
const resourcesUseableMap = [...selectedResources].reduce((acc, n) => {
|
|
856
|
+
acc[n] = false;
|
|
857
|
+
return acc;
|
|
858
|
+
}, {});
|
|
811
859
|
if (timeSlots) {
|
|
812
860
|
let targetResource = null;
|
|
813
861
|
for (const n of resources) {
|
|
814
862
|
const recordCount = countMap[n.id] || 0;
|
|
815
|
-
const
|
|
863
|
+
const mTimes = n.times.filter((n2) => {
|
|
864
|
+
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(timeSlots.end_at));
|
|
865
|
+
});
|
|
866
|
+
if (mTimes.length === 0) {
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
const canUseTime = mTimes.find((item) => {
|
|
816
870
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
817
871
|
timeSlice: timeSlots,
|
|
818
872
|
time: item,
|
|
@@ -825,7 +879,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
825
879
|
}
|
|
826
880
|
return res.usable;
|
|
827
881
|
});
|
|
828
|
-
if (canUseTime) {
|
|
882
|
+
if (canUseTime && !n.onlyComputed) {
|
|
829
883
|
targetResource = n;
|
|
830
884
|
break;
|
|
831
885
|
}
|
|
@@ -834,11 +888,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
834
888
|
selectedResource: targetResource
|
|
835
889
|
};
|
|
836
890
|
} else {
|
|
837
|
-
const
|
|
891
|
+
const resourcesMap2 = (0, import_utils.getResourcesMap)(resources);
|
|
838
892
|
const resourceIds = resources.map((n) => n.id);
|
|
839
893
|
const timeSlots2 = (0, import_resources.getTimeSlicesByResources)({
|
|
840
894
|
resourceIds,
|
|
841
|
-
resourcesMap,
|
|
895
|
+
resourcesMap: resourcesMap2,
|
|
842
896
|
duration,
|
|
843
897
|
currentDate: dateRange[0].date,
|
|
844
898
|
split: 10,
|
|
@@ -904,6 +958,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
904
958
|
};
|
|
905
959
|
}
|
|
906
960
|
const res = this.autoSelectAccountResources({
|
|
961
|
+
cartItem: item,
|
|
907
962
|
holder_id: item.holder_id,
|
|
908
963
|
resources_code,
|
|
909
964
|
timeSlots: recordTimeSlots,
|
|
@@ -923,7 +978,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
923
978
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
924
979
|
resources: [
|
|
925
980
|
...(item._origin.resources || []).filter(
|
|
926
|
-
(existingRes) =>
|
|
981
|
+
(existingRes) => {
|
|
982
|
+
var _a3;
|
|
983
|
+
return existingRes.form_id !== ((_a3 = res.selectedResource) == null ? void 0 : _a3.form_id);
|
|
984
|
+
}
|
|
927
985
|
),
|
|
928
986
|
res.selectedResource
|
|
929
987
|
]
|
|
@@ -934,14 +992,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
934
992
|
} else {
|
|
935
993
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
936
994
|
let selectedResources = [];
|
|
937
|
-
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
995
|
+
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
996
|
+
((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
|
|
997
|
+
);
|
|
938
998
|
const currentResourcesRenderList = [];
|
|
939
999
|
resources2.forEach((n) => {
|
|
940
1000
|
var _a3;
|
|
941
1001
|
if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
|
|
942
1002
|
n.renderList = n.renderList.filter((m) => {
|
|
1003
|
+
var _a4;
|
|
943
1004
|
const recordCount = m.capacity || 0;
|
|
944
|
-
|
|
1005
|
+
const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
|
|
1006
|
+
resource: m,
|
|
1007
|
+
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 0,
|
|
1008
|
+
split: 10,
|
|
1009
|
+
currentDate: dateRange[0].date
|
|
1010
|
+
});
|
|
1011
|
+
return recordCount >= currentCapacity && timeSlots2.length > 0;
|
|
945
1012
|
});
|
|
946
1013
|
currentResourcesRenderList.push(...n.renderList || []);
|
|
947
1014
|
}
|
|
@@ -1030,7 +1097,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1030
1097
|
if (item.resource_id) {
|
|
1031
1098
|
resourceIds.push(item.resource_id);
|
|
1032
1099
|
}
|
|
1033
|
-
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(
|
|
1100
|
+
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(
|
|
1101
|
+
(n) => n.code === resources_code
|
|
1102
|
+
)) == null ? void 0 : _g.id;
|
|
1034
1103
|
});
|
|
1035
1104
|
if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
|
|
1036
1105
|
dateRange[0].resource.forEach((n) => {
|
|
@@ -1146,6 +1215,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1146
1215
|
});
|
|
1147
1216
|
});
|
|
1148
1217
|
const newScheduleArr = Object.values(newSchedule);
|
|
1218
|
+
newScheduleArr.sort((a, b) => {
|
|
1219
|
+
return (0, import_dayjs.default)(a.date).diff((0, import_dayjs.default)(b.date));
|
|
1220
|
+
});
|
|
1149
1221
|
return newScheduleArr;
|
|
1150
1222
|
}
|
|
1151
1223
|
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
@@ -1214,11 +1286,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1214
1286
|
return -1;
|
|
1215
1287
|
return 0;
|
|
1216
1288
|
});
|
|
1217
|
-
const resourcesUseableMap = {};
|
|
1218
1289
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1290
|
+
const resourcesUseableMap = {};
|
|
1219
1291
|
let count = 0;
|
|
1220
1292
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1221
|
-
|
|
1293
|
+
let currentResourcesCount = 0;
|
|
1294
|
+
const currentResourcesTimeSlotCanUsedArr = [];
|
|
1295
|
+
const mTimes = m.times.filter((n) => {
|
|
1296
|
+
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end));
|
|
1297
|
+
});
|
|
1298
|
+
if (mTimes.length === 0) {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
mTimes.forEach((childTiem) => {
|
|
1222
1302
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1223
1303
|
timeSlice: {
|
|
1224
1304
|
start_time: item.start,
|
|
@@ -1236,9 +1316,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1236
1316
|
resourcesUseableMap[m.id] = res.usable;
|
|
1237
1317
|
}
|
|
1238
1318
|
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1239
|
-
|
|
1319
|
+
currentResourcesCount = res.remainingCapacity;
|
|
1240
1320
|
}
|
|
1321
|
+
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1241
1322
|
});
|
|
1323
|
+
if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false) && currentResourcesCount >= count) {
|
|
1324
|
+
count = currentResourcesCount;
|
|
1325
|
+
}
|
|
1242
1326
|
});
|
|
1243
1327
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1244
1328
|
const endDayJs = (0, import_dayjs.default)(item.end);
|