@pisell/pisellos 0.0.569 → 0.10.2
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 +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
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
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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;
|
|
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);
|
|
43
19
|
|
|
20
|
+
// src/modules/Customer/index.ts
|
|
21
|
+
var Customer_exports = {};
|
|
22
|
+
__export(Customer_exports, {
|
|
23
|
+
CustomerModule: () => CustomerModule
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Customer_exports);
|
|
26
|
+
var import_lodash_es = require("lodash-es");
|
|
27
|
+
var import_BaseModule = require("../BaseModule");
|
|
28
|
+
var import_plugins = require("../../plugins");
|
|
29
|
+
var import_constants = require("./constants");
|
|
30
|
+
__reExport(Customer_exports, require("./types"), module.exports);
|
|
31
|
+
var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
32
|
+
constructor(name, version) {
|
|
33
|
+
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
|
+
}
|
|
44
51
|
/**
|
|
45
52
|
* 判断两份选中客户的核心展示字段是否一致,用于避免重复 clone / emit。
|
|
46
53
|
*
|
|
@@ -48,71 +55,65 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
48
55
|
* this.isSameSelectedCustomer(currentCustomer, nextCustomer);
|
|
49
56
|
*/
|
|
50
57
|
isSameSelectedCustomer(current, next) {
|
|
51
|
-
const normalizedNext = !next ?
|
|
58
|
+
const normalizedNext = !next ? import_constants.DEFAULT_CUSTOMER : next;
|
|
52
59
|
const normalizedCurrent = current || null;
|
|
53
|
-
if (!normalizedCurrent)
|
|
54
|
-
|
|
55
|
-
if (String(normalizedCurrent
|
|
60
|
+
if (!normalizedCurrent)
|
|
61
|
+
return false;
|
|
62
|
+
if (String((normalizedCurrent == null ? void 0 : normalizedCurrent.id) ?? "") === "1" && String((normalizedNext == null ? void 0 : normalizedNext.id) ?? "") === "1") {
|
|
56
63
|
return true;
|
|
57
64
|
}
|
|
58
|
-
const keys = [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const keys = [
|
|
66
|
+
"id",
|
|
67
|
+
"name",
|
|
68
|
+
"phone",
|
|
69
|
+
"email",
|
|
70
|
+
"country_calling_code"
|
|
71
|
+
];
|
|
72
|
+
return keys.every((key) => String((normalizedCurrent == null ? void 0 : normalizedCurrent[key]) ?? "") === String((normalizedNext == null ? void 0 : normalizedNext[key]) ?? ""));
|
|
66
73
|
}
|
|
67
74
|
async initialize(core, options) {
|
|
75
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
68
76
|
this.core = core;
|
|
69
|
-
this.store = options
|
|
70
|
-
this.request = this.core.getPlugin(
|
|
71
|
-
this.otherParams = options
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (Array.isArray(options?.initialState?.customerList)) {
|
|
75
|
-
const customerList = (0, _lodashEs.cloneDeep)(options.initialState.customerList || []);
|
|
77
|
+
this.store = options == null ? void 0 : options.store;
|
|
78
|
+
this.request = this.core.getPlugin("request");
|
|
79
|
+
this.otherParams = (options == null ? void 0 : options.otherParams) || {};
|
|
80
|
+
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.customerList)) {
|
|
81
|
+
const customerList = (0, import_lodash_es.cloneDeep)(options.initialState.customerList || []);
|
|
76
82
|
this.store.customerList = customerList;
|
|
77
83
|
} else {
|
|
78
84
|
this.store.customerList = [];
|
|
79
85
|
}
|
|
80
|
-
if (options
|
|
81
|
-
this.store.selectedCustomer = (0,
|
|
86
|
+
if ((_b = options == null ? void 0 : options.initialState) == null ? void 0 : _b.selectedCustomer) {
|
|
87
|
+
this.store.selectedCustomer = (0, import_lodash_es.cloneDeep)(options.initialState.selectedCustomer);
|
|
82
88
|
} else {
|
|
83
89
|
this.store.selectedCustomer = null;
|
|
84
90
|
}
|
|
85
|
-
if (typeof options
|
|
91
|
+
if (typeof ((_c = options == null ? void 0 : options.initialState) == null ? void 0 : _c.total) === "number") {
|
|
86
92
|
this.store.total = options.initialState.total;
|
|
87
93
|
} else {
|
|
88
94
|
this.store.total = 0;
|
|
89
95
|
}
|
|
90
|
-
if (typeof options
|
|
96
|
+
if (typeof ((_d = options == null ? void 0 : options.initialState) == null ? void 0 : _d.currentPage) === "number") {
|
|
91
97
|
this.store.currentPage = options.initialState.currentPage;
|
|
92
98
|
} else {
|
|
93
99
|
this.store.currentPage = 1;
|
|
94
100
|
}
|
|
95
|
-
if (typeof options
|
|
101
|
+
if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number" && options.initialState.pageSize > 1) {
|
|
96
102
|
this.store.pageSize = options.initialState.pageSize;
|
|
97
103
|
} else {
|
|
98
|
-
this.store.pageSize =
|
|
104
|
+
this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
|
|
99
105
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.store.
|
|
103
|
-
|
|
104
|
-
this.store.searchParams = options?.initialState?.searchParams ?? {};
|
|
105
|
-
|
|
106
|
-
// 缓存配置
|
|
107
|
-
if (options?.otherParams?.cacheId) {
|
|
106
|
+
this.store.hasMore = ((_f = options == null ? void 0 : options.initialState) == null ? void 0 : _f.hasMore) ?? true;
|
|
107
|
+
this.store.loadingMore = ((_g = options == null ? void 0 : options.initialState) == null ? void 0 : _g.loadingMore) ?? false;
|
|
108
|
+
this.store.searchParams = ((_h = options == null ? void 0 : options.initialState) == null ? void 0 : _h.searchParams) ?? {};
|
|
109
|
+
if ((_i = options == null ? void 0 : options.otherParams) == null ? void 0 : _i.cacheId) {
|
|
108
110
|
this.openCache = options.otherParams.openCache;
|
|
109
111
|
this.cacheId = options.otherParams.cacheId;
|
|
110
112
|
}
|
|
111
|
-
if (options
|
|
113
|
+
if ((_j = options == null ? void 0 : options.otherParams) == null ? void 0 : _j.fatherModule) {
|
|
112
114
|
this.fatherModule = options.otherParams.fatherModule;
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
|
|
116
117
|
/**
|
|
117
118
|
* 更新父级解决方案透传的运行态参数,并刷新客户模块缓存配置。
|
|
118
119
|
*
|
|
@@ -125,64 +126,54 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
125
126
|
this.cacheId = this.otherParams.cacheId;
|
|
126
127
|
this.fatherModule = this.otherParams.fatherModule;
|
|
127
128
|
}
|
|
128
|
-
|
|
129
129
|
/**
|
|
130
130
|
* 获取客户列表数据(内部方法)
|
|
131
131
|
* @param params 查询参数
|
|
132
132
|
* @returns API响应数据
|
|
133
133
|
*/
|
|
134
134
|
async fetchCustomerListData(params = {}) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (this.otherParams
|
|
138
|
-
url =
|
|
135
|
+
var _a, _b, _c, _d;
|
|
136
|
+
let url = "/customer/select-list";
|
|
137
|
+
if ((_a = this.otherParams) == null ? void 0 : _a.isFranchisee) {
|
|
138
|
+
url = "/franchisee/customer/select-list";
|
|
139
139
|
}
|
|
140
|
-
const {
|
|
141
|
-
skip = 1,
|
|
142
|
-
num = _constants.DEFAULT_PAGE_SIZE,
|
|
143
|
-
search,
|
|
144
|
-
..._otherParams
|
|
145
|
-
} = params;
|
|
140
|
+
const { skip = 1, num = import_constants.DEFAULT_PAGE_SIZE, search, ..._otherParams } = params;
|
|
146
141
|
const queryParams = {
|
|
147
142
|
skip,
|
|
148
143
|
num,
|
|
149
|
-
sort_by:
|
|
150
|
-
with: [
|
|
144
|
+
sort_by: import_constants.SORT_BY,
|
|
145
|
+
with: ["latestWalletDetail.wallet", "contactsInfo", "formRecord"],
|
|
151
146
|
search_wallet_flag: 1,
|
|
152
147
|
search_wallet_pass_flag: 1,
|
|
153
|
-
...
|
|
154
|
-
search
|
|
155
|
-
}),
|
|
148
|
+
...search && { search },
|
|
156
149
|
..._otherParams
|
|
157
150
|
};
|
|
158
151
|
const res = await this.request.get(url, queryParams, {
|
|
159
152
|
cache: {
|
|
160
|
-
mode:
|
|
153
|
+
mode: import_plugins.RequestModeENUM.REMOTE_LOCAL,
|
|
161
154
|
type: "memory"
|
|
162
155
|
}
|
|
163
156
|
});
|
|
164
|
-
if (res
|
|
165
|
-
throw new Error(res
|
|
157
|
+
if ((res == null ? void 0 : res.code) !== 200) {
|
|
158
|
+
throw new Error(res == null ? void 0 : res.message);
|
|
166
159
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (this.otherParams?.isFranchisee && _customerList?.length > 0) {
|
|
171
|
-
_customerList = _customerList?.map(item => {
|
|
160
|
+
let _customerList = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.list) || [];
|
|
161
|
+
if (((_c = this.otherParams) == null ? void 0 : _c.isFranchisee) && (_customerList == null ? void 0 : _customerList.length) > 0) {
|
|
162
|
+
_customerList = _customerList == null ? void 0 : _customerList.map((item) => {
|
|
172
163
|
return {
|
|
173
|
-
...
|
|
174
|
-
is_franchisor_customer: 1
|
|
164
|
+
...item || {},
|
|
165
|
+
is_franchisor_customer: 1
|
|
166
|
+
// 标识是总店的客户
|
|
175
167
|
};
|
|
176
168
|
});
|
|
177
169
|
}
|
|
178
170
|
return {
|
|
179
171
|
customerList: _customerList,
|
|
180
|
-
total: res
|
|
172
|
+
total: ((_d = res == null ? void 0 : res.data) == null ? void 0 : _d.count) || 0,
|
|
181
173
|
page: skip,
|
|
182
174
|
pageSize: num
|
|
183
175
|
};
|
|
184
176
|
}
|
|
185
|
-
|
|
186
177
|
/**
|
|
187
178
|
* 处理客户列表操作的错误(内部方法)
|
|
188
179
|
* @param error 错误对象
|
|
@@ -191,21 +182,18 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
191
182
|
async handleCustomerListError(error, operation) {
|
|
192
183
|
console.error(`Failed to ${operation}:`, error);
|
|
193
184
|
this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
|
|
194
|
-
await this.core.effects.emit(
|
|
185
|
+
await this.core.effects.emit(
|
|
186
|
+
`${this.name}:onCustomerListError`,
|
|
187
|
+
this.store.error
|
|
188
|
+
);
|
|
195
189
|
}
|
|
196
|
-
|
|
197
190
|
/**
|
|
198
191
|
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
199
192
|
*
|
|
200
193
|
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
201
194
|
*/
|
|
202
195
|
async queryCustomerList(params = {}) {
|
|
203
|
-
const {
|
|
204
|
-
customerList,
|
|
205
|
-
total,
|
|
206
|
-
page,
|
|
207
|
-
pageSize
|
|
208
|
-
} = await this.fetchCustomerListData(params);
|
|
196
|
+
const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
|
|
209
197
|
return {
|
|
210
198
|
list: customerList,
|
|
211
199
|
total,
|
|
@@ -213,7 +201,6 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
213
201
|
pageSize
|
|
214
202
|
};
|
|
215
203
|
}
|
|
216
|
-
|
|
217
204
|
/**
|
|
218
205
|
* 获取客户列表
|
|
219
206
|
* @param params 查询参数
|
|
@@ -223,33 +210,14 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
223
210
|
try {
|
|
224
211
|
this.store.loading = true;
|
|
225
212
|
this.store.error = null;
|
|
226
|
-
const {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
page,
|
|
230
|
-
pageSize
|
|
231
|
-
} = await this.fetchCustomerListData(params);
|
|
232
|
-
|
|
233
|
-
// 保存搜索条件(排除skip和num)
|
|
234
|
-
const {
|
|
235
|
-
skip,
|
|
236
|
-
num,
|
|
237
|
-
...searchParams
|
|
238
|
-
} = params;
|
|
239
|
-
this.store.searchParams = (0, _lodashEs.cloneDeep)(searchParams);
|
|
240
|
-
|
|
241
|
-
// 更新分页状态
|
|
213
|
+
const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
|
|
214
|
+
const { skip, num, ...searchParams } = params;
|
|
215
|
+
this.store.searchParams = (0, import_lodash_es.cloneDeep)(searchParams);
|
|
242
216
|
this.store.currentPage = page;
|
|
243
217
|
this.store.pageSize = pageSize;
|
|
244
218
|
this.store.total = total;
|
|
245
|
-
|
|
246
|
-
// 计算是否还有更多数据
|
|
247
219
|
this.store.hasMore = page * pageSize < total;
|
|
248
|
-
|
|
249
|
-
// 设置客户列表(替换模式)
|
|
250
|
-
this.store.customerList = (0, _lodashEs.cloneDeep)(customerList);
|
|
251
|
-
|
|
252
|
-
// 触发分页变化事件
|
|
220
|
+
this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
|
|
253
221
|
this.triggerPaginationChange({
|
|
254
222
|
page,
|
|
255
223
|
pageSize,
|
|
@@ -264,28 +232,29 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
264
232
|
};
|
|
265
233
|
return response;
|
|
266
234
|
} catch (error) {
|
|
267
|
-
await this.handleCustomerListError(error,
|
|
235
|
+
await this.handleCustomerListError(error, "fetch customer list");
|
|
268
236
|
throw error;
|
|
269
237
|
} finally {
|
|
270
238
|
this.store.loading = false;
|
|
271
239
|
this.storeChange();
|
|
272
|
-
await this.core.effects.emit(
|
|
240
|
+
await this.core.effects.emit(
|
|
241
|
+
`${this.name}:onCustomerListUpdate`,
|
|
242
|
+
this.store
|
|
243
|
+
);
|
|
273
244
|
}
|
|
274
245
|
}
|
|
275
|
-
|
|
276
246
|
/**
|
|
277
247
|
* 设置客户列表
|
|
278
248
|
* @param customers 客户列表
|
|
279
249
|
* @param total 总数
|
|
280
250
|
*/
|
|
281
251
|
setCustomerList(customers, total) {
|
|
282
|
-
this.store.customerList = (0,
|
|
283
|
-
if (typeof total ===
|
|
252
|
+
this.store.customerList = (0, import_lodash_es.cloneDeep)(customers);
|
|
253
|
+
if (typeof total === "number") {
|
|
284
254
|
this.store.total = total;
|
|
285
255
|
}
|
|
286
256
|
this.storeChange();
|
|
287
257
|
}
|
|
288
|
-
|
|
289
258
|
/**
|
|
290
259
|
* 设置当前选择的客户
|
|
291
260
|
* @param customer 选择的客户
|
|
@@ -294,11 +263,13 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
294
263
|
if (this.isSameSelectedCustomer(this.store.selectedCustomer, customer)) {
|
|
295
264
|
return;
|
|
296
265
|
}
|
|
297
|
-
this.store.selectedCustomer = !customer ?
|
|
298
|
-
this.core.effects.emit(
|
|
266
|
+
this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
|
|
267
|
+
this.core.effects.emit(
|
|
268
|
+
`${this.name}:onCustomerSelected`,
|
|
269
|
+
this.store.selectedCustomer
|
|
270
|
+
);
|
|
299
271
|
this.storeChange();
|
|
300
272
|
}
|
|
301
|
-
|
|
302
273
|
/**
|
|
303
274
|
* 获取当前选择的客户
|
|
304
275
|
* @returns 当前选择的客户
|
|
@@ -306,7 +277,6 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
306
277
|
getSelectedCustomer() {
|
|
307
278
|
return this.store.selectedCustomer;
|
|
308
279
|
}
|
|
309
|
-
|
|
310
280
|
/**
|
|
311
281
|
* 获取客户列表
|
|
312
282
|
* @returns 客户列表
|
|
@@ -314,16 +284,14 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
314
284
|
getCustomers() {
|
|
315
285
|
return [...this.store.customerList];
|
|
316
286
|
}
|
|
317
|
-
|
|
318
287
|
/**
|
|
319
288
|
* 根据ID查找客户
|
|
320
289
|
* @param id 客户ID
|
|
321
290
|
* @returns 客户信息
|
|
322
291
|
*/
|
|
323
292
|
getCustomerById(id) {
|
|
324
|
-
return this.store.customerList.find(customer => customer.id === id) || null;
|
|
293
|
+
return this.store.customerList.find((customer) => customer.id === id) || null;
|
|
325
294
|
}
|
|
326
|
-
|
|
327
295
|
/**
|
|
328
296
|
* 清空客户列表
|
|
329
297
|
*/
|
|
@@ -332,43 +300,37 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
332
300
|
this.store.selectedCustomer = null;
|
|
333
301
|
this.store.total = 0;
|
|
334
302
|
this.store.currentPage = 1;
|
|
335
|
-
this.store.pageSize =
|
|
303
|
+
this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
|
|
336
304
|
this.store.hasMore = true;
|
|
337
305
|
this.store.loadingMore = false;
|
|
338
306
|
this.store.searchParams = {};
|
|
339
|
-
this.core.effects.emit(
|
|
307
|
+
this.core.effects.emit(
|
|
308
|
+
`${this.name}:onCustomerListUpdate`,
|
|
309
|
+
this.store
|
|
310
|
+
);
|
|
340
311
|
this.storeChange();
|
|
341
312
|
}
|
|
342
|
-
|
|
343
313
|
/**
|
|
344
314
|
* 添加客户到列表第一位
|
|
345
315
|
* @param customer 要添加的客户信息
|
|
346
316
|
*/
|
|
347
317
|
addCustomerToFirst(customer) {
|
|
348
|
-
|
|
349
|
-
const newCustomer = (0, _lodashEs.cloneDeep)(customer);
|
|
350
|
-
|
|
351
|
-
// 将客户添加到列表第一位
|
|
318
|
+
const newCustomer = (0, import_lodash_es.cloneDeep)(customer);
|
|
352
319
|
this.store.customerList = [newCustomer, ...this.store.customerList];
|
|
353
|
-
|
|
354
|
-
// 更新总数
|
|
355
320
|
this.store.total += 1;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
// 保存状态变化
|
|
321
|
+
this.core.effects.emit(
|
|
322
|
+
`${this.name}:onCustomerListUpdate`,
|
|
323
|
+
this.store
|
|
324
|
+
);
|
|
361
325
|
this.storeChange();
|
|
362
326
|
}
|
|
363
|
-
|
|
364
327
|
/**
|
|
365
328
|
* 获取当前状态
|
|
366
329
|
* @returns 当前状态
|
|
367
330
|
*/
|
|
368
331
|
getState() {
|
|
369
|
-
return (0,
|
|
332
|
+
return (0, import_lodash_es.cloneDeep)(this.store);
|
|
370
333
|
}
|
|
371
|
-
|
|
372
334
|
/**
|
|
373
335
|
* 获取分页信息
|
|
374
336
|
* @returns 分页信息
|
|
@@ -381,15 +343,16 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
381
343
|
totalPages: Math.ceil(this.store.total / this.store.pageSize)
|
|
382
344
|
};
|
|
383
345
|
}
|
|
384
|
-
|
|
385
346
|
/**
|
|
386
347
|
* 触发分页变化事件
|
|
387
348
|
* @param pagination 分页信息
|
|
388
349
|
*/
|
|
389
350
|
triggerPaginationChange(pagination) {
|
|
390
|
-
this.core.effects.emit(
|
|
351
|
+
this.core.effects.emit(
|
|
352
|
+
`${this.name}:onPaginationChange`,
|
|
353
|
+
pagination
|
|
354
|
+
);
|
|
391
355
|
}
|
|
392
|
-
|
|
393
356
|
/**
|
|
394
357
|
* 设置分页信息
|
|
395
358
|
* @param page 页码
|
|
@@ -399,8 +362,6 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
399
362
|
this.store.currentPage = page;
|
|
400
363
|
this.store.pageSize = pageSize;
|
|
401
364
|
this.storeChange();
|
|
402
|
-
|
|
403
|
-
// 触发分页变化事件
|
|
404
365
|
this.triggerPaginationChange({
|
|
405
366
|
page,
|
|
406
367
|
pageSize,
|
|
@@ -408,7 +369,6 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
408
369
|
totalPages: Math.ceil(this.store.total / pageSize)
|
|
409
370
|
});
|
|
410
371
|
}
|
|
411
|
-
|
|
412
372
|
/**
|
|
413
373
|
* 便捷方法:切换分页并自动获取数据
|
|
414
374
|
* @param page 页码
|
|
@@ -417,28 +377,21 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
417
377
|
*/
|
|
418
378
|
async changeCustomerPage(page, pageSize) {
|
|
419
379
|
const targetPageSize = pageSize || this.store.pageSize;
|
|
420
|
-
|
|
421
|
-
// 先更新分页状态
|
|
422
380
|
this.setPaginationInfo(page, targetPageSize);
|
|
423
|
-
|
|
424
|
-
// skip直接使用page,num使用pageSize
|
|
425
381
|
const skip = page;
|
|
426
382
|
const num = targetPageSize;
|
|
427
|
-
|
|
428
|
-
// 自动调用获取客户列表,使用存储的搜索条件
|
|
429
383
|
return await this.getCustomerList({
|
|
430
384
|
skip,
|
|
431
385
|
num,
|
|
432
|
-
...this.store.searchParams
|
|
386
|
+
...this.store.searchParams
|
|
387
|
+
// 使用存储的搜索条件
|
|
433
388
|
});
|
|
434
389
|
}
|
|
435
|
-
|
|
436
390
|
/**
|
|
437
391
|
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
438
392
|
* @returns 客户列表响应
|
|
439
393
|
*/
|
|
440
394
|
async loadMoreCustomers() {
|
|
441
|
-
// 如果没有更多数据或正在加载,直接返回
|
|
442
395
|
if (!this.store.hasMore || this.store.loadingMore) {
|
|
443
396
|
return {
|
|
444
397
|
list: [],
|
|
@@ -447,8 +400,6 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
447
400
|
pageSize: this.store.pageSize
|
|
448
401
|
};
|
|
449
402
|
}
|
|
450
|
-
|
|
451
|
-
// 计算下一页
|
|
452
403
|
const nextPage = this.store.currentPage + 1;
|
|
453
404
|
try {
|
|
454
405
|
this.store.loadingMore = true;
|
|
@@ -456,35 +407,24 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
456
407
|
const loadMoreParams = {
|
|
457
408
|
skip: nextPage,
|
|
458
409
|
num: this.store.pageSize,
|
|
459
|
-
...this.store.searchParams
|
|
410
|
+
...this.store.searchParams
|
|
411
|
+
// 使用存储的搜索条件
|
|
460
412
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const {
|
|
464
|
-
customerList: newCustomers,
|
|
465
|
-
total,
|
|
466
|
-
page,
|
|
467
|
-
pageSize
|
|
468
|
-
} = await this.fetchCustomerListData(loadMoreParams);
|
|
469
|
-
|
|
470
|
-
// 将新数据追加到现有列表(追加模式)
|
|
471
|
-
const updatedCustomerList = [...this.store.customerList, ...(0, _lodashEs.cloneDeep)(newCustomers)];
|
|
472
|
-
|
|
473
|
-
// 更新状态
|
|
413
|
+
const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData(loadMoreParams);
|
|
414
|
+
const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
|
|
474
415
|
this.store.customerList = updatedCustomerList;
|
|
475
416
|
this.store.currentPage = page;
|
|
476
417
|
this.store.total = total;
|
|
477
418
|
this.store.hasMore = page * pageSize < total;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
// 触发分页变化事件
|
|
419
|
+
await this.core.effects.emit(
|
|
420
|
+
`${this.name}:onScrollLoadMore`,
|
|
421
|
+
{
|
|
422
|
+
newCustomers,
|
|
423
|
+
allCustomers: this.store.customerList,
|
|
424
|
+
currentPage: page,
|
|
425
|
+
hasMore: this.store.hasMore
|
|
426
|
+
}
|
|
427
|
+
);
|
|
488
428
|
this.triggerPaginationChange({
|
|
489
429
|
page,
|
|
490
430
|
pageSize,
|
|
@@ -500,46 +440,43 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
500
440
|
};
|
|
501
441
|
return response;
|
|
502
442
|
} catch (error) {
|
|
503
|
-
await this.handleCustomerListError(error,
|
|
443
|
+
await this.handleCustomerListError(error, "load more customers");
|
|
504
444
|
throw error;
|
|
505
445
|
} finally {
|
|
506
446
|
this.store.loadingMore = false;
|
|
507
447
|
this.storeChange();
|
|
508
|
-
await this.core.effects.emit(
|
|
448
|
+
await this.core.effects.emit(
|
|
449
|
+
`${this.name}:onCustomerListUpdate`,
|
|
450
|
+
this.store
|
|
451
|
+
);
|
|
509
452
|
}
|
|
510
453
|
}
|
|
511
|
-
|
|
512
454
|
/**
|
|
513
455
|
* 重置并重新开始滚动加载
|
|
514
456
|
* @param params 查询参数
|
|
515
457
|
* @returns 客户列表响应
|
|
516
458
|
*/
|
|
517
459
|
async resetAndLoadCustomers(params = {}) {
|
|
518
|
-
// 重置状态
|
|
519
460
|
this.store.customerList = [];
|
|
520
461
|
this.store.currentPage = 1;
|
|
521
462
|
this.store.hasMore = true;
|
|
522
463
|
this.store.loadingMore = false;
|
|
523
|
-
|
|
524
|
-
// 使用第一页参数
|
|
525
464
|
const resetParams = {
|
|
526
465
|
...params,
|
|
527
466
|
skip: 1,
|
|
528
467
|
num: params.num || this.store.pageSize
|
|
529
468
|
};
|
|
530
|
-
|
|
531
|
-
// 调用普通的获取列表方法
|
|
532
469
|
const response = await this.getCustomerList(resetParams);
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
470
|
+
await this.core.effects.emit(
|
|
471
|
+
`${this.name}:onScrollLoadComplete`,
|
|
472
|
+
{
|
|
473
|
+
customers: this.store.customerList,
|
|
474
|
+
total: this.store.total,
|
|
475
|
+
hasMore: this.store.hasMore
|
|
476
|
+
}
|
|
477
|
+
);
|
|
540
478
|
return response;
|
|
541
479
|
}
|
|
542
|
-
|
|
543
480
|
/**
|
|
544
481
|
* 检查是否还有更多数据可以加载
|
|
545
482
|
* @returns 是否还有更多数据
|
|
@@ -547,30 +484,30 @@ class CustomerModule extends _BaseModule.BaseModule {
|
|
|
547
484
|
hasMoreCustomers() {
|
|
548
485
|
return this.store.hasMore && !this.store.loadingMore;
|
|
549
486
|
}
|
|
550
|
-
|
|
551
487
|
/**
|
|
552
488
|
* 获取当前的搜索条件
|
|
553
489
|
* @returns 当前搜索条件
|
|
554
490
|
*/
|
|
555
491
|
getCurrentSearchParams() {
|
|
556
|
-
return (0,
|
|
492
|
+
return (0, import_lodash_es.cloneDeep)(this.store.searchParams);
|
|
557
493
|
}
|
|
558
|
-
|
|
559
494
|
/**
|
|
560
495
|
* 缓存状态变化
|
|
561
496
|
*/
|
|
562
497
|
storeChange() {
|
|
563
498
|
if (this.openCache) {
|
|
564
|
-
const store = (0,
|
|
499
|
+
const store = (0, import_lodash_es.cloneDeep)(this.store);
|
|
565
500
|
this.checkSaveCache({
|
|
566
501
|
cacheId: this.cacheId,
|
|
567
502
|
fatherModule: this.fatherModule,
|
|
568
503
|
store,
|
|
569
|
-
cacheKey: [
|
|
504
|
+
cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize", "hasMore", "loadingMore", "searchParams"]
|
|
570
505
|
});
|
|
571
506
|
}
|
|
572
507
|
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
508
|
+
};
|
|
509
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
510
|
+
0 && (module.exports = {
|
|
511
|
+
CustomerModule,
|
|
512
|
+
...require("./types")
|
|
513
|
+
});
|