@pisell/pisellos 0.0.44 → 0.0.46
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/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +20 -1
- package/dist/modules/AccountList/index.js +243 -75
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +5 -5
- package/dist/modules/Cart/index.js +33 -19
- package/dist/modules/Cart/types.d.ts +21 -7
- package/dist/modules/Cart/utils.d.ts +29 -5
- package/dist/modules/Cart/utils.js +72 -26
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -55
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +74 -23
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +10 -5
- package/dist/modules/Order/index.js +32 -16
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Product/index.d.ts +4 -1
- package/dist/modules/Product/index.js +22 -0
- package/dist/modules/Product/types.d.ts +7 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -4
- package/dist/modules/Rules/index.js +11 -11
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/index.d.ts +8 -3
- package/dist/modules/Schedule/index.js +45 -5
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +8 -8
- package/dist/modules/Schedule/utils.d.ts +9 -3
- package/dist/modules/Schedule/utils.js +77 -48
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +5 -5
- package/dist/modules/Summary/index.js +7 -7
- package/dist/modules/Summary/types.d.ts +2 -2
- package/dist/modules/Summary/utils.d.ts +4 -4
- package/dist/modules/Summary/utils.js +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +71 -16
- package/dist/solution/BookingByStep/index.js +643 -227
- package/dist/solution/BookingByStep/types.d.ts +2 -2
- package/dist/solution/BookingByStep/types.js +9 -9
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -5
- package/dist/solution/BookingByStep/utils/resources.js +37 -19
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +20 -1
- package/lib/modules/AccountList/index.js +122 -13
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +5 -5
- package/lib/modules/Cart/index.js +28 -6
- package/lib/modules/Cart/types.d.ts +21 -7
- package/lib/modules/Cart/utils.d.ts +29 -5
- package/lib/modules/Cart/utils.js +47 -3
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +6 -6
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +37 -6
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +10 -5
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +4 -1
- package/lib/modules/Product/index.js +16 -0
- package/lib/modules/Product/types.d.ts +7 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +4 -4
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.d.ts +8 -3
- package/lib/modules/Schedule/index.js +33 -2
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +8 -8
- package/lib/modules/Schedule/utils.d.ts +9 -3
- package/lib/modules/Schedule/utils.js +32 -4
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +5 -5
- package/lib/modules/Summary/types.d.ts +2 -2
- package/lib/modules/Summary/utils.d.ts +4 -4
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +71 -16
- package/lib/solution/BookingByStep/index.js +396 -48
- package/lib/solution/BookingByStep/types.d.ts +2 -2
- package/lib/solution/BookingByStep/types.js +36 -9
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -5
- package/lib/solution/BookingByStep/utils/resources.js +128 -58
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -5,9 +5,14 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
7
7
|
private store;
|
|
8
|
+
private cacheId;
|
|
9
|
+
private openCache;
|
|
10
|
+
private fatherModule;
|
|
8
11
|
constructor(name?: string, version?: string);
|
|
9
|
-
initialize(core: PisellCore, options
|
|
12
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
10
13
|
setScheduleList(list: ScheduleItem[]): void;
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
getScheduleListByIds(ids: number[]): ScheduleItem[];
|
|
15
|
+
setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
|
|
16
|
+
getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
|
|
17
|
+
storeChange(): void;
|
|
13
18
|
}
|
|
@@ -22,6 +22,7 @@ __export(Schedule_exports, {
|
|
|
22
22
|
ScheduleModule: () => ScheduleModule
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(Schedule_exports);
|
|
25
|
+
var import_lodash_es = require("lodash-es");
|
|
25
26
|
var import_BaseModule = require("../BaseModule");
|
|
26
27
|
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
27
28
|
constructor(name, version) {
|
|
@@ -29,20 +30,50 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
29
30
|
this.defaultName = "schedule";
|
|
30
31
|
this.defaultVersion = "1.0.0";
|
|
31
32
|
this.store = {};
|
|
33
|
+
this.openCache = false;
|
|
32
34
|
}
|
|
33
35
|
async initialize(core, options) {
|
|
36
|
+
var _a, _b;
|
|
34
37
|
this.core = core;
|
|
35
38
|
this.store = options == null ? void 0 : options.store;
|
|
39
|
+
if (options.initialState) {
|
|
40
|
+
this.store.scheduleList = options.initialState.scheduleList;
|
|
41
|
+
this.store.availabilityDateList = options.initialState.availabilityDateList;
|
|
42
|
+
} else {
|
|
43
|
+
this.store.scheduleList = [];
|
|
44
|
+
this.store.availabilityDateList = [];
|
|
45
|
+
}
|
|
46
|
+
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
47
|
+
this.openCache = options.otherParams.openCache;
|
|
48
|
+
this.cacheId = options.otherParams.cacheId;
|
|
49
|
+
}
|
|
50
|
+
if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
|
|
51
|
+
this.fatherModule = options.otherParams.fatherModule;
|
|
52
|
+
}
|
|
36
53
|
}
|
|
37
54
|
setScheduleList(list) {
|
|
38
55
|
this.store.scheduleList = list;
|
|
39
56
|
}
|
|
40
|
-
|
|
57
|
+
getScheduleListByIds(ids) {
|
|
58
|
+
return this.store.scheduleList.filter((n) => ids.includes(n.id));
|
|
59
|
+
}
|
|
60
|
+
setAvailabilityScheduleDateList(list) {
|
|
41
61
|
this.store.availabilityDateList = list;
|
|
42
62
|
}
|
|
43
|
-
|
|
63
|
+
getAvailabilityScheduleDateList() {
|
|
44
64
|
return this.store.availabilityDateList;
|
|
45
65
|
}
|
|
66
|
+
storeChange() {
|
|
67
|
+
if (this.openCache) {
|
|
68
|
+
const store = (0, import_lodash_es.cloneDeep)(this.store);
|
|
69
|
+
this.checkSaveCache({
|
|
70
|
+
cacheId: this.cacheId,
|
|
71
|
+
fatherModule: this.fatherModule,
|
|
72
|
+
store,
|
|
73
|
+
cacheKey: ["scheduleList", "availabilityDateList"]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
46
77
|
};
|
|
47
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
79
|
0 && (module.exports = {
|
|
@@ -18,7 +18,7 @@ export type ScheduleItem = {
|
|
|
18
18
|
repeat_rule: {
|
|
19
19
|
end: {
|
|
20
20
|
/** 截止类型 */
|
|
21
|
-
type:
|
|
21
|
+
type: 'date' | 'never';
|
|
22
22
|
/** 结束时间 */
|
|
23
23
|
end_date: string | null;
|
|
24
24
|
occurrence: any | null;
|
|
@@ -28,13 +28,13 @@ export type ScheduleItem = {
|
|
|
28
28
|
included_date: ExcIncDate[];
|
|
29
29
|
frequency_date: number[];
|
|
30
30
|
};
|
|
31
|
-
repeat_type:
|
|
31
|
+
repeat_type: 'daily' | 'none' | 'weekly';
|
|
32
32
|
/** 日程类型
|
|
33
33
|
* standard: 标准日程
|
|
34
34
|
* time-slots: 时间段日程
|
|
35
35
|
* designation: 指定日期日程
|
|
36
36
|
* */
|
|
37
|
-
type:
|
|
37
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
38
38
|
conflict?: boolean;
|
|
39
39
|
time_slot: {
|
|
40
40
|
start_time: string;
|
|
@@ -77,7 +77,7 @@ export type ScheduleFormOtherValue = {
|
|
|
77
77
|
excludedStatus: boolean;
|
|
78
78
|
/** 是否包含排除日期 */
|
|
79
79
|
includeStatus: boolean;
|
|
80
|
-
type:
|
|
80
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
81
81
|
};
|
|
82
82
|
export type ExcIncDate = {
|
|
83
83
|
start: string;
|
|
@@ -89,15 +89,15 @@ export type ScheduleFormData = {
|
|
|
89
89
|
/** 日程名称 */
|
|
90
90
|
name: {
|
|
91
91
|
en: string;
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
'zh-CN': string;
|
|
93
|
+
'zh-HK': string;
|
|
94
94
|
original: string;
|
|
95
95
|
} | string;
|
|
96
96
|
/** 重复模式
|
|
97
97
|
* 0:不重复
|
|
98
98
|
* 1:按天重复
|
|
99
99
|
* 2:按周重复 */
|
|
100
|
-
repeat_type:
|
|
100
|
+
repeat_type: '0' | '1' | '2';
|
|
101
101
|
/** 备注 */
|
|
102
102
|
note: string;
|
|
103
103
|
/** 指定的开始时间结束时间 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import dayjs from
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
2
|
export interface ScheduleState {
|
|
3
3
|
scheduleList: ScheduleItem[];
|
|
4
4
|
availabilityDateList: ScheduleAvailabilityDateItem[];
|
|
@@ -29,7 +29,7 @@ export type ScheduleItem = {
|
|
|
29
29
|
repeat_rule: {
|
|
30
30
|
end: {
|
|
31
31
|
/** 截止类型 */
|
|
32
|
-
type:
|
|
32
|
+
type: 'date' | 'never';
|
|
33
33
|
/** 结束时间 */
|
|
34
34
|
end_date: string | null;
|
|
35
35
|
occurrence: any | null;
|
|
@@ -39,13 +39,13 @@ export type ScheduleItem = {
|
|
|
39
39
|
included_date: ExcIncDate[];
|
|
40
40
|
frequency_date: number[];
|
|
41
41
|
};
|
|
42
|
-
repeat_type:
|
|
42
|
+
repeat_type: 'daily' | 'none' | 'weekly';
|
|
43
43
|
/** 日程类型
|
|
44
44
|
* standard: 标准日程
|
|
45
45
|
* time-slots: 时间段日程
|
|
46
46
|
* designation: 指定日期日程
|
|
47
47
|
* */
|
|
48
|
-
type:
|
|
48
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
49
49
|
conflict?: boolean;
|
|
50
50
|
time_slot: {
|
|
51
51
|
start_time: string;
|
|
@@ -88,7 +88,7 @@ export type ScheduleFormOtherValue = {
|
|
|
88
88
|
excludedStatus: boolean;
|
|
89
89
|
/** 是否包含排除日期 */
|
|
90
90
|
includeStatus: boolean;
|
|
91
|
-
type:
|
|
91
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
92
92
|
};
|
|
93
93
|
export type ExcIncDate = {
|
|
94
94
|
start: string;
|
|
@@ -100,15 +100,15 @@ export type ScheduleFormData = {
|
|
|
100
100
|
/** 日程名称 */
|
|
101
101
|
name: {
|
|
102
102
|
en: string;
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
'zh-CN': string;
|
|
104
|
+
'zh-HK': string;
|
|
105
105
|
original: string;
|
|
106
106
|
} | string;
|
|
107
107
|
/** 重复模式
|
|
108
108
|
* 0:不重复
|
|
109
109
|
* 1:按天重复
|
|
110
110
|
* 2:按周重复 */
|
|
111
|
-
repeat_type:
|
|
111
|
+
repeat_type: '0' | '1' | '2';
|
|
112
112
|
/** 备注 */
|
|
113
113
|
note: string;
|
|
114
114
|
/** 指定的开始时间结束时间 */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ScheduleFormData, ScheduleFormOtherValue, ScheduleItem, ScheduleAllMap } from
|
|
1
|
+
import { ScheduleFormData, ScheduleFormOtherValue, ScheduleItem, ScheduleAllMap } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* 根据日程配置生成日历数据
|
|
4
4
|
* @param values
|
|
5
5
|
* @param others
|
|
6
6
|
* @param type
|
|
7
7
|
*/
|
|
8
|
-
export declare const calcCalendarDataBySchedule: (values: ScheduleFormData, others: ScheduleFormOtherValue, type?:
|
|
8
|
+
export declare const calcCalendarDataBySchedule: (values: ScheduleFormData, others: ScheduleFormOtherValue, type?: 'standard' | 'time-slots' | 'designation') => any[];
|
|
9
9
|
/**
|
|
10
10
|
* 获取开始时间和结束时间之间的所有日期
|
|
11
11
|
* @param startDate
|
|
@@ -46,7 +46,7 @@ export declare const formatScheduleResult: (schedule: ScheduleItem) => {
|
|
|
46
46
|
};
|
|
47
47
|
export declare const calcScheduleDateRange: (schedule: ScheduleItem) => any[];
|
|
48
48
|
export declare const calcCalendarDataBySchedules: (schedules: ScheduleItem[]) => unknown[];
|
|
49
|
-
export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap
|
|
49
|
+
export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) => {};
|
|
50
50
|
/**
|
|
51
51
|
* @title: 格式化日程数据
|
|
52
52
|
* @description:
|
|
@@ -59,3 +59,9 @@ export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[],
|
|
|
59
59
|
* @Date: 2024-09-04 11:54
|
|
60
60
|
*/
|
|
61
61
|
export declare const formatScheduleData: (relation: Array<any>, table_type?: string, item_type?: string, isExcluded?: boolean) => any;
|
|
62
|
+
export interface TimeRange {
|
|
63
|
+
start: string;
|
|
64
|
+
end: string;
|
|
65
|
+
count?: number;
|
|
66
|
+
}
|
|
67
|
+
export declare function getAllSortedDateRanges(schedules: Record<string, any>): TimeRange[];
|
|
@@ -39,6 +39,7 @@ __export(utils_exports, {
|
|
|
39
39
|
calcScheduleDateRange: () => calcScheduleDateRange,
|
|
40
40
|
formatScheduleData: () => formatScheduleData,
|
|
41
41
|
formatScheduleResult: () => formatScheduleResult,
|
|
42
|
+
getAllSortedDateRanges: () => getAllSortedDateRanges,
|
|
42
43
|
getDaysByStartEnd: () => getDaysByStartEnd,
|
|
43
44
|
isAllDay: () => isAllDay
|
|
44
45
|
});
|
|
@@ -490,7 +491,7 @@ var calcCalendarDataBySchedules = (schedules) => {
|
|
|
490
491
|
var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
|
|
491
492
|
return schedules.reduce((pre, cur) => {
|
|
492
493
|
var _a;
|
|
493
|
-
let dateRange = ((_a = scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
|
|
494
|
+
let dateRange = ((_a = scheduleAllMap == null ? void 0 : scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
|
|
494
495
|
let dateRangeFormat = [];
|
|
495
496
|
if (selectDate) {
|
|
496
497
|
const dateRangeTmp = [];
|
|
@@ -543,18 +544,44 @@ var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
|
|
|
543
544
|
var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
|
|
544
545
|
const _relation = relation || [];
|
|
545
546
|
if (table_type && item_type && isExcluded) {
|
|
546
|
-
return _relation.find(
|
|
547
|
+
return _relation.find(
|
|
548
|
+
(item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) !== item_type
|
|
549
|
+
);
|
|
547
550
|
}
|
|
548
551
|
if (table_type && item_type) {
|
|
549
|
-
return _relation.find(
|
|
552
|
+
return _relation.find(
|
|
553
|
+
(item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) === item_type
|
|
554
|
+
);
|
|
550
555
|
}
|
|
551
556
|
if (table_type) {
|
|
552
|
-
return _relation.some(
|
|
557
|
+
return _relation.some(
|
|
558
|
+
(item) => (item == null ? void 0 : item.relation_table_type) === table_type
|
|
559
|
+
);
|
|
553
560
|
}
|
|
554
561
|
if (item_type) {
|
|
555
562
|
return _relation.find((item) => (item == null ? void 0 : item.item_type) === item_type);
|
|
556
563
|
}
|
|
557
564
|
};
|
|
565
|
+
function getAllSortedDateRanges(schedules) {
|
|
566
|
+
const allDateRanges = [];
|
|
567
|
+
Object.values(schedules).forEach((schedule) => {
|
|
568
|
+
if (schedule.dateRange && Array.isArray(schedule.dateRange)) {
|
|
569
|
+
allDateRanges.push(...schedule.dateRange);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
if (allDateRanges.length === 0) {
|
|
573
|
+
console.log("No dateRanges found in schedules:", schedules);
|
|
574
|
+
return [];
|
|
575
|
+
}
|
|
576
|
+
return allDateRanges.sort((a, b) => {
|
|
577
|
+
const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
578
|
+
if (startTimeCompare !== 0)
|
|
579
|
+
return startTimeCompare;
|
|
580
|
+
const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
|
|
581
|
+
const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
582
|
+
return durationA - durationB;
|
|
583
|
+
});
|
|
584
|
+
}
|
|
558
585
|
// Annotate the CommonJS export names for ESM import in node:
|
|
559
586
|
0 && (module.exports = {
|
|
560
587
|
calcCalendarDataByDesignation,
|
|
@@ -567,6 +594,7 @@ var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
|
|
|
567
594
|
calcScheduleDateRange,
|
|
568
595
|
formatScheduleData,
|
|
569
596
|
formatScheduleResult,
|
|
597
|
+
getAllSortedDateRanges,
|
|
570
598
|
getDaysByStartEnd,
|
|
571
599
|
isAllDay
|
|
572
600
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { IStep, IStepModuleAPI } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { IStep, IStepModuleAPI } from './tyeps';
|
|
4
4
|
export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -19,5 +19,16 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
|
|
|
19
19
|
prevStep(): void;
|
|
20
20
|
nextStep(): void;
|
|
21
21
|
gotoStep(stepIndex: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* 添加步骤
|
|
24
|
+
* @param step 步骤
|
|
25
|
+
* @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
|
|
26
|
+
*/
|
|
27
|
+
addStep(step: IStep, key?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* 删除步骤
|
|
30
|
+
* @param key 步骤的 key
|
|
31
|
+
*/
|
|
32
|
+
removeStep(key: string): void;
|
|
22
33
|
storeChange(): void;
|
|
23
34
|
}
|
|
@@ -83,9 +83,46 @@ var StepModule = class extends import_BaseModule.BaseModule {
|
|
|
83
83
|
gotoStep(stepIndex) {
|
|
84
84
|
this.setCurrentStep(stepIndex);
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* 添加步骤
|
|
88
|
+
* @param step 步骤
|
|
89
|
+
* @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
|
|
90
|
+
*/
|
|
91
|
+
addStep(step, key) {
|
|
92
|
+
let stepList = this.store.stepList;
|
|
93
|
+
const index = stepList.findIndex((n) => n.key === step.key);
|
|
94
|
+
if (index !== -1) {
|
|
95
|
+
console.log("[StepModule] 步骤已存在,添加失败");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (key) {
|
|
99
|
+
const index2 = this.store.stepList.findIndex((n) => n.key === key);
|
|
100
|
+
if (index2 !== -1) {
|
|
101
|
+
stepList.splice(index2 + 1, 0, step);
|
|
102
|
+
} else {
|
|
103
|
+
stepList = [...stepList, step];
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
stepList.splice(this.store.currentStepIndex + 1, 0, step);
|
|
107
|
+
}
|
|
108
|
+
this.store.stepList = [...stepList];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 删除步骤
|
|
112
|
+
* @param key 步骤的 key
|
|
113
|
+
*/
|
|
114
|
+
removeStep(key) {
|
|
115
|
+
const newStepList = this.store.stepList.filter((n) => n.key !== key);
|
|
116
|
+
this.store.stepList = [...newStepList];
|
|
117
|
+
}
|
|
86
118
|
storeChange() {
|
|
87
119
|
if (this.openCache) {
|
|
88
|
-
this.checkSaveCache({
|
|
120
|
+
this.checkSaveCache({
|
|
121
|
+
cacheId: this.cacheId,
|
|
122
|
+
fatherModule: this.fatherModule,
|
|
123
|
+
store: this.store,
|
|
124
|
+
cacheKey: ["currentStepIndex", "currentStep", "stepList"]
|
|
125
|
+
});
|
|
89
126
|
}
|
|
90
127
|
}
|
|
91
128
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { CartItem } from
|
|
4
|
-
import { ISummaryState, ISummaryModuleAPI } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { CartItem } from '../Cart/types';
|
|
4
|
+
import { ISummaryState, ISummaryModuleAPI } from './types';
|
|
5
5
|
export declare class SummaryModule extends BaseModule implements Module, ISummaryModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
@@ -13,7 +13,7 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
13
13
|
private fatherModule;
|
|
14
14
|
constructor(name?: string, version?: string);
|
|
15
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
|
-
getSummary(cartItems: CartItem[]): Promise<ISummaryState[
|
|
16
|
+
getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
|
|
17
17
|
/**
|
|
18
18
|
* 获取协议
|
|
19
19
|
* @param protocolId 协议ID
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartItem } from
|
|
1
|
+
import { CartItem } from '../Cart/types';
|
|
2
2
|
export interface ISummaryState {
|
|
3
3
|
summary: {
|
|
4
4
|
/** 商品总价 */
|
|
@@ -30,5 +30,5 @@ export interface IProtocol {
|
|
|
30
30
|
id: string;
|
|
31
31
|
}
|
|
32
32
|
export interface ISummaryModuleAPI {
|
|
33
|
-
getSummary(cartItems: CartItem[]): Promise<ISummaryState[
|
|
33
|
+
getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
|
|
34
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Decimal from
|
|
2
|
-
import { CartItem } from
|
|
3
|
-
import { ISummaryState } from
|
|
4
|
-
export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState[
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { CartItem } from '../Cart/types';
|
|
3
|
+
import { ISummaryState } from './types';
|
|
4
|
+
export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState['summary'];
|
|
5
5
|
/**
|
|
6
6
|
* 计算商品小计(不含其他费用)
|
|
7
7
|
* @param items - 购物车商品数组
|
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './request';
|
|
2
|
+
export * from './window';
|
|
3
|
+
export * from './shopStore';
|
package/lib/plugins/request.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* RequestPlugin 接口定义
|
|
4
4
|
*/
|
|
@@ -40,13 +40,13 @@ export interface RequestPlugin extends Plugin {
|
|
|
40
40
|
*/
|
|
41
41
|
export interface RequestOptions {
|
|
42
42
|
url?: string;
|
|
43
|
-
method?:
|
|
43
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
44
44
|
headers?: Record<string, string>;
|
|
45
45
|
data?: any;
|
|
46
46
|
body?: any;
|
|
47
47
|
params?: Record<string, string | number | boolean>;
|
|
48
48
|
timeout?: number;
|
|
49
|
-
responseType?:
|
|
49
|
+
responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
|
|
50
50
|
withCredentials?: boolean;
|
|
51
51
|
useCache?: boolean;
|
|
52
52
|
}
|
package/lib/plugins/request.js
CHANGED
|
@@ -148,11 +148,16 @@ var RequestPluginImpl = class {
|
|
|
148
148
|
try {
|
|
149
149
|
config = await Promise.resolve(interceptor(config));
|
|
150
150
|
} catch (error) {
|
|
151
|
-
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
151
|
+
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
152
|
+
error instanceof Error ? error.message : "请求拦截器错误",
|
|
153
|
+
config
|
|
154
|
+
);
|
|
152
155
|
let processedError = requestError;
|
|
153
156
|
for (const errorInterceptor of this.interceptors.error) {
|
|
154
157
|
try {
|
|
155
|
-
processedError = await Promise.resolve(
|
|
158
|
+
processedError = await Promise.resolve(
|
|
159
|
+
errorInterceptor(processedError)
|
|
160
|
+
);
|
|
156
161
|
} catch (e) {
|
|
157
162
|
}
|
|
158
163
|
}
|
|
@@ -164,13 +169,22 @@ var RequestPluginImpl = class {
|
|
|
164
169
|
let processedResponse = response;
|
|
165
170
|
for (const interceptor of this.interceptors.response) {
|
|
166
171
|
try {
|
|
167
|
-
processedResponse = await Promise.resolve(
|
|
172
|
+
processedResponse = await Promise.resolve(
|
|
173
|
+
interceptor(processedResponse)
|
|
174
|
+
);
|
|
168
175
|
} catch (error) {
|
|
169
|
-
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
176
|
+
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
177
|
+
error instanceof Error ? error.message : "响应拦截器错误",
|
|
178
|
+
config,
|
|
179
|
+
null,
|
|
180
|
+
response
|
|
181
|
+
);
|
|
170
182
|
let processedError = requestError;
|
|
171
183
|
for (const errorInterceptor of this.interceptors.error) {
|
|
172
184
|
try {
|
|
173
|
-
processedError = await Promise.resolve(
|
|
185
|
+
processedError = await Promise.resolve(
|
|
186
|
+
errorInterceptor(processedError)
|
|
187
|
+
);
|
|
174
188
|
} catch (e) {
|
|
175
189
|
}
|
|
176
190
|
}
|
|
@@ -179,11 +193,16 @@ var RequestPluginImpl = class {
|
|
|
179
193
|
}
|
|
180
194
|
return processedResponse.data;
|
|
181
195
|
} catch (error) {
|
|
182
|
-
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
196
|
+
const requestError = error instanceof RequestError ? error : new RequestError(
|
|
197
|
+
error instanceof Error ? error.message : "请求错误",
|
|
198
|
+
config
|
|
199
|
+
);
|
|
183
200
|
let processedError = requestError;
|
|
184
201
|
for (const errorInterceptor of this.interceptors.error) {
|
|
185
202
|
try {
|
|
186
|
-
processedError = await Promise.resolve(
|
|
203
|
+
processedError = await Promise.resolve(
|
|
204
|
+
errorInterceptor(processedError)
|
|
205
|
+
);
|
|
187
206
|
} catch (e) {
|
|
188
207
|
}
|
|
189
208
|
}
|
|
@@ -195,13 +214,24 @@ var RequestPluginImpl = class {
|
|
|
195
214
|
* 这里实现了一个基于 fetch API 的请求
|
|
196
215
|
*/
|
|
197
216
|
async performRequest(config) {
|
|
198
|
-
const {
|
|
217
|
+
const {
|
|
218
|
+
url,
|
|
219
|
+
method,
|
|
220
|
+
headers,
|
|
221
|
+
data,
|
|
222
|
+
params,
|
|
223
|
+
timeout,
|
|
224
|
+
responseType,
|
|
225
|
+
withCredentials
|
|
226
|
+
} = config;
|
|
199
227
|
if (!url) {
|
|
200
228
|
throw new RequestError("URL不能为空", config);
|
|
201
229
|
}
|
|
202
230
|
let fullUrl = url;
|
|
203
231
|
if (params && Object.keys(params).length > 0) {
|
|
204
|
-
const queryString = Object.entries(params).map(
|
|
232
|
+
const queryString = Object.entries(params).map(
|
|
233
|
+
([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
234
|
+
).join("&");
|
|
205
235
|
fullUrl += (url.includes("?") ? "&" : "?") + queryString;
|
|
206
236
|
}
|
|
207
237
|
const fetchOptions = {
|
|
@@ -230,7 +260,9 @@ var RequestPluginImpl = class {
|
|
|
230
260
|
}
|
|
231
261
|
});
|
|
232
262
|
try {
|
|
233
|
-
const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
|
|
263
|
+
const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
|
|
264
|
+
new RequestError("当前环境不支持 fetch API", config)
|
|
265
|
+
);
|
|
234
266
|
const response = await Promise.race([fetchPromise, timeoutPromise]);
|
|
235
267
|
const responseHeaders = {};
|
|
236
268
|
response.headers.forEach((value, key) => {
|
|
@@ -264,7 +296,12 @@ var RequestPluginImpl = class {
|
|
|
264
296
|
config
|
|
265
297
|
};
|
|
266
298
|
if (!response.ok) {
|
|
267
|
-
throw new RequestError(
|
|
299
|
+
throw new RequestError(
|
|
300
|
+
`请求失败,状态码: ${response.status}`,
|
|
301
|
+
config,
|
|
302
|
+
fetchOptions,
|
|
303
|
+
result
|
|
304
|
+
);
|
|
268
305
|
}
|
|
269
306
|
return result;
|
|
270
307
|
} finally {
|