@pisell/pisellos 3.0.12 → 3.0.14
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 +154 -58
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -1
- package/dist/solution/BookingByStep/utils/resources.js +34 -27
- 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 +99 -27
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -1
- package/lib/solution/BookingByStep/utils/resources.js +9 -2
- 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
|
});
|
|
@@ -1179,6 +1196,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1179
1196
|
capacity: formatCapacity
|
|
1180
1197
|
});
|
|
1181
1198
|
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
|
|
1199
|
+
debugger;
|
|
1182
1200
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1183
1201
|
if (cartItem._origin.start_time) {
|
|
1184
1202
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1196,7 +1214,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1214
|
});
|
|
1197
1215
|
n.renderList = n.renderList.filter(function (m) {
|
|
1198
1216
|
var recordCount = capacityMap[m.id] || 0;
|
|
1199
|
-
|
|
1217
|
+
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1218
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1219
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1220
|
+
var mTimes = m.times.filter(function (n) {
|
|
1221
|
+
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
1222
|
+
});
|
|
1223
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1224
|
+
if (mTimes.length === 0) {
|
|
1225
|
+
return false;
|
|
1226
|
+
}
|
|
1227
|
+
var canUseArr = mTimes.map(function (item) {
|
|
1200
1228
|
var res = getIsUsableByTimeItem({
|
|
1201
1229
|
timeSlice: {
|
|
1202
1230
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1324,7 +1352,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1324
1352
|
}, {
|
|
1325
1353
|
key: "autoSelectAccountResources",
|
|
1326
1354
|
value: function autoSelectAccountResources(_ref8) {
|
|
1327
|
-
var
|
|
1355
|
+
var _cartItem$_productOri3, _allProductResources$;
|
|
1356
|
+
var cartItem = _ref8.cartItem,
|
|
1357
|
+
holder_id = _ref8.holder_id,
|
|
1328
1358
|
resources_code = _ref8.resources_code,
|
|
1329
1359
|
timeSlots = _ref8.timeSlots,
|
|
1330
1360
|
countMap = _ref8.countMap,
|
|
@@ -1347,15 +1377,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1347
1377
|
// 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
|
|
1348
1378
|
// let durationType = accountCartItems[0]?._productOrigin?.duration?.type ?? "minutes";
|
|
1349
1379
|
// 取出账号下所对应类型的所有的可用资源
|
|
1350
|
-
|
|
1351
|
-
accountCartItems.forEach(
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1380
|
+
// let resourcesCartItems: any[] = [];
|
|
1381
|
+
// accountCartItems.forEach((item) => {
|
|
1382
|
+
// item._productOrigin?.product_resource?.resources?.forEach((n) => {
|
|
1383
|
+
// if (n.code === resources_code) {
|
|
1384
|
+
// resourcesCartItems.push(...(n.renderList || []));
|
|
1385
|
+
// }
|
|
1386
|
+
// });
|
|
1387
|
+
// });
|
|
1388
|
+
var AllResources = [];
|
|
1389
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1390
|
+
dateRange.forEach(function (n) {
|
|
1391
|
+
if (n.resource) AllResources.push.apply(AllResources, _toConsumableArray(n.resource));
|
|
1357
1392
|
});
|
|
1358
|
-
}
|
|
1393
|
+
}
|
|
1394
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1395
|
+
if (!AllResources.length) {
|
|
1396
|
+
var dateList = this.store.date.getDateList();
|
|
1397
|
+
dateList.forEach(function (n) {
|
|
1398
|
+
if (n.resource) AllResources.push.apply(AllResources, _toConsumableArray(n.resource));
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1402
|
+
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1403
|
+
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1404
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.product_resource) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.resources) || [], selectedResources, 1);
|
|
1405
|
+
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1406
|
+
return n.code === resources_code;
|
|
1407
|
+
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
1359
1408
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1360
1409
|
resources.sort(function (a, b) {
|
|
1361
1410
|
var _a$metadata2, _b$metadata2;
|
|
@@ -1365,7 +1414,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1365
1414
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1366
1415
|
return 0;
|
|
1367
1416
|
});
|
|
1368
|
-
var resourcesUseableMap = {
|
|
1417
|
+
var resourcesUseableMap = _toConsumableArray(selectedResources).reduce(function (acc, n) {
|
|
1418
|
+
acc[n] = false;
|
|
1419
|
+
return acc;
|
|
1420
|
+
}, {});
|
|
1369
1421
|
|
|
1370
1422
|
// 如果有选择时间了,则代表不是第一种资源了,则需要根据开始时间去匹配
|
|
1371
1423
|
// 每个商品
|
|
@@ -1380,29 +1432,47 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1380
1432
|
_step2;
|
|
1381
1433
|
try {
|
|
1382
1434
|
var _loop = function _loop() {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1435
|
+
var n = _step2.value;
|
|
1436
|
+
// 如果资源是独占的,并且 countMap 里选择过这个资源,则直接跳过
|
|
1437
|
+
// if (n.resourceType === 'single' && countMap[n.id]) {
|
|
1438
|
+
// resourcesUseableMap[n.id] = false;
|
|
1439
|
+
// continue
|
|
1440
|
+
// }
|
|
1441
|
+
var recordCount = countMap[n.id] || 0;
|
|
1442
|
+
// n.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1443
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1444
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1445
|
+
var mTimes = n.times.filter(function (n) {
|
|
1446
|
+
return !dayjs(n.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(n.end_at).isBefore(dayjs(timeSlots.end_at));
|
|
1392
1447
|
});
|
|
1393
|
-
//
|
|
1394
|
-
if (
|
|
1395
|
-
|
|
1448
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1449
|
+
if (mTimes.length === 0) {
|
|
1450
|
+
return 0; // continue
|
|
1396
1451
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1452
|
+
var canUseTime = mTimes.find(function (item) {
|
|
1453
|
+
var res = getIsUsableByTimeItem({
|
|
1454
|
+
timeSlice: timeSlots,
|
|
1455
|
+
time: item,
|
|
1456
|
+
resource: n,
|
|
1457
|
+
currentCount: recordCount + (capacity || 0),
|
|
1458
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1459
|
+
});
|
|
1460
|
+
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1461
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1462
|
+
resourcesUseableMap[n.id] = res.usable;
|
|
1463
|
+
}
|
|
1464
|
+
return res.usable;
|
|
1465
|
+
});
|
|
1466
|
+
if (canUseTime && !n.onlyComputed) {
|
|
1467
|
+
targetResource = n;
|
|
1468
|
+
return 1; // break
|
|
1469
|
+
}
|
|
1470
|
+
},
|
|
1471
|
+
_ret;
|
|
1404
1472
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1405
|
-
|
|
1473
|
+
_ret = _loop();
|
|
1474
|
+
if (_ret === 0) continue;
|
|
1475
|
+
if (_ret === 1) break;
|
|
1406
1476
|
}
|
|
1407
1477
|
} catch (err) {
|
|
1408
1478
|
_iterator2.e(err);
|
|
@@ -1413,13 +1483,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1413
1483
|
selectedResource: targetResource
|
|
1414
1484
|
};
|
|
1415
1485
|
} else {
|
|
1416
|
-
var
|
|
1486
|
+
var _resourcesMap = getResourcesMap(resources);
|
|
1417
1487
|
var resourceIds = resources.map(function (n) {
|
|
1418
1488
|
return n.id;
|
|
1419
1489
|
});
|
|
1420
1490
|
var _timeSlots = getTimeSlicesByResources({
|
|
1421
1491
|
resourceIds: resourceIds,
|
|
1422
|
-
resourcesMap:
|
|
1492
|
+
resourcesMap: _resourcesMap,
|
|
1423
1493
|
duration: duration,
|
|
1424
1494
|
currentDate: dateRange[0].date,
|
|
1425
1495
|
split: 10,
|
|
@@ -1462,9 +1532,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1462
1532
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
1463
1533
|
|
|
1464
1534
|
cartItems.forEach(function (item, index) {
|
|
1465
|
-
var _item$
|
|
1535
|
+
var _item$_productOrigin2;
|
|
1466
1536
|
var formatCapacity = formatDefaultCapacitys({
|
|
1467
|
-
capacity: (_item$
|
|
1537
|
+
capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
|
|
1468
1538
|
product_bundle: item._origin.product.product_bundle
|
|
1469
1539
|
});
|
|
1470
1540
|
var currentCapacity = getSumCapacity({
|
|
@@ -1481,9 +1551,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1481
1551
|
}
|
|
1482
1552
|
if (recordTimeSlots) {
|
|
1483
1553
|
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$
|
|
1554
|
+
var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
|
|
1555
|
+
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');
|
|
1556
|
+
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
1557
|
recordTimeSlots = {
|
|
1488
1558
|
start_time: start_at.format('HH:mm'),
|
|
1489
1559
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1493,6 +1563,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1493
1563
|
}
|
|
1494
1564
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1495
1565
|
var res = _this8.autoSelectAccountResources({
|
|
1566
|
+
cartItem: item,
|
|
1496
1567
|
holder_id: item.holder_id,
|
|
1497
1568
|
resources_code: resources_code,
|
|
1498
1569
|
timeSlots: recordTimeSlots,
|
|
@@ -1515,7 +1586,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1515
1586
|
_id: item._id,
|
|
1516
1587
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1517
1588
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1518
|
-
|
|
1589
|
+
var _res$selectedResource;
|
|
1590
|
+
return existingRes.form_id !== ((_res$selectedResource = res.selectedResource) === null || _res$selectedResource === void 0 ? void 0 : _res$selectedResource.form_id);
|
|
1519
1591
|
})), [res.selectedResource])
|
|
1520
1592
|
});
|
|
1521
1593
|
} else {
|
|
@@ -1523,12 +1595,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1523
1595
|
errorList.push(item._id);
|
|
1524
1596
|
}
|
|
1525
1597
|
} else {
|
|
1526
|
-
var _item$
|
|
1598
|
+
var _item$_productOrigin7, _productResources$fin;
|
|
1527
1599
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1528
1600
|
var allCartItems = cloneDeep(_this8.store.cart.getItems());
|
|
1529
1601
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1530
1602
|
var selectedResources = [];
|
|
1531
|
-
var _resources = cloneDeep(((_item$
|
|
1603
|
+
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
1604
|
var currentResourcesRenderList = [];
|
|
1533
1605
|
_resources.forEach(function (n) {
|
|
1534
1606
|
var _n$renderList;
|
|
@@ -1541,13 +1613,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1541
1613
|
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1542
1614
|
}
|
|
1543
1615
|
});
|
|
1544
|
-
var
|
|
1616
|
+
var _resourcesMap2 = getResourcesMap(currentResourcesRenderList);
|
|
1545
1617
|
if (item.holder_id) {
|
|
1546
|
-
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id,
|
|
1618
|
+
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, _resourcesMap2);
|
|
1547
1619
|
} else {
|
|
1548
|
-
selectedResources = getOthersCartSelectedResources(allCartItems, item._id,
|
|
1620
|
+
selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap2);
|
|
1549
1621
|
}
|
|
1550
|
-
var productResources = getResourcesByProduct(
|
|
1622
|
+
var productResources = getResourcesByProduct(_resourcesMap2, cloneDeep(_resources), selectedResources, currentCapacity);
|
|
1551
1623
|
productResources.forEach(function (item) {
|
|
1552
1624
|
item.renderList = item.renderList.filter(function (n) {
|
|
1553
1625
|
var recordCount = n.capacity || 0;
|
|
@@ -1615,8 +1687,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1615
1687
|
var resourceIds = [];
|
|
1616
1688
|
var resourcesTypeId = undefined;
|
|
1617
1689
|
cartItems.forEach(function (item) {
|
|
1618
|
-
var _item$
|
|
1619
|
-
(_item$
|
|
1690
|
+
var _item$_productOrigin8, _item$_productOrigin9;
|
|
1691
|
+
(_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
1692
|
if (n.code === resources_code) {
|
|
1621
1693
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1622
1694
|
}
|
|
@@ -1627,9 +1699,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1627
1699
|
if (item.resource_id) {
|
|
1628
1700
|
resourceIds.push(item.resource_id);
|
|
1629
1701
|
}
|
|
1630
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
1702
|
+
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
1703
|
return n.code === resources_code;
|
|
1632
|
-
})) === null || _item$
|
|
1704
|
+
})) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.id;
|
|
1633
1705
|
});
|
|
1634
1706
|
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1635
1707
|
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 +1721,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1649
1721
|
var checkDuration = function checkDuration(cartItems) {
|
|
1650
1722
|
var accountDuration = 0;
|
|
1651
1723
|
cartItems.forEach(function (item) {
|
|
1652
|
-
var _item$_productOrigin$3, _item$
|
|
1653
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1724
|
+
var _item$_productOrigin$3, _item$_productOrigin10;
|
|
1725
|
+
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
1726
|
});
|
|
1655
1727
|
if (accountDuration > duration) {
|
|
1656
1728
|
duration = accountDuration;
|
|
@@ -1719,9 +1791,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1719
1791
|
accountItems.forEach(function (item, index) {
|
|
1720
1792
|
var newResources = cloneDeep(item._origin.resources);
|
|
1721
1793
|
newResources.forEach(function (resource) {
|
|
1722
|
-
var _item$_productOrigin$4, _item$
|
|
1794
|
+
var _item$_productOrigin$4, _item$_productOrigin11, _ref11, _item$_productOrigin12;
|
|
1723
1795
|
resource.startTime = currentStartTime;
|
|
1724
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
1796
|
+
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
1797
|
delete resource.times;
|
|
1726
1798
|
});
|
|
1727
1799
|
_this10.store.cart.updateItem({
|
|
@@ -1762,6 +1834,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1762
1834
|
});
|
|
1763
1835
|
});
|
|
1764
1836
|
var newScheduleArr = Object.values(newSchedule);
|
|
1837
|
+
// newScheduleArr 需要做个排序,按日期从小到大
|
|
1838
|
+
newScheduleArr.sort(function (a, b) {
|
|
1839
|
+
return dayjs(a.date).diff(dayjs(b.date));
|
|
1840
|
+
});
|
|
1765
1841
|
return newScheduleArr;
|
|
1766
1842
|
}
|
|
1767
1843
|
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
@@ -1848,7 +1924,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1924
|
// 遍历所有资源
|
|
1849
1925
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
1850
1926
|
// 遍历所有资源的上工时间片
|
|
1851
|
-
|
|
1927
|
+
var currentResourcesCount = 0;
|
|
1928
|
+
var currentResourcesTimeSlotCanUsedArr = [];
|
|
1929
|
+
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1930
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1931
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1932
|
+
var mTimes = m.times.filter(function (n) {
|
|
1933
|
+
return !dayjs(n.start_at).isAfter(dayjs(item.start)) && !dayjs(n.end_at).isBefore(dayjs(item.end));
|
|
1934
|
+
});
|
|
1935
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1936
|
+
if (mTimes.length === 0) {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
mTimes.forEach(function (childTiem) {
|
|
1852
1940
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
1853
1941
|
var res = getIsUsableByTimeItem({
|
|
1854
1942
|
timeSlice: {
|
|
@@ -1860,15 +1948,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1860
1948
|
time: childTiem,
|
|
1861
1949
|
resource: m,
|
|
1862
1950
|
currentCount: 1,
|
|
1863
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1951
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1952
|
+
cut_off_time: targetProductData === null || targetProductData === void 0 ? void 0 : targetProductData.cut_off_time
|
|
1864
1953
|
});
|
|
1865
1954
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1866
1955
|
resourcesUseableMap[m.id] = res.usable;
|
|
1867
1956
|
}
|
|
1868
1957
|
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1869
|
-
|
|
1958
|
+
currentResourcesCount = res.remainingCapacity;
|
|
1870
1959
|
}
|
|
1960
|
+
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1871
1961
|
});
|
|
1962
|
+
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
1963
|
+
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
1964
|
+
return n === false;
|
|
1965
|
+
})) {
|
|
1966
|
+
count = currentResourcesCount;
|
|
1967
|
+
}
|
|
1872
1968
|
});
|
|
1873
1969
|
var startDayJs = dayjs(item.start);
|
|
1874
1970
|
var endDayJs = dayjs(item.end);
|
|
@@ -27,12 +27,17 @@ interface BookingItem {
|
|
|
27
27
|
* @return {*}
|
|
28
28
|
* @Author: zhiwei.Wang
|
|
29
29
|
*/
|
|
30
|
-
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, }: {
|
|
30
|
+
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, cut_off_time, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
34
34
|
currentCount: number;
|
|
35
35
|
resourcesUseableMap: Record<string, boolean>;
|
|
36
|
+
cut_off_time?: {
|
|
37
|
+
future_day: number;
|
|
38
|
+
unit: number;
|
|
39
|
+
unit_type: string;
|
|
40
|
+
} | undefined;
|
|
36
41
|
}) => {
|
|
37
42
|
afterToDay: boolean;
|
|
38
43
|
capacity: boolean;
|
|
@@ -175,7 +175,8 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
175
175
|
_ref2$currentCount = _ref2.currentCount,
|
|
176
176
|
currentCount = _ref2$currentCount === void 0 ? 1 : _ref2$currentCount,
|
|
177
177
|
_ref2$resourcesUseabl = _ref2.resourcesUseableMap,
|
|
178
|
-
resourcesUseableMap = _ref2$resourcesUseabl === void 0 ? {} : _ref2$resourcesUseabl
|
|
178
|
+
resourcesUseableMap = _ref2$resourcesUseabl === void 0 ? {} : _ref2$resourcesUseabl,
|
|
179
|
+
cut_off_time = _ref2.cut_off_time;
|
|
179
180
|
var status = {
|
|
180
181
|
afterToDay: false,
|
|
181
182
|
capacity: false,
|
|
@@ -186,6 +187,12 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
186
187
|
};
|
|
187
188
|
// 最早可预约时间为 当前日期之后并且提前量之后
|
|
188
189
|
var earliest = dayjs();
|
|
190
|
+
var _ref3 = cut_off_time || {},
|
|
191
|
+
unit = _ref3.unit,
|
|
192
|
+
unit_type = _ref3.unit_type;
|
|
193
|
+
if (unit) {
|
|
194
|
+
earliest = earliest.add(unit, unit_type);
|
|
195
|
+
}
|
|
189
196
|
// 不可预约提前量时间之前的
|
|
190
197
|
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
191
198
|
return status;
|
|
@@ -323,9 +330,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
323
330
|
* @Author: zhiwei.Wang
|
|
324
331
|
* @Date: 2024-01-09 13:38
|
|
325
332
|
*/
|
|
326
|
-
export var formatResources = function formatResources(
|
|
327
|
-
var booking =
|
|
328
|
-
resources =
|
|
333
|
+
export var formatResources = function formatResources(_ref4) {
|
|
334
|
+
var booking = _ref4.booking,
|
|
335
|
+
resources = _ref4.resources;
|
|
329
336
|
try {
|
|
330
337
|
var _list = _toConsumableArray(resources);
|
|
331
338
|
var maps = {};
|
|
@@ -371,16 +378,16 @@ export var formatResources = function formatResources(_ref3) {
|
|
|
371
378
|
* @return {*}
|
|
372
379
|
* @Author: zhiwei.Wang
|
|
373
380
|
*/
|
|
374
|
-
export var getTimeSlicesByResource = function getTimeSlicesByResource(
|
|
375
|
-
var resource =
|
|
376
|
-
duration =
|
|
377
|
-
|
|
378
|
-
split =
|
|
379
|
-
|
|
380
|
-
currentDate =
|
|
381
|
-
capacity =
|
|
382
|
-
|
|
383
|
-
resourcesUseableMap =
|
|
381
|
+
export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
382
|
+
var resource = _ref5.resource,
|
|
383
|
+
duration = _ref5.duration,
|
|
384
|
+
_ref5$split = _ref5.split,
|
|
385
|
+
split = _ref5$split === void 0 ? 10 : _ref5$split,
|
|
386
|
+
_ref5$currentDate = _ref5.currentDate,
|
|
387
|
+
currentDate = _ref5$currentDate === void 0 ? dayjs() : _ref5$currentDate,
|
|
388
|
+
capacity = _ref5.capacity,
|
|
389
|
+
_ref5$resourcesUseabl = _ref5.resourcesUseableMap,
|
|
390
|
+
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl;
|
|
384
391
|
var times = resource.times;
|
|
385
392
|
|
|
386
393
|
// 存储所有时间切片
|
|
@@ -521,14 +528,14 @@ export var mergeSubResourcesTimeSlices = function mergeSubResourcesTimeSlices(re
|
|
|
521
528
|
* @return {*}
|
|
522
529
|
* @Author: zhiwei.Wang
|
|
523
530
|
*/
|
|
524
|
-
export var getTimeSlicesByResources = function getTimeSlicesByResources(
|
|
525
|
-
var resourceIds =
|
|
526
|
-
resourcesMap =
|
|
527
|
-
duration =
|
|
528
|
-
currentDate =
|
|
529
|
-
split =
|
|
530
|
-
capacity =
|
|
531
|
-
resourcesUseableMap =
|
|
531
|
+
export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
532
|
+
var resourceIds = _ref6.resourceIds,
|
|
533
|
+
resourcesMap = _ref6.resourcesMap,
|
|
534
|
+
duration = _ref6.duration,
|
|
535
|
+
currentDate = _ref6.currentDate,
|
|
536
|
+
split = _ref6.split,
|
|
537
|
+
capacity = _ref6.capacity,
|
|
538
|
+
resourcesUseableMap = _ref6.resourcesUseableMap;
|
|
532
539
|
// 获取资源列表
|
|
533
540
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
534
541
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -660,9 +667,9 @@ export var getOthersCartSelectedResources = function getOthersCartSelectedResour
|
|
|
660
667
|
* @return {*}
|
|
661
668
|
* @Author: zhiwei.Wang
|
|
662
669
|
*/
|
|
663
|
-
export var formatDefaultCapacitys = function formatDefaultCapacitys(
|
|
664
|
-
var capacity =
|
|
665
|
-
product_bundle =
|
|
670
|
+
export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref7) {
|
|
671
|
+
var capacity = _ref7.capacity,
|
|
672
|
+
product_bundle = _ref7.product_bundle;
|
|
666
673
|
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
667
674
|
return (product_bundle || []).map(function (d) {
|
|
668
675
|
var id = d.bundle_product_id;
|
|
@@ -701,8 +708,8 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref6) {
|
|
|
701
708
|
* @return {*}
|
|
702
709
|
* @Author: zhiwei.Wang
|
|
703
710
|
*/
|
|
704
|
-
export var getSumCapacity = function getSumCapacity(
|
|
705
|
-
var capacity =
|
|
711
|
+
export var getSumCapacity = function getSumCapacity(_ref8) {
|
|
712
|
+
var capacity = _ref8.capacity;
|
|
706
713
|
var sum = 0;
|
|
707
714
|
var _iterator2 = _createForOfIteratorHelper(capacity || []),
|
|
708
715
|
_step2;
|
|
@@ -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;
|
|
@@ -627,6 +638,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
627
638
|
selectedResources,
|
|
628
639
|
currentCapacity
|
|
629
640
|
);
|
|
641
|
+
debugger;
|
|
630
642
|
if (cartItem._origin.start_time) {
|
|
631
643
|
const startTime = (0, import_dayjs.default)(
|
|
632
644
|
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
@@ -648,7 +660,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
648
660
|
});
|
|
649
661
|
n.renderList = n.renderList.filter((m) => {
|
|
650
662
|
const recordCount = capacityMap[m.id] || 0;
|
|
651
|
-
const
|
|
663
|
+
const mTimes = m.times.filter((n2) => {
|
|
664
|
+
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));
|
|
665
|
+
});
|
|
666
|
+
if (mTimes.length === 0) {
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
const canUseArr = mTimes.map((item) => {
|
|
652
670
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
653
671
|
timeSlice: {
|
|
654
672
|
start_time: startTime.format("HH:mm"),
|
|
@@ -772,12 +790,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
772
790
|
}
|
|
773
791
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
774
792
|
autoSelectAccountResources({
|
|
793
|
+
cartItem,
|
|
775
794
|
holder_id,
|
|
776
795
|
resources_code,
|
|
777
796
|
timeSlots,
|
|
778
797
|
countMap,
|
|
779
798
|
capacity
|
|
780
799
|
}) {
|
|
800
|
+
var _a, _b, _c;
|
|
781
801
|
const dateRange = this.store.date.getDateRange();
|
|
782
802
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
783
803
|
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
@@ -785,34 +805,62 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
785
805
|
accountCartItems = cartItems;
|
|
786
806
|
}
|
|
787
807
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
788
|
-
var
|
|
789
|
-
return acc + (((
|
|
808
|
+
var _a2, _b2;
|
|
809
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0);
|
|
790
810
|
}, 0);
|
|
791
|
-
let
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
resources.push(...n.renderList || []);
|
|
797
|
-
}
|
|
811
|
+
let AllResources = [];
|
|
812
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
813
|
+
dateRange.forEach((n) => {
|
|
814
|
+
if (n.resource)
|
|
815
|
+
AllResources.push(...n.resource);
|
|
798
816
|
});
|
|
799
|
-
}
|
|
817
|
+
}
|
|
818
|
+
if (!AllResources.length) {
|
|
819
|
+
const dateList = this.store.date.getDateList();
|
|
820
|
+
dateList.forEach((n) => {
|
|
821
|
+
if (n.resource)
|
|
822
|
+
AllResources.push(...n.resource);
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(AllResources));
|
|
826
|
+
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
827
|
+
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
828
|
+
allCartItems,
|
|
829
|
+
holder_id,
|
|
830
|
+
resourcesMap
|
|
831
|
+
);
|
|
832
|
+
let allProductResources = (0, import_resources.getResourcesByProduct)(
|
|
833
|
+
resourcesMap,
|
|
834
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
835
|
+
selectedResources,
|
|
836
|
+
1
|
|
837
|
+
);
|
|
838
|
+
const resources = ((_c = allProductResources.find((n) => n.code === resources_code)) == null ? void 0 : _c.renderList) || [];
|
|
800
839
|
resources.sort((a, b) => {
|
|
801
|
-
var
|
|
802
|
-
const aIsCombined = ((
|
|
803
|
-
const bIsCombined = ((_d = (
|
|
840
|
+
var _a2, _b2, _c2, _d;
|
|
841
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
842
|
+
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
804
843
|
if (aIsCombined && !bIsCombined)
|
|
805
844
|
return 1;
|
|
806
845
|
if (!aIsCombined && bIsCombined)
|
|
807
846
|
return -1;
|
|
808
847
|
return 0;
|
|
809
848
|
});
|
|
810
|
-
const resourcesUseableMap = {
|
|
849
|
+
const resourcesUseableMap = [...selectedResources].reduce((acc, n) => {
|
|
850
|
+
acc[n] = false;
|
|
851
|
+
return acc;
|
|
852
|
+
}, {});
|
|
811
853
|
if (timeSlots) {
|
|
812
854
|
let targetResource = null;
|
|
813
855
|
for (const n of resources) {
|
|
814
856
|
const recordCount = countMap[n.id] || 0;
|
|
815
|
-
const
|
|
857
|
+
const mTimes = n.times.filter((n2) => {
|
|
858
|
+
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));
|
|
859
|
+
});
|
|
860
|
+
if (mTimes.length === 0) {
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const canUseTime = mTimes.find((item) => {
|
|
816
864
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
817
865
|
timeSlice: timeSlots,
|
|
818
866
|
time: item,
|
|
@@ -825,7 +873,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
825
873
|
}
|
|
826
874
|
return res.usable;
|
|
827
875
|
});
|
|
828
|
-
if (canUseTime) {
|
|
876
|
+
if (canUseTime && !n.onlyComputed) {
|
|
829
877
|
targetResource = n;
|
|
830
878
|
break;
|
|
831
879
|
}
|
|
@@ -834,11 +882,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
834
882
|
selectedResource: targetResource
|
|
835
883
|
};
|
|
836
884
|
} else {
|
|
837
|
-
const
|
|
885
|
+
const resourcesMap2 = (0, import_utils.getResourcesMap)(resources);
|
|
838
886
|
const resourceIds = resources.map((n) => n.id);
|
|
839
887
|
const timeSlots2 = (0, import_resources.getTimeSlicesByResources)({
|
|
840
888
|
resourceIds,
|
|
841
|
-
resourcesMap,
|
|
889
|
+
resourcesMap: resourcesMap2,
|
|
842
890
|
duration,
|
|
843
891
|
currentDate: dateRange[0].date,
|
|
844
892
|
split: 10,
|
|
@@ -904,6 +952,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
904
952
|
};
|
|
905
953
|
}
|
|
906
954
|
const res = this.autoSelectAccountResources({
|
|
955
|
+
cartItem: item,
|
|
907
956
|
holder_id: item.holder_id,
|
|
908
957
|
resources_code,
|
|
909
958
|
timeSlots: recordTimeSlots,
|
|
@@ -923,7 +972,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
923
972
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
924
973
|
resources: [
|
|
925
974
|
...(item._origin.resources || []).filter(
|
|
926
|
-
(existingRes) =>
|
|
975
|
+
(existingRes) => {
|
|
976
|
+
var _a3;
|
|
977
|
+
return existingRes.form_id !== ((_a3 = res.selectedResource) == null ? void 0 : _a3.form_id);
|
|
978
|
+
}
|
|
927
979
|
),
|
|
928
980
|
res.selectedResource
|
|
929
981
|
]
|
|
@@ -934,7 +986,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
934
986
|
} else {
|
|
935
987
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
936
988
|
let selectedResources = [];
|
|
937
|
-
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
989
|
+
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
990
|
+
((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
|
|
991
|
+
);
|
|
938
992
|
const currentResourcesRenderList = [];
|
|
939
993
|
resources2.forEach((n) => {
|
|
940
994
|
var _a3;
|
|
@@ -1030,7 +1084,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1030
1084
|
if (item.resource_id) {
|
|
1031
1085
|
resourceIds.push(item.resource_id);
|
|
1032
1086
|
}
|
|
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(
|
|
1087
|
+
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(
|
|
1088
|
+
(n) => n.code === resources_code
|
|
1089
|
+
)) == null ? void 0 : _g.id;
|
|
1034
1090
|
});
|
|
1035
1091
|
if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
|
|
1036
1092
|
dateRange[0].resource.forEach((n) => {
|
|
@@ -1146,6 +1202,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1146
1202
|
});
|
|
1147
1203
|
});
|
|
1148
1204
|
const newScheduleArr = Object.values(newSchedule);
|
|
1205
|
+
newScheduleArr.sort((a, b) => {
|
|
1206
|
+
return (0, import_dayjs.default)(a.date).diff((0, import_dayjs.default)(b.date));
|
|
1207
|
+
});
|
|
1149
1208
|
return newScheduleArr;
|
|
1150
1209
|
}
|
|
1151
1210
|
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
@@ -1218,7 +1277,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1218
1277
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1219
1278
|
let count = 0;
|
|
1220
1279
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1221
|
-
|
|
1280
|
+
let currentResourcesCount = 0;
|
|
1281
|
+
const currentResourcesTimeSlotCanUsedArr = [];
|
|
1282
|
+
const mTimes = m.times.filter((n) => {
|
|
1283
|
+
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));
|
|
1284
|
+
});
|
|
1285
|
+
if (mTimes.length === 0) {
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
mTimes.forEach((childTiem) => {
|
|
1222
1289
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1223
1290
|
timeSlice: {
|
|
1224
1291
|
start_time: item.start,
|
|
@@ -1229,15 +1296,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1229
1296
|
time: childTiem,
|
|
1230
1297
|
resource: m,
|
|
1231
1298
|
currentCount: 1,
|
|
1232
|
-
resourcesUseableMap
|
|
1299
|
+
resourcesUseableMap,
|
|
1300
|
+
cut_off_time: targetProductData == null ? void 0 : targetProductData.cut_off_time
|
|
1233
1301
|
});
|
|
1234
1302
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1235
1303
|
resourcesUseableMap[m.id] = res.usable;
|
|
1236
1304
|
}
|
|
1237
1305
|
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1238
|
-
|
|
1306
|
+
currentResourcesCount = res.remainingCapacity;
|
|
1239
1307
|
}
|
|
1308
|
+
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1240
1309
|
});
|
|
1310
|
+
if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
|
|
1311
|
+
count = currentResourcesCount;
|
|
1312
|
+
}
|
|
1241
1313
|
});
|
|
1242
1314
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1243
1315
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
@@ -27,12 +27,17 @@ interface BookingItem {
|
|
|
27
27
|
* @return {*}
|
|
28
28
|
* @Author: zhiwei.Wang
|
|
29
29
|
*/
|
|
30
|
-
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, }: {
|
|
30
|
+
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, cut_off_time, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
34
34
|
currentCount: number;
|
|
35
35
|
resourcesUseableMap: Record<string, boolean>;
|
|
36
|
+
cut_off_time?: {
|
|
37
|
+
future_day: number;
|
|
38
|
+
unit: number;
|
|
39
|
+
unit_type: string;
|
|
40
|
+
} | undefined;
|
|
36
41
|
}) => {
|
|
37
42
|
afterToDay: boolean;
|
|
38
43
|
capacity: boolean;
|
|
@@ -127,7 +127,8 @@ var getIsUsableByTimeItem = ({
|
|
|
127
127
|
time,
|
|
128
128
|
resource,
|
|
129
129
|
currentCount = 1,
|
|
130
|
-
resourcesUseableMap = {}
|
|
130
|
+
resourcesUseableMap = {},
|
|
131
|
+
cut_off_time
|
|
131
132
|
}) => {
|
|
132
133
|
var _a;
|
|
133
134
|
let status = {
|
|
@@ -139,6 +140,10 @@ var getIsUsableByTimeItem = ({
|
|
|
139
140
|
reason: ""
|
|
140
141
|
};
|
|
141
142
|
let earliest = (0, import_dayjs.default)();
|
|
143
|
+
const { unit, unit_type } = cut_off_time || {};
|
|
144
|
+
if (unit) {
|
|
145
|
+
earliest = earliest.add(unit, unit_type);
|
|
146
|
+
}
|
|
142
147
|
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
143
148
|
return status;
|
|
144
149
|
}
|
|
@@ -373,7 +378,9 @@ var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
|
373
378
|
const subResource = resourcesMap[id];
|
|
374
379
|
if (subResource) {
|
|
375
380
|
subResource.times.forEach((time) => {
|
|
376
|
-
const fatherResourcesTime = item.times.find(
|
|
381
|
+
const fatherResourcesTime = item.times.find(
|
|
382
|
+
(n) => n.start_at === time.start_at && n.end_at === time.end_at
|
|
383
|
+
);
|
|
377
384
|
if (fatherResourcesTime) {
|
|
378
385
|
fatherResourcesTime.event_list.push(...time.event_list || []);
|
|
379
386
|
}
|