@pisell/pisellos 0.0.37 → 2.0.1
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/Cart/types.d.ts +0 -4
- package/dist/modules/Cart/utils.d.ts +0 -1
- package/dist/modules/Cart/utils.js +12 -23
- package/dist/modules/Product/index.d.ts +0 -10
- package/dist/modules/Product/index.js +0 -13
- package/dist/modules/Product/types.d.ts +0 -4
- package/dist/modules/Resource/types.d.ts +0 -1
- package/dist/modules/index.d.ts +0 -9
- package/dist/modules/index.js +1 -10
- package/dist/solution/BookingByStep/index.d.ts +5 -14
- package/dist/solution/BookingByStep/index.js +163 -284
- package/dist/solution/BookingByStep/types.d.ts +10 -2
- package/dist/solution/BookingByStep/types.js +7 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts +4 -45
- package/dist/solution/BookingByStep/utils/resources.js +32 -153
- package/lib/modules/Cart/types.d.ts +0 -4
- package/lib/modules/Cart/utils.d.ts +0 -1
- package/lib/modules/Cart/utils.js +12 -24
- package/lib/modules/Product/index.d.ts +0 -10
- package/lib/modules/Product/index.js +0 -3
- package/lib/modules/Product/types.d.ts +0 -4
- package/lib/modules/Resource/types.d.ts +0 -1
- package/lib/modules/index.d.ts +0 -9
- package/lib/modules/index.js +1 -19
- package/lib/solution/BookingByStep/index.d.ts +5 -14
- package/lib/solution/BookingByStep/index.js +35 -84
- package/lib/solution/BookingByStep/types.d.ts +10 -2
- package/lib/solution/BookingByStep/types.js +12 -6
- package/lib/solution/BookingByStep/utils/resources.d.ts +4 -45
- package/lib/solution/BookingByStep/utils/resources.js +24 -101
- package/package.json +2 -2
- package/dist/modules/Schedule/index.d.ts +0 -10
- package/dist/modules/Schedule/index.js +0 -56
- package/dist/modules/Schedule/type.d.ts +0 -157
- package/dist/modules/Schedule/type.js +0 -1
- package/dist/modules/Schedule/types.d.ts +0 -177
- package/dist/modules/Schedule/types.js +0 -1
- package/dist/modules/Schedule/utils.d.ts +0 -61
- package/dist/modules/Schedule/utils.js +0 -700
- package/lib/modules/Schedule/index.d.ts +0 -10
- package/lib/modules/Schedule/index.js +0 -41
- package/lib/modules/Schedule/type.d.ts +0 -157
- package/lib/modules/Schedule/type.js +0 -17
- package/lib/modules/Schedule/types.d.ts +0 -177
- package/lib/modules/Schedule/types.js +0 -17
- package/lib/modules/Schedule/utils.d.ts +0 -61
- package/lib/modules/Schedule/utils.js +0 -572
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { ProductList, CartModule
|
|
1
|
+
import { ProductList, CartModule } from "../../modules";
|
|
2
|
+
import { AccountModule } from "../../modules/Account";
|
|
3
|
+
import { AccountListModule } from "../../modules/AccountList";
|
|
4
|
+
import { DateModule } from "../../modules/Date";
|
|
5
|
+
import { GuestListModule } from "../../modules/Guests";
|
|
6
|
+
import { OrderModule } from "../../modules/Order";
|
|
7
|
+
import { PaymentModule } from "../../modules/Payment";
|
|
8
|
+
import { ResourceListModule } from "../../modules/Resource";
|
|
9
|
+
import { StepModule } from "../../modules/Step";
|
|
10
|
+
import { SummaryModule } from "../../modules/Summary";
|
|
2
11
|
export interface BookingByStepState {
|
|
3
12
|
cart: CartModule;
|
|
4
13
|
summary: SummaryModule;
|
|
@@ -11,7 +20,6 @@ export interface BookingByStepState {
|
|
|
11
20
|
accountList: AccountListModule;
|
|
12
21
|
order: OrderModule;
|
|
13
22
|
payment: PaymentModule;
|
|
14
|
-
currentProduct: Product;
|
|
15
23
|
}
|
|
16
24
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
17
25
|
export declare enum BookingByStepHooks {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { ProductList, CartModule
|
|
1
|
+
import { ProductList, CartModule } from "../../modules";
|
|
2
|
+
import { AccountListModule } from "../../modules/AccountList";
|
|
3
|
+
import { DateModule } from "../../modules/Date";
|
|
4
|
+
import { OrderModule } from "../../modules/Order";
|
|
5
|
+
import { PaymentModule } from "../../modules/Payment";
|
|
6
|
+
import { StepModule } from "../../modules/Step";
|
|
7
|
+
import { SummaryModule } from "../../modules/Summary";
|
|
2
8
|
export function createModule(moduleName, solutionName, name, version) {
|
|
3
9
|
switch (moduleName) {
|
|
4
10
|
case "cart":
|
|
@@ -45,7 +45,8 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
45
45
|
* @return {*}
|
|
46
46
|
* @Author: zhiwei.Wang
|
|
47
47
|
*/
|
|
48
|
-
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>,
|
|
48
|
+
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>, cartItem: CartItem, cartList: CartItem[]) => ResourceItem[];
|
|
49
|
+
export declare const getSumCapacity: () => number;
|
|
49
50
|
/**
|
|
50
51
|
* @title: 获取资源列表
|
|
51
52
|
* @description:
|
|
@@ -66,12 +67,11 @@ export declare const formatResources: ({ booking, resources }: {
|
|
|
66
67
|
* @return {*}
|
|
67
68
|
* @Author: zhiwei.Wang
|
|
68
69
|
*/
|
|
69
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate
|
|
70
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate }: {
|
|
70
71
|
resource: ResourceItem;
|
|
71
72
|
duration: number;
|
|
72
73
|
split: number;
|
|
73
74
|
currentDate: DateType | string;
|
|
74
|
-
capacity?: number | undefined;
|
|
75
75
|
}) => TimeSliceItem[];
|
|
76
76
|
/**
|
|
77
77
|
* @title: 获取时间切片列表的交集
|
|
@@ -100,52 +100,11 @@ export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceIt
|
|
|
100
100
|
* @return {*}
|
|
101
101
|
* @Author: zhiwei.Wang
|
|
102
102
|
*/
|
|
103
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split
|
|
103
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split }: {
|
|
104
104
|
resourceIds: number[];
|
|
105
105
|
resourcesMap: any;
|
|
106
106
|
duration: number;
|
|
107
107
|
currentDate: DateType | string;
|
|
108
108
|
split: number;
|
|
109
|
-
capacity?: number | undefined;
|
|
110
109
|
}) => any[];
|
|
111
|
-
/**
|
|
112
|
-
* @title: 获取其他人的已选资源
|
|
113
|
-
* @description:
|
|
114
|
-
* @param {CartItem[]} cartItems
|
|
115
|
-
* @param {number | string} accountId
|
|
116
|
-
* @return {*}
|
|
117
|
-
* @Author: jinglin.tan
|
|
118
|
-
*/
|
|
119
|
-
export declare const getOthersSelectedResources: (cartItems: CartItem[], accountId: number | string, resourcesMap: Record<string, ResourceItem>) => number[];
|
|
120
|
-
interface CapacityItem {
|
|
121
|
-
id: number;
|
|
122
|
-
value: number;
|
|
123
|
-
name: string;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* @title: 基于选择的商品格式化容量
|
|
127
|
-
* @description:
|
|
128
|
-
* @param {any} param1
|
|
129
|
-
* @return {*}
|
|
130
|
-
* @Author: zhiwei.Wang
|
|
131
|
-
*/
|
|
132
|
-
export declare const formatDefaultCapacitys: ({ capacity, product_bundle }: any) => CapacityItem[];
|
|
133
|
-
/**
|
|
134
|
-
* @title: 获取总容量
|
|
135
|
-
* @description:
|
|
136
|
-
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
137
|
-
* @return {*}
|
|
138
|
-
* @Author: zhiwei.Wang
|
|
139
|
-
*/
|
|
140
|
-
export declare const getSumCapacity: ({ capacity }: {
|
|
141
|
-
capacity: CapacityItem[];
|
|
142
|
-
}) => number;
|
|
143
|
-
/**
|
|
144
|
-
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
145
|
-
* @description:
|
|
146
|
-
* @param {object} resource
|
|
147
|
-
* @return {*}
|
|
148
|
-
* @Author: jinglin.tan
|
|
149
|
-
*/
|
|
150
|
-
export declare const checkSubResourcesCapacity: (resource: ResourceItem) => void;
|
|
151
110
|
export {};
|
|
@@ -191,39 +191,41 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
191
191
|
* @return {*}
|
|
192
192
|
* @Author: zhiwei.Wang
|
|
193
193
|
*/
|
|
194
|
-
export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
195
|
-
var
|
|
196
|
-
|
|
194
|
+
export var getResourcesByProduct = function getResourcesByProduct(resourcesMap, cartItem, cartList) {
|
|
195
|
+
var _product$product_reso;
|
|
196
|
+
var product = cartItem._productOrigin;
|
|
197
|
+
return ((product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources) || []).reduce(function (acc, item) {
|
|
197
198
|
if ((item === null || item === void 0 ? void 0 : item.status) == 1) {
|
|
198
199
|
var form_id = item.id;
|
|
199
200
|
// 去重 可选资源和必选资源可能会有重复的
|
|
200
201
|
item.optional_resource = (item.optional_resource || []).filter(function (d) {
|
|
201
202
|
return item.default_resource.indexOf(d) == -1;
|
|
202
203
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
|
|
205
|
+
// 如果购物车里有 某一项的 resources 选中过了某些资源,则把这些资源给过滤掉
|
|
206
|
+
// 这里做一个拍平,把非当前 holder_id 的资源洗到一个数组里
|
|
207
|
+
var selectedResources = cartList.reduce(function (acc, d) {
|
|
208
|
+
if (d.holder_id !== cartItem.holder_id) {
|
|
209
|
+
var _d$_origin;
|
|
210
|
+
if ((_d$_origin = d._origin) !== null && _d$_origin !== void 0 && _d$_origin.resources) {
|
|
211
|
+
d._origin.resources.forEach(function (n) {
|
|
212
|
+
acc.push(n.id);
|
|
212
213
|
});
|
|
213
214
|
}
|
|
215
|
+
}
|
|
216
|
+
return acc;
|
|
217
|
+
}, []);
|
|
218
|
+
var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
|
|
219
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
214
220
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
215
221
|
form_id: form_id,
|
|
216
|
-
resourceType: item.type
|
|
217
|
-
children: combiningResources,
|
|
218
|
-
metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
|
|
219
|
-
combined_resource: resourcesMap[d].combined_resource
|
|
220
|
-
})
|
|
222
|
+
resourceType: item.type
|
|
221
223
|
}));
|
|
222
224
|
}
|
|
223
225
|
return childAcc;
|
|
224
226
|
}, []);
|
|
225
227
|
var default_resource = item.default_resource.reduce(function (childAcc, d) {
|
|
226
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
228
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
227
229
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
228
230
|
form_id: form_id,
|
|
229
231
|
resourceType: item.type,
|
|
@@ -247,6 +249,14 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
247
249
|
return acc;
|
|
248
250
|
}, []);
|
|
249
251
|
};
|
|
252
|
+
export var getSumCapacity = function getSumCapacity() {
|
|
253
|
+
// let sum = 0;
|
|
254
|
+
// for (let item of booking._extend.capacity || []) {
|
|
255
|
+
// sum += item.value;
|
|
256
|
+
// }
|
|
257
|
+
// 一期默认为1人
|
|
258
|
+
return 1;
|
|
259
|
+
};
|
|
250
260
|
|
|
251
261
|
/**
|
|
252
262
|
* @title: 获取资源列表
|
|
@@ -309,8 +319,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
309
319
|
_ref4$split = _ref4.split,
|
|
310
320
|
split = _ref4$split === void 0 ? 10 : _ref4$split,
|
|
311
321
|
_ref4$currentDate = _ref4.currentDate,
|
|
312
|
-
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate
|
|
313
|
-
capacity = _ref4.capacity;
|
|
322
|
+
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate;
|
|
314
323
|
var times = resource.times;
|
|
315
324
|
|
|
316
325
|
// 存储所有时间切片
|
|
@@ -347,7 +356,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
347
356
|
timeSlice: timeSlice,
|
|
348
357
|
time: time,
|
|
349
358
|
resource: resource,
|
|
350
|
-
currentCount:
|
|
359
|
+
currentCount: getSumCapacity()
|
|
351
360
|
});
|
|
352
361
|
if (_status.usable) {
|
|
353
362
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
@@ -421,8 +430,7 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
421
430
|
resourcesMap = _ref5.resourcesMap,
|
|
422
431
|
duration = _ref5.duration,
|
|
423
432
|
currentDate = _ref5.currentDate,
|
|
424
|
-
split = _ref5.split
|
|
425
|
-
capacity = _ref5.capacity;
|
|
433
|
+
split = _ref5.split;
|
|
426
434
|
// 获取资源列表
|
|
427
435
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
428
436
|
|
|
@@ -432,140 +440,11 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
432
440
|
resource: item,
|
|
433
441
|
duration: duration,
|
|
434
442
|
split: split,
|
|
435
|
-
currentDate: currentDate
|
|
436
|
-
capacity: capacity
|
|
443
|
+
currentDate: currentDate
|
|
437
444
|
}));
|
|
438
445
|
}, []);
|
|
439
446
|
|
|
440
447
|
// 获取时间切片列表的交集
|
|
441
448
|
var intersection = getTimesIntersection(timeSliceList, resources.length);
|
|
442
449
|
return intersection;
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* @title: 获取其他人的已选资源
|
|
447
|
-
* @description:
|
|
448
|
-
* @param {CartItem[]} cartItems
|
|
449
|
-
* @param {number | string} accountId
|
|
450
|
-
* @return {*}
|
|
451
|
-
* @Author: jinglin.tan
|
|
452
|
-
*/
|
|
453
|
-
export var getOthersSelectedResources = function getOthersSelectedResources(cartItems, accountId, resourcesMap) {
|
|
454
|
-
return cartItems.reduce(function (acc, d) {
|
|
455
|
-
if (d.holder_id !== accountId) {
|
|
456
|
-
var _d$_origin;
|
|
457
|
-
if ((_d$_origin = d._origin) !== null && _d$_origin !== void 0 && _d$_origin.resources) {
|
|
458
|
-
d._origin.resources.forEach(function (n) {
|
|
459
|
-
// 如果是组合资源,还需要检查组合资源里子资源是否被占用过
|
|
460
|
-
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
461
|
-
// 如果组合资源里子资源被占用过,则这个资源不可以进待选列表了
|
|
462
|
-
if (n.metadata.combined_resource.resource_ids.some(function (m) {
|
|
463
|
-
return acc.includes(m);
|
|
464
|
-
})) {
|
|
465
|
-
return acc;
|
|
466
|
-
}
|
|
467
|
-
acc.push.apply(acc, _toConsumableArray(n.metadata.combined_resource.resource_ids));
|
|
468
|
-
} else {
|
|
469
|
-
// 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
|
|
470
|
-
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
471
|
-
Object.values(resourcesMap).forEach(function (m) {
|
|
472
|
-
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
473
|
-
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
474
|
-
acc.push(m.id);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
acc.push(n.id);
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return acc;
|
|
484
|
-
}, []);
|
|
485
|
-
};
|
|
486
|
-
/**
|
|
487
|
-
* @title: 基于选择的商品格式化容量
|
|
488
|
-
* @description:
|
|
489
|
-
* @param {any} param1
|
|
490
|
-
* @return {*}
|
|
491
|
-
* @Author: zhiwei.Wang
|
|
492
|
-
*/
|
|
493
|
-
export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref6) {
|
|
494
|
-
var capacity = _ref6.capacity,
|
|
495
|
-
product_bundle = _ref6.product_bundle;
|
|
496
|
-
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
497
|
-
return (product_bundle || []).map(function (d) {
|
|
498
|
-
var id = d.bundle_product_id;
|
|
499
|
-
var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
|
|
500
|
-
return item.product_id === id;
|
|
501
|
-
});
|
|
502
|
-
return {
|
|
503
|
-
id: id,
|
|
504
|
-
value: item ? d.num || 0 : 0,
|
|
505
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || (d === null || d === void 0 ? void 0 : d.title)
|
|
506
|
-
};
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'custom') {
|
|
510
|
-
return ((capacity === null || capacity === void 0 ? void 0 : capacity.custom) || []).map(function (d) {
|
|
511
|
-
return {
|
|
512
|
-
id: d.id,
|
|
513
|
-
value: d.min,
|
|
514
|
-
name: d.name
|
|
515
|
-
};
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// 默认为1
|
|
520
|
-
return [{
|
|
521
|
-
id: 0,
|
|
522
|
-
value: 1,
|
|
523
|
-
name: ''
|
|
524
|
-
}];
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* @title: 获取总容量
|
|
529
|
-
* @description:
|
|
530
|
-
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
531
|
-
* @return {*}
|
|
532
|
-
* @Author: zhiwei.Wang
|
|
533
|
-
*/
|
|
534
|
-
export var getSumCapacity = function getSumCapacity(_ref7) {
|
|
535
|
-
var capacity = _ref7.capacity;
|
|
536
|
-
var sum = 0;
|
|
537
|
-
var _iterator2 = _createForOfIteratorHelper(capacity || []),
|
|
538
|
-
_step2;
|
|
539
|
-
try {
|
|
540
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
541
|
-
var item = _step2.value;
|
|
542
|
-
sum += item.value;
|
|
543
|
-
}
|
|
544
|
-
} catch (err) {
|
|
545
|
-
_iterator2.e(err);
|
|
546
|
-
} finally {
|
|
547
|
-
_iterator2.f();
|
|
548
|
-
}
|
|
549
|
-
return sum;
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
554
|
-
* @description:
|
|
555
|
-
* @param {object} resource
|
|
556
|
-
* @return {*}
|
|
557
|
-
* @Author: jinglin.tan
|
|
558
|
-
*/
|
|
559
|
-
export var checkSubResourcesCapacity = function checkSubResourcesCapacity(resource) {
|
|
560
|
-
if (resource.children && resource.children.length) {
|
|
561
|
-
var countCapacity = resource.capacity;
|
|
562
|
-
resource.children.forEach(function (child) {
|
|
563
|
-
if (child.capacity <= countCapacity) {
|
|
564
|
-
countCapacity -= child.capacity;
|
|
565
|
-
} else {
|
|
566
|
-
child.capacity = countCapacity;
|
|
567
|
-
countCapacity = 0;
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
450
|
};
|
|
@@ -77,8 +77,8 @@ var createCartItemOrigin = () => {
|
|
|
77
77
|
// 资源相关
|
|
78
78
|
// 资源状态 -固定
|
|
79
79
|
like_status: "common",
|
|
80
|
-
// 资源类型 -
|
|
81
|
-
relation_type: "form",
|
|
80
|
+
// // 资源类型 - 固定----谭景琳备注:马天宇说现在平行资源是不传这个的
|
|
81
|
+
// relation_type: "form",
|
|
82
82
|
// 所选资源
|
|
83
83
|
resources: null,
|
|
84
84
|
// 日程id - 固定
|
|
@@ -213,29 +213,17 @@ var formatResourceToCartItemOrigin = (params) => {
|
|
|
213
213
|
let origin = cartItem._origin;
|
|
214
214
|
if (resources && (resources == null ? void 0 : resources.length)) {
|
|
215
215
|
origin.resources = [];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
like_status: "common",
|
|
226
|
-
id: resource.id,
|
|
227
|
-
main_field: resource.main_field,
|
|
228
|
-
resourceType: resource.resourceType,
|
|
229
|
-
form_id: resource.form_id,
|
|
230
|
-
relation_id: resource.id,
|
|
231
|
-
capacity: (resource == null ? void 0 : resource.capacity) || 0,
|
|
232
|
-
children: childArr,
|
|
233
|
-
metadata: (resource == null ? void 0 : resource.metadata) || {}
|
|
234
|
-
// 后端可以在这里挂一个前端用于计算的数据
|
|
235
|
-
});
|
|
216
|
+
resources.forEach((resource) => {
|
|
217
|
+
origin.resources.push({
|
|
218
|
+
like_status: "common",
|
|
219
|
+
id: resource.id,
|
|
220
|
+
main_field: resource.main_field,
|
|
221
|
+
resourceType: resource.resourceType,
|
|
222
|
+
form_id: resource.form_id,
|
|
223
|
+
relation_id: resource.id,
|
|
224
|
+
capacity: (resource == null ? void 0 : resource.capacity) || 0
|
|
236
225
|
});
|
|
237
|
-
};
|
|
238
|
-
checkResourcesFormat(resources, origin.resources);
|
|
226
|
+
});
|
|
239
227
|
const { startTime, endTime } = resources[0];
|
|
240
228
|
if (startTime && endTime) {
|
|
241
229
|
origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
@@ -2,20 +2,10 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { ProductData, ProductMedia, ProductTag, ProductCategory, ProductBundleGroup } from './types';
|
|
4
4
|
export * from './types';
|
|
5
|
-
/**
|
|
6
|
-
* 商品详情模块
|
|
7
|
-
* 除了跟商品列表模块组合外,还会提供单独的商品详情页的一些方法
|
|
8
|
-
*
|
|
9
|
-
* @export
|
|
10
|
-
* @class Product
|
|
11
|
-
* @extends {BaseModule}
|
|
12
|
-
* @implements {Module}
|
|
13
|
-
*/
|
|
14
5
|
export declare class Product extends BaseModule implements Module {
|
|
15
6
|
protected defaultName: string;
|
|
16
7
|
protected defaultVersion: string;
|
|
17
8
|
private store;
|
|
18
|
-
protected otherParams: any;
|
|
19
9
|
constructor(name?: string, version?: string);
|
|
20
10
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
21
11
|
/**
|
|
@@ -30,9 +30,6 @@ var Product = class extends import_BaseModule.BaseModule {
|
|
|
30
30
|
super(name, version);
|
|
31
31
|
this.defaultName = "product";
|
|
32
32
|
this.defaultVersion = "1.0.0";
|
|
33
|
-
this.otherParams = {
|
|
34
|
-
scheduler: []
|
|
35
|
-
};
|
|
36
33
|
}
|
|
37
34
|
async initialize(core, options) {
|
|
38
35
|
this.core = core;
|
package/lib/modules/index.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
export * from './Product';
|
|
2
2
|
export * from './ProductList';
|
|
3
3
|
export * from './Cart';
|
|
4
|
-
export * from './Account';
|
|
5
|
-
export * from './AccountList';
|
|
6
|
-
export * from './Date';
|
|
7
|
-
export * from './Guests';
|
|
8
|
-
export * from './Order';
|
|
9
|
-
export * from './Payment';
|
|
10
|
-
export * from './Resource';
|
|
11
|
-
export * from './Step';
|
|
12
|
-
export * from './Summary';
|
package/lib/modules/index.js
CHANGED
|
@@ -19,27 +19,9 @@ module.exports = __toCommonJS(modules_exports);
|
|
|
19
19
|
__reExport(modules_exports, require("./Product"), module.exports);
|
|
20
20
|
__reExport(modules_exports, require("./ProductList"), module.exports);
|
|
21
21
|
__reExport(modules_exports, require("./Cart"), module.exports);
|
|
22
|
-
__reExport(modules_exports, require("./Account"), module.exports);
|
|
23
|
-
__reExport(modules_exports, require("./AccountList"), module.exports);
|
|
24
|
-
__reExport(modules_exports, require("./Date"), module.exports);
|
|
25
|
-
__reExport(modules_exports, require("./Guests"), module.exports);
|
|
26
|
-
__reExport(modules_exports, require("./Order"), module.exports);
|
|
27
|
-
__reExport(modules_exports, require("./Payment"), module.exports);
|
|
28
|
-
__reExport(modules_exports, require("./Resource"), module.exports);
|
|
29
|
-
__reExport(modules_exports, require("./Step"), module.exports);
|
|
30
|
-
__reExport(modules_exports, require("./Summary"), module.exports);
|
|
31
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
23
|
0 && (module.exports = {
|
|
33
24
|
...require("./Product"),
|
|
34
25
|
...require("./ProductList"),
|
|
35
|
-
...require("./Cart")
|
|
36
|
-
...require("./Account"),
|
|
37
|
-
...require("./AccountList"),
|
|
38
|
-
...require("./Date"),
|
|
39
|
-
...require("./Guests"),
|
|
40
|
-
...require("./Order"),
|
|
41
|
-
...require("./Payment"),
|
|
42
|
-
...require("./Resource"),
|
|
43
|
-
...require("./Step"),
|
|
44
|
-
...require("./Summary")
|
|
26
|
+
...require("./Cart")
|
|
45
27
|
});
|
|
@@ -5,7 +5,7 @@ import { BookingByStepState } from "./types";
|
|
|
5
5
|
import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
|
|
6
6
|
import { Account } from "../../modules/Account/types";
|
|
7
7
|
import { IStep } from "../../modules/Step/tyeps";
|
|
8
|
-
import { TimeSliceItem
|
|
8
|
+
import { TimeSliceItem } from "./utils/resources";
|
|
9
9
|
import { ITime } from "../../modules/Date/types";
|
|
10
10
|
export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
11
11
|
protected defaultName: string;
|
|
@@ -27,17 +27,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
27
27
|
back(): void;
|
|
28
28
|
gotoStep(index: number): void;
|
|
29
29
|
getStepList(): IStep[];
|
|
30
|
-
loadProducts({ category_ids, product_ids, collection,
|
|
30
|
+
loadProducts({ category_ids, product_ids, collection, }: {
|
|
31
31
|
category_ids?: number[];
|
|
32
32
|
product_ids?: number[];
|
|
33
33
|
collection?: number | string[];
|
|
34
|
-
schedule_ids?: number[];
|
|
35
|
-
}): Promise<any>;
|
|
36
|
-
loadAllSchedule(): Promise<void>;
|
|
37
|
-
loadAvailableDate({ startDate, endDate, custom_page_id }: {
|
|
38
|
-
startDate: string;
|
|
39
|
-
endDate: string;
|
|
40
|
-
custom_page_id?: number;
|
|
41
34
|
}): Promise<any>;
|
|
42
35
|
storeProduct(productData: ProductData): Promise<void>;
|
|
43
36
|
addAccount(accounts: Account[]): Promise<void>;
|
|
@@ -94,8 +87,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
94
87
|
id: number | undefined;
|
|
95
88
|
_id: string;
|
|
96
89
|
product: ProductData | undefined;
|
|
97
|
-
resources: ResourceItem[];
|
|
98
|
-
holder_id: string | number;
|
|
90
|
+
resources: import("./utils/resources").ResourceItem[];
|
|
91
|
+
holder_id: string | number | undefined;
|
|
99
92
|
holder_name: string | undefined;
|
|
100
93
|
} | undefined;
|
|
101
94
|
getResourceTimeSlot({ product, resources, currentResourceId, }: {
|
|
@@ -114,12 +107,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
114
107
|
timeSlots: any[];
|
|
115
108
|
selectedResource: any;
|
|
116
109
|
} | undefined;
|
|
117
|
-
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap,
|
|
110
|
+
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, }: {
|
|
118
111
|
holder_id: string;
|
|
119
112
|
resources_code: string | number;
|
|
120
113
|
timeSlots?: TimeSliceItem;
|
|
121
114
|
countMap: Record<number, number>;
|
|
122
|
-
capacity?: number;
|
|
123
115
|
}): {
|
|
124
116
|
selectedResource: any;
|
|
125
117
|
timeSlots?: undefined;
|
|
@@ -134,5 +126,4 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
134
126
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
135
127
|
clearCache(): void;
|
|
136
128
|
clearCacheByModule(module: string): void;
|
|
137
|
-
openProductDetail(productId: number): Promise<void>;
|
|
138
129
|
}
|