@pisell/pisellos 0.0.567 → 0.0.568
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/core/index.js +6 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -3
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +1 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +14 -41
- package/dist/modules/Payment/index.js +142 -270
- package/dist/modules/Payment/walletpass.js +4 -5
- package/dist/modules/Rules/index.js +0 -7
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.js +88 -121
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/products/index.js +29 -49
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +32 -40
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +5 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -246
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.d.ts +5 -0
- package/dist/solution/VenueBooking/index.js +364 -327
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +130 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +92 -53
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +84 -63
- package/lib/model/strategy/adapter/promotion/evaluator.js +381 -231
- package/lib/model/strategy/adapter/promotion/examples.js +139 -159
- package/lib/model/strategy/adapter/promotion/index.js +1 -49
- package/lib/model/strategy/adapter/promotion/type.js +199 -35
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -152
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +652 -402
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +22 -45
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +306 -241
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +72 -78
- package/lib/modules/Cart/utils/changePrice.js +26 -62
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +216 -153
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +117 -113
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +63 -74
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +332 -320
- package/lib/modules/Order/types.js +24 -33
- package/lib/modules/Order/utils.js +350 -284
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +566 -432
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +216 -107
- package/lib/modules/Payment/utils.js +50 -47
- package/lib/modules/Payment/walletpass.js +221 -203
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +111 -110
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +60 -82
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/Rules/index.js +1172 -872
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +59 -68
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +176 -193
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -167
- package/lib/modules/Schedule/index.js +97 -107
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -70
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +782 -429
- package/lib/modules/index.js +212 -57
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.js +882 -623
- package/lib/server/modules/index.js +85 -59
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.js +195 -231
- package/lib/server/modules/order/types.js +107 -32
- package/lib/server/modules/order/utils/filterBookings.js +174 -140
- package/lib/server/modules/order/utils/filterOrders.js +89 -60
- package/lib/server/modules/products/index.js +430 -335
- package/lib/server/modules/products/types.js +41 -34
- package/lib/server/modules/quotation/index.js +76 -77
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +216 -187
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +134 -119
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1530 -1343
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +147 -122
- package/lib/solution/BookingTicket/types.js +38 -64
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +64 -80
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +82 -80
- package/lib/solution/BookingTicket/utils/scan/index.js +90 -94
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +227 -158
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +218 -200
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +803 -840
- package/lib/solution/ScanOrder/types.js +34 -34
- package/lib/solution/ScanOrder/utils.js +372 -331
- package/lib/solution/ShopDiscount/index.js +230 -236
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +309 -172
- package/lib/solution/VenueBooking/index.d.ts +5 -0
- package/lib/solution/VenueBooking/index.js +886 -929
- package/lib/solution/VenueBooking/types.js +20 -40
- package/lib/solution/VenueBooking/utils/dateSummary.js +22 -54
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +88 -106
- package/lib/solution/VenueBooking/utils/smartPricing.js +112 -100
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +102 -37
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,144 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
__export(Customer_exports, {
|
|
23
|
-
CustomerModule: () => CustomerModule
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
CustomerModule: true
|
|
8
|
+
};
|
|
9
|
+
exports.CustomerModule = void 0;
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
|
+
var _BaseModule = require("../BaseModule");
|
|
12
|
+
var _plugins = require("../../plugins");
|
|
13
|
+
var _constants = require("./constants");
|
|
14
|
+
var _types = require("./types");
|
|
15
|
+
Object.keys(_types).forEach(function (key) {
|
|
16
|
+
if (key === "default" || key === "__esModule") return;
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _types[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
class CustomerModule extends _BaseModule.BaseModule {
|
|
27
|
+
defaultName = 'customer';
|
|
28
|
+
defaultVersion = '1.0.0';
|
|
29
|
+
store = {
|
|
30
|
+
customerList: [],
|
|
31
|
+
selectedCustomer: null,
|
|
32
|
+
total: 0,
|
|
33
|
+
currentPage: 1,
|
|
34
|
+
pageSize: _constants.DEFAULT_PAGE_SIZE,
|
|
35
|
+
loading: false,
|
|
36
|
+
error: null,
|
|
37
|
+
hasMore: true,
|
|
38
|
+
loadingMore: false,
|
|
39
|
+
searchParams: {}
|
|
40
|
+
};
|
|
41
|
+
request;
|
|
42
|
+
cacheId;
|
|
43
|
+
openCache = false;
|
|
44
|
+
fatherModule;
|
|
45
|
+
otherParams = {};
|
|
32
46
|
constructor(name, version) {
|
|
33
47
|
super(name, version);
|
|
34
|
-
this.defaultName = "customer";
|
|
35
|
-
this.defaultVersion = "1.0.0";
|
|
36
|
-
this.store = {
|
|
37
|
-
customerList: [],
|
|
38
|
-
selectedCustomer: null,
|
|
39
|
-
total: 0,
|
|
40
|
-
currentPage: 1,
|
|
41
|
-
pageSize: import_constants.DEFAULT_PAGE_SIZE,
|
|
42
|
-
loading: false,
|
|
43
|
-
error: null,
|
|
44
|
-
hasMore: true,
|
|
45
|
-
loadingMore: false,
|
|
46
|
-
searchParams: {}
|
|
47
|
-
};
|
|
48
|
-
this.openCache = false;
|
|
49
|
-
this.otherParams = {};
|
|
50
48
|
}
|
|
51
49
|
async initialize(core, options) {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
53
50
|
this.core = core;
|
|
54
|
-
this.store = options
|
|
55
|
-
this.request = this.core.getPlugin(
|
|
56
|
-
this.otherParams =
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
this.store = options?.store;
|
|
52
|
+
this.request = this.core.getPlugin('request');
|
|
53
|
+
this.otherParams = options?.otherParams || {};
|
|
54
|
+
|
|
55
|
+
// 初始化状态
|
|
56
|
+
if (Array.isArray(options?.initialState?.customerList)) {
|
|
57
|
+
const customerList = (0, _lodashEs.cloneDeep)(options.initialState.customerList || []);
|
|
59
58
|
this.store.customerList = customerList;
|
|
60
59
|
} else {
|
|
61
60
|
this.store.customerList = [];
|
|
62
61
|
}
|
|
63
|
-
if (
|
|
64
|
-
this.store.selectedCustomer = (0,
|
|
62
|
+
if (options?.initialState?.selectedCustomer) {
|
|
63
|
+
this.store.selectedCustomer = (0, _lodashEs.cloneDeep)(options.initialState.selectedCustomer);
|
|
65
64
|
} else {
|
|
66
65
|
this.store.selectedCustomer = null;
|
|
67
66
|
}
|
|
68
|
-
if (typeof
|
|
67
|
+
if (typeof options?.initialState?.total === 'number') {
|
|
69
68
|
this.store.total = options.initialState.total;
|
|
70
69
|
} else {
|
|
71
70
|
this.store.total = 0;
|
|
72
71
|
}
|
|
73
|
-
if (typeof
|
|
72
|
+
if (typeof options?.initialState?.currentPage === 'number') {
|
|
74
73
|
this.store.currentPage = options.initialState.currentPage;
|
|
75
74
|
} else {
|
|
76
75
|
this.store.currentPage = 1;
|
|
77
76
|
}
|
|
78
|
-
if (typeof
|
|
77
|
+
if (typeof options?.initialState?.pageSize === 'number') {
|
|
79
78
|
this.store.pageSize = options.initialState.pageSize;
|
|
80
79
|
} else {
|
|
81
|
-
this.store.pageSize =
|
|
80
|
+
this.store.pageSize = _constants.DEFAULT_PAGE_SIZE;
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.store.
|
|
86
|
-
|
|
82
|
+
|
|
83
|
+
// 初始化滚动加载相关状态
|
|
84
|
+
this.store.hasMore = options?.initialState?.hasMore ?? true;
|
|
85
|
+
this.store.loadingMore = options?.initialState?.loadingMore ?? false;
|
|
86
|
+
this.store.searchParams = options?.initialState?.searchParams ?? {};
|
|
87
|
+
|
|
88
|
+
// 缓存配置
|
|
89
|
+
if (options?.otherParams?.cacheId) {
|
|
87
90
|
this.openCache = options.otherParams.openCache;
|
|
88
91
|
this.cacheId = options.otherParams.cacheId;
|
|
89
92
|
}
|
|
90
|
-
if (
|
|
93
|
+
if (options?.otherParams?.fatherModule) {
|
|
91
94
|
this.fatherModule = options.otherParams.fatherModule;
|
|
92
95
|
}
|
|
93
96
|
}
|
|
97
|
+
|
|
94
98
|
/**
|
|
95
99
|
* 获取客户列表数据(内部方法)
|
|
96
100
|
* @param params 查询参数
|
|
97
101
|
* @returns API响应数据
|
|
98
102
|
*/
|
|
99
103
|
async fetchCustomerListData(params = {}) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
url =
|
|
104
|
+
let url = '/customer/select-list';
|
|
105
|
+
// 如果是加盟子店铺,则使用加盟商的客户列表接口
|
|
106
|
+
if (this.otherParams?.isFranchisee) {
|
|
107
|
+
url = '/franchisee/customer/select-list';
|
|
104
108
|
}
|
|
105
|
-
const {
|
|
109
|
+
const {
|
|
110
|
+
skip = 1,
|
|
111
|
+
num = _constants.DEFAULT_PAGE_SIZE,
|
|
112
|
+
search,
|
|
113
|
+
..._otherParams
|
|
114
|
+
} = params;
|
|
106
115
|
const queryParams = {
|
|
107
116
|
skip,
|
|
108
117
|
num,
|
|
109
|
-
sort_by:
|
|
110
|
-
with: [
|
|
118
|
+
sort_by: _constants.SORT_BY,
|
|
119
|
+
with: ['latestWalletDetail.wallet', 'contactsInfo', 'formRecord'],
|
|
111
120
|
search_wallet_flag: 1,
|
|
112
121
|
search_wallet_pass_flag: 1,
|
|
113
|
-
...search && {
|
|
122
|
+
...(search && {
|
|
123
|
+
search
|
|
124
|
+
}),
|
|
114
125
|
..._otherParams
|
|
115
126
|
};
|
|
116
127
|
const res = await this.request.get(url, queryParams, {
|
|
117
128
|
cache: {
|
|
118
|
-
mode:
|
|
129
|
+
mode: _plugins.RequestModeENUM.REMOTE_LOCAL,
|
|
119
130
|
type: "memory"
|
|
120
131
|
}
|
|
121
132
|
});
|
|
122
|
-
if (
|
|
123
|
-
throw new Error(res
|
|
133
|
+
if (res?.code !== 200) {
|
|
134
|
+
throw new Error(res?.message);
|
|
124
135
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
136
|
+
|
|
137
|
+
// 如果是加盟子店铺,查询的接口返回的数据都是总店的客户数据,需要加上标识
|
|
138
|
+
let _customerList = res?.data?.list || [];
|
|
139
|
+
if (this.otherParams?.isFranchisee && _customerList?.length > 0) {
|
|
140
|
+
_customerList = _customerList?.map(item => {
|
|
128
141
|
return {
|
|
129
|
-
...item || {},
|
|
130
|
-
is_franchisor_customer: 1
|
|
131
|
-
// 标识是总店的客户
|
|
142
|
+
...(item || {}),
|
|
143
|
+
is_franchisor_customer: 1 // 标识是总店的客户
|
|
132
144
|
};
|
|
133
145
|
});
|
|
134
146
|
}
|
|
135
147
|
return {
|
|
136
148
|
customerList: _customerList,
|
|
137
|
-
total:
|
|
149
|
+
total: res?.data?.count || 0,
|
|
138
150
|
page: skip,
|
|
139
151
|
pageSize: num
|
|
140
152
|
};
|
|
141
153
|
}
|
|
154
|
+
|
|
142
155
|
/**
|
|
143
156
|
* 处理客户列表操作的错误(内部方法)
|
|
144
157
|
* @param error 错误对象
|
|
@@ -147,11 +160,9 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
147
160
|
async handleCustomerListError(error, operation) {
|
|
148
161
|
console.error(`Failed to ${operation}:`, error);
|
|
149
162
|
this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
|
|
150
|
-
await this.core.effects.emit(
|
|
151
|
-
`${this.name}:onCustomerListError`,
|
|
152
|
-
this.store.error
|
|
153
|
-
);
|
|
163
|
+
await this.core.effects.emit(`${this.name}:onCustomerListError`, this.store.error);
|
|
154
164
|
}
|
|
165
|
+
|
|
155
166
|
/**
|
|
156
167
|
* 获取客户列表
|
|
157
168
|
* @param params 查询参数
|
|
@@ -161,18 +172,34 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
161
172
|
try {
|
|
162
173
|
this.store.loading = true;
|
|
163
174
|
this.store.error = null;
|
|
164
|
-
const {
|
|
165
|
-
|
|
166
|
-
|
|
175
|
+
const {
|
|
176
|
+
customerList,
|
|
177
|
+
total,
|
|
178
|
+
page,
|
|
179
|
+
pageSize
|
|
180
|
+
} = await this.fetchCustomerListData(params);
|
|
181
|
+
|
|
182
|
+
// 保存搜索条件(排除skip和num)
|
|
183
|
+
const {
|
|
184
|
+
skip,
|
|
185
|
+
num,
|
|
186
|
+
...searchParams
|
|
187
|
+
} = params;
|
|
188
|
+
this.store.searchParams = (0, _lodashEs.cloneDeep)(searchParams);
|
|
189
|
+
|
|
190
|
+
// 更新分页状态
|
|
167
191
|
this.store.currentPage = page;
|
|
168
192
|
this.store.pageSize = pageSize;
|
|
169
193
|
this.store.total = total;
|
|
194
|
+
|
|
195
|
+
// 计算是否还有更多数据
|
|
170
196
|
this.store.hasMore = page * pageSize < total;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
197
|
+
|
|
198
|
+
// 设置客户列表(替换模式)
|
|
199
|
+
this.store.customerList = (0, _lodashEs.cloneDeep)(customerList);
|
|
200
|
+
await this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
|
|
201
|
+
|
|
202
|
+
// 触发分页变化事件
|
|
176
203
|
this.triggerPaginationChange({
|
|
177
204
|
page,
|
|
178
205
|
pageSize,
|
|
@@ -187,37 +214,37 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
187
214
|
};
|
|
188
215
|
return response;
|
|
189
216
|
} catch (error) {
|
|
190
|
-
await this.handleCustomerListError(error,
|
|
217
|
+
await this.handleCustomerListError(error, 'fetch customer list');
|
|
191
218
|
throw error;
|
|
192
219
|
} finally {
|
|
193
220
|
this.store.loading = false;
|
|
194
221
|
this.storeChange();
|
|
195
222
|
}
|
|
196
223
|
}
|
|
224
|
+
|
|
197
225
|
/**
|
|
198
226
|
* 设置客户列表
|
|
199
227
|
* @param customers 客户列表
|
|
200
228
|
* @param total 总数
|
|
201
229
|
*/
|
|
202
230
|
setCustomerList(customers, total) {
|
|
203
|
-
this.store.customerList = (0,
|
|
204
|
-
if (typeof total ===
|
|
231
|
+
this.store.customerList = (0, _lodashEs.cloneDeep)(customers);
|
|
232
|
+
if (typeof total === 'number') {
|
|
205
233
|
this.store.total = total;
|
|
206
234
|
}
|
|
207
235
|
this.storeChange();
|
|
208
236
|
}
|
|
237
|
+
|
|
209
238
|
/**
|
|
210
239
|
* 设置当前选择的客户
|
|
211
240
|
* @param customer 选择的客户
|
|
212
241
|
*/
|
|
213
242
|
setSelectedCustomer(customer) {
|
|
214
|
-
this.store.selectedCustomer = !customer ?
|
|
215
|
-
this.core.effects.emit(
|
|
216
|
-
`${this.name}:onCustomerSelected`,
|
|
217
|
-
this.store.selectedCustomer
|
|
218
|
-
);
|
|
243
|
+
this.store.selectedCustomer = !customer ? _constants.DEFAULT_CUSTOMER : (0, _lodashEs.cloneDeep)(customer);
|
|
244
|
+
this.core.effects.emit(`${this.name}:onCustomerSelected`, this.store.selectedCustomer);
|
|
219
245
|
this.storeChange();
|
|
220
246
|
}
|
|
247
|
+
|
|
221
248
|
/**
|
|
222
249
|
* 获取当前选择的客户
|
|
223
250
|
* @returns 当前选择的客户
|
|
@@ -225,6 +252,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
225
252
|
getSelectedCustomer() {
|
|
226
253
|
return this.store.selectedCustomer;
|
|
227
254
|
}
|
|
255
|
+
|
|
228
256
|
/**
|
|
229
257
|
* 获取客户列表
|
|
230
258
|
* @returns 客户列表
|
|
@@ -232,14 +260,16 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
232
260
|
getCustomers() {
|
|
233
261
|
return [...this.store.customerList];
|
|
234
262
|
}
|
|
263
|
+
|
|
235
264
|
/**
|
|
236
265
|
* 根据ID查找客户
|
|
237
266
|
* @param id 客户ID
|
|
238
267
|
* @returns 客户信息
|
|
239
268
|
*/
|
|
240
269
|
getCustomerById(id) {
|
|
241
|
-
return this.store.customerList.find(
|
|
270
|
+
return this.store.customerList.find(customer => customer.id === id) || null;
|
|
242
271
|
}
|
|
272
|
+
|
|
243
273
|
/**
|
|
244
274
|
* 清空客户列表
|
|
245
275
|
*/
|
|
@@ -248,37 +278,43 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
248
278
|
this.store.selectedCustomer = null;
|
|
249
279
|
this.store.total = 0;
|
|
250
280
|
this.store.currentPage = 1;
|
|
251
|
-
this.store.pageSize =
|
|
281
|
+
this.store.pageSize = _constants.DEFAULT_PAGE_SIZE;
|
|
252
282
|
this.store.hasMore = true;
|
|
253
283
|
this.store.loadingMore = false;
|
|
254
284
|
this.store.searchParams = {};
|
|
255
|
-
this.core.effects.emit(
|
|
256
|
-
`${this.name}:onCustomerListUpdate`,
|
|
257
|
-
this.store
|
|
258
|
-
);
|
|
285
|
+
this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
|
|
259
286
|
this.storeChange();
|
|
260
287
|
}
|
|
288
|
+
|
|
261
289
|
/**
|
|
262
290
|
* 添加客户到列表第一位
|
|
263
291
|
* @param customer 要添加的客户信息
|
|
264
292
|
*/
|
|
265
293
|
addCustomerToFirst(customer) {
|
|
266
|
-
|
|
294
|
+
// 深拷贝客户对象以避免引用问题
|
|
295
|
+
const newCustomer = (0, _lodashEs.cloneDeep)(customer);
|
|
296
|
+
|
|
297
|
+
// 将客户添加到列表第一位
|
|
267
298
|
this.store.customerList = [newCustomer, ...this.store.customerList];
|
|
299
|
+
|
|
300
|
+
// 更新总数
|
|
268
301
|
this.store.total += 1;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
302
|
+
|
|
303
|
+
// 触发客户列表更新事件
|
|
304
|
+
this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
|
|
305
|
+
|
|
306
|
+
// 保存状态变化
|
|
273
307
|
this.storeChange();
|
|
274
308
|
}
|
|
309
|
+
|
|
275
310
|
/**
|
|
276
311
|
* 获取当前状态
|
|
277
312
|
* @returns 当前状态
|
|
278
313
|
*/
|
|
279
314
|
getState() {
|
|
280
|
-
return (0,
|
|
315
|
+
return (0, _lodashEs.cloneDeep)(this.store);
|
|
281
316
|
}
|
|
317
|
+
|
|
282
318
|
/**
|
|
283
319
|
* 获取分页信息
|
|
284
320
|
* @returns 分页信息
|
|
@@ -291,16 +327,15 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
291
327
|
totalPages: Math.ceil(this.store.total / this.store.pageSize)
|
|
292
328
|
};
|
|
293
329
|
}
|
|
330
|
+
|
|
294
331
|
/**
|
|
295
332
|
* 触发分页变化事件
|
|
296
333
|
* @param pagination 分页信息
|
|
297
334
|
*/
|
|
298
335
|
triggerPaginationChange(pagination) {
|
|
299
|
-
this.core.effects.emit(
|
|
300
|
-
`${this.name}:onPaginationChange`,
|
|
301
|
-
pagination
|
|
302
|
-
);
|
|
336
|
+
this.core.effects.emit(`${this.name}:onPaginationChange`, pagination);
|
|
303
337
|
}
|
|
338
|
+
|
|
304
339
|
/**
|
|
305
340
|
* 设置分页信息
|
|
306
341
|
* @param page 页码
|
|
@@ -310,6 +345,8 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
310
345
|
this.store.currentPage = page;
|
|
311
346
|
this.store.pageSize = pageSize;
|
|
312
347
|
this.storeChange();
|
|
348
|
+
|
|
349
|
+
// 触发分页变化事件
|
|
313
350
|
this.triggerPaginationChange({
|
|
314
351
|
page,
|
|
315
352
|
pageSize,
|
|
@@ -317,6 +354,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
317
354
|
totalPages: Math.ceil(this.store.total / pageSize)
|
|
318
355
|
});
|
|
319
356
|
}
|
|
357
|
+
|
|
320
358
|
/**
|
|
321
359
|
* 便捷方法:切换分页并自动获取数据
|
|
322
360
|
* @param page 页码
|
|
@@ -325,21 +363,28 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
325
363
|
*/
|
|
326
364
|
async changeCustomerPage(page, pageSize) {
|
|
327
365
|
const targetPageSize = pageSize || this.store.pageSize;
|
|
366
|
+
|
|
367
|
+
// 先更新分页状态
|
|
328
368
|
this.setPaginationInfo(page, targetPageSize);
|
|
369
|
+
|
|
370
|
+
// skip直接使用page,num使用pageSize
|
|
329
371
|
const skip = page;
|
|
330
372
|
const num = targetPageSize;
|
|
373
|
+
|
|
374
|
+
// 自动调用获取客户列表,使用存储的搜索条件
|
|
331
375
|
return await this.getCustomerList({
|
|
332
376
|
skip,
|
|
333
377
|
num,
|
|
334
|
-
...this.store.searchParams
|
|
335
|
-
// 使用存储的搜索条件
|
|
378
|
+
...this.store.searchParams // 使用存储的搜索条件
|
|
336
379
|
});
|
|
337
380
|
}
|
|
381
|
+
|
|
338
382
|
/**
|
|
339
383
|
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
340
384
|
* @returns 客户列表响应
|
|
341
385
|
*/
|
|
342
386
|
async loadMoreCustomers() {
|
|
387
|
+
// 如果没有更多数据或正在加载,直接返回
|
|
343
388
|
if (!this.store.hasMore || this.store.loadingMore) {
|
|
344
389
|
return {
|
|
345
390
|
list: [],
|
|
@@ -348,34 +393,46 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
348
393
|
pageSize: this.store.pageSize
|
|
349
394
|
};
|
|
350
395
|
}
|
|
396
|
+
|
|
397
|
+
// 计算下一页
|
|
351
398
|
const nextPage = this.store.currentPage + 1;
|
|
352
399
|
try {
|
|
353
400
|
this.store.loadingMore = true;
|
|
354
401
|
this.store.error = null;
|
|
355
|
-
|
|
402
|
+
|
|
403
|
+
// 使用公共方法获取数据,传入存储的搜索条件
|
|
404
|
+
const {
|
|
405
|
+
customerList: newCustomers,
|
|
406
|
+
total,
|
|
407
|
+
page,
|
|
408
|
+
pageSize
|
|
409
|
+
} = await this.fetchCustomerListData({
|
|
356
410
|
skip: nextPage,
|
|
357
411
|
num: this.store.pageSize,
|
|
358
|
-
...this.store.searchParams
|
|
359
|
-
// 使用存储的搜索条件
|
|
412
|
+
...this.store.searchParams // 使用存储的搜索条件
|
|
360
413
|
});
|
|
361
|
-
|
|
414
|
+
|
|
415
|
+
// 将新数据追加到现有列表(追加模式)
|
|
416
|
+
const updatedCustomerList = [...this.store.customerList, ...(0, _lodashEs.cloneDeep)(newCustomers)];
|
|
417
|
+
|
|
418
|
+
// 更新状态
|
|
362
419
|
this.store.customerList = updatedCustomerList;
|
|
363
420
|
this.store.currentPage = page;
|
|
364
421
|
this.store.total = total;
|
|
365
422
|
this.store.hasMore = page * pageSize < total;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
423
|
+
|
|
424
|
+
// 触发滚动加载特定事件
|
|
425
|
+
await this.core.effects.emit(`${this.name}:onScrollLoadMore`, {
|
|
426
|
+
newCustomers,
|
|
427
|
+
allCustomers: this.store.customerList,
|
|
428
|
+
currentPage: page,
|
|
429
|
+
hasMore: this.store.hasMore
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// 触发通用更新事件
|
|
433
|
+
await this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
|
|
434
|
+
|
|
435
|
+
// 触发分页变化事件
|
|
379
436
|
this.triggerPaginationChange({
|
|
380
437
|
page,
|
|
381
438
|
pageSize,
|
|
@@ -391,39 +448,45 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
391
448
|
};
|
|
392
449
|
return response;
|
|
393
450
|
} catch (error) {
|
|
394
|
-
await this.handleCustomerListError(error,
|
|
451
|
+
await this.handleCustomerListError(error, 'load more customers');
|
|
395
452
|
throw error;
|
|
396
453
|
} finally {
|
|
397
454
|
this.store.loadingMore = false;
|
|
398
455
|
this.storeChange();
|
|
399
456
|
}
|
|
400
457
|
}
|
|
458
|
+
|
|
401
459
|
/**
|
|
402
460
|
* 重置并重新开始滚动加载
|
|
403
461
|
* @param params 查询参数
|
|
404
462
|
* @returns 客户列表响应
|
|
405
463
|
*/
|
|
406
464
|
async resetAndLoadCustomers(params = {}) {
|
|
465
|
+
// 重置状态
|
|
407
466
|
this.store.customerList = [];
|
|
408
467
|
this.store.currentPage = 1;
|
|
409
468
|
this.store.hasMore = true;
|
|
410
469
|
this.store.loadingMore = false;
|
|
470
|
+
|
|
471
|
+
// 使用第一页参数
|
|
411
472
|
const resetParams = {
|
|
412
473
|
...params,
|
|
413
474
|
skip: 1,
|
|
414
475
|
num: params.num || this.store.pageSize
|
|
415
476
|
};
|
|
477
|
+
|
|
478
|
+
// 调用普通的获取列表方法
|
|
416
479
|
const response = await this.getCustomerList(resetParams);
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
);
|
|
480
|
+
|
|
481
|
+
// 触发滚动加载完成事件
|
|
482
|
+
await this.core.effects.emit(`${this.name}:onScrollLoadComplete`, {
|
|
483
|
+
customers: this.store.customerList,
|
|
484
|
+
total: this.store.total,
|
|
485
|
+
hasMore: this.store.hasMore
|
|
486
|
+
});
|
|
425
487
|
return response;
|
|
426
488
|
}
|
|
489
|
+
|
|
427
490
|
/**
|
|
428
491
|
* 检查是否还有更多数据可以加载
|
|
429
492
|
* @returns 是否还有更多数据
|
|
@@ -431,30 +494,30 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
431
494
|
hasMoreCustomers() {
|
|
432
495
|
return this.store.hasMore && !this.store.loadingMore;
|
|
433
496
|
}
|
|
497
|
+
|
|
434
498
|
/**
|
|
435
499
|
* 获取当前的搜索条件
|
|
436
500
|
* @returns 当前搜索条件
|
|
437
501
|
*/
|
|
438
502
|
getCurrentSearchParams() {
|
|
439
|
-
return (0,
|
|
503
|
+
return (0, _lodashEs.cloneDeep)(this.store.searchParams);
|
|
440
504
|
}
|
|
505
|
+
|
|
441
506
|
/**
|
|
442
507
|
* 缓存状态变化
|
|
443
508
|
*/
|
|
444
509
|
storeChange() {
|
|
445
510
|
if (this.openCache) {
|
|
446
|
-
const store = (0,
|
|
511
|
+
const store = (0, _lodashEs.cloneDeep)(this.store);
|
|
447
512
|
this.checkSaveCache({
|
|
448
513
|
cacheId: this.cacheId,
|
|
449
514
|
fatherModule: this.fatherModule,
|
|
450
515
|
store,
|
|
451
|
-
cacheKey: [
|
|
516
|
+
cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize', 'hasMore', 'loadingMore', 'searchParams']
|
|
452
517
|
});
|
|
453
518
|
}
|
|
454
519
|
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
...require("./types")
|
|
460
|
-
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// 导出类型和模块
|
|
523
|
+
exports.CustomerModule = CustomerModule;
|