@pisell/pisellos 0.0.175 → 0.0.177
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/Date/index.js +14 -11
- package/dist/modules/Date/types.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +5 -2
- package/lib/modules/Date/index.js +23 -25
- package/lib/modules/Date/types.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +3 -2
- package/package.json +1 -1
|
@@ -93,11 +93,14 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
93
93
|
key: "getResourceDates",
|
|
94
94
|
value: function () {
|
|
95
95
|
var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
96
|
-
var _params$query;
|
|
97
|
-
var currentDateList, currentDateListMap, resourceIds, hasResource, dates;
|
|
96
|
+
var _params$query, currentDateList, currentDateListMap, resourceIds, hasResource, dates;
|
|
98
97
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
99
98
|
while (1) switch (_context2.prev = _context2.next) {
|
|
100
99
|
case 0:
|
|
100
|
+
if (!params.useCache) {
|
|
101
|
+
_context2.next = 7;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
101
104
|
// 发请求之前,做一道检测,看 dateList 里是否有对应日期,且对应日期里是否都有对应 resource_ids 的资源
|
|
102
105
|
currentDateList = this.getDateList() || [];
|
|
103
106
|
currentDateListMap = new Map(currentDateList.map(function (item) {
|
|
@@ -112,18 +115,18 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
112
115
|
});
|
|
113
116
|
});
|
|
114
117
|
if (!hasResource) {
|
|
115
|
-
_context2.next =
|
|
118
|
+
_context2.next = 7;
|
|
116
119
|
break;
|
|
117
120
|
}
|
|
118
121
|
return _context2.abrupt("return", currentDateList);
|
|
119
|
-
case
|
|
120
|
-
_context2.next =
|
|
122
|
+
case 7:
|
|
123
|
+
_context2.next = 9;
|
|
121
124
|
return this.getResourceAvailableTimeList(params);
|
|
122
|
-
case
|
|
125
|
+
case 9:
|
|
123
126
|
dates = _context2.sent;
|
|
124
127
|
this.setDateList(dates);
|
|
125
128
|
return _context2.abrupt("return", dates);
|
|
126
|
-
case
|
|
129
|
+
case 12:
|
|
127
130
|
case "end":
|
|
128
131
|
return _context2.stop();
|
|
129
132
|
}
|
|
@@ -172,11 +175,11 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
172
175
|
key: "fetchResourceDates",
|
|
173
176
|
value: function () {
|
|
174
177
|
var _fetchResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
175
|
-
var url, query, fetchUrl, _ref, start_date, end_date, resource_ids, res;
|
|
178
|
+
var url, query, _params$useCache, useCache, fetchUrl, _ref, start_date, end_date, resource_ids, res;
|
|
176
179
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
177
180
|
while (1) switch (_context3.prev = _context3.next) {
|
|
178
181
|
case 0:
|
|
179
|
-
url = params.url, query = params.query;
|
|
182
|
+
url = params.url, query = params.query, _params$useCache = params.useCache, useCache = _params$useCache === void 0 ? true : _params$useCache;
|
|
180
183
|
fetchUrl = url || '/schedule/resource/list';
|
|
181
184
|
_ref = query || {}, start_date = _ref.start_date, end_date = _ref.end_date, resource_ids = _ref.resource_ids;
|
|
182
185
|
_context3.prev = 3;
|
|
@@ -185,9 +188,9 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
185
188
|
start_date: start_date,
|
|
186
189
|
end_date: end_date,
|
|
187
190
|
resource_ids: resource_ids,
|
|
188
|
-
front_end_cache_id: this.cacheId
|
|
191
|
+
front_end_cache_id: useCache && this.cacheId
|
|
189
192
|
}, {
|
|
190
|
-
useCache:
|
|
193
|
+
useCache: useCache
|
|
191
194
|
});
|
|
192
195
|
case 6:
|
|
193
196
|
res = _context3.sent;
|
|
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
131
131
|
getCart(): CartItem[];
|
|
132
132
|
getAvailableDate(params?: {
|
|
133
133
|
url?: string;
|
|
134
|
+
useCache?: boolean;
|
|
134
135
|
products?: ProductData[];
|
|
135
136
|
startDate?: string;
|
|
136
137
|
endDate?: string;
|
|
@@ -681,6 +681,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
681
681
|
startDate,
|
|
682
682
|
endDate,
|
|
683
683
|
type,
|
|
684
|
+
_params$useCache,
|
|
685
|
+
useCache,
|
|
684
686
|
tempProducts,
|
|
685
687
|
dateRange,
|
|
686
688
|
tempStartDate,
|
|
@@ -696,7 +698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
696
698
|
case 0:
|
|
697
699
|
params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
698
700
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
699
|
-
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
701
|
+
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type, _params$useCache = params.useCache, useCache = _params$useCache === void 0 ? true : _params$useCache; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
700
702
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
701
703
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
702
704
|
}
|
|
@@ -738,7 +740,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
738
740
|
resource_ids: resourceIds
|
|
739
741
|
},
|
|
740
742
|
rules: rules,
|
|
741
|
-
type: type
|
|
743
|
+
type: type,
|
|
744
|
+
useCache: useCache
|
|
742
745
|
});
|
|
743
746
|
case 15:
|
|
744
747
|
res = _context12.sent;
|
|
@@ -70,18 +70,20 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
70
70
|
}
|
|
71
71
|
async getResourceDates(params) {
|
|
72
72
|
var _a;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
if (params.useCache) {
|
|
74
|
+
const currentDateList = this.getDateList() || [];
|
|
75
|
+
const currentDateListMap = new Map(
|
|
76
|
+
currentDateList.map((item) => [item.date, item])
|
|
77
|
+
);
|
|
78
|
+
const resourceIds = ((_a = params.query) == null ? void 0 : _a.resource_ids) || [];
|
|
79
|
+
const hasResource = resourceIds.every((id) => {
|
|
80
|
+
var _a2;
|
|
81
|
+
const currentItem = currentDateListMap.get(id.toString());
|
|
82
|
+
return (_a2 = currentItem == null ? void 0 : currentItem.resource) == null ? void 0 : _a2.some((n) => n.id === id);
|
|
83
|
+
});
|
|
84
|
+
if (hasResource) {
|
|
85
|
+
return currentDateList;
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
const dates = await this.getResourceAvailableTimeList(params);
|
|
87
89
|
this.setDateList(dates);
|
|
@@ -117,22 +119,18 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
117
119
|
this.store.dateList = currentDateList;
|
|
118
120
|
}
|
|
119
121
|
async fetchResourceDates(params) {
|
|
120
|
-
const { url, query } = params;
|
|
122
|
+
const { url, query, useCache = true } = params;
|
|
121
123
|
const fetchUrl = url || "/schedule/resource/list";
|
|
122
124
|
const { start_date, end_date, resource_ids } = query || {};
|
|
123
125
|
try {
|
|
124
|
-
const res = await this.request.get(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
useCache: true
|
|
134
|
-
}
|
|
135
|
-
);
|
|
126
|
+
const res = await this.request.get(fetchUrl, {
|
|
127
|
+
start_date,
|
|
128
|
+
end_date,
|
|
129
|
+
resource_ids,
|
|
130
|
+
front_end_cache_id: useCache && this.cacheId
|
|
131
|
+
}, {
|
|
132
|
+
useCache
|
|
133
|
+
});
|
|
136
134
|
return res;
|
|
137
135
|
} catch (error) {
|
|
138
136
|
console.error(error);
|
|
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
131
131
|
getCart(): CartItem[];
|
|
132
132
|
getAvailableDate(params?: {
|
|
133
133
|
url?: string;
|
|
134
|
+
useCache?: boolean;
|
|
134
135
|
products?: ProductData[];
|
|
135
136
|
startDate?: string;
|
|
136
137
|
endDate?: string;
|
|
@@ -388,7 +388,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
388
388
|
// 获取商品/服务的可用日期
|
|
389
389
|
async getAvailableDate(params = {}) {
|
|
390
390
|
var _a, _b, _c;
|
|
391
|
-
let { products, startDate, endDate, type } = params;
|
|
391
|
+
let { products, startDate, endDate, type, useCache = true } = params;
|
|
392
392
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
393
393
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
394
394
|
}
|
|
@@ -425,7 +425,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
425
425
|
resource_ids: resourceIds
|
|
426
426
|
},
|
|
427
427
|
rules,
|
|
428
|
-
type
|
|
428
|
+
type,
|
|
429
|
+
useCache
|
|
429
430
|
});
|
|
430
431
|
return res;
|
|
431
432
|
}
|