@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,24 +1,46 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/modules/BookingContext/utils/resourceSelection.ts
|
|
20
|
+
var resourceSelection_exports = {};
|
|
21
|
+
__export(resourceSelection_exports, {
|
|
22
|
+
hasActualResourceSelection: () => hasActualResourceSelection,
|
|
23
|
+
productNeedsResourceExtend: () => productNeedsResourceExtend
|
|
5
24
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.productNeedsResourceExtend = productNeedsResourceExtend;
|
|
8
|
-
/**
|
|
9
|
-
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
25
|
+
module.exports = __toCommonJS(resourceSelection_exports);
|
|
13
26
|
function productNeedsResourceExtend(cacheItem) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
const forms = (_a = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _a.resources;
|
|
29
|
+
if (!Array.isArray(forms))
|
|
30
|
+
return false;
|
|
31
|
+
return forms.some((d) => Number(d == null ? void 0 : d.status) === 1);
|
|
17
32
|
}
|
|
18
|
-
|
|
19
|
-
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
20
33
|
function hasActualResourceSelection(cacheItem) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
const resource = (_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource;
|
|
36
|
+
if (!resource || typeof resource !== "object")
|
|
37
|
+
return false;
|
|
38
|
+
return Object.values(resource).some(
|
|
39
|
+
(rows) => Array.isArray(rows) && rows.length > 0
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
hasActualResourceSelection,
|
|
45
|
+
productNeedsResourceExtend
|
|
46
|
+
});
|
|
@@ -1,110 +1,117 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
28
|
|
|
3
|
-
|
|
4
|
-
|
|
29
|
+
// src/modules/BookingContext/utils/resources.ts
|
|
30
|
+
var resources_exports = {};
|
|
31
|
+
__export(resources_exports, {
|
|
32
|
+
formatResource: () => formatResource,
|
|
33
|
+
formatResources: () => formatResources,
|
|
34
|
+
formatTimes: () => formatTimes,
|
|
35
|
+
getResourceByIds: () => getResourceByIds,
|
|
36
|
+
getResourceTimeIsUsable: () => getResourceTimeIsUsable,
|
|
37
|
+
getSumCapacity: () => getSumCapacity,
|
|
38
|
+
getUsableTime: () => getUsableTime,
|
|
39
|
+
setDefaultCapacitys: () => setDefaultCapacitys,
|
|
40
|
+
setDefaultResource: () => setDefaultResource
|
|
5
41
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.getUsableTime = getUsableTime;
|
|
13
|
-
exports.setDefaultCapacitys = setDefaultCapacitys;
|
|
14
|
-
exports.setDefaultResource = setDefaultResource;
|
|
15
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
16
|
-
var _lodashEs = require("lodash-es");
|
|
17
|
-
var _flexible = require("./flexible");
|
|
18
|
-
var _noResource = require("./noResource");
|
|
19
|
-
var _serviceTimes = require("./serviceTimes");
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
/**
|
|
22
|
-
* 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
|
|
23
|
-
*
|
|
24
|
-
* 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
|
|
25
|
-
* 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
|
|
26
|
-
*
|
|
27
|
-
* 三个 info2 独有特性保留:
|
|
28
|
-
* 1. `resource_display_scope='all'`:取全部资源
|
|
29
|
-
* 2. `extraResources`:拖入未绑定资源时兼容渲染
|
|
30
|
-
* 3. `getNoResource2()`:占位"无资源"行
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
|
|
35
|
-
* 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
|
|
36
|
-
*/
|
|
42
|
+
module.exports = __toCommonJS(resources_exports);
|
|
43
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
44
|
+
var import_lodash_es = require("lodash-es");
|
|
45
|
+
var import_flexible = require("./flexible");
|
|
46
|
+
var import_noResource = require("./noResource");
|
|
47
|
+
var import_serviceTimes = require("./serviceTimes");
|
|
37
48
|
function getUsableTime(cacheItem) {
|
|
49
|
+
var _a, _b, _c;
|
|
38
50
|
try {
|
|
39
|
-
const resourceByForm = cacheItem
|
|
40
|
-
const resourceMaps = cacheItem
|
|
51
|
+
const resourceByForm = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
|
|
52
|
+
const resourceMaps = ((_b = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _b.resourceMaps) || {};
|
|
41
53
|
let items = [];
|
|
42
54
|
for (const formId of Object.keys(resourceByForm)) {
|
|
43
55
|
const selected = resourceByForm[formId];
|
|
44
|
-
const maps = resourceMaps[formId]
|
|
45
|
-
if (!Array.isArray(selected) || !maps)
|
|
46
|
-
|
|
56
|
+
const maps = (_c = resourceMaps[formId]) == null ? void 0 : _c.renderListMaps;
|
|
57
|
+
if (!Array.isArray(selected) || !maps)
|
|
58
|
+
continue;
|
|
59
|
+
items = items.concat(
|
|
60
|
+
selected.map((d) => maps[d.relation_id]).filter(Boolean)
|
|
61
|
+
);
|
|
47
62
|
}
|
|
48
|
-
if (!items.length)
|
|
63
|
+
if (!items.length)
|
|
64
|
+
return null;
|
|
49
65
|
return items.reduce((pre, event) => {
|
|
50
|
-
|
|
51
|
-
const
|
|
66
|
+
var _a2, _b2, _c2, _d;
|
|
67
|
+
const endAt = (0, import_dayjs.default)((_b2 = (_a2 = event._extend) == null ? void 0 : _a2.usableTime) == null ? void 0 : _b2.end_at);
|
|
68
|
+
const preEnd = (0, import_dayjs.default)((_d = (_c2 = pre._extend) == null ? void 0 : _c2.usableTime) == null ? void 0 : _d.end_at);
|
|
52
69
|
return endAt.isBefore(preEnd) ? event : pre;
|
|
53
70
|
}, items[0]);
|
|
54
71
|
} catch {
|
|
55
72
|
return null;
|
|
56
73
|
}
|
|
57
74
|
}
|
|
58
|
-
|
|
59
|
-
/** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
|
|
60
75
|
function getSumCapacity(cacheItem, isCalcQuantity = true) {
|
|
61
|
-
|
|
76
|
+
var _a, _b;
|
|
77
|
+
const list = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.capacity) || [];
|
|
62
78
|
let sum = 0;
|
|
63
79
|
for (const item of list) {
|
|
64
|
-
sum += Number(item
|
|
80
|
+
sum += Number((item == null ? void 0 : item.value) || 0);
|
|
65
81
|
}
|
|
66
|
-
return sum * (isCalcQuantity ? cacheItem
|
|
82
|
+
return sum * (isCalcQuantity ? ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) || 1 : 1);
|
|
67
83
|
}
|
|
68
|
-
|
|
69
|
-
/** 当前 time 剩余容量 = totalCapacity - Σ event.pax。 */
|
|
70
84
|
function getUseableEventCount(eventList, current) {
|
|
71
|
-
return (eventList || []).reduce((pre, event) => pre - (event
|
|
85
|
+
return (eventList || []).reduce((pre, event) => pre - ((event == null ? void 0 : event.pax) || 0), current || 0);
|
|
72
86
|
}
|
|
73
|
-
|
|
74
|
-
/** 判断两个时间段是否有冲突。 */
|
|
75
87
|
function isConflict(event, current) {
|
|
76
|
-
const eventStart = (0,
|
|
77
|
-
const eventEnd = (0,
|
|
78
|
-
const currentStart = (0,
|
|
88
|
+
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
89
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
90
|
+
const currentStart = (0, import_dayjs.default)(current.start_at);
|
|
79
91
|
const isBefore = currentStart.isBefore(eventEnd);
|
|
80
92
|
let isAfter = true;
|
|
81
93
|
if (current.end_at) {
|
|
82
|
-
const currentEnd = (0,
|
|
94
|
+
const currentEnd = (0, import_dayjs.default)(current.end_at);
|
|
83
95
|
isAfter = currentEnd.isAfter(eventStart);
|
|
84
96
|
}
|
|
85
97
|
return isBefore && isAfter;
|
|
86
98
|
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
|
|
90
|
-
* 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
|
|
91
|
-
*/
|
|
92
99
|
function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
93
|
-
const startDate = (0,
|
|
94
|
-
|
|
100
|
+
const startDate = (0, import_dayjs.default)(
|
|
101
|
+
`${(0, import_dayjs.default)(cacheItem._extend.start_date).format("YYYY-MM-DD")} ${(0, import_serviceTimes.getServeStartTime)(cacheItem._extend.start_time)}`
|
|
102
|
+
);
|
|
103
|
+
const isFlexible = import_flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
|
|
95
104
|
let isMaxLimitRange = false;
|
|
96
105
|
let isDateRange = false;
|
|
97
106
|
let isCountRange = false;
|
|
98
|
-
const time = {
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
const timeStartDate = (0, _dayjs.default)(`${time.start_date} ${time.start_time}`).subtract(1, 'second');
|
|
102
|
-
const timeEndDate = (0, _dayjs.default)(`${time.end_date} ${time.end_time}`).add(1, 'second');
|
|
107
|
+
const time = { ...item };
|
|
108
|
+
const timeStartDate = (0, import_dayjs.default)(`${time.start_date} ${time.start_time}`).subtract(1, "second");
|
|
109
|
+
const timeEndDate = (0, import_dayjs.default)(`${time.end_date} ${time.end_time}`).add(1, "second");
|
|
103
110
|
const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
|
|
104
111
|
const currentCount = getSumCapacity(cacheItem);
|
|
105
112
|
let eventList = time.event_list || [];
|
|
106
|
-
if (cacheItem
|
|
107
|
-
eventList = eventList.filter(event => event.id !== cacheItem.booking_id);
|
|
113
|
+
if (cacheItem == null ? void 0 : cacheItem.booking_id) {
|
|
114
|
+
eventList = eventList.filter((event) => event.id !== cacheItem.booking_id);
|
|
108
115
|
}
|
|
109
116
|
let endDate = null;
|
|
110
117
|
let isCalcCount = true;
|
|
@@ -116,25 +123,20 @@ function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
|
116
123
|
isCountRange = false;
|
|
117
124
|
}
|
|
118
125
|
} else {
|
|
119
|
-
endDate = startDate.add(
|
|
126
|
+
endDate = startDate.add(import_flexible.flexibleObj.getValue(cacheItem._extend.duration), "minute");
|
|
120
127
|
const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
|
|
121
|
-
if (isTimeRange)
|
|
128
|
+
if (isTimeRange)
|
|
129
|
+
isDateRange = true;
|
|
122
130
|
}
|
|
123
131
|
if (isCalcCount) {
|
|
124
|
-
const conflict = (eventList || []).filter(
|
|
125
|
-
start_at: d.start_at,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
start_at: startDate,
|
|
129
|
-
end_at: endDate
|
|
130
|
-
}));
|
|
131
|
-
if (resourceItem.resourceType === 'single') {
|
|
132
|
+
const conflict = (eventList || []).filter(
|
|
133
|
+
(d) => isConflict({ start_at: d.start_at, end_at: d.end_at }, { start_at: startDate, end_at: endDate })
|
|
134
|
+
);
|
|
135
|
+
if (resourceItem.resourceType === "single") {
|
|
132
136
|
isCountRange = conflict.length === 0;
|
|
133
137
|
} else {
|
|
134
138
|
const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
|
|
135
139
|
isCountRange = currentCount <= conflictCount;
|
|
136
|
-
// totalCount 当前未直接参与判定,保留 reference 以与原版接近。
|
|
137
|
-
void totalCount;
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
const isUsable = isDateRange && isCountRange;
|
|
@@ -146,27 +148,22 @@ function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
|
146
148
|
};
|
|
147
149
|
return time;
|
|
148
150
|
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
|
|
152
|
-
* 与 info2 `utilsByBooking.ts#formatTimes` 等价。
|
|
153
|
-
*/
|
|
154
151
|
function formatTimes(resourceItem, cacheItem) {
|
|
155
152
|
const usableTimes = [];
|
|
156
|
-
const _resourceItem = {
|
|
157
|
-
...resourceItem
|
|
158
|
-
};
|
|
153
|
+
const _resourceItem = { ...resourceItem };
|
|
159
154
|
const sum = getSumCapacity(cacheItem);
|
|
160
155
|
if (_resourceItem.capacity >= sum) {
|
|
161
|
-
_resourceItem.times = (_resourceItem.times || []).map(time => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
_resourceItem.times = (_resourceItem.times || []).map((time) => {
|
|
157
|
+
var _a;
|
|
158
|
+
const _time2 = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
|
|
159
|
+
if ((_a = _time2 == null ? void 0 : _time2._extend) == null ? void 0 : _a.isDateRange)
|
|
160
|
+
usableTimes.push(_time2);
|
|
161
|
+
return _time2;
|
|
165
162
|
});
|
|
166
163
|
}
|
|
167
164
|
const _time = usableTimes.sort((a, b) => {
|
|
168
|
-
const aEnd = (0,
|
|
169
|
-
const bEnd = (0,
|
|
165
|
+
const aEnd = (0, import_dayjs.default)(`${a.end_date} ${a.end_time}`).valueOf();
|
|
166
|
+
const bEnd = (0, import_dayjs.default)(`${b.end_date} ${b.end_time}`).valueOf();
|
|
170
167
|
return aEnd - bEnd;
|
|
171
168
|
})[0];
|
|
172
169
|
resourceItem._extend = {
|
|
@@ -175,81 +172,53 @@ function formatTimes(resourceItem, cacheItem) {
|
|
|
175
172
|
};
|
|
176
173
|
return resourceItem;
|
|
177
174
|
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 单个 resource 的整体可用性 + labelText 填充。
|
|
181
|
-
* 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
|
|
182
|
-
*/
|
|
183
175
|
function formatResource(resourceItem, cacheItem) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
};
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
let _resourceItem = { ...resourceItem };
|
|
187
178
|
_resourceItem = formatTimes(_resourceItem, cacheItem);
|
|
188
179
|
_resourceItem.labelText = _resourceItem.main_field;
|
|
189
|
-
const usable = _resourceItem._extend
|
|
180
|
+
const usable = (_c = (_b = (_a = _resourceItem._extend) == null ? void 0 : _a.usableTime) == null ? void 0 : _b._extend) == null ? void 0 : _c.isUsable;
|
|
190
181
|
_resourceItem.usable = usable;
|
|
191
182
|
return _resourceItem;
|
|
192
183
|
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
|
|
196
|
-
* 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
|
|
197
|
-
* 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
|
|
198
|
-
*/
|
|
199
184
|
function formatResources(params) {
|
|
200
|
-
const {
|
|
201
|
-
cacheItem,
|
|
202
|
-
resourcesOrigin
|
|
203
|
-
} = params;
|
|
185
|
+
const { cacheItem, resourcesOrigin } = params;
|
|
204
186
|
try {
|
|
205
187
|
const maps = {};
|
|
206
|
-
const list = resourcesOrigin.map(item => {
|
|
207
|
-
const _item = (0,
|
|
188
|
+
const list = resourcesOrigin.map((item) => {
|
|
189
|
+
const _item = (0, import_lodash_es.cloneDeep)(item);
|
|
208
190
|
const renderListMaps = {};
|
|
209
|
-
_item.renderList = _item.renderList.map(d => {
|
|
191
|
+
_item.renderList = _item.renderList.map((d) => {
|
|
210
192
|
const res = formatResource(d, cacheItem);
|
|
211
193
|
const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
|
|
212
|
-
if (unbound)
|
|
194
|
+
if (unbound)
|
|
195
|
+
res.unbound = true;
|
|
213
196
|
renderListMaps[res.id] = res;
|
|
214
197
|
return res;
|
|
215
198
|
}).sort((a, b) => b.usable ? 1 : -1);
|
|
216
|
-
maps[_item.form_id] = {
|
|
217
|
-
..._item,
|
|
218
|
-
renderListMaps
|
|
219
|
-
};
|
|
199
|
+
maps[_item.form_id] = { ..._item, renderListMaps };
|
|
220
200
|
return _item;
|
|
221
201
|
});
|
|
222
|
-
return {
|
|
223
|
-
list,
|
|
224
|
-
maps
|
|
225
|
-
};
|
|
202
|
+
return { list, maps };
|
|
226
203
|
} catch (err) {
|
|
227
|
-
console.warn(
|
|
228
|
-
return {
|
|
229
|
-
list: [],
|
|
230
|
-
maps: {}
|
|
231
|
-
};
|
|
204
|
+
console.warn("[BookingContext] formatResources error", err);
|
|
205
|
+
return { list: [], maps: {} };
|
|
232
206
|
}
|
|
233
207
|
}
|
|
234
|
-
|
|
235
|
-
/** 取可用资源中"最大空闲时长"的那一个,作为自动分派候选。 */
|
|
236
208
|
function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
237
|
-
const {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (!isAutoAllocationOn(form_id)) return [];
|
|
242
|
-
const usableList = (renderList || []).filter(d => d.usable && d.id !== 0);
|
|
209
|
+
const { renderList, form_id } = resource;
|
|
210
|
+
if (!isAutoAllocationOn(form_id))
|
|
211
|
+
return [];
|
|
212
|
+
const usableList = (renderList || []).filter((d) => d.usable && d.id !== 0);
|
|
243
213
|
let defaultResource = [];
|
|
244
214
|
let maxFreeTime = 0;
|
|
245
|
-
usableList.forEach(d => {
|
|
246
|
-
const {
|
|
247
|
-
times = []
|
|
248
|
-
} = d;
|
|
215
|
+
usableList.forEach((d) => {
|
|
216
|
+
const { times = [] } = d;
|
|
249
217
|
const currentMaxFreeTime = times.reduce((pre, cur) => {
|
|
250
|
-
|
|
218
|
+
var _a, _b, _c;
|
|
219
|
+
const start = ((_c = (_b = cur.event_list) == null ? void 0 : _b[((_a = cur.event_list) == null ? void 0 : _a.length) - 1]) == null ? void 0 : _c.end_at) || cur.start_at;
|
|
251
220
|
const end = cur.end_at;
|
|
252
|
-
const diff = (0,
|
|
221
|
+
const diff = (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(start), "minute");
|
|
253
222
|
return diff > pre ? diff : pre;
|
|
254
223
|
}, 0);
|
|
255
224
|
if (currentMaxFreeTime > maxFreeTime) {
|
|
@@ -259,19 +228,8 @@ function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
|
259
228
|
});
|
|
260
229
|
return defaultResource;
|
|
261
230
|
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* 计算每类资源的默认值(写入 cacheItem._extend.resource)。
|
|
265
|
-
* 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
|
|
266
|
-
* `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
|
|
267
|
-
*/
|
|
268
231
|
function setDefaultResource(params) {
|
|
269
|
-
const {
|
|
270
|
-
cacheItem,
|
|
271
|
-
resources,
|
|
272
|
-
resourceIdFromCalendar,
|
|
273
|
-
isAutoAllocationOn = () => true
|
|
274
|
-
} = params;
|
|
232
|
+
const { cacheItem, resources, resourceIdFromCalendar, isAutoAllocationOn = () => true } = params;
|
|
275
233
|
const obj = {};
|
|
276
234
|
const resourceId = Number(resourceIdFromCalendar) || 0;
|
|
277
235
|
for (const item of resources) {
|
|
@@ -280,8 +238,8 @@ function setDefaultResource(params) {
|
|
|
280
238
|
optional_resource = [],
|
|
281
239
|
default_resource = []
|
|
282
240
|
} = item;
|
|
283
|
-
const renderList = item.renderList.filter(d => {
|
|
284
|
-
if (select_type
|
|
241
|
+
const renderList = item.renderList.filter((d) => {
|
|
242
|
+
if ((select_type == null ? void 0 : select_type.type) === "single") {
|
|
285
243
|
if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
|
|
286
244
|
return d.id === resourceId;
|
|
287
245
|
}
|
|
@@ -295,64 +253,46 @@ function setDefaultResource(params) {
|
|
|
295
253
|
} else {
|
|
296
254
|
defaultOriginalResource = renderList;
|
|
297
255
|
}
|
|
298
|
-
obj[item.form_id] = defaultOriginalResource.map(d => ({
|
|
256
|
+
obj[item.form_id] = defaultOriginalResource.map((d) => ({
|
|
299
257
|
children: d.children,
|
|
300
258
|
relation_type: d.relation_type,
|
|
301
259
|
form_id: item.form_id,
|
|
302
260
|
relation_id: d.id,
|
|
303
|
-
like_status:
|
|
261
|
+
like_status: "common",
|
|
304
262
|
metadata: {
|
|
305
263
|
form_name: item.title,
|
|
306
264
|
resource_name: d.main_field
|
|
307
265
|
}
|
|
308
266
|
}));
|
|
309
|
-
// errors 字段由调用方在需要时通过 getResourceErrors 单独算,OS 这里不耦合。
|
|
310
267
|
}
|
|
311
268
|
return obj;
|
|
312
269
|
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
|
|
316
|
-
* package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
|
|
317
|
-
*/
|
|
318
270
|
function setDefaultCapacitys(params) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (capacitys?.type === 'package') {
|
|
324
|
-
return (cacheItem?._extend?.other?.bundle || []).map(d => {
|
|
271
|
+
var _a, _b;
|
|
272
|
+
const { capacitys, cacheItem } = params;
|
|
273
|
+
if ((capacitys == null ? void 0 : capacitys.type) === "package") {
|
|
274
|
+
return (((_b = (_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle) || []).map((d) => {
|
|
325
275
|
const id = d._bundle_product_id;
|
|
326
|
-
const item = (capacitys
|
|
276
|
+
const item = ((capacitys == null ? void 0 : capacitys.package) || []).find((p) => p.product_id === id);
|
|
327
277
|
return {
|
|
328
278
|
id,
|
|
329
279
|
value: item ? d.quantity || 0 : 0,
|
|
330
|
-
name: item
|
|
280
|
+
name: (item == null ? void 0 : item.name) || (d == null ? void 0 : d.title)
|
|
331
281
|
};
|
|
332
282
|
});
|
|
333
283
|
}
|
|
334
|
-
if (capacitys
|
|
335
|
-
return (capacitys
|
|
284
|
+
if ((capacitys == null ? void 0 : capacitys.type) === "custom") {
|
|
285
|
+
return ((capacitys == null ? void 0 : capacitys.custom) || []).map((d) => ({
|
|
336
286
|
id: d.id,
|
|
337
287
|
value: d.min,
|
|
338
288
|
name: d.name
|
|
339
289
|
}));
|
|
340
290
|
}
|
|
341
|
-
return [{
|
|
342
|
-
id: 0,
|
|
343
|
-
value: 1,
|
|
344
|
-
name: ''
|
|
345
|
-
}];
|
|
291
|
+
return [{ id: 0, value: 1, name: "" }];
|
|
346
292
|
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
|
|
350
|
-
* 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
|
|
351
|
-
*/
|
|
352
293
|
function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}));
|
|
294
|
+
var _a, _b;
|
|
295
|
+
const _resources = [...((_a = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _a.resources) || []].filter((d) => Number(d == null ? void 0 : d.status) === 1).map((item) => ({ ...item }));
|
|
356
296
|
const {
|
|
357
297
|
extraResources = [],
|
|
358
298
|
resourcesOrigin = [],
|
|
@@ -360,24 +300,29 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
|
360
300
|
} = extraParams || {};
|
|
361
301
|
for (const item of _resources) {
|
|
362
302
|
const form_id = item.id;
|
|
363
|
-
const isAllResource = resourceTab
|
|
303
|
+
const isAllResource = ((_b = resourceTab == null ? void 0 : resourceTab[item.code]) == null ? void 0 : _b.resource_display_scope) === "all";
|
|
364
304
|
let extraResourceIds = [];
|
|
365
305
|
if (isAllResource) {
|
|
366
|
-
extraResourceIds = (resourcesOrigin || []).filter(d => d.form_code === item.code).map(d => d.id);
|
|
306
|
+
extraResourceIds = (resourcesOrigin || []).filter((d) => d.form_code === item.code).map((d) => d.id);
|
|
367
307
|
} else {
|
|
368
|
-
extraResourceIds = extraResources.filter(
|
|
308
|
+
extraResourceIds = extraResources.filter(
|
|
309
|
+
(_extraItem) => _extraItem.form_id === form_id && !!_extraItem.id && !item.optional_resource.includes(_extraItem.id) && !item.default_resource.includes(_extraItem.id)
|
|
310
|
+
).map((_extraItem) => _extraItem.id);
|
|
369
311
|
}
|
|
370
312
|
extraResourceIds = Array.from(new Set(extraResourceIds));
|
|
371
|
-
item.optional_resource = (item.optional_resource || []).filter(
|
|
372
|
-
|
|
313
|
+
item.optional_resource = (item.optional_resource || []).filter(
|
|
314
|
+
(d) => item.default_resource.indexOf(d) === -1
|
|
315
|
+
);
|
|
316
|
+
const getChildrenMetadata = (id) => {
|
|
373
317
|
const combiningResources = [];
|
|
374
318
|
const origin = resourcesOriginMap[id];
|
|
375
|
-
if (origin
|
|
376
|
-
(origin.combined_resource.resource_ids || []).forEach(cid => {
|
|
319
|
+
if ((origin == null ? void 0 : origin.combined_resource) && origin.combined_resource.status === 1) {
|
|
320
|
+
(origin.combined_resource.resource_ids || []).forEach((cid) => {
|
|
321
|
+
var _a2, _b2;
|
|
377
322
|
if (resourcesOriginMap[cid]) {
|
|
378
323
|
combiningResources.push({
|
|
379
324
|
...resourcesOriginMap[cid],
|
|
380
|
-
relation_id: resourcesOriginMap[cid]
|
|
325
|
+
relation_id: ((_a2 = resourcesOriginMap[cid]) == null ? void 0 : _a2.relation_id) || ((_b2 = resourcesOriginMap[cid]) == null ? void 0 : _b2.id)
|
|
381
326
|
});
|
|
382
327
|
}
|
|
383
328
|
});
|
|
@@ -385,22 +330,23 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
|
385
330
|
return {
|
|
386
331
|
children: combiningResources,
|
|
387
332
|
metadata: {
|
|
388
|
-
...(origin
|
|
389
|
-
combined_resource: origin
|
|
333
|
+
...(origin == null ? void 0 : origin.metadata) || {},
|
|
334
|
+
combined_resource: origin == null ? void 0 : origin.combined_resource
|
|
390
335
|
}
|
|
391
336
|
};
|
|
392
337
|
};
|
|
393
|
-
const optional_resource = Array.from(
|
|
394
|
-
|
|
338
|
+
const optional_resource = Array.from(
|
|
339
|
+
/* @__PURE__ */ new Set([...item.optional_resource, ...extraResourceIds])
|
|
340
|
+
).map((d) => {
|
|
341
|
+
if (!resourcesOriginMap[d])
|
|
342
|
+
return null;
|
|
395
343
|
return Object.assign({}, resourcesOriginMap[d], {
|
|
396
344
|
form_id,
|
|
397
345
|
resourceType: item.type,
|
|
398
346
|
...getChildrenMetadata(d)
|
|
399
347
|
});
|
|
400
|
-
}).filter(d => d).concat((0,
|
|
401
|
-
|
|
402
|
-
}));
|
|
403
|
-
const default_resource = (item.default_resource || []).map(d => {
|
|
348
|
+
}).filter((d) => d).concat((0, import_noResource.getNoResource2)({ form_id }));
|
|
349
|
+
const default_resource = (item.default_resource || []).map((d) => {
|
|
404
350
|
const origin = resourcesOriginMap[d];
|
|
405
351
|
if (origin) {
|
|
406
352
|
origin.is_default = 1;
|
|
@@ -411,9 +357,21 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
|
411
357
|
});
|
|
412
358
|
}
|
|
413
359
|
return null;
|
|
414
|
-
}).filter(d => d);
|
|
360
|
+
}).filter((d) => d);
|
|
415
361
|
item.renderList = optional_resource.concat(default_resource);
|
|
416
362
|
item.form_id = form_id;
|
|
417
363
|
}
|
|
418
364
|
return _resources;
|
|
419
|
-
}
|
|
365
|
+
}
|
|
366
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
367
|
+
0 && (module.exports = {
|
|
368
|
+
formatResource,
|
|
369
|
+
formatResources,
|
|
370
|
+
formatTimes,
|
|
371
|
+
getResourceByIds,
|
|
372
|
+
getResourceTimeIsUsable,
|
|
373
|
+
getSumCapacity,
|
|
374
|
+
getUsableTime,
|
|
375
|
+
setDefaultCapacitys,
|
|
376
|
+
setDefaultResource
|
|
377
|
+
});
|