@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.
- package/dist/modules/Customer/index.d.ts +33 -0
- package/dist/modules/Customer/index.js +316 -58
- package/dist/modules/Customer/types.d.ts +17 -1
- package/dist/modules/Customer/types.js +2 -0
- package/dist/modules/ProductList/index.d.ts +6 -0
- package/dist/modules/ProductList/index.js +20 -0
- package/dist/solution/BookingTicket/index.d.ts +33 -0
- package/dist/solution/BookingTicket/index.js +167 -21
- package/dist/solution/BookingTicket/types.d.ts +3 -1
- package/dist/solution/BookingTicket/types.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +15 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +99 -55
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +12 -4
- package/dist/solution/BookingTicket/utils/scan/index.js +32 -20
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/lib/modules/Customer/index.d.ts +33 -0
- package/lib/modules/Customer/index.js +168 -32
- package/lib/modules/Customer/types.d.ts +17 -1
- package/lib/modules/Customer/types.js +2 -0
- package/lib/modules/ProductList/index.d.ts +6 -0
- package/lib/modules/ProductList/index.js +18 -0
- package/lib/solution/BookingTicket/index.d.ts +33 -0
- package/lib/solution/BookingTicket/index.js +98 -8
- package/lib/solution/BookingTicket/types.d.ts +3 -1
- package/lib/solution/BookingTicket/types.js +2 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +23 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +58 -16
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +12 -4
- package/lib/solution/BookingTicket/utils/scan/index.js +16 -20
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/package.json +1 -1
|
@@ -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,46 +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_pass_flag: 1,
|
|
104
|
-
...search && { search },
|
|
105
|
-
...otherParams
|
|
106
|
-
};
|
|
107
|
-
const res = await this.request.get(url, queryParams);
|
|
108
|
-
if ((res == null ? void 0 : res.code) !== 200) {
|
|
109
|
-
throw new Error(res == null ? void 0 : res.message);
|
|
110
|
-
}
|
|
111
|
-
const customerList = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [];
|
|
112
|
-
const total = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.count) || 0;
|
|
113
|
-
const page = skip;
|
|
114
|
-
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);
|
|
115
147
|
this.store.currentPage = page;
|
|
116
148
|
this.store.pageSize = pageSize;
|
|
117
149
|
this.store.total = total;
|
|
150
|
+
this.store.hasMore = page * pageSize < total;
|
|
118
151
|
this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
|
|
119
152
|
await this.core.effects.emit(
|
|
120
153
|
import_types.CustomerHooks.OnCustomerListUpdate,
|
|
@@ -134,12 +167,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
134
167
|
};
|
|
135
168
|
return response;
|
|
136
169
|
} catch (error) {
|
|
137
|
-
|
|
138
|
-
this.store.error = error instanceof Error ? error.message : "Failed to fetch customer list";
|
|
139
|
-
await this.core.effects.emit(
|
|
140
|
-
import_types.CustomerHooks.OnCustomerListError,
|
|
141
|
-
this.store.error
|
|
142
|
-
);
|
|
170
|
+
await this.handleCustomerListError(error, "fetch customer list");
|
|
143
171
|
throw error;
|
|
144
172
|
} finally {
|
|
145
173
|
this.store.loading = false;
|
|
@@ -201,6 +229,9 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
201
229
|
this.store.total = 0;
|
|
202
230
|
this.store.currentPage = 1;
|
|
203
231
|
this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
|
|
232
|
+
this.store.hasMore = true;
|
|
233
|
+
this.store.loadingMore = false;
|
|
234
|
+
this.store.searchParams = {};
|
|
204
235
|
this.core.effects.emit(
|
|
205
236
|
import_types.CustomerHooks.OnCustomerListUpdate,
|
|
206
237
|
this.store
|
|
@@ -279,9 +310,114 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
279
310
|
const num = targetPageSize;
|
|
280
311
|
return await this.getCustomerList({
|
|
281
312
|
skip,
|
|
282
|
-
num
|
|
313
|
+
num,
|
|
314
|
+
...this.store.searchParams
|
|
315
|
+
// 使用存储的搜索条件
|
|
283
316
|
});
|
|
284
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
|
+
}
|
|
285
421
|
/**
|
|
286
422
|
* 缓存状态变化
|
|
287
423
|
*/
|
|
@@ -292,7 +428,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
292
428
|
cacheId: this.cacheId,
|
|
293
429
|
fatherModule: this.fatherModule,
|
|
294
430
|
store,
|
|
295
|
-
cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize"]
|
|
431
|
+
cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize", "hasMore", "loadingMore", "searchParams"]
|
|
296
432
|
});
|
|
297
433
|
}
|
|
298
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:
|
|
@@ -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
|
}
|
|
@@ -170,6 +170,24 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
170
170
|
async selectProducts(products) {
|
|
171
171
|
this.store.selectProducts = products;
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* 根据商品编码或条码搜索商品
|
|
175
|
+
* @param code 商品编码或条码
|
|
176
|
+
* @returns 匹配的商品列表,如果没有匹配则返回空数组
|
|
177
|
+
*/
|
|
178
|
+
findProductsByCodeOrBarcode(code) {
|
|
179
|
+
if (!code || typeof code !== "string") {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const trimmedCode = code.trim();
|
|
183
|
+
if (!trimmedCode) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const matchingProducts = this.store.list.filter((product) => {
|
|
187
|
+
return product.code && product.code.trim() === trimmedCode || product.barcode && product.barcode.trim() === trimmedCode;
|
|
188
|
+
});
|
|
189
|
+
return (0, import_lodash_es.cloneDeep)(matchingProducts);
|
|
190
|
+
}
|
|
173
191
|
};
|
|
174
192
|
// Annotate the CommonJS export names for ESM import in node:
|
|
175
193
|
0 && (module.exports = {
|
|
@@ -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 回调
|
|
@@ -105,6 +131,13 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
105
131
|
scanCustomerListener(callback: (data: IScanResult) => void): {
|
|
106
132
|
remove: () => void;
|
|
107
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* 调用摄像头
|
|
136
|
+
* @param data 用户自定义数据
|
|
137
|
+
*/
|
|
138
|
+
activateCamera(data?: {
|
|
139
|
+
[key: string]: any;
|
|
140
|
+
}): void;
|
|
108
141
|
/**
|
|
109
142
|
* 设置其他参数
|
|
110
143
|
* @param params 参数
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
17
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/solution/BookingTicket/index.ts
|
|
@@ -26,8 +36,9 @@ __export(BookingTicket_exports, {
|
|
|
26
36
|
module.exports = __toCommonJS(BookingTicket_exports);
|
|
27
37
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
28
38
|
var import_types = require("./types");
|
|
29
|
-
var import_scan = require("./utils/scan
|
|
39
|
+
var import_scan = __toESM(require("./utils/scan"));
|
|
30
40
|
var import_handleScan = require("./utils/scan/handleScan");
|
|
41
|
+
var import_scanCache = __toESM(require("./utils/scan/scanCache"));
|
|
31
42
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
32
43
|
var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
33
44
|
constructor() {
|
|
@@ -55,7 +66,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
55
66
|
let targetCacheData = {};
|
|
56
67
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
57
68
|
this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
|
|
58
|
-
this.scan = new import_scan.
|
|
69
|
+
this.scan = new import_scan.default(this, "BOOKING_TICKET_SCAN");
|
|
59
70
|
if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
|
|
60
71
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
61
72
|
if (sessionData) {
|
|
@@ -230,14 +241,72 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
230
241
|
throw error;
|
|
231
242
|
}
|
|
232
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
|
+
}
|
|
233
294
|
/**
|
|
234
295
|
* 全局扫描监听
|
|
235
296
|
* @param callback 回调
|
|
236
297
|
*/
|
|
237
298
|
scanGlobalListener(callback) {
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
const
|
|
299
|
+
const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
|
|
300
|
+
const scanCallback = (0, import_handleScan.handleGlobalScan)(this.request, localSearch);
|
|
301
|
+
const safeCallback = (d) => {
|
|
302
|
+
try {
|
|
303
|
+
callback(d);
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error("scanGlobalListener回掉函数异常", error);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const listener = { key: "global", callback: safeCallback };
|
|
309
|
+
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
241
310
|
return removeListener;
|
|
242
311
|
}
|
|
243
312
|
/**
|
|
@@ -245,11 +314,31 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
245
314
|
* @param callback 回调
|
|
246
315
|
*/
|
|
247
316
|
scanCustomerListener(callback) {
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
const
|
|
317
|
+
const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
|
|
318
|
+
const scanCallback = (0, import_handleScan.handleCustomerScan)(this.request, localSearch);
|
|
319
|
+
const safeCallback = (d) => {
|
|
320
|
+
try {
|
|
321
|
+
callback(d);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
console.error("scanCustomerListener回掉函数异常", error);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const listener = { key: "customer", callback: safeCallback };
|
|
327
|
+
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
251
328
|
return removeListener;
|
|
252
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* 调用摄像头
|
|
332
|
+
* @param data 用户自定义数据
|
|
333
|
+
*/
|
|
334
|
+
activateCamera(data) {
|
|
335
|
+
var _a, _b, _c, _d;
|
|
336
|
+
(_d = (_c = (_b = (_a = this.window) == null ? void 0 : _a.interaction) == null ? void 0 : _b.utils) == null ? void 0 : _c.postMessageToApp) == null ? void 0 : _d.call(_c, {
|
|
337
|
+
module: "global",
|
|
338
|
+
key: "active_native_scanner",
|
|
339
|
+
data
|
|
340
|
+
});
|
|
341
|
+
}
|
|
253
342
|
/**
|
|
254
343
|
* 设置其他参数
|
|
255
344
|
* @param params 参数
|
|
@@ -281,6 +370,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
281
370
|
(_e = this.store.order) == null ? void 0 : _e.destroy();
|
|
282
371
|
this.core.effects.offByModuleDestroy(this.name);
|
|
283
372
|
this.core.unregisterModule(this);
|
|
373
|
+
import_scanCache.default.clear();
|
|
284
374
|
}
|
|
285
375
|
};
|
|
286
376
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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:
|
|
@@ -31,6 +31,7 @@ var searchWalletPass = async (request, code) => {
|
|
|
31
31
|
// 翻译识别码名称 0:不翻译 1:翻译
|
|
32
32
|
relation_product: 1,
|
|
33
33
|
// 组装关联商品: 0不处理 1处理
|
|
34
|
+
with: ["customer"],
|
|
34
35
|
tags: [
|
|
35
36
|
"point_card",
|
|
36
37
|
// 积分卡
|
|
@@ -62,7 +63,7 @@ var searchWalletPass = async (request, code) => {
|
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
65
|
var searchWallet = async (request, code) => {
|
|
65
|
-
const params = { code };
|
|
66
|
+
const params = { code, with_customer: 1 };
|
|
66
67
|
try {
|
|
67
68
|
const res = await (request == null ? void 0 : request.post(
|
|
68
69
|
"/wallet/detail/search",
|
|
@@ -78,9 +79,28 @@ var searchWallet = async (request, code) => {
|
|
|
78
79
|
};
|
|
79
80
|
var searchProduct = async (request, code) => {
|
|
80
81
|
var _a, _b;
|
|
81
|
-
const params = {
|
|
82
|
+
const params = {
|
|
83
|
+
exact_search: code,
|
|
84
|
+
open_bundle: 0,
|
|
85
|
+
// 套餐子信息
|
|
86
|
+
open_quotation: 1,
|
|
87
|
+
// 报价单
|
|
88
|
+
skip: 1,
|
|
89
|
+
num: 20,
|
|
90
|
+
status: "published",
|
|
91
|
+
with: ["variantGroup"],
|
|
92
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
93
|
+
exclude_extension_type: [
|
|
94
|
+
"product_party",
|
|
95
|
+
"product_event",
|
|
96
|
+
"product_series_event",
|
|
97
|
+
"product_package_ticket",
|
|
98
|
+
"ticket",
|
|
99
|
+
"event_item"
|
|
100
|
+
]
|
|
101
|
+
};
|
|
82
102
|
try {
|
|
83
|
-
const res = await (request == null ? void 0 : request.
|
|
103
|
+
const res = await (request == null ? void 0 : request.post("/product/query", params));
|
|
84
104
|
if ((res == null ? void 0 : res.code) == 200 && ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) == null ? void 0 : _b.length) > 0) {
|
|
85
105
|
return { searchType: "product", response: res };
|
|
86
106
|
}
|
|
@@ -4,7 +4,7 @@ import { RequestPlugin } from '../../../../plugins';
|
|
|
4
4
|
* @param request 请求插件
|
|
5
5
|
* @returns 处理结果
|
|
6
6
|
*/
|
|
7
|
-
export declare const handleGlobalScan: (request: RequestPlugin) => (scanResult: {
|
|
7
|
+
export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
|
|
8
8
|
type: string;
|
|
9
9
|
value: string;
|
|
10
10
|
}) => Promise<any>;
|
|
@@ -13,7 +13,7 @@ export declare const handleGlobalScan: (request: RequestPlugin) => (scanResult:
|
|
|
13
13
|
* @param request 请求插件
|
|
14
14
|
* @returns 处理结果
|
|
15
15
|
*/
|
|
16
|
-
export declare const handleCustomerScan: (request: RequestPlugin) => (scanResult: {
|
|
16
|
+
export declare const handleCustomerScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
|
|
17
17
|
type: string;
|
|
18
18
|
value: string;
|
|
19
19
|
}) => Promise<any>;
|