@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
|
@@ -380,11 +380,117 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
380
380
|
}
|
|
381
381
|
return changeCustomerPage;
|
|
382
382
|
}()
|
|
383
|
+
/**
|
|
384
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
385
|
+
* @returns 客户列表响应
|
|
386
|
+
*/
|
|
387
|
+
)
|
|
388
|
+
}, {
|
|
389
|
+
key: "loadMoreCustomers",
|
|
390
|
+
value: (function () {
|
|
391
|
+
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
392
|
+
var result;
|
|
393
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
394
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
395
|
+
case 0:
|
|
396
|
+
_context6.prev = 0;
|
|
397
|
+
_context6.next = 3;
|
|
398
|
+
return this.store.customer.loadMoreCustomers();
|
|
399
|
+
case 3:
|
|
400
|
+
result = _context6.sent;
|
|
401
|
+
this.core.effects.emit(BookingTicketHooks.onCustomerListUpdate, result);
|
|
402
|
+
return _context6.abrupt("return", result);
|
|
403
|
+
case 8:
|
|
404
|
+
_context6.prev = 8;
|
|
405
|
+
_context6.t0 = _context6["catch"](0);
|
|
406
|
+
console.error('Failed to load more customers:', _context6.t0);
|
|
407
|
+
throw _context6.t0;
|
|
408
|
+
case 12:
|
|
409
|
+
case "end":
|
|
410
|
+
return _context6.stop();
|
|
411
|
+
}
|
|
412
|
+
}, _callee6, this, [[0, 8]]);
|
|
413
|
+
}));
|
|
414
|
+
function loadMoreCustomers() {
|
|
415
|
+
return _loadMoreCustomers.apply(this, arguments);
|
|
416
|
+
}
|
|
417
|
+
return loadMoreCustomers;
|
|
418
|
+
}()
|
|
419
|
+
/**
|
|
420
|
+
* 重置并重新开始滚动加载客户数据
|
|
421
|
+
* @param params 查询参数
|
|
422
|
+
* @returns 客户列表响应
|
|
423
|
+
*/
|
|
424
|
+
)
|
|
425
|
+
}, {
|
|
426
|
+
key: "resetAndLoadCustomers",
|
|
427
|
+
value: (function () {
|
|
428
|
+
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
429
|
+
var params,
|
|
430
|
+
result,
|
|
431
|
+
_args7 = arguments;
|
|
432
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
433
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
434
|
+
case 0:
|
|
435
|
+
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
436
|
+
_context7.prev = 1;
|
|
437
|
+
_context7.next = 4;
|
|
438
|
+
return this.store.customer.resetAndLoadCustomers(params);
|
|
439
|
+
case 4:
|
|
440
|
+
result = _context7.sent;
|
|
441
|
+
this.core.effects.emit(BookingTicketHooks.onCustomerListReset, result);
|
|
442
|
+
return _context7.abrupt("return", result);
|
|
443
|
+
case 9:
|
|
444
|
+
_context7.prev = 9;
|
|
445
|
+
_context7.t0 = _context7["catch"](1);
|
|
446
|
+
console.error('Failed to reset and load customers:', _context7.t0);
|
|
447
|
+
throw _context7.t0;
|
|
448
|
+
case 13:
|
|
449
|
+
case "end":
|
|
450
|
+
return _context7.stop();
|
|
451
|
+
}
|
|
452
|
+
}, _callee7, this, [[1, 9]]);
|
|
453
|
+
}));
|
|
454
|
+
function resetAndLoadCustomers() {
|
|
455
|
+
return _resetAndLoadCustomers.apply(this, arguments);
|
|
456
|
+
}
|
|
457
|
+
return resetAndLoadCustomers;
|
|
458
|
+
}()
|
|
459
|
+
/**
|
|
460
|
+
* 检查是否还有更多客户数据可以加载
|
|
461
|
+
* @returns 是否还有更多数据
|
|
462
|
+
*/
|
|
463
|
+
)
|
|
464
|
+
}, {
|
|
465
|
+
key: "hasMoreCustomers",
|
|
466
|
+
value: function hasMoreCustomers() {
|
|
467
|
+
return this.store.customer.hasMoreCustomers();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* 获取当前的客户搜索条件
|
|
472
|
+
* @returns 当前搜索条件
|
|
473
|
+
*/
|
|
474
|
+
}, {
|
|
475
|
+
key: "getCurrentCustomerSearchParams",
|
|
476
|
+
value: function getCurrentCustomerSearchParams() {
|
|
477
|
+
return this.store.customer.getCurrentSearchParams();
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* 获取客户列表状态(包含滚动加载相关状态)
|
|
482
|
+
* @returns 客户状态
|
|
483
|
+
*/
|
|
484
|
+
}, {
|
|
485
|
+
key: "getCustomerState",
|
|
486
|
+
value: function getCustomerState() {
|
|
487
|
+
return this.store.customer.getState();
|
|
488
|
+
}
|
|
489
|
+
|
|
383
490
|
/**
|
|
384
491
|
* 全局扫描监听
|
|
385
492
|
* @param callback 回调
|
|
386
493
|
*/
|
|
387
|
-
)
|
|
388
494
|
}, {
|
|
389
495
|
key: "scanGlobalListener",
|
|
390
496
|
value: function scanGlobalListener(callback) {
|
|
@@ -458,15 +564,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
458
564
|
}, {
|
|
459
565
|
key: "setOtherParams",
|
|
460
566
|
value: (function () {
|
|
461
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
567
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
462
568
|
var _ref,
|
|
463
569
|
_ref$cover,
|
|
464
570
|
cover,
|
|
465
|
-
|
|
466
|
-
return _regeneratorRuntime().wrap(function
|
|
467
|
-
while (1) switch (
|
|
571
|
+
_args8 = arguments;
|
|
572
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
573
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
468
574
|
case 0:
|
|
469
|
-
_ref =
|
|
575
|
+
_ref = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {}, _ref$cover = _ref.cover, cover = _ref$cover === void 0 ? false : _ref$cover;
|
|
470
576
|
if (cover) {
|
|
471
577
|
this.otherParams = params;
|
|
472
578
|
} else {
|
|
@@ -474,9 +580,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
474
580
|
}
|
|
475
581
|
case 2:
|
|
476
582
|
case "end":
|
|
477
|
-
return
|
|
583
|
+
return _context8.stop();
|
|
478
584
|
}
|
|
479
|
-
},
|
|
585
|
+
}, _callee8, this);
|
|
480
586
|
}));
|
|
481
587
|
function setOtherParams(_x5) {
|
|
482
588
|
return _setOtherParams.apply(this, arguments);
|
|
@@ -491,16 +597,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
491
597
|
}, {
|
|
492
598
|
key: "getOtherParams",
|
|
493
599
|
value: (function () {
|
|
494
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
495
|
-
return _regeneratorRuntime().wrap(function
|
|
496
|
-
while (1) switch (
|
|
600
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
601
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
602
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
497
603
|
case 0:
|
|
498
|
-
return
|
|
604
|
+
return _context9.abrupt("return", this.otherParams);
|
|
499
605
|
case 1:
|
|
500
606
|
case "end":
|
|
501
|
-
return
|
|
607
|
+
return _context9.stop();
|
|
502
608
|
}
|
|
503
|
-
},
|
|
609
|
+
}, _callee9, this);
|
|
504
610
|
}));
|
|
505
611
|
function getOtherParams() {
|
|
506
612
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -12,7 +12,9 @@ export declare enum BookingTicketHooks {
|
|
|
12
12
|
onInited = "bookingTicket:onInited",
|
|
13
13
|
onDestroy = "bookingTicket:onDestroy",
|
|
14
14
|
onProductsLoaded = "bookingTicket:onProductsLoaded",
|
|
15
|
-
onCustomerSelected = "bookingTicket:onCustomerSelected"
|
|
15
|
+
onCustomerSelected = "bookingTicket:onCustomerSelected",
|
|
16
|
+
onCustomerListUpdate = "bookingTicket:onCustomerListUpdate",
|
|
17
|
+
onCustomerListReset = "bookingTicket:onCustomerListReset"
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* 获取客户列表的参数
|
|
@@ -21,6 +21,8 @@ export var BookingTicketHooks = /*#__PURE__*/function (BookingTicketHooks) {
|
|
|
21
21
|
BookingTicketHooks["onDestroy"] = "bookingTicket:onDestroy";
|
|
22
22
|
BookingTicketHooks["onProductsLoaded"] = "bookingTicket:onProductsLoaded";
|
|
23
23
|
BookingTicketHooks["onCustomerSelected"] = "bookingTicket:onCustomerSelected";
|
|
24
|
+
BookingTicketHooks["onCustomerListUpdate"] = "bookingTicket:onCustomerListUpdate";
|
|
25
|
+
BookingTicketHooks["onCustomerListReset"] = "bookingTicket:onCustomerListReset";
|
|
24
26
|
return BookingTicketHooks;
|
|
25
27
|
}({});
|
|
26
28
|
|
|
@@ -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
|
*/
|
|
@@ -40,12 +40,15 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
40
40
|
currentPage: 1,
|
|
41
41
|
pageSize: import_constants.DEFAULT_PAGE_SIZE,
|
|
42
42
|
loading: false,
|
|
43
|
-
error: null
|
|
43
|
+
error: null,
|
|
44
|
+
hasMore: true,
|
|
45
|
+
loadingMore: false,
|
|
46
|
+
searchParams: {}
|
|
44
47
|
};
|
|
45
48
|
this.openCache = false;
|
|
46
49
|
}
|
|
47
50
|
async initialize(core, options) {
|
|
48
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
49
52
|
this.core = core;
|
|
50
53
|
this.store = options == null ? void 0 : options.store;
|
|
51
54
|
this.request = this.core.getPlugin("request");
|
|
@@ -75,47 +78,76 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
75
78
|
} else {
|
|
76
79
|
this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
|
|
77
80
|
}
|
|
78
|
-
|
|
81
|
+
this.store.hasMore = ((_f = options == null ? void 0 : options.initialState) == null ? void 0 : _f.hasMore) ?? true;
|
|
82
|
+
this.store.loadingMore = ((_g = options == null ? void 0 : options.initialState) == null ? void 0 : _g.loadingMore) ?? false;
|
|
83
|
+
this.store.searchParams = ((_h = options == null ? void 0 : options.initialState) == null ? void 0 : _h.searchParams) ?? {};
|
|
84
|
+
if ((_i = options == null ? void 0 : options.otherParams) == null ? void 0 : _i.cacheId) {
|
|
79
85
|
this.openCache = options.otherParams.openCache;
|
|
80
86
|
this.cacheId = options.otherParams.cacheId;
|
|
81
87
|
}
|
|
82
|
-
if ((
|
|
88
|
+
if ((_j = options == null ? void 0 : options.otherParams) == null ? void 0 : _j.fatherModule) {
|
|
83
89
|
this.fatherModule = options.otherParams.fatherModule;
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
|
-
*
|
|
93
|
+
* 获取客户列表数据(内部方法)
|
|
88
94
|
* @param params 查询参数
|
|
89
|
-
* @returns
|
|
95
|
+
* @returns API响应数据
|
|
90
96
|
*/
|
|
91
|
-
async
|
|
97
|
+
async fetchCustomerListData(params = {}) {
|
|
92
98
|
var _a, _b;
|
|
93
99
|
const url = "/customer/select-list";
|
|
94
100
|
const { skip = 1, num = import_constants.DEFAULT_PAGE_SIZE, search, ...otherParams } = params;
|
|
101
|
+
const queryParams = {
|
|
102
|
+
skip,
|
|
103
|
+
num,
|
|
104
|
+
sort_by: import_constants.SORT_BY,
|
|
105
|
+
with: ["latestWalletDetail.wallet"],
|
|
106
|
+
search_wallet_flag: 1,
|
|
107
|
+
search_wallet_pass_flag: 1,
|
|
108
|
+
...search && { search },
|
|
109
|
+
...otherParams
|
|
110
|
+
};
|
|
111
|
+
const res = await this.request.get(url, queryParams);
|
|
112
|
+
if ((res == null ? void 0 : res.code) !== 200) {
|
|
113
|
+
throw new Error(res == null ? void 0 : res.message);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
customerList: ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [],
|
|
117
|
+
total: ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.count) || 0,
|
|
118
|
+
page: skip,
|
|
119
|
+
pageSize: num
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 处理客户列表操作的错误(内部方法)
|
|
124
|
+
* @param error 错误对象
|
|
125
|
+
* @param operation 操作名称
|
|
126
|
+
*/
|
|
127
|
+
async handleCustomerListError(error, operation) {
|
|
128
|
+
console.error(`Failed to ${operation}:`, error);
|
|
129
|
+
this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
|
|
130
|
+
await this.core.effects.emit(
|
|
131
|
+
import_types.CustomerHooks.OnCustomerListError,
|
|
132
|
+
this.store.error
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 获取客户列表
|
|
137
|
+
* @param params 查询参数
|
|
138
|
+
* @returns 客户列表响应
|
|
139
|
+
*/
|
|
140
|
+
async getCustomerList(params = {}) {
|
|
95
141
|
try {
|
|
96
142
|
this.store.loading = true;
|
|
97
143
|
this.store.error = null;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
sort_by: import_constants.SORT_BY,
|
|
102
|
-
with: ["latestWalletDetail.wallet"],
|
|
103
|
-
search_wallet_flag: 1,
|
|
104
|
-
search_wallet_pass_flag: 1,
|
|
105
|
-
...search && { search },
|
|
106
|
-
...otherParams
|
|
107
|
-
};
|
|
108
|
-
const res = await this.request.get(url, queryParams);
|
|
109
|
-
if ((res == null ? void 0 : res.code) !== 200) {
|
|
110
|
-
throw new Error(res == null ? void 0 : res.message);
|
|
111
|
-
}
|
|
112
|
-
const customerList = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [];
|
|
113
|
-
const total = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.count) || 0;
|
|
114
|
-
const page = skip;
|
|
115
|
-
const pageSize = num;
|
|
144
|
+
const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
|
|
145
|
+
const { skip, num, ...searchParams } = params;
|
|
146
|
+
this.store.searchParams = (0, import_lodash_es.cloneDeep)(searchParams);
|
|
116
147
|
this.store.currentPage = page;
|
|
117
148
|
this.store.pageSize = pageSize;
|
|
118
149
|
this.store.total = total;
|
|
150
|
+
this.store.hasMore = page * pageSize < total;
|
|
119
151
|
this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
|
|
120
152
|
await this.core.effects.emit(
|
|
121
153
|
import_types.CustomerHooks.OnCustomerListUpdate,
|
|
@@ -135,12 +167,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
135
167
|
};
|
|
136
168
|
return response;
|
|
137
169
|
} catch (error) {
|
|
138
|
-
|
|
139
|
-
this.store.error = error instanceof Error ? error.message : "Failed to fetch customer list";
|
|
140
|
-
await this.core.effects.emit(
|
|
141
|
-
import_types.CustomerHooks.OnCustomerListError,
|
|
142
|
-
this.store.error
|
|
143
|
-
);
|
|
170
|
+
await this.handleCustomerListError(error, "fetch customer list");
|
|
144
171
|
throw error;
|
|
145
172
|
} finally {
|
|
146
173
|
this.store.loading = false;
|
|
@@ -202,6 +229,9 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
202
229
|
this.store.total = 0;
|
|
203
230
|
this.store.currentPage = 1;
|
|
204
231
|
this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
|
|
232
|
+
this.store.hasMore = true;
|
|
233
|
+
this.store.loadingMore = false;
|
|
234
|
+
this.store.searchParams = {};
|
|
205
235
|
this.core.effects.emit(
|
|
206
236
|
import_types.CustomerHooks.OnCustomerListUpdate,
|
|
207
237
|
this.store
|
|
@@ -280,9 +310,114 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
280
310
|
const num = targetPageSize;
|
|
281
311
|
return await this.getCustomerList({
|
|
282
312
|
skip,
|
|
283
|
-
num
|
|
313
|
+
num,
|
|
314
|
+
...this.store.searchParams
|
|
315
|
+
// 使用存储的搜索条件
|
|
284
316
|
});
|
|
285
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
320
|
+
* @returns 客户列表响应
|
|
321
|
+
*/
|
|
322
|
+
async loadMoreCustomers() {
|
|
323
|
+
if (!this.store.hasMore || this.store.loadingMore) {
|
|
324
|
+
return {
|
|
325
|
+
list: [],
|
|
326
|
+
total: this.store.total,
|
|
327
|
+
page: this.store.currentPage,
|
|
328
|
+
pageSize: this.store.pageSize
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
const nextPage = this.store.currentPage + 1;
|
|
332
|
+
try {
|
|
333
|
+
this.store.loadingMore = true;
|
|
334
|
+
this.store.error = null;
|
|
335
|
+
const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData({
|
|
336
|
+
skip: nextPage,
|
|
337
|
+
num: this.store.pageSize,
|
|
338
|
+
...this.store.searchParams
|
|
339
|
+
// 使用存储的搜索条件
|
|
340
|
+
});
|
|
341
|
+
const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
|
|
342
|
+
this.store.customerList = updatedCustomerList;
|
|
343
|
+
this.store.currentPage = page;
|
|
344
|
+
this.store.total = total;
|
|
345
|
+
this.store.hasMore = page * pageSize < total;
|
|
346
|
+
await this.core.effects.emit(
|
|
347
|
+
import_types.CustomerHooks.OnScrollLoadMore,
|
|
348
|
+
{
|
|
349
|
+
newCustomers,
|
|
350
|
+
allCustomers: this.store.customerList,
|
|
351
|
+
currentPage: page,
|
|
352
|
+
hasMore: this.store.hasMore
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
await this.core.effects.emit(
|
|
356
|
+
import_types.CustomerHooks.OnCustomerListUpdate,
|
|
357
|
+
this.store
|
|
358
|
+
);
|
|
359
|
+
this.triggerPaginationChange({
|
|
360
|
+
page,
|
|
361
|
+
pageSize,
|
|
362
|
+
total,
|
|
363
|
+
totalPages: Math.ceil(total / pageSize)
|
|
364
|
+
});
|
|
365
|
+
const response = {
|
|
366
|
+
list: newCustomers,
|
|
367
|
+
// 返回新加载的数据
|
|
368
|
+
total,
|
|
369
|
+
page,
|
|
370
|
+
pageSize
|
|
371
|
+
};
|
|
372
|
+
return response;
|
|
373
|
+
} catch (error) {
|
|
374
|
+
await this.handleCustomerListError(error, "load more customers");
|
|
375
|
+
throw error;
|
|
376
|
+
} finally {
|
|
377
|
+
this.store.loadingMore = false;
|
|
378
|
+
this.storeChange();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* 重置并重新开始滚动加载
|
|
383
|
+
* @param params 查询参数
|
|
384
|
+
* @returns 客户列表响应
|
|
385
|
+
*/
|
|
386
|
+
async resetAndLoadCustomers(params = {}) {
|
|
387
|
+
this.store.customerList = [];
|
|
388
|
+
this.store.currentPage = 1;
|
|
389
|
+
this.store.hasMore = true;
|
|
390
|
+
this.store.loadingMore = false;
|
|
391
|
+
const resetParams = {
|
|
392
|
+
...params,
|
|
393
|
+
skip: 1,
|
|
394
|
+
num: params.num || this.store.pageSize
|
|
395
|
+
};
|
|
396
|
+
const response = await this.getCustomerList(resetParams);
|
|
397
|
+
await this.core.effects.emit(
|
|
398
|
+
import_types.CustomerHooks.OnScrollLoadComplete,
|
|
399
|
+
{
|
|
400
|
+
customers: this.store.customerList,
|
|
401
|
+
total: this.store.total,
|
|
402
|
+
hasMore: this.store.hasMore
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
return response;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* 检查是否还有更多数据可以加载
|
|
409
|
+
* @returns 是否还有更多数据
|
|
410
|
+
*/
|
|
411
|
+
hasMoreCustomers() {
|
|
412
|
+
return this.store.hasMore && !this.store.loadingMore;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* 获取当前的搜索条件
|
|
416
|
+
* @returns 当前搜索条件
|
|
417
|
+
*/
|
|
418
|
+
getCurrentSearchParams() {
|
|
419
|
+
return (0, import_lodash_es.cloneDeep)(this.store.searchParams);
|
|
420
|
+
}
|
|
286
421
|
/**
|
|
287
422
|
* 缓存状态变化
|
|
288
423
|
*/
|
|
@@ -293,7 +428,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
293
428
|
cacheId: this.cacheId,
|
|
294
429
|
fatherModule: this.fatherModule,
|
|
295
430
|
store,
|
|
296
|
-
cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize"]
|
|
431
|
+
cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize", "hasMore", "loadingMore", "searchParams"]
|
|
297
432
|
});
|
|
298
433
|
}
|
|
299
434
|
}
|
|
@@ -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 {};
|
|
@@ -27,6 +27,8 @@ var CustomerHooks = /* @__PURE__ */ ((CustomerHooks2) => {
|
|
|
27
27
|
CustomerHooks2["OnCustomerListError"] = "customer:onError";
|
|
28
28
|
CustomerHooks2["OnCustomerSelected"] = "customer:onSelected";
|
|
29
29
|
CustomerHooks2["OnPaginationChange"] = "customer:onPaginationChange";
|
|
30
|
+
CustomerHooks2["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
31
|
+
CustomerHooks2["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
30
32
|
return CustomerHooks2;
|
|
31
33
|
})(CustomerHooks || {});
|
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -345,8 +345,11 @@ var getTimeSlicesByResource = ({
|
|
|
345
345
|
operating_day_boundary,
|
|
346
346
|
maxBlockThreshold
|
|
347
347
|
}) => {
|
|
348
|
-
|
|
348
|
+
let { times } = resource;
|
|
349
349
|
const timeSlices = [];
|
|
350
|
+
times.sort((a, b) => {
|
|
351
|
+
return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at), "minute");
|
|
352
|
+
});
|
|
350
353
|
times.forEach((time) => {
|
|
351
354
|
const startTime = (0, import_dayjs.default)(`${time.start_at}`);
|
|
352
355
|
const endTime = (0, import_dayjs.default)(`${time.end_at}`);
|
|
@@ -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 回调
|
|
@@ -241,6 +241,56 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
241
241
|
throw error;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
246
|
+
* @returns 客户列表响应
|
|
247
|
+
*/
|
|
248
|
+
async loadMoreCustomers() {
|
|
249
|
+
try {
|
|
250
|
+
const result = await this.store.customer.loadMoreCustomers();
|
|
251
|
+
this.core.effects.emit(import_types.BookingTicketHooks.onCustomerListUpdate, result);
|
|
252
|
+
return result;
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.error("Failed to load more customers:", error);
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 重置并重新开始滚动加载客户数据
|
|
260
|
+
* @param params 查询参数
|
|
261
|
+
* @returns 客户列表响应
|
|
262
|
+
*/
|
|
263
|
+
async resetAndLoadCustomers(params = {}) {
|
|
264
|
+
try {
|
|
265
|
+
const result = await this.store.customer.resetAndLoadCustomers(params);
|
|
266
|
+
this.core.effects.emit(import_types.BookingTicketHooks.onCustomerListReset, result);
|
|
267
|
+
return result;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
console.error("Failed to reset and load customers:", error);
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* 检查是否还有更多客户数据可以加载
|
|
275
|
+
* @returns 是否还有更多数据
|
|
276
|
+
*/
|
|
277
|
+
hasMoreCustomers() {
|
|
278
|
+
return this.store.customer.hasMoreCustomers();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* 获取当前的客户搜索条件
|
|
282
|
+
* @returns 当前搜索条件
|
|
283
|
+
*/
|
|
284
|
+
getCurrentCustomerSearchParams() {
|
|
285
|
+
return this.store.customer.getCurrentSearchParams();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 获取客户列表状态(包含滚动加载相关状态)
|
|
289
|
+
* @returns 客户状态
|
|
290
|
+
*/
|
|
291
|
+
getCustomerState() {
|
|
292
|
+
return this.store.customer.getState();
|
|
293
|
+
}
|
|
244
294
|
/**
|
|
245
295
|
* 全局扫描监听
|
|
246
296
|
* @param callback 回调
|
|
@@ -12,7 +12,9 @@ export declare enum BookingTicketHooks {
|
|
|
12
12
|
onInited = "bookingTicket:onInited",
|
|
13
13
|
onDestroy = "bookingTicket:onDestroy",
|
|
14
14
|
onProductsLoaded = "bookingTicket:onProductsLoaded",
|
|
15
|
-
onCustomerSelected = "bookingTicket:onCustomerSelected"
|
|
15
|
+
onCustomerSelected = "bookingTicket:onCustomerSelected",
|
|
16
|
+
onCustomerListUpdate = "bookingTicket:onCustomerListUpdate",
|
|
17
|
+
onCustomerListReset = "bookingTicket:onCustomerListReset"
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* 获取客户列表的参数
|
|
@@ -61,6 +61,8 @@ var BookingTicketHooks = /* @__PURE__ */ ((BookingTicketHooks2) => {
|
|
|
61
61
|
BookingTicketHooks2["onDestroy"] = "bookingTicket:onDestroy";
|
|
62
62
|
BookingTicketHooks2["onProductsLoaded"] = "bookingTicket:onProductsLoaded";
|
|
63
63
|
BookingTicketHooks2["onCustomerSelected"] = "bookingTicket:onCustomerSelected";
|
|
64
|
+
BookingTicketHooks2["onCustomerListUpdate"] = "bookingTicket:onCustomerListUpdate";
|
|
65
|
+
BookingTicketHooks2["onCustomerListReset"] = "bookingTicket:onCustomerListReset";
|
|
64
66
|
return BookingTicketHooks2;
|
|
65
67
|
})(BookingTicketHooks || {});
|
|
66
68
|
// Annotate the CommonJS export names for ESM import in node:
|