@pisell/pisellos 0.0.216 → 0.0.218
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/Customer/index.d.ts +33 -0
- package/dist/modules/Customer/index.js +315 -58
- package/dist/modules/Customer/types.d.ts +17 -1
- package/dist/modules/Customer/types.js +2 -0
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/dist/solution/BookingTicket/index.d.ts +26 -0
- package/dist/solution/BookingTicket/index.js +120 -14
- package/dist/solution/BookingTicket/types.d.ts +3 -1
- package/dist/solution/BookingTicket/types.js +2 -0
- package/lib/modules/Customer/index.d.ts +33 -0
- package/lib/modules/Customer/index.js +168 -33
- package/lib/modules/Customer/types.d.ts +17 -1
- package/lib/modules/Customer/types.js +2 -0
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/lib/solution/BookingTicket/index.d.ts +26 -0
- package/lib/solution/BookingTicket/index.js +50 -0
- package/lib/solution/BookingTicket/types.d.ts +3 -1
- package/lib/solution/BookingTicket/types.js +2 -0
- package/package.json +1 -1
|
@@ -11,6 +11,18 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
11
11
|
private fatherModule;
|
|
12
12
|
constructor(name?: string, version?: string);
|
|
13
13
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* 获取客户列表数据(内部方法)
|
|
16
|
+
* @param params 查询参数
|
|
17
|
+
* @returns API响应数据
|
|
18
|
+
*/
|
|
19
|
+
private fetchCustomerListData;
|
|
20
|
+
/**
|
|
21
|
+
* 处理客户列表操作的错误(内部方法)
|
|
22
|
+
* @param error 错误对象
|
|
23
|
+
* @param operation 操作名称
|
|
24
|
+
*/
|
|
25
|
+
private handleCustomerListError;
|
|
14
26
|
/**
|
|
15
27
|
* 获取客户列表
|
|
16
28
|
* @param params 查询参数
|
|
@@ -81,6 +93,27 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
81
93
|
* @returns 客户列表响应
|
|
82
94
|
*/
|
|
83
95
|
changeCustomerPage(page: number, pageSize?: number): Promise<ICustomerListResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
98
|
+
* @returns 客户列表响应
|
|
99
|
+
*/
|
|
100
|
+
loadMoreCustomers(): Promise<ICustomerListResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* 重置并重新开始滚动加载
|
|
103
|
+
* @param params 查询参数
|
|
104
|
+
* @returns 客户列表响应
|
|
105
|
+
*/
|
|
106
|
+
resetAndLoadCustomers(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* 检查是否还有更多数据可以加载
|
|
109
|
+
* @returns 是否还有更多数据
|
|
110
|
+
*/
|
|
111
|
+
hasMoreCustomers(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* 获取当前的搜索条件
|
|
114
|
+
* @returns 当前搜索条件
|
|
115
|
+
*/
|
|
116
|
+
getCurrentSearchParams(): Omit<ShopGetCustomerListParams, 'skip' | 'num'>;
|
|
84
117
|
/**
|
|
85
118
|
* 缓存状态变化
|
|
86
119
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var _excluded = ["skip", "num", "search"]
|
|
1
|
+
var _excluded = ["skip", "num", "search"],
|
|
2
|
+
_excluded2 = ["skip", "num"];
|
|
2
3
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -46,7 +47,10 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
46
47
|
currentPage: 1,
|
|
47
48
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
48
49
|
loading: false,
|
|
49
|
-
error: null
|
|
50
|
+
error: null,
|
|
51
|
+
hasMore: true,
|
|
52
|
+
loadingMore: false,
|
|
53
|
+
searchParams: {}
|
|
50
54
|
});
|
|
51
55
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
52
56
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
@@ -58,7 +62,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
58
62
|
key: "initialize",
|
|
59
63
|
value: function () {
|
|
60
64
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
61
|
-
var _options$initialState, _options$initialState2, _options$initialState3, _options$initialState4, _options$initialState5, _options$otherParams, _options$otherParams2;
|
|
65
|
+
var _options$initialState, _options$initialState2, _options$initialState3, _options$initialState4, _options$initialState5, _options$initialState6, _options$initialState7, _options$initialState8, _options$initialState9, _options$initialState10, _options$initialState11, _options$otherParams, _options$otherParams2;
|
|
62
66
|
var customerList;
|
|
63
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
68
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -95,6 +99,11 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
95
99
|
this.store.pageSize = DEFAULT_PAGE_SIZE;
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
// 初始化滚动加载相关状态
|
|
103
|
+
this.store.hasMore = (_options$initialState6 = options === null || options === void 0 || (_options$initialState7 = options.initialState) === null || _options$initialState7 === void 0 ? void 0 : _options$initialState7.hasMore) !== null && _options$initialState6 !== void 0 ? _options$initialState6 : true;
|
|
104
|
+
this.store.loadingMore = (_options$initialState8 = options === null || options === void 0 || (_options$initialState9 = options.initialState) === null || _options$initialState9 === void 0 ? void 0 : _options$initialState9.loadingMore) !== null && _options$initialState8 !== void 0 ? _options$initialState8 : false;
|
|
105
|
+
this.store.searchParams = (_options$initialState10 = options === null || options === void 0 || (_options$initialState11 = options.initialState) === null || _options$initialState11 === void 0 ? void 0 : _options$initialState11.searchParams) !== null && _options$initialState10 !== void 0 ? _options$initialState10 : {};
|
|
106
|
+
|
|
98
107
|
// 缓存配置
|
|
99
108
|
if (options !== null && options !== void 0 && (_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
|
|
100
109
|
this.openCache = options.otherParams.openCache;
|
|
@@ -103,7 +112,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
103
112
|
if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
|
|
104
113
|
this.fatherModule = options.otherParams.fatherModule;
|
|
105
114
|
}
|
|
106
|
-
case
|
|
115
|
+
case 13:
|
|
107
116
|
case "end":
|
|
108
117
|
return _context.stop();
|
|
109
118
|
}
|
|
@@ -115,14 +124,15 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
115
124
|
return initialize;
|
|
116
125
|
}()
|
|
117
126
|
/**
|
|
118
|
-
*
|
|
127
|
+
* 获取客户列表数据(内部方法)
|
|
119
128
|
* @param params 查询参数
|
|
120
|
-
* @returns
|
|
129
|
+
* @returns API响应数据
|
|
121
130
|
*/
|
|
122
131
|
}, {
|
|
123
|
-
key: "
|
|
132
|
+
key: "fetchCustomerListData",
|
|
124
133
|
value: (function () {
|
|
125
|
-
var
|
|
134
|
+
var _fetchCustomerListData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
135
|
+
var _res$data, _res$data2;
|
|
126
136
|
var params,
|
|
127
137
|
url,
|
|
128
138
|
_params$skip,
|
|
@@ -131,15 +141,8 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
131
141
|
num,
|
|
132
142
|
search,
|
|
133
143
|
otherParams,
|
|
134
|
-
_res$data,
|
|
135
|
-
_res$data2,
|
|
136
144
|
queryParams,
|
|
137
145
|
res,
|
|
138
|
-
customerList,
|
|
139
|
-
total,
|
|
140
|
-
page,
|
|
141
|
-
pageSize,
|
|
142
|
-
response,
|
|
143
146
|
_args2 = arguments;
|
|
144
147
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
145
148
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -147,9 +150,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
147
150
|
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
148
151
|
url = '/customer/select-list';
|
|
149
152
|
_params$skip = params.skip, skip = _params$skip === void 0 ? 1 : _params$skip, _params$num = params.num, num = _params$num === void 0 ? DEFAULT_PAGE_SIZE : _params$num, search = params.search, otherParams = _objectWithoutProperties(params, _excluded);
|
|
150
|
-
_context2.prev = 3;
|
|
151
|
-
this.store.loading = true;
|
|
152
|
-
this.store.error = null;
|
|
153
153
|
queryParams = _objectSpread(_objectSpread({
|
|
154
154
|
skip: skip,
|
|
155
155
|
num: num,
|
|
@@ -160,29 +160,114 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
160
160
|
}, search && {
|
|
161
161
|
search: search
|
|
162
162
|
}), otherParams);
|
|
163
|
-
_context2.next =
|
|
163
|
+
_context2.next = 6;
|
|
164
164
|
return this.request.get(url, queryParams);
|
|
165
|
-
case
|
|
165
|
+
case 6:
|
|
166
166
|
res = _context2.sent;
|
|
167
167
|
if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
|
|
168
|
-
_context2.next =
|
|
168
|
+
_context2.next = 9;
|
|
169
169
|
break;
|
|
170
170
|
}
|
|
171
171
|
throw new Error(res === null || res === void 0 ? void 0 : res.message);
|
|
172
|
-
case
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
case 9:
|
|
173
|
+
return _context2.abrupt("return", {
|
|
174
|
+
customerList: (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [],
|
|
175
|
+
total: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.count) || 0,
|
|
176
|
+
page: skip,
|
|
177
|
+
pageSize: num
|
|
178
|
+
});
|
|
179
|
+
case 10:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context2.stop();
|
|
182
|
+
}
|
|
183
|
+
}, _callee2, this);
|
|
184
|
+
}));
|
|
185
|
+
function fetchCustomerListData() {
|
|
186
|
+
return _fetchCustomerListData.apply(this, arguments);
|
|
187
|
+
}
|
|
188
|
+
return fetchCustomerListData;
|
|
189
|
+
}()
|
|
190
|
+
/**
|
|
191
|
+
* 处理客户列表操作的错误(内部方法)
|
|
192
|
+
* @param error 错误对象
|
|
193
|
+
* @param operation 操作名称
|
|
194
|
+
*/
|
|
195
|
+
)
|
|
196
|
+
}, {
|
|
197
|
+
key: "handleCustomerListError",
|
|
198
|
+
value: (function () {
|
|
199
|
+
var _handleCustomerListError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error, operation) {
|
|
200
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
201
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
202
|
+
case 0:
|
|
203
|
+
console.error("Failed to ".concat(operation, ":"), error);
|
|
204
|
+
this.store.error = error instanceof Error ? error.message : "Failed to ".concat(operation);
|
|
205
|
+
_context3.next = 4;
|
|
206
|
+
return this.core.effects.emit(CustomerHooks.OnCustomerListError, this.store.error);
|
|
207
|
+
case 4:
|
|
208
|
+
case "end":
|
|
209
|
+
return _context3.stop();
|
|
210
|
+
}
|
|
211
|
+
}, _callee3, this);
|
|
212
|
+
}));
|
|
213
|
+
function handleCustomerListError(_x3, _x4) {
|
|
214
|
+
return _handleCustomerListError.apply(this, arguments);
|
|
215
|
+
}
|
|
216
|
+
return handleCustomerListError;
|
|
217
|
+
}()
|
|
218
|
+
/**
|
|
219
|
+
* 获取客户列表
|
|
220
|
+
* @param params 查询参数
|
|
221
|
+
* @returns 客户列表响应
|
|
222
|
+
*/
|
|
223
|
+
)
|
|
224
|
+
}, {
|
|
225
|
+
key: "getCustomerList",
|
|
226
|
+
value: (function () {
|
|
227
|
+
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
228
|
+
var params,
|
|
229
|
+
_yield$this$fetchCust,
|
|
230
|
+
customerList,
|
|
231
|
+
total,
|
|
232
|
+
page,
|
|
233
|
+
pageSize,
|
|
234
|
+
skip,
|
|
235
|
+
num,
|
|
236
|
+
searchParams,
|
|
237
|
+
response,
|
|
238
|
+
_args4 = arguments;
|
|
239
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
240
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
241
|
+
case 0:
|
|
242
|
+
params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
243
|
+
_context4.prev = 1;
|
|
244
|
+
this.store.loading = true;
|
|
245
|
+
this.store.error = null;
|
|
246
|
+
_context4.next = 6;
|
|
247
|
+
return this.fetchCustomerListData(params);
|
|
248
|
+
case 6:
|
|
249
|
+
_yield$this$fetchCust = _context4.sent;
|
|
250
|
+
customerList = _yield$this$fetchCust.customerList;
|
|
251
|
+
total = _yield$this$fetchCust.total;
|
|
252
|
+
page = _yield$this$fetchCust.page;
|
|
253
|
+
pageSize = _yield$this$fetchCust.pageSize;
|
|
254
|
+
// 保存搜索条件(排除skip和num)
|
|
255
|
+
skip = params.skip, num = params.num, searchParams = _objectWithoutProperties(params, _excluded2);
|
|
256
|
+
this.store.searchParams = cloneDeep(searchParams);
|
|
257
|
+
|
|
258
|
+
// 更新分页状态
|
|
177
259
|
this.store.currentPage = page;
|
|
178
260
|
this.store.pageSize = pageSize;
|
|
179
261
|
this.store.total = total;
|
|
180
262
|
|
|
181
|
-
//
|
|
263
|
+
// 计算是否还有更多数据
|
|
264
|
+
this.store.hasMore = page * pageSize < total;
|
|
265
|
+
|
|
266
|
+
// 设置客户列表(替换模式)
|
|
182
267
|
this.store.customerList = cloneDeep(customerList);
|
|
183
|
-
|
|
268
|
+
_context4.next = 20;
|
|
184
269
|
return this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
|
|
185
|
-
case
|
|
270
|
+
case 20:
|
|
186
271
|
// 触发分页变化事件
|
|
187
272
|
this.triggerPaginationChange({
|
|
188
273
|
page: page,
|
|
@@ -196,26 +281,24 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
281
|
page: page,
|
|
197
282
|
pageSize: pageSize
|
|
198
283
|
};
|
|
199
|
-
return
|
|
200
|
-
case
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
case
|
|
208
|
-
|
|
209
|
-
case 34:
|
|
210
|
-
_context2.prev = 34;
|
|
284
|
+
return _context4.abrupt("return", response);
|
|
285
|
+
case 25:
|
|
286
|
+
_context4.prev = 25;
|
|
287
|
+
_context4.t0 = _context4["catch"](1);
|
|
288
|
+
_context4.next = 29;
|
|
289
|
+
return this.handleCustomerListError(_context4.t0, 'fetch customer list');
|
|
290
|
+
case 29:
|
|
291
|
+
throw _context4.t0;
|
|
292
|
+
case 30:
|
|
293
|
+
_context4.prev = 30;
|
|
211
294
|
this.store.loading = false;
|
|
212
295
|
this.storeChange();
|
|
213
|
-
return
|
|
214
|
-
case
|
|
296
|
+
return _context4.finish(30);
|
|
297
|
+
case 34:
|
|
215
298
|
case "end":
|
|
216
|
-
return
|
|
299
|
+
return _context4.stop();
|
|
217
300
|
}
|
|
218
|
-
},
|
|
301
|
+
}, _callee4, this, [[1, 25, 30, 34]]);
|
|
219
302
|
}));
|
|
220
303
|
function getCustomerList() {
|
|
221
304
|
return _getCustomerList.apply(this, arguments);
|
|
@@ -294,6 +377,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
294
377
|
this.store.total = 0;
|
|
295
378
|
this.store.currentPage = 1;
|
|
296
379
|
this.store.pageSize = DEFAULT_PAGE_SIZE;
|
|
380
|
+
this.store.hasMore = true;
|
|
381
|
+
this.store.loadingMore = false;
|
|
382
|
+
this.store.searchParams = {};
|
|
297
383
|
this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
|
|
298
384
|
this.storeChange();
|
|
299
385
|
}
|
|
@@ -386,39 +472,210 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
386
472
|
}, {
|
|
387
473
|
key: "changeCustomerPage",
|
|
388
474
|
value: (function () {
|
|
389
|
-
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
475
|
+
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
|
|
390
476
|
var targetPageSize, skip, num;
|
|
391
|
-
return _regeneratorRuntime().wrap(function
|
|
392
|
-
while (1) switch (
|
|
477
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
478
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
393
479
|
case 0:
|
|
394
480
|
targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
|
|
395
481
|
this.setPaginationInfo(page, targetPageSize);
|
|
396
482
|
|
|
397
483
|
// skip直接使用page,num使用pageSize
|
|
398
484
|
skip = page;
|
|
399
|
-
num = targetPageSize; //
|
|
400
|
-
|
|
401
|
-
return this.getCustomerList({
|
|
485
|
+
num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
|
|
486
|
+
_context5.next = 6;
|
|
487
|
+
return this.getCustomerList(_objectSpread({
|
|
402
488
|
skip: skip,
|
|
403
489
|
num: num
|
|
404
|
-
});
|
|
490
|
+
}, this.store.searchParams));
|
|
405
491
|
case 6:
|
|
406
|
-
return
|
|
492
|
+
return _context5.abrupt("return", _context5.sent);
|
|
407
493
|
case 7:
|
|
408
494
|
case "end":
|
|
409
|
-
return
|
|
495
|
+
return _context5.stop();
|
|
410
496
|
}
|
|
411
|
-
},
|
|
497
|
+
}, _callee5, this);
|
|
412
498
|
}));
|
|
413
|
-
function changeCustomerPage(
|
|
499
|
+
function changeCustomerPage(_x5, _x6) {
|
|
414
500
|
return _changeCustomerPage.apply(this, arguments);
|
|
415
501
|
}
|
|
416
502
|
return changeCustomerPage;
|
|
417
503
|
}()
|
|
418
504
|
/**
|
|
419
|
-
*
|
|
505
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
506
|
+
* @returns 客户列表响应
|
|
507
|
+
*/
|
|
508
|
+
)
|
|
509
|
+
}, {
|
|
510
|
+
key: "loadMoreCustomers",
|
|
511
|
+
value: (function () {
|
|
512
|
+
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
513
|
+
var nextPage, _yield$this$fetchCust2, newCustomers, total, page, pageSize, updatedCustomerList, response;
|
|
514
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
515
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
516
|
+
case 0:
|
|
517
|
+
if (!(!this.store.hasMore || this.store.loadingMore)) {
|
|
518
|
+
_context6.next = 2;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
return _context6.abrupt("return", {
|
|
522
|
+
list: [],
|
|
523
|
+
total: this.store.total,
|
|
524
|
+
page: this.store.currentPage,
|
|
525
|
+
pageSize: this.store.pageSize
|
|
526
|
+
});
|
|
527
|
+
case 2:
|
|
528
|
+
// 计算下一页
|
|
529
|
+
nextPage = this.store.currentPage + 1;
|
|
530
|
+
_context6.prev = 3;
|
|
531
|
+
this.store.loadingMore = true;
|
|
532
|
+
this.store.error = null;
|
|
533
|
+
|
|
534
|
+
// 使用公共方法获取数据,传入存储的搜索条件
|
|
535
|
+
_context6.next = 8;
|
|
536
|
+
return this.fetchCustomerListData(_objectSpread({
|
|
537
|
+
skip: nextPage,
|
|
538
|
+
num: this.store.pageSize
|
|
539
|
+
}, this.store.searchParams));
|
|
540
|
+
case 8:
|
|
541
|
+
_yield$this$fetchCust2 = _context6.sent;
|
|
542
|
+
newCustomers = _yield$this$fetchCust2.customerList;
|
|
543
|
+
total = _yield$this$fetchCust2.total;
|
|
544
|
+
page = _yield$this$fetchCust2.page;
|
|
545
|
+
pageSize = _yield$this$fetchCust2.pageSize;
|
|
546
|
+
// 将新数据追加到现有列表(追加模式)
|
|
547
|
+
updatedCustomerList = [].concat(_toConsumableArray(this.store.customerList), _toConsumableArray(cloneDeep(newCustomers))); // 更新状态
|
|
548
|
+
this.store.customerList = updatedCustomerList;
|
|
549
|
+
this.store.currentPage = page;
|
|
550
|
+
this.store.total = total;
|
|
551
|
+
this.store.hasMore = page * pageSize < total;
|
|
552
|
+
|
|
553
|
+
// 触发滚动加载特定事件
|
|
554
|
+
_context6.next = 20;
|
|
555
|
+
return this.core.effects.emit(CustomerHooks.OnScrollLoadMore, {
|
|
556
|
+
newCustomers: newCustomers,
|
|
557
|
+
allCustomers: this.store.customerList,
|
|
558
|
+
currentPage: page,
|
|
559
|
+
hasMore: this.store.hasMore
|
|
560
|
+
});
|
|
561
|
+
case 20:
|
|
562
|
+
_context6.next = 22;
|
|
563
|
+
return this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
|
|
564
|
+
case 22:
|
|
565
|
+
// 触发分页变化事件
|
|
566
|
+
this.triggerPaginationChange({
|
|
567
|
+
page: page,
|
|
568
|
+
pageSize: pageSize,
|
|
569
|
+
total: total,
|
|
570
|
+
totalPages: Math.ceil(total / pageSize)
|
|
571
|
+
});
|
|
572
|
+
response = {
|
|
573
|
+
list: newCustomers,
|
|
574
|
+
// 返回新加载的数据
|
|
575
|
+
total: total,
|
|
576
|
+
page: page,
|
|
577
|
+
pageSize: pageSize
|
|
578
|
+
};
|
|
579
|
+
return _context6.abrupt("return", response);
|
|
580
|
+
case 27:
|
|
581
|
+
_context6.prev = 27;
|
|
582
|
+
_context6.t0 = _context6["catch"](3);
|
|
583
|
+
_context6.next = 31;
|
|
584
|
+
return this.handleCustomerListError(_context6.t0, 'load more customers');
|
|
585
|
+
case 31:
|
|
586
|
+
throw _context6.t0;
|
|
587
|
+
case 32:
|
|
588
|
+
_context6.prev = 32;
|
|
589
|
+
this.store.loadingMore = false;
|
|
590
|
+
this.storeChange();
|
|
591
|
+
return _context6.finish(32);
|
|
592
|
+
case 36:
|
|
593
|
+
case "end":
|
|
594
|
+
return _context6.stop();
|
|
595
|
+
}
|
|
596
|
+
}, _callee6, this, [[3, 27, 32, 36]]);
|
|
597
|
+
}));
|
|
598
|
+
function loadMoreCustomers() {
|
|
599
|
+
return _loadMoreCustomers.apply(this, arguments);
|
|
600
|
+
}
|
|
601
|
+
return loadMoreCustomers;
|
|
602
|
+
}()
|
|
603
|
+
/**
|
|
604
|
+
* 重置并重新开始滚动加载
|
|
605
|
+
* @param params 查询参数
|
|
606
|
+
* @returns 客户列表响应
|
|
420
607
|
*/
|
|
421
608
|
)
|
|
609
|
+
}, {
|
|
610
|
+
key: "resetAndLoadCustomers",
|
|
611
|
+
value: (function () {
|
|
612
|
+
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
613
|
+
var params,
|
|
614
|
+
resetParams,
|
|
615
|
+
response,
|
|
616
|
+
_args7 = arguments;
|
|
617
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
618
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
619
|
+
case 0:
|
|
620
|
+
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
621
|
+
// 重置状态
|
|
622
|
+
this.store.customerList = [];
|
|
623
|
+
this.store.currentPage = 1;
|
|
624
|
+
this.store.hasMore = true;
|
|
625
|
+
this.store.loadingMore = false;
|
|
626
|
+
|
|
627
|
+
// 使用第一页参数
|
|
628
|
+
resetParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
629
|
+
skip: 1,
|
|
630
|
+
num: params.num || this.store.pageSize
|
|
631
|
+
}); // 调用普通的获取列表方法
|
|
632
|
+
_context7.next = 8;
|
|
633
|
+
return this.getCustomerList(resetParams);
|
|
634
|
+
case 8:
|
|
635
|
+
response = _context7.sent;
|
|
636
|
+
_context7.next = 11;
|
|
637
|
+
return this.core.effects.emit(CustomerHooks.OnScrollLoadComplete, {
|
|
638
|
+
customers: this.store.customerList,
|
|
639
|
+
total: this.store.total,
|
|
640
|
+
hasMore: this.store.hasMore
|
|
641
|
+
});
|
|
642
|
+
case 11:
|
|
643
|
+
return _context7.abrupt("return", response);
|
|
644
|
+
case 12:
|
|
645
|
+
case "end":
|
|
646
|
+
return _context7.stop();
|
|
647
|
+
}
|
|
648
|
+
}, _callee7, this);
|
|
649
|
+
}));
|
|
650
|
+
function resetAndLoadCustomers() {
|
|
651
|
+
return _resetAndLoadCustomers.apply(this, arguments);
|
|
652
|
+
}
|
|
653
|
+
return resetAndLoadCustomers;
|
|
654
|
+
}()
|
|
655
|
+
/**
|
|
656
|
+
* 检查是否还有更多数据可以加载
|
|
657
|
+
* @returns 是否还有更多数据
|
|
658
|
+
*/
|
|
659
|
+
)
|
|
660
|
+
}, {
|
|
661
|
+
key: "hasMoreCustomers",
|
|
662
|
+
value: function hasMoreCustomers() {
|
|
663
|
+
return this.store.hasMore && !this.store.loadingMore;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* 获取当前的搜索条件
|
|
668
|
+
* @returns 当前搜索条件
|
|
669
|
+
*/
|
|
670
|
+
}, {
|
|
671
|
+
key: "getCurrentSearchParams",
|
|
672
|
+
value: function getCurrentSearchParams() {
|
|
673
|
+
return cloneDeep(this.store.searchParams);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* 缓存状态变化
|
|
678
|
+
*/
|
|
422
679
|
}, {
|
|
423
680
|
key: "storeChange",
|
|
424
681
|
value: function storeChange() {
|
|
@@ -428,7 +685,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
685
|
cacheId: this.cacheId,
|
|
429
686
|
fatherModule: this.fatherModule,
|
|
430
687
|
store: store,
|
|
431
|
-
cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize']
|
|
688
|
+
cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize', 'hasMore', 'loadingMore', 'searchParams']
|
|
432
689
|
});
|
|
433
690
|
}
|
|
434
691
|
}
|
|
@@ -3,7 +3,9 @@ export declare enum CustomerHooks {
|
|
|
3
3
|
OnCustomerListUpdate = "customer:onUpdate",
|
|
4
4
|
OnCustomerListError = "customer:onError",
|
|
5
5
|
OnCustomerSelected = "customer:onSelected",
|
|
6
|
-
OnPaginationChange = "customer:onPaginationChange"
|
|
6
|
+
OnPaginationChange = "customer:onPaginationChange",
|
|
7
|
+
OnScrollLoadMore = "customer:onScrollLoadMore",
|
|
8
|
+
OnScrollLoadComplete = "customer:onScrollLoadComplete"
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* 客户数据
|
|
@@ -95,6 +97,12 @@ export interface CustomerState {
|
|
|
95
97
|
loading: boolean;
|
|
96
98
|
/** 错误信息 */
|
|
97
99
|
error: string | null;
|
|
100
|
+
/** 是否支持滚动加载更多 */
|
|
101
|
+
hasMore: boolean;
|
|
102
|
+
/** 滚动加载状态 */
|
|
103
|
+
loadingMore: boolean;
|
|
104
|
+
/** 当前搜索条件 */
|
|
105
|
+
searchParams: Omit<ShopGetCustomerListParams, 'skip' | 'num'>;
|
|
98
106
|
}
|
|
99
107
|
/**
|
|
100
108
|
* 客户模块 API
|
|
@@ -126,5 +134,13 @@ export interface CustomerModuleAPI {
|
|
|
126
134
|
setPaginationInfo: (page: number, pageSize: number) => void;
|
|
127
135
|
/** 便捷方法:切换分页并自动获取数据 */
|
|
128
136
|
changeCustomerPage: (page: number, pageSize?: number) => Promise<ICustomerListResponse>;
|
|
137
|
+
/** 滚动加载更多客户数据 */
|
|
138
|
+
loadMoreCustomers: () => Promise<ICustomerListResponse>;
|
|
139
|
+
/** 重置并重新开始滚动加载 */
|
|
140
|
+
resetAndLoadCustomers: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
141
|
+
/** 检查是否还有更多数据可以加载 */
|
|
142
|
+
hasMoreCustomers: () => boolean;
|
|
143
|
+
/** 获取当前的搜索条件 */
|
|
144
|
+
getCurrentSearchParams: () => Omit<ShopGetCustomerListParams, 'skip' | 'num'>;
|
|
129
145
|
}
|
|
130
146
|
export {};
|
|
@@ -3,6 +3,8 @@ export var CustomerHooks = /*#__PURE__*/function (CustomerHooks) {
|
|
|
3
3
|
CustomerHooks["OnCustomerListError"] = "customer:onError";
|
|
4
4
|
CustomerHooks["OnCustomerSelected"] = "customer:onSelected";
|
|
5
5
|
CustomerHooks["OnPaginationChange"] = "customer:onPaginationChange";
|
|
6
|
+
CustomerHooks["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
7
|
+
CustomerHooks["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
6
8
|
return CustomerHooks;
|
|
7
9
|
}({});
|
|
8
10
|
|
|
@@ -431,6 +431,10 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
431
431
|
|
|
432
432
|
// 存储所有时间切片
|
|
433
433
|
var timeSlices = [];
|
|
434
|
+
// times 先以开始时间为准做个排序,时间早的先循环
|
|
435
|
+
times.sort(function (a, b) {
|
|
436
|
+
return dayjs(a.start_at).diff(dayjs(b.start_at), 'minute');
|
|
437
|
+
});
|
|
434
438
|
|
|
435
439
|
// 处理每个时间范围
|
|
436
440
|
times.forEach(function (time) {
|
|
@@ -91,6 +91,32 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
91
91
|
* @returns 客户列表响应
|
|
92
92
|
*/
|
|
93
93
|
changeCustomerPage(page: number, pageSize?: number): Promise<import("../../modules").ICustomerListResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
96
|
+
* @returns 客户列表响应
|
|
97
|
+
*/
|
|
98
|
+
loadMoreCustomers(): Promise<import("../../modules").ICustomerListResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* 重置并重新开始滚动加载客户数据
|
|
101
|
+
* @param params 查询参数
|
|
102
|
+
* @returns 客户列表响应
|
|
103
|
+
*/
|
|
104
|
+
resetAndLoadCustomers(params?: IGetCustomerListParams): Promise<import("../../modules").ICustomerListResponse>;
|
|
105
|
+
/**
|
|
106
|
+
* 检查是否还有更多客户数据可以加载
|
|
107
|
+
* @returns 是否还有更多数据
|
|
108
|
+
*/
|
|
109
|
+
hasMoreCustomers(): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* 获取当前的客户搜索条件
|
|
112
|
+
* @returns 当前搜索条件
|
|
113
|
+
*/
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
115
|
+
/**
|
|
116
|
+
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
|
+
* @returns 客户状态
|
|
118
|
+
*/
|
|
119
|
+
getCustomerState(): import("../../modules").CustomerState;
|
|
94
120
|
/**
|
|
95
121
|
* 全局扫描监听
|
|
96
122
|
* @param callback 回调
|