@pisell/pisellos 2.3.74 → 2.3.76
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 -10
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- 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 +2 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +75 -91
- package/dist/modules/Order/types.d.ts +3 -1
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Rules/index.js +1 -4
- package/dist/modules/Schedule/index.js +0 -1
- 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 +97 -129
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.js +2 -4
- package/dist/server/modules/products/index.js +24 -42
- 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 +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BaseSales/index.js +100 -72
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
- 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.js +0 -2
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -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 -252
- 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.js +45 -55
- 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 +134 -134
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- 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 +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -0
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- 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 +588 -378
- 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 +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- 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 +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- 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 +122 -127
- 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 +70 -76
- 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 +1733 -2121
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.d.ts +3 -1
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils.js +814 -647
- 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 +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- 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 +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +81 -118
- 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/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +589 -770
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- 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 -163
- package/lib/modules/Schedule/index.js +100 -114
- 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 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- 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 +3050 -2665
- package/lib/server/modules/floor-plan/index.js +118 -134
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +142 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.js +784 -1002
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.js +583 -471
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +220 -186
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- 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/small-ticket.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1220 -1412
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- package/lib/solution/BookingByStep/index.js +1527 -1340
- 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.js +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- 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 +228 -156
- 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 +328 -324
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,46 +1,24 @@
|
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(resourceSelection_exports, {
|
|
22
|
-
hasActualResourceSelection: () => hasActualResourceSelection,
|
|
23
|
-
productNeedsResourceExtend: () => productNeedsResourceExtend
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
24
5
|
});
|
|
25
|
-
|
|
6
|
+
exports.hasActualResourceSelection = hasActualResourceSelection;
|
|
7
|
+
exports.productNeedsResourceExtend = productNeedsResourceExtend;
|
|
8
|
+
/**
|
|
9
|
+
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
26
13
|
function productNeedsResourceExtend(cacheItem) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return false;
|
|
31
|
-
return forms.some((d) => Number(d == null ? void 0 : d.status) === 1);
|
|
14
|
+
const forms = cacheItem?.product_resource?.resources;
|
|
15
|
+
if (!Array.isArray(forms)) return false;
|
|
16
|
+
return forms.some(d => Number(d?.status) === 1);
|
|
32
17
|
}
|
|
18
|
+
|
|
19
|
+
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
33
20
|
function hasActualResourceSelection(cacheItem) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
});
|
|
21
|
+
const resource = cacheItem?._extend?.resource;
|
|
22
|
+
if (!resource || typeof resource !== 'object') return false;
|
|
23
|
+
return Object.values(resource).some(rows => Array.isArray(rows) && rows.length > 0);
|
|
24
|
+
}
|
|
@@ -1,117 +1,110 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
41
5
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
6
|
+
exports.formatResource = formatResource;
|
|
7
|
+
exports.formatResources = formatResources;
|
|
8
|
+
exports.formatTimes = formatTimes;
|
|
9
|
+
exports.getResourceByIds = getResourceByIds;
|
|
10
|
+
exports.getResourceTimeIsUsable = getResourceTimeIsUsable;
|
|
11
|
+
exports.getSumCapacity = getSumCapacity;
|
|
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
|
+
*/
|
|
48
37
|
function getUsableTime(cacheItem) {
|
|
49
|
-
var _a, _b, _c;
|
|
50
38
|
try {
|
|
51
|
-
const resourceByForm =
|
|
52
|
-
const resourceMaps =
|
|
39
|
+
const resourceByForm = cacheItem?._extend?.resource || {};
|
|
40
|
+
const resourceMaps = cacheItem?._data?.resourceMaps || {};
|
|
53
41
|
let items = [];
|
|
54
42
|
for (const formId of Object.keys(resourceByForm)) {
|
|
55
43
|
const selected = resourceByForm[formId];
|
|
56
|
-
const maps =
|
|
57
|
-
if (!Array.isArray(selected) || !maps)
|
|
58
|
-
|
|
59
|
-
items = items.concat(
|
|
60
|
-
selected.map((d) => maps[d.relation_id]).filter(Boolean)
|
|
61
|
-
);
|
|
44
|
+
const maps = resourceMaps[formId]?.renderListMaps;
|
|
45
|
+
if (!Array.isArray(selected) || !maps) continue;
|
|
46
|
+
items = items.concat(selected.map(d => maps[d.relation_id]).filter(Boolean));
|
|
62
47
|
}
|
|
63
|
-
if (!items.length)
|
|
64
|
-
return null;
|
|
48
|
+
if (!items.length) return null;
|
|
65
49
|
return items.reduce((pre, event) => {
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const preEnd = (0, import_dayjs.default)((_d = (_c2 = pre._extend) == null ? void 0 : _c2.usableTime) == null ? void 0 : _d.end_at);
|
|
50
|
+
const endAt = (0, _dayjs.default)(event._extend?.usableTime?.end_at);
|
|
51
|
+
const preEnd = (0, _dayjs.default)(pre._extend?.usableTime?.end_at);
|
|
69
52
|
return endAt.isBefore(preEnd) ? event : pre;
|
|
70
53
|
}, items[0]);
|
|
71
54
|
} catch {
|
|
72
55
|
return null;
|
|
73
56
|
}
|
|
74
57
|
}
|
|
58
|
+
|
|
59
|
+
/** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
|
|
75
60
|
function getSumCapacity(cacheItem, isCalcQuantity = true) {
|
|
76
|
-
|
|
77
|
-
const list = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.capacity) || [];
|
|
61
|
+
const list = cacheItem?._extend?.capacity || [];
|
|
78
62
|
let sum = 0;
|
|
79
63
|
for (const item of list) {
|
|
80
|
-
sum += Number(
|
|
64
|
+
sum += Number(item?.value || 0);
|
|
81
65
|
}
|
|
82
|
-
return sum * (isCalcQuantity ?
|
|
66
|
+
return sum * (isCalcQuantity ? cacheItem?._extend?.quantity || 1 : 1);
|
|
83
67
|
}
|
|
68
|
+
|
|
69
|
+
/** 当前 time 剩余容量 = totalCapacity - Σ event.pax。 */
|
|
84
70
|
function getUseableEventCount(eventList, current) {
|
|
85
|
-
return (eventList || []).reduce((pre, event) => pre - (
|
|
71
|
+
return (eventList || []).reduce((pre, event) => pre - (event?.pax || 0), current || 0);
|
|
86
72
|
}
|
|
73
|
+
|
|
74
|
+
/** 判断两个时间段是否有冲突。 */
|
|
87
75
|
function isConflict(event, current) {
|
|
88
|
-
const eventStart = (0,
|
|
89
|
-
const eventEnd = (0,
|
|
90
|
-
const currentStart = (0,
|
|
76
|
+
const eventStart = (0, _dayjs.default)(event.start_at);
|
|
77
|
+
const eventEnd = (0, _dayjs.default)(event.end_at);
|
|
78
|
+
const currentStart = (0, _dayjs.default)(current.start_at);
|
|
91
79
|
const isBefore = currentStart.isBefore(eventEnd);
|
|
92
80
|
let isAfter = true;
|
|
93
81
|
if (current.end_at) {
|
|
94
|
-
const currentEnd = (0,
|
|
82
|
+
const currentEnd = (0, _dayjs.default)(current.end_at);
|
|
95
83
|
isAfter = currentEnd.isAfter(eventStart);
|
|
96
84
|
}
|
|
97
85
|
return isBefore && isAfter;
|
|
98
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
|
|
90
|
+
* 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
|
|
91
|
+
*/
|
|
99
92
|
function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
100
|
-
const startDate = (0,
|
|
101
|
-
|
|
102
|
-
);
|
|
103
|
-
const isFlexible = import_flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
|
|
93
|
+
const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem._extend.start_date).format('YYYY-MM-DD')} ${(0, _serviceTimes.getServeStartTime)(cacheItem._extend.start_time)}`);
|
|
94
|
+
const isFlexible = _flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
|
|
104
95
|
let isMaxLimitRange = false;
|
|
105
96
|
let isDateRange = false;
|
|
106
97
|
let isCountRange = false;
|
|
107
|
-
const time = {
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
const time = {
|
|
99
|
+
...item
|
|
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');
|
|
110
103
|
const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
|
|
111
104
|
const currentCount = getSumCapacity(cacheItem);
|
|
112
105
|
let eventList = time.event_list || [];
|
|
113
|
-
if (cacheItem
|
|
114
|
-
eventList = eventList.filter(
|
|
106
|
+
if (cacheItem?.booking_id) {
|
|
107
|
+
eventList = eventList.filter(event => event.id !== cacheItem.booking_id);
|
|
115
108
|
}
|
|
116
109
|
let endDate = null;
|
|
117
110
|
let isCalcCount = true;
|
|
@@ -123,20 +116,25 @@ function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
|
123
116
|
isCountRange = false;
|
|
124
117
|
}
|
|
125
118
|
} else {
|
|
126
|
-
endDate = startDate.add(
|
|
119
|
+
endDate = startDate.add(_flexible.flexibleObj.getValue(cacheItem._extend.duration), 'minute');
|
|
127
120
|
const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
|
|
128
|
-
if (isTimeRange)
|
|
129
|
-
isDateRange = true;
|
|
121
|
+
if (isTimeRange) isDateRange = true;
|
|
130
122
|
}
|
|
131
123
|
if (isCalcCount) {
|
|
132
|
-
const conflict = (eventList || []).filter(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
const conflict = (eventList || []).filter(d => isConflict({
|
|
125
|
+
start_at: d.start_at,
|
|
126
|
+
end_at: d.end_at
|
|
127
|
+
}, {
|
|
128
|
+
start_at: startDate,
|
|
129
|
+
end_at: endDate
|
|
130
|
+
}));
|
|
131
|
+
if (resourceItem.resourceType === 'single') {
|
|
136
132
|
isCountRange = conflict.length === 0;
|
|
137
133
|
} else {
|
|
138
134
|
const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
|
|
139
135
|
isCountRange = currentCount <= conflictCount;
|
|
136
|
+
// totalCount 当前未直接参与判定,保留 reference 以与原版接近。
|
|
137
|
+
void totalCount;
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
140
|
const isUsable = isDateRange && isCountRange;
|
|
@@ -148,22 +146,27 @@ function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
|
148
146
|
};
|
|
149
147
|
return time;
|
|
150
148
|
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
|
|
152
|
+
* 与 info2 `utilsByBooking.ts#formatTimes` 等价。
|
|
153
|
+
*/
|
|
151
154
|
function formatTimes(resourceItem, cacheItem) {
|
|
152
155
|
const usableTimes = [];
|
|
153
|
-
const _resourceItem = {
|
|
156
|
+
const _resourceItem = {
|
|
157
|
+
...resourceItem
|
|
158
|
+
};
|
|
154
159
|
const sum = getSumCapacity(cacheItem);
|
|
155
160
|
if (_resourceItem.capacity >= sum) {
|
|
156
|
-
_resourceItem.times = (_resourceItem.times || []).map(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
usableTimes.push(_time2);
|
|
161
|
-
return _time2;
|
|
161
|
+
_resourceItem.times = (_resourceItem.times || []).map(time => {
|
|
162
|
+
const _time = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
|
|
163
|
+
if (_time?._extend?.isDateRange) usableTimes.push(_time);
|
|
164
|
+
return _time;
|
|
162
165
|
});
|
|
163
166
|
}
|
|
164
167
|
const _time = usableTimes.sort((a, b) => {
|
|
165
|
-
const aEnd = (0,
|
|
166
|
-
const bEnd = (0,
|
|
168
|
+
const aEnd = (0, _dayjs.default)(`${a.end_date} ${a.end_time}`).valueOf();
|
|
169
|
+
const bEnd = (0, _dayjs.default)(`${b.end_date} ${b.end_time}`).valueOf();
|
|
167
170
|
return aEnd - bEnd;
|
|
168
171
|
})[0];
|
|
169
172
|
resourceItem._extend = {
|
|
@@ -172,53 +175,81 @@ function formatTimes(resourceItem, cacheItem) {
|
|
|
172
175
|
};
|
|
173
176
|
return resourceItem;
|
|
174
177
|
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 单个 resource 的整体可用性 + labelText 填充。
|
|
181
|
+
* 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
|
|
182
|
+
*/
|
|
175
183
|
function formatResource(resourceItem, cacheItem) {
|
|
176
|
-
|
|
177
|
-
|
|
184
|
+
let _resourceItem = {
|
|
185
|
+
...resourceItem
|
|
186
|
+
};
|
|
178
187
|
_resourceItem = formatTimes(_resourceItem, cacheItem);
|
|
179
188
|
_resourceItem.labelText = _resourceItem.main_field;
|
|
180
|
-
const usable =
|
|
189
|
+
const usable = _resourceItem._extend?.usableTime?._extend?.isUsable;
|
|
181
190
|
_resourceItem.usable = usable;
|
|
182
191
|
return _resourceItem;
|
|
183
192
|
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
|
|
196
|
+
* 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
|
|
197
|
+
* 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
|
|
198
|
+
*/
|
|
184
199
|
function formatResources(params) {
|
|
185
|
-
const {
|
|
200
|
+
const {
|
|
201
|
+
cacheItem,
|
|
202
|
+
resourcesOrigin
|
|
203
|
+
} = params;
|
|
186
204
|
try {
|
|
187
205
|
const maps = {};
|
|
188
|
-
const list = resourcesOrigin.map(
|
|
189
|
-
const _item = (0,
|
|
206
|
+
const list = resourcesOrigin.map(item => {
|
|
207
|
+
const _item = (0, _lodashEs.cloneDeep)(item);
|
|
190
208
|
const renderListMaps = {};
|
|
191
|
-
_item.renderList = _item.renderList.map(
|
|
209
|
+
_item.renderList = _item.renderList.map(d => {
|
|
192
210
|
const res = formatResource(d, cacheItem);
|
|
193
211
|
const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
|
|
194
|
-
if (unbound)
|
|
195
|
-
res.unbound = true;
|
|
212
|
+
if (unbound) res.unbound = true;
|
|
196
213
|
renderListMaps[res.id] = res;
|
|
197
214
|
return res;
|
|
198
215
|
}).sort((a, b) => b.usable ? 1 : -1);
|
|
199
|
-
maps[_item.form_id] = {
|
|
216
|
+
maps[_item.form_id] = {
|
|
217
|
+
..._item,
|
|
218
|
+
renderListMaps
|
|
219
|
+
};
|
|
200
220
|
return _item;
|
|
201
221
|
});
|
|
202
|
-
return {
|
|
222
|
+
return {
|
|
223
|
+
list,
|
|
224
|
+
maps
|
|
225
|
+
};
|
|
203
226
|
} catch (err) {
|
|
204
|
-
console.warn(
|
|
205
|
-
return {
|
|
227
|
+
console.warn('[BookingContext] formatResources error', err);
|
|
228
|
+
return {
|
|
229
|
+
list: [],
|
|
230
|
+
maps: {}
|
|
231
|
+
};
|
|
206
232
|
}
|
|
207
233
|
}
|
|
234
|
+
|
|
235
|
+
/** 取可用资源中"最大空闲时长"的那一个,作为自动分派候选。 */
|
|
208
236
|
function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
209
|
-
const {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
237
|
+
const {
|
|
238
|
+
renderList,
|
|
239
|
+
form_id
|
|
240
|
+
} = resource;
|
|
241
|
+
if (!isAutoAllocationOn(form_id)) return [];
|
|
242
|
+
const usableList = (renderList || []).filter(d => d.usable && d.id !== 0);
|
|
213
243
|
let defaultResource = [];
|
|
214
244
|
let maxFreeTime = 0;
|
|
215
|
-
usableList.forEach(
|
|
216
|
-
const {
|
|
245
|
+
usableList.forEach(d => {
|
|
246
|
+
const {
|
|
247
|
+
times = []
|
|
248
|
+
} = d;
|
|
217
249
|
const currentMaxFreeTime = times.reduce((pre, cur) => {
|
|
218
|
-
|
|
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;
|
|
250
|
+
const start = cur.event_list?.[cur.event_list?.length - 1]?.end_at || cur.start_at;
|
|
220
251
|
const end = cur.end_at;
|
|
221
|
-
const diff = (0,
|
|
252
|
+
const diff = (0, _dayjs.default)(end).diff((0, _dayjs.default)(start), 'minute');
|
|
222
253
|
return diff > pre ? diff : pre;
|
|
223
254
|
}, 0);
|
|
224
255
|
if (currentMaxFreeTime > maxFreeTime) {
|
|
@@ -228,8 +259,19 @@ function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
|
228
259
|
});
|
|
229
260
|
return defaultResource;
|
|
230
261
|
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 计算每类资源的默认值(写入 cacheItem._extend.resource)。
|
|
265
|
+
* 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
|
|
266
|
+
* `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
|
|
267
|
+
*/
|
|
231
268
|
function setDefaultResource(params) {
|
|
232
|
-
const {
|
|
269
|
+
const {
|
|
270
|
+
cacheItem,
|
|
271
|
+
resources,
|
|
272
|
+
resourceIdFromCalendar,
|
|
273
|
+
isAutoAllocationOn = () => true
|
|
274
|
+
} = params;
|
|
233
275
|
const obj = {};
|
|
234
276
|
const resourceId = Number(resourceIdFromCalendar) || 0;
|
|
235
277
|
for (const item of resources) {
|
|
@@ -238,8 +280,8 @@ function setDefaultResource(params) {
|
|
|
238
280
|
optional_resource = [],
|
|
239
281
|
default_resource = []
|
|
240
282
|
} = item;
|
|
241
|
-
const renderList = item.renderList.filter(
|
|
242
|
-
if (
|
|
283
|
+
const renderList = item.renderList.filter(d => {
|
|
284
|
+
if (select_type?.type === 'single') {
|
|
243
285
|
if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
|
|
244
286
|
return d.id === resourceId;
|
|
245
287
|
}
|
|
@@ -253,46 +295,64 @@ function setDefaultResource(params) {
|
|
|
253
295
|
} else {
|
|
254
296
|
defaultOriginalResource = renderList;
|
|
255
297
|
}
|
|
256
|
-
obj[item.form_id] = defaultOriginalResource.map(
|
|
298
|
+
obj[item.form_id] = defaultOriginalResource.map(d => ({
|
|
257
299
|
children: d.children,
|
|
258
300
|
relation_type: d.relation_type,
|
|
259
301
|
form_id: item.form_id,
|
|
260
302
|
relation_id: d.id,
|
|
261
|
-
like_status:
|
|
303
|
+
like_status: 'common',
|
|
262
304
|
metadata: {
|
|
263
305
|
form_name: item.title,
|
|
264
306
|
resource_name: d.main_field
|
|
265
307
|
}
|
|
266
308
|
}));
|
|
309
|
+
// errors 字段由调用方在需要时通过 getResourceErrors 单独算,OS 这里不耦合。
|
|
267
310
|
}
|
|
268
311
|
return obj;
|
|
269
312
|
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
|
|
316
|
+
* package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
|
|
317
|
+
*/
|
|
270
318
|
function setDefaultCapacitys(params) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
319
|
+
const {
|
|
320
|
+
capacitys,
|
|
321
|
+
cacheItem
|
|
322
|
+
} = params;
|
|
323
|
+
if (capacitys?.type === 'package') {
|
|
324
|
+
return (cacheItem?._extend?.other?.bundle || []).map(d => {
|
|
275
325
|
const id = d._bundle_product_id;
|
|
276
|
-
const item = (
|
|
326
|
+
const item = (capacitys?.package || []).find(p => p.product_id === id);
|
|
277
327
|
return {
|
|
278
328
|
id,
|
|
279
329
|
value: item ? d.quantity || 0 : 0,
|
|
280
|
-
name:
|
|
330
|
+
name: item?.name || d?.title
|
|
281
331
|
};
|
|
282
332
|
});
|
|
283
333
|
}
|
|
284
|
-
if (
|
|
285
|
-
return (
|
|
334
|
+
if (capacitys?.type === 'custom') {
|
|
335
|
+
return (capacitys?.custom || []).map(d => ({
|
|
286
336
|
id: d.id,
|
|
287
337
|
value: d.min,
|
|
288
338
|
name: d.name
|
|
289
339
|
}));
|
|
290
340
|
}
|
|
291
|
-
return [{
|
|
341
|
+
return [{
|
|
342
|
+
id: 0,
|
|
343
|
+
value: 1,
|
|
344
|
+
name: ''
|
|
345
|
+
}];
|
|
292
346
|
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
|
|
350
|
+
* 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
|
|
351
|
+
*/
|
|
293
352
|
function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
294
|
-
|
|
295
|
-
|
|
353
|
+
const _resources = [...(cacheItem?.product_resource?.resources || [])].filter(d => Number(d?.status) === 1).map(item => ({
|
|
354
|
+
...item
|
|
355
|
+
}));
|
|
296
356
|
const {
|
|
297
357
|
extraResources = [],
|
|
298
358
|
resourcesOrigin = [],
|
|
@@ -300,29 +360,24 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
|
300
360
|
} = extraParams || {};
|
|
301
361
|
for (const item of _resources) {
|
|
302
362
|
const form_id = item.id;
|
|
303
|
-
const isAllResource =
|
|
363
|
+
const isAllResource = resourceTab?.[item.code]?.resource_display_scope === 'all';
|
|
304
364
|
let extraResourceIds = [];
|
|
305
365
|
if (isAllResource) {
|
|
306
|
-
extraResourceIds = (resourcesOrigin || []).filter(
|
|
366
|
+
extraResourceIds = (resourcesOrigin || []).filter(d => d.form_code === item.code).map(d => d.id);
|
|
307
367
|
} else {
|
|
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);
|
|
368
|
+
extraResourceIds = extraResources.filter(_extraItem => _extraItem.form_id === form_id && !!_extraItem.id && !item.optional_resource.includes(_extraItem.id) && !item.default_resource.includes(_extraItem.id)).map(_extraItem => _extraItem.id);
|
|
311
369
|
}
|
|
312
370
|
extraResourceIds = Array.from(new Set(extraResourceIds));
|
|
313
|
-
item.optional_resource = (item.optional_resource || []).filter(
|
|
314
|
-
|
|
315
|
-
);
|
|
316
|
-
const getChildrenMetadata = (id) => {
|
|
371
|
+
item.optional_resource = (item.optional_resource || []).filter(d => item.default_resource.indexOf(d) === -1);
|
|
372
|
+
const getChildrenMetadata = id => {
|
|
317
373
|
const combiningResources = [];
|
|
318
374
|
const origin = resourcesOriginMap[id];
|
|
319
|
-
if (
|
|
320
|
-
(origin.combined_resource.resource_ids || []).forEach(
|
|
321
|
-
var _a2, _b2;
|
|
375
|
+
if (origin?.combined_resource && origin.combined_resource.status === 1) {
|
|
376
|
+
(origin.combined_resource.resource_ids || []).forEach(cid => {
|
|
322
377
|
if (resourcesOriginMap[cid]) {
|
|
323
378
|
combiningResources.push({
|
|
324
379
|
...resourcesOriginMap[cid],
|
|
325
|
-
relation_id:
|
|
380
|
+
relation_id: resourcesOriginMap[cid]?.relation_id || resourcesOriginMap[cid]?.id
|
|
326
381
|
});
|
|
327
382
|
}
|
|
328
383
|
});
|
|
@@ -330,23 +385,22 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
|
330
385
|
return {
|
|
331
386
|
children: combiningResources,
|
|
332
387
|
metadata: {
|
|
333
|
-
...(origin
|
|
334
|
-
combined_resource: origin
|
|
388
|
+
...(origin?.metadata || {}),
|
|
389
|
+
combined_resource: origin?.combined_resource
|
|
335
390
|
}
|
|
336
391
|
};
|
|
337
392
|
};
|
|
338
|
-
const optional_resource = Array.from(
|
|
339
|
-
|
|
340
|
-
).map((d) => {
|
|
341
|
-
if (!resourcesOriginMap[d])
|
|
342
|
-
return null;
|
|
393
|
+
const optional_resource = Array.from(new Set([...item.optional_resource, ...extraResourceIds])).map(d => {
|
|
394
|
+
if (!resourcesOriginMap[d]) return null;
|
|
343
395
|
return Object.assign({}, resourcesOriginMap[d], {
|
|
344
396
|
form_id,
|
|
345
397
|
resourceType: item.type,
|
|
346
398
|
...getChildrenMetadata(d)
|
|
347
399
|
});
|
|
348
|
-
}).filter(
|
|
349
|
-
|
|
400
|
+
}).filter(d => d).concat((0, _noResource.getNoResource2)({
|
|
401
|
+
form_id
|
|
402
|
+
}));
|
|
403
|
+
const default_resource = (item.default_resource || []).map(d => {
|
|
350
404
|
const origin = resourcesOriginMap[d];
|
|
351
405
|
if (origin) {
|
|
352
406
|
origin.is_default = 1;
|
|
@@ -357,21 +411,9 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
|
357
411
|
});
|
|
358
412
|
}
|
|
359
413
|
return null;
|
|
360
|
-
}).filter(
|
|
414
|
+
}).filter(d => d);
|
|
361
415
|
item.renderList = optional_resource.concat(default_resource);
|
|
362
416
|
item.form_id = form_id;
|
|
363
417
|
}
|
|
364
418
|
return _resources;
|
|
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
|
-
});
|
|
419
|
+
}
|