@pisell/pisellos 0.0.215 → 0.0.217

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.
Files changed (35) hide show
  1. package/dist/modules/Customer/index.d.ts +33 -0
  2. package/dist/modules/Customer/index.js +316 -58
  3. package/dist/modules/Customer/types.d.ts +17 -1
  4. package/dist/modules/Customer/types.js +2 -0
  5. package/dist/modules/ProductList/index.d.ts +6 -0
  6. package/dist/modules/ProductList/index.js +20 -0
  7. package/dist/solution/BookingTicket/index.d.ts +33 -0
  8. package/dist/solution/BookingTicket/index.js +167 -21
  9. package/dist/solution/BookingTicket/types.d.ts +3 -1
  10. package/dist/solution/BookingTicket/types.js +2 -0
  11. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +15 -3
  12. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
  13. package/dist/solution/BookingTicket/utils/scan/handleScan.js +99 -55
  14. package/dist/solution/BookingTicket/utils/scan/index.d.ts +12 -4
  15. package/dist/solution/BookingTicket/utils/scan/index.js +32 -20
  16. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  17. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  18. package/lib/modules/Customer/index.d.ts +33 -0
  19. package/lib/modules/Customer/index.js +168 -32
  20. package/lib/modules/Customer/types.d.ts +17 -1
  21. package/lib/modules/Customer/types.js +2 -0
  22. package/lib/modules/ProductList/index.d.ts +6 -0
  23. package/lib/modules/ProductList/index.js +18 -0
  24. package/lib/solution/BookingTicket/index.d.ts +33 -0
  25. package/lib/solution/BookingTicket/index.js +98 -8
  26. package/lib/solution/BookingTicket/types.d.ts +3 -1
  27. package/lib/solution/BookingTicket/types.js +2 -0
  28. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +23 -3
  29. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
  30. package/lib/solution/BookingTicket/utils/scan/handleScan.js +58 -16
  31. package/lib/solution/BookingTicket/utils/scan/index.d.ts +12 -4
  32. package/lib/solution/BookingTicket/utils/scan/index.js +16 -20
  33. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  34. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  35. 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 10:
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: "getCustomerList",
132
+ key: "fetchCustomerListData",
124
133
  value: (function () {
125
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
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,41 +150,124 @@ 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,
156
156
  sort_by: SORT_BY,
157
157
  with: ['latestWalletDetail.wallet'],
158
+ search_wallet_flag: 1,
158
159
  search_wallet_pass_flag: 1
159
160
  }, search && {
160
161
  search: search
161
162
  }), otherParams);
162
- _context2.next = 9;
163
+ _context2.next = 6;
163
164
  return this.request.get(url, queryParams);
164
- case 9:
165
+ case 6:
165
166
  res = _context2.sent;
166
167
  if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
167
- _context2.next = 12;
168
+ _context2.next = 9;
168
169
  break;
169
170
  }
170
171
  throw new Error(res === null || res === void 0 ? void 0 : res.message);
171
- case 12:
172
- customerList = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
173
- total = (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.count) || 0; // skip直接作为page使用,num作为pageSize
174
- page = skip;
175
- pageSize = num; // 更新分页状态
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
+ // 更新分页状态
176
259
  this.store.currentPage = page;
177
260
  this.store.pageSize = pageSize;
178
261
  this.store.total = total;
179
262
 
180
- // 设置客户列表
263
+ // 计算是否还有更多数据
264
+ this.store.hasMore = page * pageSize < total;
265
+
266
+ // 设置客户列表(替换模式)
181
267
  this.store.customerList = cloneDeep(customerList);
182
- _context2.next = 22;
268
+ _context4.next = 20;
183
269
  return this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
184
- case 22:
270
+ case 20:
185
271
  // 触发分页变化事件
186
272
  this.triggerPaginationChange({
187
273
  page: page,
@@ -195,26 +281,24 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
195
281
  page: page,
196
282
  pageSize: pageSize
197
283
  };
198
- return _context2.abrupt("return", response);
199
- case 27:
200
- _context2.prev = 27;
201
- _context2.t0 = _context2["catch"](3);
202
- console.error('Failed to fetch customer list:', _context2.t0);
203
- this.store.error = _context2.t0 instanceof Error ? _context2.t0.message : 'Failed to fetch customer list';
204
- _context2.next = 33;
205
- return this.core.effects.emit(CustomerHooks.OnCustomerListError, this.store.error);
206
- case 33:
207
- throw _context2.t0;
208
- case 34:
209
- _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;
210
294
  this.store.loading = false;
211
295
  this.storeChange();
212
- return _context2.finish(34);
213
- case 38:
296
+ return _context4.finish(30);
297
+ case 34:
214
298
  case "end":
215
- return _context2.stop();
299
+ return _context4.stop();
216
300
  }
