@pisell/pisellos 2.2.171 → 2.2.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +47 -16
- package/dist/modules/Order/index.js +743 -334
- package/dist/modules/Order/types.d.ts +57 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +23 -1
- package/dist/modules/Order/utils.js +139 -30
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +9 -8
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +65 -7
- package/dist/solution/BaseSales/index.js +1066 -315
- package/dist/solution/BaseSales/types.d.ts +53 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +768 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +47 -16
- package/lib/modules/Order/index.js +389 -90
- package/lib/modules/Order/types.d.ts +57 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +23 -1
- package/lib/modules/Order/utils.js +145 -21
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +8 -9
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +65 -7
- package/lib/solution/BaseSales/index.js +492 -20
- package/lib/solution/BaseSales/types.d.ts +53 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +341 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
|
|
3
|
+
*
|
|
4
|
+
* 与 info2 type 字段映射:
|
|
5
|
+
* - `no_product` ↔ type='products'
|
|
6
|
+
* - `time_out_of_range` ↔ type='time'
|
|
7
|
+
* - `count_out_of_range` ↔ type='limit'
|
|
8
|
+
* - `resource_unbound` ↔ type='unbound'
|
|
9
|
+
*
|
|
10
|
+
* OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
|
|
11
|
+
*/
|
|
12
|
+
export type ResourceUnavailableReason = 'no_product' | 'time_out_of_range' | 'count_out_of_range' | 'resource_unbound';
|
|
13
|
+
export interface ResourceError {
|
|
14
|
+
reason: ResourceUnavailableReason;
|
|
15
|
+
params: {
|
|
16
|
+
/** 资源名(time / limit 用)。 */
|
|
17
|
+
labelText?: string;
|
|
18
|
+
/** 起始时间(time / limit 用,格式 'hh:mm A')。 */
|
|
19
|
+
startText?: string;
|
|
20
|
+
/** 结束时间(time / limit 用,格式 'hh:mm A')。 */
|
|
21
|
+
endText?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 结束时间是否跨到第二天。UI 收到 true 时可在 endText 前加 'tomorrow' / '明天' 前缀。
|
|
24
|
+
* 与 info2 旧实现「endText = locales.getText('pisell1.text.tomorrow') + endText」等价。
|
|
25
|
+
*/
|
|
26
|
+
isCrossDay?: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
|
|
31
|
+
*
|
|
32
|
+
* 行为对齐:
|
|
33
|
+
* 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
|
|
34
|
+
* 2. 资源 null / 无 _extend → 返回 []。
|
|
35
|
+
* 3. resource.usable=false 时:
|
|
36
|
+
* - 没有 _extend.usableTime → `time_out_of_range`
|
|
37
|
+
* - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
|
|
38
|
+
* 4. resource.unbound=true → 追加 `resource_unbound`。
|
|
39
|
+
* 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function getResourceErrors(resource: any, cacheItem: any): ResourceError[];
|
|
@@ -0,0 +1,80 @@
|
|
|
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);
|
|
28
|
+
|
|
29
|
+
// src/modules/BookingContext/utils/resourceErrors.ts
|
|
30
|
+
var resourceErrors_exports = {};
|
|
31
|
+
__export(resourceErrors_exports, {
|
|
32
|
+
getResourceErrors: () => getResourceErrors
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(resourceErrors_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_serviceTimes = require("./serviceTimes");
|
|
37
|
+
function getResourceErrors(resource, cacheItem) {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
if (!(cacheItem == null ? void 0 : cacheItem.id)) {
|
|
40
|
+
return [{ reason: "no_product", params: {} }];
|
|
41
|
+
}
|
|
42
|
+
if (!resource)
|
|
43
|
+
return [];
|
|
44
|
+
const list = [];
|
|
45
|
+
if (!resource.usable) {
|
|
46
|
+
const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)(cacheItem);
|
|
47
|
+
const startText = startDate.format("hh:mm A");
|
|
48
|
+
const endText = endDate.format("hh:mm A");
|
|
49
|
+
const isCrossDay = (0, import_dayjs.default)(endDate).isAfter(startDate, "day");
|
|
50
|
+
if (!((_a = resource._extend) == null ? void 0 : _a.usableTime)) {
|
|
51
|
+
list.push({
|
|
52
|
+
reason: "time_out_of_range",
|
|
53
|
+
params: {
|
|
54
|
+
labelText: resource.labelText,
|
|
55
|
+
startText,
|
|
56
|
+
endText,
|
|
57
|
+
isCrossDay
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} else if (!((_d = (_c = (_b = resource._extend) == null ? void 0 : _b.usableTime) == null ? void 0 : _c._extend) == null ? void 0 : _d.isCountRange)) {
|
|
61
|
+
list.push({
|
|
62
|
+
reason: "count_out_of_range",
|
|
63
|
+
params: {
|
|
64
|
+
labelText: resource.labelText,
|
|
65
|
+
startText,
|
|
66
|
+
endText,
|
|
67
|
+
isCrossDay
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (resource.unbound) {
|
|
73
|
+
list.push({ reason: "resource_unbound", params: {} });
|
|
74
|
+
}
|
|
75
|
+
return list;
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
getResourceErrors
|
|
80
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
3
|
+
*/
|
|
4
|
+
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
5
|
+
export declare function productNeedsResourceExtend(cacheItem: any): boolean;
|
|
6
|
+
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
7
|
+
export declare function hasActualResourceSelection(cacheItem: any): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
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);
|
|
18
|
+
|
|
19
|
+
// src/modules/BookingContext/utils/resourceSelection.ts
|
|
20
|
+
var resourceSelection_exports = {};
|
|
21
|
+
__export(resourceSelection_exports, {
|
|
22
|
+
hasActualResourceSelection: () => hasActualResourceSelection,
|
|
23
|
+
productNeedsResourceExtend: () => productNeedsResourceExtend
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(resourceSelection_exports);
|
|
26
|
+
function productNeedsResourceExtend(cacheItem) {
|
|
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);
|
|
32
|
+
}
|
|
33
|
+
function hasActualResourceSelection(cacheItem) {
|
|
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
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
|
|
3
|
+
*
|
|
4
|
+
* 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
|
|
5
|
+
* 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
|
|
6
|
+
*
|
|
7
|
+
* 三个 info2 独有特性保留:
|
|
8
|
+
* 1. `resource_display_scope='all'`:取全部资源
|
|
9
|
+
* 2. `extraResources`:拖入未绑定资源时兼容渲染
|
|
10
|
+
* 3. `getNoResource2()`:占位"无资源"行
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
|
|
14
|
+
* 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
|
|
15
|
+
*/
|
|
16
|
+
export declare function getUsableTime(cacheItem: any): any | null;
|
|
17
|
+
/** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
|
|
18
|
+
export declare function getSumCapacity(cacheItem: any, isCalcQuantity?: boolean): number;
|
|
19
|
+
/**
|
|
20
|
+
* 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
|
|
21
|
+
* 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
|
|
22
|
+
*/
|
|
23
|
+
export declare function getResourceTimeIsUsable(item: any, cacheItem: any, resourceItem: any): any;
|
|
24
|
+
/**
|
|
25
|
+
* 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
|
|
26
|
+
* 与 info2 `utilsByBooking.ts#formatTimes` 等价。
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatTimes(resourceItem: any, cacheItem: any): any;
|
|
29
|
+
/**
|
|
30
|
+
* 单个 resource 的整体可用性 + labelText 填充。
|
|
31
|
+
* 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatResource(resourceItem: any, cacheItem?: any): any;
|
|
34
|
+
/**
|
|
35
|
+
* 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
|
|
36
|
+
* 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
|
|
37
|
+
* 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatResources(params: {
|
|
40
|
+
cacheItem: any;
|
|
41
|
+
resourcesOrigin: any[];
|
|
42
|
+
}): {
|
|
43
|
+
list: any[];
|
|
44
|
+
maps: Record<string, any>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 计算每类资源的默认值(写入 cacheItem._extend.resource)。
|
|
48
|
+
* 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
|
|
49
|
+
* `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
|
|
50
|
+
*/
|
|
51
|
+
export declare function setDefaultResource(params: {
|
|
52
|
+
cacheItem: any;
|
|
53
|
+
resources: any[];
|
|
54
|
+
resourceIdFromCalendar?: number;
|
|
55
|
+
isAutoAllocationOn?: (formId: any) => boolean;
|
|
56
|
+
}): Record<string, any[]>;
|
|
57
|
+
/**
|
|
58
|
+
* 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
|
|
59
|
+
* package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
|
|
60
|
+
*/
|
|
61
|
+
export declare function setDefaultCapacitys(params: {
|
|
62
|
+
capacitys: any;
|
|
63
|
+
cacheItem: any;
|
|
64
|
+
}): Array<{
|
|
65
|
+
id: number | string;
|
|
66
|
+
value: number;
|
|
67
|
+
name?: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
|
|
71
|
+
* 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
|
|
72
|
+
*/
|
|
73
|
+
export declare function getResourceByIds(resourcesOriginMap: Record<string, any>, cacheItem: any, extraParams?: {
|
|
74
|
+
extraResources?: Array<{
|
|
75
|
+
form_id: number | string;
|
|
76
|
+
id: number;
|
|
77
|
+
}>;
|
|
78
|
+
resourcesOrigin?: any[];
|
|
79
|
+
resourceTab?: Record<string, any>;
|
|
80
|
+
}): any[];
|
|
@@ -0,0 +1,377 @@
|
|
|
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);
|
|
28
|
+
|
|
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
|
|
41
|
+
});
|
|
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");
|
|
48
|
+
function getUsableTime(cacheItem) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
try {
|
|
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) || {};
|
|
53
|
+
let items = [];
|
|
54
|
+
for (const formId of Object.keys(resourceByForm)) {
|
|
55
|
+
const selected = resourceByForm[formId];
|
|
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
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (!items.length)
|
|
64
|
+
return null;
|
|
65
|
+
return items.reduce((pre, event) => {
|
|
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);
|
|
69
|
+
return endAt.isBefore(preEnd) ? event : pre;
|
|
70
|
+
}, items[0]);
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getSumCapacity(cacheItem, isCalcQuantity = true) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
const list = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.capacity) || [];
|
|
78
|
+
let sum = 0;
|
|
79
|
+
for (const item of list) {
|
|
80
|
+
sum += Number((item == null ? void 0 : item.value) || 0);
|
|
81
|
+
}
|
|
82
|
+
return sum * (isCalcQuantity ? ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) || 1 : 1);
|
|
83
|
+
}
|
|
84
|
+
function getUseableEventCount(eventList, current) {
|
|
85
|
+
return (eventList || []).reduce((pre, event) => pre - ((event == null ? void 0 : event.pax) || 0), current || 0);
|
|
86
|
+
}
|
|
87
|
+
function isConflict(event, current) {
|
|
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);
|
|
91
|
+
const isBefore = currentStart.isBefore(eventEnd);
|
|
92
|
+
let isAfter = true;
|
|
93
|
+
if (current.end_at) {
|
|
94
|
+
const currentEnd = (0, import_dayjs.default)(current.end_at);
|
|
95
|
+
isAfter = currentEnd.isAfter(eventStart);
|
|
96
|
+
}
|
|
97
|
+
return isBefore && isAfter;
|
|
98
|
+
}
|
|
99
|
+
function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
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);
|
|
104
|
+
let isMaxLimitRange = false;
|
|
105
|
+
let isDateRange = false;
|
|
106
|
+
let isCountRange = false;
|
|
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");
|
|
110
|
+
const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
|
|
111
|
+
const currentCount = getSumCapacity(cacheItem);
|
|
112
|
+
let eventList = time.event_list || [];
|
|
113
|
+
if (cacheItem == null ? void 0 : cacheItem.booking_id) {
|
|
114
|
+
eventList = eventList.filter((event) => event.id !== cacheItem.booking_id);
|
|
115
|
+
}
|
|
116
|
+
let endDate = null;
|
|
117
|
+
let isCalcCount = true;
|
|
118
|
+
if (isFlexible) {
|
|
119
|
+
isDateRange = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
|
|
120
|
+
if (!isDateRange && eventList.length) {
|
|
121
|
+
isCalcCount = false;
|
|
122
|
+
isDateRange = true;
|
|
123
|
+
isCountRange = false;
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
endDate = startDate.add(import_flexible.flexibleObj.getValue(cacheItem._extend.duration), "minute");
|
|
127
|
+
const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
|
|
128
|
+
if (isTimeRange)
|
|
129
|
+
isDateRange = true;
|
|
130
|
+
}
|
|
131
|
+
if (isCalcCount) {
|
|
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") {
|
|
136
|
+
isCountRange = conflict.length === 0;
|
|
137
|
+
} else {
|
|
138
|
+
const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
|
|
139
|
+
isCountRange = currentCount <= conflictCount;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const isUsable = isDateRange && isCountRange;
|
|
143
|
+
time._extend = {
|
|
144
|
+
isMaxLimitRange,
|
|
145
|
+
isDateRange,
|
|
146
|
+
isCountRange,
|
|
147
|
+
isUsable
|
|
148
|
+
};
|
|
149
|
+
return time;
|
|
150
|
+
}
|
|
151
|
+
function formatTimes(resourceItem, cacheItem) {
|
|
152
|
+
const usableTimes = [];
|
|
153
|
+
const _resourceItem = { ...resourceItem };
|
|
154
|
+
const sum = getSumCapacity(cacheItem);
|
|
155
|
+
if (_resourceItem.capacity >= sum) {
|
|
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;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const _time = usableTimes.sort((a, b) => {
|
|
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();
|
|
167
|
+
return aEnd - bEnd;
|
|
168
|
+
})[0];
|
|
169
|
+
resourceItem._extend = {
|
|
170
|
+
...resourceItem._extend,
|
|
171
|
+
usableTime: _time
|
|
172
|
+
};
|
|
173
|
+
return resourceItem;
|
|
174
|
+
}
|
|
175
|
+
function formatResource(resourceItem, cacheItem) {
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
let _resourceItem = { ...resourceItem };
|
|
178
|
+
_resourceItem = formatTimes(_resourceItem, cacheItem);
|
|
179
|
+
_resourceItem.labelText = _resourceItem.main_field;
|
|
180
|
+
const usable = (_c = (_b = (_a = _resourceItem._extend) == null ? void 0 : _a.usableTime) == null ? void 0 : _b._extend) == null ? void 0 : _c.isUsable;
|
|
181
|
+
_resourceItem.usable = usable;
|
|
182
|
+
return _resourceItem;
|
|
183
|
+
}
|
|
184
|
+
function formatResources(params) {
|
|
185
|
+
const { cacheItem, resourcesOrigin } = params;
|
|
186
|
+
try {
|
|
187
|
+
const maps = {};
|
|
188
|
+
const list = resourcesOrigin.map((item) => {
|
|
189
|
+
const _item = (0, import_lodash_es.cloneDeep)(item);
|
|
190
|
+
const renderListMaps = {};
|
|
191
|
+
_item.renderList = _item.renderList.map((d) => {
|
|
192
|
+
const res = formatResource(d, cacheItem);
|
|
193
|
+
const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
|
|
194
|
+
if (unbound)
|
|
195
|
+
res.unbound = true;
|
|
196
|
+
renderListMaps[res.id] = res;
|
|
197
|
+
return res;
|
|
198
|
+
}).sort((a, b) => b.usable ? 1 : -1);
|
|
199
|
+
maps[_item.form_id] = { ..._item, renderListMaps };
|
|
200
|
+
return _item;
|
|
201
|
+
});
|
|
202
|
+
return { list, maps };
|
|
203
|
+
} catch (err) {
|
|
204
|
+
console.warn("[BookingContext] formatResources error", err);
|
|
205
|
+
return { list: [], maps: {} };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
209
|
+
const { renderList, form_id } = resource;
|
|
210
|
+
if (!isAutoAllocationOn(form_id))
|
|
211
|
+
return [];
|
|
212
|
+
const usableList = (renderList || []).filter((d) => d.usable && d.id !== 0);
|
|
213
|
+
let defaultResource = [];
|
|
214
|
+
let maxFreeTime = 0;
|
|
215
|
+
usableList.forEach((d) => {
|
|
216
|
+
const { times = [] } = d;
|
|
217
|
+
const currentMaxFreeTime = times.reduce((pre, cur) => {
|
|
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;
|
|
220
|
+
const end = cur.end_at;
|
|
221
|
+
const diff = (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(start), "minute");
|
|
222
|
+
return diff > pre ? diff : pre;
|
|
223
|
+
}, 0);
|
|
224
|
+
if (currentMaxFreeTime > maxFreeTime) {
|
|
225
|
+
maxFreeTime = currentMaxFreeTime;
|
|
226
|
+
defaultResource = [d];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return defaultResource;
|
|
230
|
+
}
|
|
231
|
+
function setDefaultResource(params) {
|
|
232
|
+
const { cacheItem, resources, resourceIdFromCalendar, isAutoAllocationOn = () => true } = params;
|
|
233
|
+
const obj = {};
|
|
234
|
+
const resourceId = Number(resourceIdFromCalendar) || 0;
|
|
235
|
+
for (const item of resources) {
|
|
236
|
+
const {
|
|
237
|
+
select_type = {},
|
|
238
|
+
optional_resource = [],
|
|
239
|
+
default_resource = []
|
|
240
|
+
} = item;
|
|
241
|
+
const renderList = item.renderList.filter((d) => {
|
|
242
|
+
if ((select_type == null ? void 0 : select_type.type) === "single") {
|
|
243
|
+
if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
|
|
244
|
+
return d.id === resourceId;
|
|
245
|
+
}
|
|
246
|
+
return d.is_default === 1;
|
|
247
|
+
}
|
|
248
|
+
return d.is_default === 1 || d.id === resourceId;
|
|
249
|
+
});
|
|
250
|
+
let defaultOriginalResource = [];
|
|
251
|
+
if (renderList.length === 0) {
|
|
252
|
+
defaultOriginalResource = getResourceMaxFreeTime(item, isAutoAllocationOn);
|
|
253
|
+
} else {
|
|
254
|
+
defaultOriginalResource = renderList;
|
|
255
|
+
}
|
|
256
|
+
obj[item.form_id] = defaultOriginalResource.map((d) => ({
|
|
257
|
+
children: d.children,
|
|
258
|
+
relation_type: d.relation_type,
|
|
259
|
+
form_id: item.form_id,
|
|
260
|
+
relation_id: d.id,
|
|
261
|
+
like_status: "common",
|
|
262
|
+
metadata: {
|
|
263
|
+
form_name: item.title,
|
|
264
|
+
resource_name: d.main_field
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
return obj;
|
|
269
|
+
}
|
|
270
|
+
function setDefaultCapacitys(params) {
|
|
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) => {
|
|
275
|
+
const id = d._bundle_product_id;
|
|
276
|
+
const item = ((capacitys == null ? void 0 : capacitys.package) || []).find((p) => p.product_id === id);
|
|
277
|
+
return {
|
|
278
|
+
id,
|
|
279
|
+
value: item ? d.quantity || 0 : 0,
|
|
280
|
+
name: (item == null ? void 0 : item.name) || (d == null ? void 0 : d.title)
|
|
281
|
+
};
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
if ((capacitys == null ? void 0 : capacitys.type) === "custom") {
|
|
285
|
+
return ((capacitys == null ? void 0 : capacitys.custom) || []).map((d) => ({
|
|
286
|
+
id: d.id,
|
|
287
|
+
value: d.min,
|
|
288
|
+
name: d.name
|
|
289
|
+
}));
|
|
290
|
+
}
|
|
291
|
+
return [{ id: 0, value: 1, name: "" }];
|
|
292
|
+
}
|
|
293
|
+
function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
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 }));
|
|
296
|
+
const {
|
|
297
|
+
extraResources = [],
|
|
298
|
+
resourcesOrigin = [],
|
|
299
|
+
resourceTab = {}
|
|
300
|
+
} = extraParams || {};
|
|
301
|
+
for (const item of _resources) {
|
|
302
|
+
const form_id = item.id;
|
|
303
|
+
const isAllResource = ((_b = resourceTab == null ? void 0 : resourceTab[item.code]) == null ? void 0 : _b.resource_display_scope) === "all";
|
|
304
|
+
let extraResourceIds = [];
|
|
305
|
+
if (isAllResource) {
|
|
306
|
+
extraResourceIds = (resourcesOrigin || []).filter((d) => d.form_code === item.code).map((d) => d.id);
|
|
307
|
+
} 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);
|
|
311
|
+
}
|
|
312
|
+
extraResourceIds = Array.from(new Set(extraResourceIds));
|
|
313
|
+
item.optional_resource = (item.optional_resource || []).filter(
|
|
314
|
+
(d) => item.default_resource.indexOf(d) === -1
|
|
315
|
+
);
|
|
316
|
+
const getChildrenMetadata = (id) => {
|
|
317
|
+
const combiningResources = [];
|
|
318
|
+
const origin = resourcesOriginMap[id];
|
|
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;
|
|
322
|
+
if (resourcesOriginMap[cid]) {
|
|
323
|
+
combiningResources.push({
|
|
324
|
+
...resourcesOriginMap[cid],
|
|
325
|
+
relation_id: ((_a2 = resourcesOriginMap[cid]) == null ? void 0 : _a2.relation_id) || ((_b2 = resourcesOriginMap[cid]) == null ? void 0 : _b2.id)
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
children: combiningResources,
|
|
332
|
+
metadata: {
|
|
333
|
+
...(origin == null ? void 0 : origin.metadata) || {},
|
|
334
|
+
combined_resource: origin == null ? void 0 : origin.combined_resource
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
const optional_resource = Array.from(
|
|
339
|
+
/* @__PURE__ */ new Set([...item.optional_resource, ...extraResourceIds])
|
|
340
|
+
).map((d) => {
|
|
341
|
+
if (!resourcesOriginMap[d])
|
|
342
|
+
return null;
|
|
343
|
+
return Object.assign({}, resourcesOriginMap[d], {
|
|
344
|
+
form_id,
|
|
345
|
+
resourceType: item.type,
|
|
346
|
+
...getChildrenMetadata(d)
|
|
347
|
+
});
|
|
348
|
+
}).filter((d) => d).concat((0, import_noResource.getNoResource2)({ form_id }));
|
|
349
|
+
const default_resource = (item.default_resource || []).map((d) => {
|
|
350
|
+
const origin = resourcesOriginMap[d];
|
|
351
|
+
if (origin) {
|
|
352
|
+
origin.is_default = 1;
|
|
353
|
+
return Object.assign({}, origin, {
|
|
354
|
+
form_id,
|
|
355
|
+
resourceType: item.type,
|
|
356
|
+
...getChildrenMetadata(d)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
}).filter((d) => d);
|
|
361
|
+
item.renderList = optional_resource.concat(default_resource);
|
|
362
|
+
item.form_id = form_id;
|
|
363
|
+
}
|
|
364
|
+
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
|
+
});
|