@pisell/pisellos 0.0.35 → 0.0.37
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 +4 -0
- package/dist/modules/Cart/utils.js +21 -11
- package/dist/modules/Product/index.d.ts +10 -0
- package/dist/modules/Product/index.js +13 -0
- package/dist/modules/Product/types.d.ts +4 -0
- package/dist/modules/Resource/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +10 -0
- package/dist/modules/Schedule/index.js +56 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/type.js +1 -0
- package/dist/modules/Schedule/types.d.ts +177 -0
- package/dist/modules/Schedule/types.js +1 -0
- package/dist/modules/Schedule/utils.d.ts +61 -0
- package/dist/modules/Schedule/utils.js +700 -0
- package/dist/modules/index.d.ts +9 -0
- package/dist/modules/index.js +10 -1
- package/dist/solution/BookingByStep/index.d.ts +14 -5
- package/dist/solution/BookingByStep/index.js +284 -163
- package/dist/solution/BookingByStep/types.d.ts +2 -10
- package/dist/solution/BookingByStep/types.js +1 -7
- package/dist/solution/BookingByStep/utils/resources.d.ts +45 -4
- package/dist/solution/BookingByStep/utils/resources.js +153 -32
- package/lib/modules/Cart/types.d.ts +4 -0
- package/lib/modules/Cart/utils.js +22 -11
- package/lib/modules/Product/index.d.ts +10 -0
- package/lib/modules/Product/index.js +3 -0
- package/lib/modules/Product/types.d.ts +4 -0
- package/lib/modules/Resource/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +10 -0
- package/lib/modules/Schedule/index.js +41 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/type.js +17 -0
- package/lib/modules/Schedule/types.d.ts +177 -0
- package/lib/modules/Schedule/types.js +17 -0
- package/lib/modules/Schedule/utils.d.ts +61 -0
- package/lib/modules/Schedule/utils.js +572 -0
- package/lib/modules/index.d.ts +9 -0
- package/lib/modules/index.js +19 -1
- package/lib/solution/BookingByStep/index.d.ts +14 -5
- package/lib/solution/BookingByStep/index.js +84 -35
- package/lib/solution/BookingByStep/types.d.ts +2 -10
- package/lib/solution/BookingByStep/types.js +6 -12
- package/lib/solution/BookingByStep/utils/resources.d.ts +45 -4
- package/lib/solution/BookingByStep/utils/resources.js +101 -24
- package/package.json +1 -1
|
@@ -1,13 +1,4 @@
|
|
|
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";
|
|
1
|
+
import { ProductList, CartModule, Product, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule } from "../../modules";
|
|
11
2
|
export interface BookingByStepState {
|
|
12
3
|
cart: CartModule;
|
|
13
4
|
summary: SummaryModule;
|
|
@@ -20,6 +11,7 @@ export interface BookingByStepState {
|
|
|
20
11
|
accountList: AccountListModule;
|
|
21
12
|
order: OrderModule;
|
|
22
13
|
payment: PaymentModule;
|
|
14
|
+
currentProduct: Product;
|
|
23
15
|
}
|
|
24
16
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
25
17
|
export declare enum BookingByStepHooks {
|
|
@@ -1,10 +1,4 @@
|
|
|
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";
|
|
1
|
+
import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule } from "../../modules";
|
|
8
2
|
export function createModule(moduleName, solutionName, name, version) {
|
|
9
3
|
switch (moduleName) {
|
|
10
4
|
case "cart":
|
|
@@ -45,8 +45,7 @@ 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>,
|
|
49
|
-
export declare const getSumCapacity: () => number;
|
|
48
|
+
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>, resources: ResourceItem[], selectedResources: number[], capacity?: number) => ResourceItem[];
|
|
50
49
|
/**
|
|
51
50
|
* @title: 获取资源列表
|
|
52
51
|
* @description:
|
|
@@ -67,11 +66,12 @@ export declare const formatResources: ({ booking, resources }: {
|
|
|
67
66
|
* @return {*}
|
|
68
67
|
* @Author: zhiwei.Wang
|
|
69
68
|
*/
|
|
70
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate }: {
|
|
69
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity }: {
|
|
71
70
|
resource: ResourceItem;
|
|
72
71
|
duration: number;
|
|
73
72
|
split: number;
|
|
74
73
|
currentDate: DateType | string;
|
|
74
|
+
capacity?: number | undefined;
|
|
75
75
|
}) => TimeSliceItem[];
|
|
76
76
|
/**
|
|
77
77
|
* @title: 获取时间切片列表的交集
|
|
@@ -100,11 +100,52 @@ 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, capacity }: {
|
|
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;
|
|
109
110
|
}) => 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;
|
|
110
151
|
export {};
|
|
@@ -191,41 +191,39 @@ 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
|
-
|
|
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) {
|
|
194
|
+
export var getResourcesByProduct = function getResourcesByProduct(resourcesMap, resources, selectedResources) {
|
|
195
|
+
var capacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
196
|
+
return (resources || []).reduce(function (acc, item) {
|
|
198
197
|
if ((item === null || item === void 0 ? void 0 : item.status) == 1) {
|
|
199
198
|
var form_id = item.id;
|
|
200
199
|
// 去重 可选资源和必选资源可能会有重复的
|
|
201
200
|
item.optional_resource = (item.optional_resource || []).filter(function (d) {
|
|
202
201
|
return item.default_resource.indexOf(d) == -1;
|
|
203
202
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
|
|
204
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id) && capacity <= resourcesMap[d].capacity) {
|
|
205
|
+
// 拼装组合资源的数据
|
|
206
|
+
var combiningResources = [];
|
|
207
|
+
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
208
|
+
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
209
|
+
if (resourcesMap[id]) {
|
|
210
|
+
combiningResources.push(resourcesMap[id]);
|
|
211
|
+
}
|
|
213
212
|
});
|
|
214
213
|
}
|
|
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)) {
|
|
220
214
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
221
215
|
form_id: form_id,
|
|
222
|
-
resourceType: item.type
|
|
216
|
+
resourceType: item.type,
|
|
217
|
+
children: combiningResources,
|
|
218
|
+
metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
|
|
219
|
+
combined_resource: resourcesMap[d].combined_resource
|
|
220
|
+
})
|
|
223
221
|
}));
|
|
224
222
|
}
|
|
225
223
|
return childAcc;
|
|
226
224
|
}, []);
|
|
227
225
|
var default_resource = item.default_resource.reduce(function (childAcc, d) {
|
|
228
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
226
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id) && capacity <= resourcesMap[d].capacity) {
|
|
229
227
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
230
228
|
form_id: form_id,
|
|
231
229
|
resourceType: item.type,
|
|
@@ -249,14 +247,6 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
249
247
|
return acc;
|
|
250
248
|
}, []);
|
|
251
249
|
};
|
|
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
|
-
};
|
|
260
250
|
|
|
261
251
|
/**
|
|
262
252
|
* @title: 获取资源列表
|
|
@@ -319,7 +309,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
319
309
|
_ref4$split = _ref4.split,
|
|
320
310
|
split = _ref4$split === void 0 ? 10 : _ref4$split,
|
|
321
311
|
_ref4$currentDate = _ref4.currentDate,
|
|
322
|
-
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate
|
|
312
|
+
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate,
|
|
313
|
+
capacity = _ref4.capacity;
|
|
323
314
|
var times = resource.times;
|
|
324
315
|
|
|
325
316
|
// 存储所有时间切片
|
|
@@ -356,7 +347,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
356
347
|
timeSlice: timeSlice,
|
|
357
348
|
time: time,
|
|
358
349
|
resource: resource,
|
|
359
|
-
currentCount:
|
|
350
|
+
currentCount: capacity || 1
|
|
360
351
|
});
|
|
361
352
|
if (_status.usable) {
|
|
362
353
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
@@ -430,7 +421,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
430
421
|
resourcesMap = _ref5.resourcesMap,
|
|
431
422
|
duration = _ref5.duration,
|
|
432
423
|
currentDate = _ref5.currentDate,
|
|
433
|
-
split = _ref5.split
|
|
424
|
+
split = _ref5.split,
|
|
425
|
+
capacity = _ref5.capacity;
|
|
434
426
|
// 获取资源列表
|
|
435
427
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
436
428
|
|
|
@@ -440,11 +432,140 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
440
432
|
resource: item,
|
|
441
433
|
duration: duration,
|
|
442
434
|
split: split,
|
|
443
|
-
currentDate: currentDate
|
|
435
|
+
currentDate: currentDate,
|
|
436
|
+
capacity: capacity
|
|
444
437
|
}));
|
|
445
438
|
}, []);
|
|
446
439
|
|
|
447
440
|
// 获取时间切片列表的交集
|
|
448
441
|
var intersection = getTimesIntersection(timeSliceList, resources.length);
|
|
449
442
|
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
|
+
}
|
|
450
571
|
};
|
|
@@ -213,18 +213,29 @@ 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
|
-
|
|
216
|
+
const checkResourcesFormat = (resources2, arr) => {
|
|
217
|
+
resources2.forEach((resource) => {
|
|
218
|
+
var _a;
|
|
219
|
+
const childArr = [];
|
|
220
|
+
if ((_a = resource == null ? void 0 : resource.children) == null ? void 0 : _a.length) {
|
|
221
|
+
checkResourcesFormat(resource.children, childArr);
|
|
222
|
+
}
|
|
223
|
+
arr.push({
|
|
224
|
+
relation_type: "form",
|
|
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
|
+
});
|
|
226
236
|
});
|
|
227
|
-
}
|
|
237
|
+
};
|
|
238
|
+
checkResourcesFormat(resources, origin.resources);
|
|
228
239
|
const { startTime, endTime } = resources[0];
|
|
229
240
|
if (startTime && endTime) {
|
|
230
241
|
origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
@@ -2,10 +2,20 @@ 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
|
+
*/
|
|
5
14
|
export declare class Product extends BaseModule implements Module {
|
|
6
15
|
protected defaultName: string;
|
|
7
16
|
protected defaultVersion: string;
|
|
8
17
|
private store;
|
|
18
|
+
protected otherParams: any;
|
|
9
19
|
constructor(name?: string, version?: string);
|
|
10
20
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
11
21
|
/**
|
|
@@ -30,6 +30,9 @@ 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
|
+
};
|
|
33
36
|
}
|
|
34
37
|
async initialize(core, options) {
|
|
35
38
|
this.core = core;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { ScheduleModuleAPI } from './types';
|
|
4
|
+
export declare class ScheduleModule extends BaseModule implements Module, ScheduleModuleAPI {
|
|
5
|
+
protected defaultName: string;
|
|
6
|
+
protected defaultVersion: string;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(name?: string, version?: string);
|
|
9
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Schedule/index.ts
|
|
20
|
+
var Schedule_exports = {};
|
|
21
|
+
__export(Schedule_exports, {
|
|
22
|
+
ScheduleModule: () => ScheduleModule
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Schedule_exports);
|
|
25
|
+
var import_BaseModule = require("../BaseModule");
|
|
26
|
+
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
27
|
+
constructor(name, version) {
|
|
28
|
+
super(name, version);
|
|
29
|
+
this.defaultName = "schedule";
|
|
30
|
+
this.defaultVersion = "1.0.0";
|
|
31
|
+
this.store = {};
|
|
32
|
+
}
|
|
33
|
+
async initialize(core, options) {
|
|
34
|
+
this.core = core;
|
|
35
|
+
this.store = options == null ? void 0 : options.store;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
ScheduleModule
|
|
41
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export type ScheduleItem = {
|
|
2
|
+
/** 颜色 */
|
|
3
|
+
color: string;
|
|
4
|
+
/** 创建时间 */
|
|
5
|
+
created_at: string;
|
|
6
|
+
/** 更新时间 */
|
|
7
|
+
updated_at: string;
|
|
8
|
+
/** 开始时间 */
|
|
9
|
+
start_time: string;
|
|
10
|
+
/** 结束时间 */
|
|
11
|
+
end_time: string;
|
|
12
|
+
/** 日程名称 */
|
|
13
|
+
name: string;
|
|
14
|
+
/** 关联订单 */
|
|
15
|
+
order_count: number;
|
|
16
|
+
/** 关联项目数据*/
|
|
17
|
+
relation_count: number;
|
|
18
|
+
repeat_rule: {
|
|
19
|
+
end: {
|
|
20
|
+
/** 截止类型 */
|
|
21
|
+
type: "date" | "never";
|
|
22
|
+
/** 结束时间 */
|
|
23
|
+
end_date: string | null;
|
|
24
|
+
occurrence: any | null;
|
|
25
|
+
};
|
|
26
|
+
frequency: number;
|
|
27
|
+
excluded_date: ExcIncDate[];
|
|
28
|
+
included_date: ExcIncDate[];
|
|
29
|
+
frequency_date: number[];
|
|
30
|
+
};
|
|
31
|
+
repeat_type: "daily" | "none" | "weekly";
|
|
32
|
+
/** 日程类型
|
|
33
|
+
* standard: 标准日程
|
|
34
|
+
* time-slots: 时间段日程
|
|
35
|
+
* designation: 指定日期日程
|
|
36
|
+
* */
|
|
37
|
+
type: "standard" | "time-slots" | "designation";
|
|
38
|
+
conflict?: boolean;
|
|
39
|
+
time_slot: {
|
|
40
|
+
start_time: string;
|
|
41
|
+
end_time: string;
|
|
42
|
+
id: number;
|
|
43
|
+
}[];
|
|
44
|
+
id: number;
|
|
45
|
+
/** 指定的开始时间结束时间 */
|
|
46
|
+
designation: {
|
|
47
|
+
start_date: string;
|
|
48
|
+
end_date: string;
|
|
49
|
+
start_time: string;
|
|
50
|
+
end_time: string;
|
|
51
|
+
} | {
|
|
52
|
+
start_date: string;
|
|
53
|
+
end_date: string;
|
|
54
|
+
start_time: string;
|
|
55
|
+
end_time: string;
|
|
56
|
+
}[];
|
|
57
|
+
/** 是否全天 */
|
|
58
|
+
is_all: 1 | 0;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
relation?: {
|
|
61
|
+
id: number;
|
|
62
|
+
item_id: number;
|
|
63
|
+
item_type: string;
|
|
64
|
+
relation_table_type: string;
|
|
65
|
+
schedule_id: number;
|
|
66
|
+
}[];
|
|
67
|
+
};
|
|
68
|
+
export type ScheduleFormOtherValue = {
|
|
69
|
+
/** 截止模式
|
|
70
|
+
* 1: 永不截止
|
|
71
|
+
* 2: 按日期截止
|
|
72
|
+
* */
|
|
73
|
+
endRadio: 1 | 2;
|
|
74
|
+
/** 是否为全天 */
|
|
75
|
+
isAllDay: boolean;
|
|
76
|
+
/** 是否开启排除日期 */
|
|
77
|
+
excludedStatus: boolean;
|
|
78
|
+
/** 是否包含排除日期 */
|
|
79
|
+
includeStatus: boolean;
|
|
80
|
+
type: "standard" | "time-slots" | "designation";
|
|
81
|
+
};
|
|
82
|
+
export type ExcIncDate = {
|
|
83
|
+
start: string;
|
|
84
|
+
end: string;
|
|
85
|
+
};
|
|
86
|
+
export type ScheduleFormData = {
|
|
87
|
+
/** 颜色 */
|
|
88
|
+
color: string;
|
|
89
|
+
/** 日程名称 */
|
|
90
|
+
name: {
|
|
91
|
+
en: string;
|
|
92
|
+
"zh-CN": string;
|
|
93
|
+
"zh-HK": string;
|
|
94
|
+
original: string;
|
|
95
|
+
} | string;
|
|
96
|
+
/** 重复模式
|
|
97
|
+
* 0:不重复
|
|
98
|
+
* 1:按天重复
|
|
99
|
+
* 2:按周重复 */
|
|
100
|
+
repeat_type: "0" | "1" | "2";
|
|
101
|
+
/** 备注 */
|
|
102
|
+
note: string;
|
|
103
|
+
/** 指定的开始时间结束时间 */
|
|
104
|
+
designation: {
|
|
105
|
+
start_date: string;
|
|
106
|
+
end_date: string;
|
|
107
|
+
start_time: string;
|
|
108
|
+
end_time: string;
|
|
109
|
+
} | {
|
|
110
|
+
start_date: string;
|
|
111
|
+
end_date: string;
|
|
112
|
+
start_time: string;
|
|
113
|
+
end_time: string;
|
|
114
|
+
}[];
|
|
115
|
+
time_slot: {
|
|
116
|
+
start_time: string;
|
|
117
|
+
end_time: string;
|
|
118
|
+
id: number;
|
|
119
|
+
}[];
|
|
120
|
+
/** 重复频率 */
|
|
121
|
+
frequency: number;
|
|
122
|
+
/** 按周重复时选择的周数据 */
|
|
123
|
+
frequency_date: number[];
|
|
124
|
+
/** 截止日期 */
|
|
125
|
+
end_date: string;
|
|
126
|
+
/** 排除的日期范围 */
|
|
127
|
+
excluded_date: ExcIncDate[];
|
|
128
|
+
/** 包含的日期范围 */
|
|
129
|
+
included_date: ExcIncDate[];
|
|
130
|
+
/** 多时间段的开始时间 */
|
|
131
|
+
start_time: any;
|
|
132
|
+
end_time: any;
|
|
133
|
+
};
|
|
134
|
+
export type CalendarDataItem = {
|
|
135
|
+
date: string;
|
|
136
|
+
color: string[];
|
|
137
|
+
isExcluded: boolean;
|
|
138
|
+
schedule_ids?: number[];
|
|
139
|
+
[key: string]: any;
|
|
140
|
+
};
|
|
141
|
+
export type RequestData<Data> = {
|
|
142
|
+
data: Data;
|
|
143
|
+
status: boolean;
|
|
144
|
+
message: string;
|
|
145
|
+
code: number;
|
|
146
|
+
};
|
|
147
|
+
export type ResponseListData<Data> = {
|
|
148
|
+
status: boolean;
|
|
149
|
+
message: string;
|
|
150
|
+
code: number;
|
|
151
|
+
data: {
|
|
152
|
+
list: Data;
|
|
153
|
+
count: number;
|
|
154
|
+
size: number;
|
|
155
|
+
skip: number;
|
|
156
|
+
};
|
|
157
|
+
};
|