217
- }, _callee2, this, [[3, 27, 34, 38]]);
301
+ }, _callee4, this, [[1, 25, 30, 34]]);
218
302
  }));
219
303
  function getCustomerList() {
220
304
  return _getCustomerList.apply(this, arguments);
@@ -293,6 +377,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
293
377
  this.store.total = 0;
294
378
  this.store.currentPage = 1;
295
379
  this.store.pageSize = DEFAULT_PAGE_SIZE;
380
+ this.store.hasMore = true;
381
+ this.store.loadingMore = false;
382
+ this.store.searchParams = {};
296
383
  this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
297
384
  this.storeChange();
298
385
  }
@@ -385,39 +472,210 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
385
472
  }, {
386
473
  key: "changeCustomerPage",
387
474
  value: (function () {
388
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(page, pageSize) {
475
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
389
476
  var targetPageSize, skip, num;
390
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
391
- while (1) switch (_context3.prev = _context3.next) {
477
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
478
+ while (1) switch (_context5.prev = _context5.next) {
392
479
  case 0:
393
480
  targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
394
481
  this.setPaginationInfo(page, targetPageSize);
395
482
 
396
483
  // skip直接使用page,num使用pageSize
397
484
  skip = page;
398
- num = targetPageSize; // 自动调用获取客户列表
399
- _context3.next = 6;
400
- return this.getCustomerList({
485
+ num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
486
+ _context5.next = 6;
487
+ return this.getCustomerList(_objectSpread({
401
488
  skip: skip,
402
489
  num: num
403
- });
490
+ }, this.store.searchParams));
404
491
  case 6:
405
- return _context3.abrupt("return", _context3.sent);
492
+ return _context5.abrupt("return", _context5.sent);
406
493
  case 7:
407
494
  case "end":
408
- return _context3.stop();
495
+ return _context5.stop();
409
496
  }
410
- }, _callee3, this);
497
+ }, _callee5, this);
411
498
  }));
412
- function changeCustomerPage(_x3, _x4) {
499
+ function changeCustomerPage(_x5, _x6) {
413
500
  return _changeCustomerPage.apply(this, arguments);
414
501
  }
415
502
  return changeCustomerPage;
416
503
  }()
417
504
  /**
418
- * 缓存状态变化
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 客户列表响应
419
607
  */
420
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
+ */
421
679
  }, {
422
680
  key: "storeChange",
423
681
  value: function storeChange() {
@@ -427,7 +685,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
427
685
  cacheId: this.cacheId,
428
686
  fatherModule: this.fatherModule,
429
687
  store: store,
430
- cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize']
688
+ cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize', 'hasMore', 'loadingMore', 'searchParams']
431
689
  });
432
690
  }
433
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
 
@@ -33,4 +33,10 @@ export declare class ProductList extends BaseModule implements Module {
33
33
  getProduct(id: number): Promise<Product | undefined>;
34
34
  addProduct(products: ProductData[]): Promise<void>;
35
35
  selectProducts(products: ProductData[]): Promise<void>;
36
+ /**
37
+ * 根据商品编码或条码搜索商品
38
+ * @param code 商品编码或条码
39
+ * @returns 匹配的商品列表,如果没有匹配则返回空数组
40
+ */
41
+ findProductsByCodeOrBarcode(code: string): ProductData[];
36
42
  }
@@ -301,6 +301,26 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
301
301
  }
302
302
  return selectProducts;
303
303
  }()
304
+ /**
305
+ * 根据商品编码或条码搜索商品
306
+ * @param code 商品编码或条码
307
+ * @returns 匹配的商品列表,如果没有匹配则返回空数组
308
+ */
309
+ }, {
310
+ key: "findProductsByCodeOrBarcode",
311
+ value: function findProductsByCodeOrBarcode(code) {
312
+ if (!code || typeof code !== 'string') {
313
+ return [];
314
+ }
315
+ var trimmedCode = code.trim();
316
+ if (!trimmedCode) {
317
+ return [];
318
+ }
319
+ var matchingProducts = this.store.list.filter(function (product) {
320
+ return product.code && product.code.trim() === trimmedCode || product.barcode && product.barcode.trim() === trimmedCode;
321
+ });
322
+ return cloneDeep(matchingProducts);
323
+ }
304
324
  }]);
305
325
  return ProductList;
306
326
  }(BaseModule);