@pisell/private-materials 6.6.101 → 6.6.103
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/booking/components/footer/utils.js +13 -0
- package/es/components/booking/components/voucher/index.js +42 -3
- package/es/components/booking/info/clientVariant/hooks/useClientFn.js +8 -5
- package/es/components/booking/info/clientVariant/vertical/index.js +1 -1
- package/es/components/booking/info2/service/editService/index.js +31 -11
- package/es/components/booking/info2/service/editService/utils.d.ts +3 -0
- package/es/components/booking/info2/service/editService/utils.js +128 -19
- package/es/components/eftpos/const.d.ts +2 -0
- package/es/components/eftpos/const.js +25 -2
- package/es/components/eftpos/device.d.ts +1 -0
- package/es/components/eftpos/device.js +9 -4
- package/es/components/eftpos/form/index.d.ts +2 -1
- package/es/components/eftpos/form/index.js +7 -2
- package/es/components/eftpos/index.js +5 -0
- package/es/components/eftpos/pos.d.ts +2 -1
- package/es/components/eftpos/pos.js +9 -4
- package/es/components/eftpos/surcharge/index.js +13 -1
- package/es/components/eftposPay/amount.js +20 -5
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/store/index.d.ts +1 -1
- package/es/components/ticketBooking/utils/index.js +4 -4
- package/es/hooks/useCardSurchargeReadOnly.d.ts +4 -0
- package/es/hooks/useCardSurchargeReadOnly.js +61 -0
- package/lib/components/booking/components/footer/utils.js +8 -1
- package/lib/components/booking/components/voucher/index.js +43 -3
- package/lib/components/booking/info/clientVariant/hooks/useClientFn.js +7 -5
- package/lib/components/booking/info/clientVariant/vertical/index.js +1 -1
- package/lib/components/booking/info2/service/editService/index.js +38 -12
- package/lib/components/booking/info2/service/editService/utils.d.ts +3 -0
- package/lib/components/booking/info2/service/editService/utils.js +94 -12
- package/lib/components/eftpos/const.d.ts +2 -0
- package/lib/components/eftpos/const.js +18 -2
- package/lib/components/eftpos/device.d.ts +1 -0
- package/lib/components/eftpos/device.js +11 -3
- package/lib/components/eftpos/form/index.d.ts +2 -1
- package/lib/components/eftpos/form/index.js +11 -2
- package/lib/components/eftpos/index.js +5 -0
- package/lib/components/eftpos/pos.d.ts +2 -1
- package/lib/components/eftpos/pos.js +15 -3
- package/lib/components/eftpos/surcharge/index.js +41 -8
- package/lib/components/eftposPay/amount.js +26 -3
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/store/index.d.ts +1 -1
- package/lib/components/ticketBooking/utils/index.js +2 -2
- package/lib/hooks/useCardSurchargeReadOnly.d.ts +4 -0
- package/lib/hooks/useCardSurchargeReadOnly.js +86 -0
- package/package.json +4 -4
|
@@ -92,6 +92,9 @@ var Info = (_, ref) => {
|
|
|
92
92
|
const resourcesRef = (0, import_react.useRef)(null);
|
|
93
93
|
const isChangeTotal = (0, import_react.useRef)(false);
|
|
94
94
|
const shouldReallocateBundlePriceRef = (0, import_react.useRef)(false);
|
|
95
|
+
const isEntitlementPrice = (0, import_utils8.hasEntitlementDiscount)(
|
|
96
|
+
state.service.cacheItem
|
|
97
|
+
);
|
|
95
98
|
const [noteModalOpen, setNoteModalOpen] = (0, import_react.useState)(false);
|
|
96
99
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
97
100
|
const [currentTab, setCurrentTab] = (0, import_react.useState)("batch_edit");
|
|
@@ -247,7 +250,7 @@ var Info = (_, ref) => {
|
|
|
247
250
|
}
|
|
248
251
|
};
|
|
249
252
|
const onFinish = (values, cacheItem) => {
|
|
250
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2;
|
|
253
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2;
|
|
251
254
|
let isSuccess = (_a2 = resourcesRef.current) == null ? void 0 : _a2.check();
|
|
252
255
|
if (isShowTimeAndResource && !isSuccess) {
|
|
253
256
|
return;
|
|
@@ -281,7 +284,8 @@ var Info = (_, ref) => {
|
|
|
281
284
|
_extend.startDate = startDate;
|
|
282
285
|
_extend.endDate = endDate;
|
|
283
286
|
}
|
|
284
|
-
const
|
|
287
|
+
const isManualPriceChange = isChangeTotal.current && !(0, import_utils8.hasEntitlementDiscount)(_item);
|
|
288
|
+
const shouldReallocatePrice = isManualPriceChange || shouldReallocateBundlePriceRef.current;
|
|
285
289
|
if (shouldReallocatePrice) {
|
|
286
290
|
const discountRatio = new import_decimal.default(values.total).div(_item._extend.origin_total);
|
|
287
291
|
const bundles2 = ((_c2 = _extend == null ? void 0 : _extend.other) == null ? void 0 : _c2.bundle) || [];
|
|
@@ -306,7 +310,9 @@ var Info = (_, ref) => {
|
|
|
306
310
|
_item._time = (/* @__PURE__ */ new Date()).getTime();
|
|
307
311
|
_item._serviceKey = (0, import_utils3.genServiceKey)(_item);
|
|
308
312
|
_item._holderKey = (0, import_utils3.genHolderKey)(_item);
|
|
309
|
-
|
|
313
|
+
const previousItem = _list.find((item) => item._id === _item._id) ?? _list.find((item) => isSameBookingServiceItem(item, _item));
|
|
314
|
+
const isEntitlementQuantityChange = (0, import_utils8.hasEntitlementDiscount)(previousItem) && Number(_item._extend.quantity || 1) !== Number(((_e2 = previousItem == null ? void 0 : previousItem._extend) == null ? void 0 : _e2.quantity) || 1);
|
|
315
|
+
if (!isEntitlementQuantityChange && (((_g2 = (_f2 = _item._extend) == null ? void 0 : _f2.holder_id) == null ? void 0 : _g2.length) > 1 || ((_h2 = _item._extend) == null ? void 0 : _h2.quantity) > 1 && ((_j2 = (_i2 = _item._extend) == null ? void 0 : _i2.holder_id) == null ? void 0 : _j2.length) >= 1)) {
|
|
310
316
|
let holder_ids = _item._extend.holder_id;
|
|
311
317
|
_item._extend.holder_id = holder_ids[0];
|
|
312
318
|
holder_ids = holder_ids.slice(1);
|
|
@@ -325,8 +331,8 @@ var Info = (_, ref) => {
|
|
|
325
331
|
}
|
|
326
332
|
}
|
|
327
333
|
let _id = _item == null ? void 0 : _item._id;
|
|
328
|
-
let groupId = (
|
|
329
|
-
const origin_total = (
|
|
334
|
+
let groupId = (_k2 = _item == null ? void 0 : _item._extend) == null ? void 0 : _k2.groupId;
|
|
335
|
+
const origin_total = (_o2 = (_n2 = (_m2 = (_l2 = _item._extend) == null ? void 0 : _l2.items) == null ? void 0 : _m2[0]) == null ? void 0 : _n2._extend) == null ? void 0 : _o2.origin_total;
|
|
330
336
|
if (groupId) {
|
|
331
337
|
if (shouldReallocatePrice) {
|
|
332
338
|
_item = deleteDiscountList(_item, true);
|
|
@@ -339,7 +345,7 @@ var Info = (_, ref) => {
|
|
|
339
345
|
} else {
|
|
340
346
|
_item = (0, import_utils8.setProductPrice)(_item, {
|
|
341
347
|
newTotal: values.total,
|
|
342
|
-
origin_total: origin_total ?? ((
|
|
348
|
+
origin_total: origin_total ?? ((_p2 = _item._extend) == null ? void 0 : _p2.origin_total)
|
|
343
349
|
});
|
|
344
350
|
const matchById = _list.some((d) => d._id === _id);
|
|
345
351
|
const matchByBooking = !matchById && _list.some((d) => isSameBookingServiceItem(d, _item));
|
|
@@ -348,13 +354,32 @@ var Info = (_, ref) => {
|
|
|
348
354
|
_item = deleteDiscountList(_item, true);
|
|
349
355
|
}
|
|
350
356
|
if (matchById) {
|
|
351
|
-
_list = _list.
|
|
357
|
+
_list = _list.flatMap((d) => {
|
|
358
|
+
if (d._id !== _id) return [d];
|
|
359
|
+
return (0, import_utils8.updateEntitlementQuantity)(
|
|
360
|
+
d,
|
|
361
|
+
{ ..._item, new: 0 }
|
|
362
|
+
).map((item) => ({
|
|
363
|
+
...item,
|
|
364
|
+
_serviceKey: (0, import_utils3.genServiceKey)(item),
|
|
365
|
+
_holderKey: (0, import_utils3.genHolderKey)(item)
|
|
366
|
+
}));
|
|
367
|
+
});
|
|
352
368
|
} else {
|
|
353
369
|
let replaced = false;
|
|
354
370
|
_list = _list.reduce((acc, d) => {
|
|
355
371
|
if (isSameBookingServiceItem(d, _item)) {
|
|
356
372
|
if (!replaced) {
|
|
357
|
-
acc.push(
|
|
373
|
+
acc.push(
|
|
374
|
+
...(0, import_utils8.updateEntitlementQuantity)(
|
|
375
|
+
d,
|
|
376
|
+
{ ..._item, new: 0, _id: d._id }
|
|
377
|
+
).map((item) => ({
|
|
378
|
+
...item,
|
|
379
|
+
_serviceKey: (0, import_utils3.genServiceKey)(item),
|
|
380
|
+
_holderKey: (0, import_utils3.genHolderKey)(item)
|
|
381
|
+
}))
|
|
382
|
+
);
|
|
358
383
|
replaced = true;
|
|
359
384
|
}
|
|
360
385
|
} else {
|
|
@@ -371,7 +396,7 @@ var Info = (_, ref) => {
|
|
|
371
396
|
(0, import_utils6.deleteCacheParams)();
|
|
372
397
|
console.log("_onFinish", _list);
|
|
373
398
|
form.resetFields();
|
|
374
|
-
if (!!((
|
|
399
|
+
if (!!((_q2 = state.service.cacheItem) == null ? void 0 : _q2.new)) {
|
|
375
400
|
window.dispatchEvent(
|
|
376
401
|
new CustomEvent("onAddNewService", {
|
|
377
402
|
detail: {
|
|
@@ -380,7 +405,7 @@ var Info = (_, ref) => {
|
|
|
380
405
|
})
|
|
381
406
|
);
|
|
382
407
|
}
|
|
383
|
-
(
|
|
408
|
+
(_r2 = window.closeBookingEditModal) == null ? void 0 : _r2.call(window);
|
|
384
409
|
_list.sort((a, b) => {
|
|
385
410
|
var _a3, _b3;
|
|
386
411
|
const aHasHolderId = ((_a3 = a._extend) == null ? void 0 : _a3.holder_id) && (Array.isArray(a._extend.holder_id) ? a._extend.holder_id.length > 0 : true);
|
|
@@ -750,7 +775,7 @@ var Info = (_, ref) => {
|
|
|
750
775
|
precision: 2,
|
|
751
776
|
prefix: state.amountSymbol,
|
|
752
777
|
onChange: handleTotalChange,
|
|
753
|
-
disabled: state.channelDisabledEdit,
|
|
778
|
+
disabled: state.channelDisabledEdit || isEntitlementPrice,
|
|
754
779
|
originalValue: ((_f2 = (_e2 = state.service.cacheItem) == null ? void 0 : _e2._extend) == null ? void 0 : _f2.origin_total) || 0,
|
|
755
780
|
placeholder: ((_h2 = (_g2 = state.service.cacheItem) == null ? void 0 : _g2._extend) == null ? void 0 : _h2.origin_total) || "0",
|
|
756
781
|
size: "large",
|
|
@@ -767,7 +792,8 @@ var Info = (_, ref) => {
|
|
|
767
792
|
useTotal,
|
|
768
793
|
(_u = (_t = state.service.cacheItem) == null ? void 0 : _t._extend) == null ? void 0 : _u.origin_total,
|
|
769
794
|
state.amountSymbol,
|
|
770
|
-
state.channelDisabledEdit
|
|
795
|
+
state.channelDisabledEdit,
|
|
796
|
+
isEntitlementPrice
|
|
771
797
|
]);
|
|
772
798
|
const reason = (0, import_react.useMemo)(() => {
|
|
773
799
|
return isReason ? /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
判断是否需要进入编辑服务页
|
|
9
9
|
*/
|
|
10
|
+
export declare const hasEntitlementDiscount: (item: any) => boolean;
|
|
11
|
+
/** 已提交部分保留原扣次;增加的数量作为新商品交给 OS 重新计算。 */
|
|
12
|
+
export declare const updateEntitlementQuantity: (previous: any, next: any) => any[];
|
|
10
13
|
export declare const getAutoAllocationStorage: (id: string | number) => any;
|
|
11
14
|
export declare const setAutoAllocationStorage: (data: {
|
|
12
15
|
[key: string]: boolean;
|
|
@@ -31,20 +31,100 @@ var utils_exports = {};
|
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
getAutoAllocationStorage: () => getAutoAllocationStorage,
|
|
33
33
|
getProductAllDiscountList: () => getProductAllDiscountList,
|
|
34
|
+
hasEntitlementDiscount: () => hasEntitlementDiscount,
|
|
34
35
|
mergeBundleWithOriginalPrice: () => mergeBundleWithOriginalPrice,
|
|
35
36
|
setAutoAllocationStorage: () => setAutoAllocationStorage,
|
|
36
|
-
setProductPrice: () => setProductPrice
|
|
37
|
+
setProductPrice: () => setProductPrice,
|
|
38
|
+
updateEntitlementQuantity: () => updateEntitlementQuantity
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(utils_exports);
|
|
39
41
|
var import_utils = require("@pisell/utils");
|
|
40
|
-
var import_utils2 = require("@pisell/utils");
|
|
41
42
|
var import_decimal = __toESM(require("decimal.js"));
|
|
42
|
-
var
|
|
43
|
+
var import_lodash = require("lodash");
|
|
44
|
+
var import_utils2 = require("../../../components/footer/utils");
|
|
45
|
+
var import_utils3 = require("../../../utils");
|
|
46
|
+
var isEntitlementDiscount = (discount) => ((discount == null ? void 0 : discount.tag) || (discount == null ? void 0 : discount.type)) === "entitlement_pass";
|
|
47
|
+
var getServiceDiscounts = (item) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return [
|
|
50
|
+
...(item == null ? void 0 : item.discount_list) || [],
|
|
51
|
+
...(((_b = (_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle) || []).flatMap((bundle) => bundle.discount_list || [])
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
var hasEntitlementDiscount = (item) => getServiceDiscounts(item).some(isEntitlementDiscount);
|
|
55
|
+
var updateEntitlementQuantity = (previous, next) => {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
const discounts = getServiceDiscounts(previous);
|
|
58
|
+
const persisted = [previous == null ? void 0 : previous.booking_id, previous == null ? void 0 : previous.order_detail_id, (_a = previous == null ? void 0 : previous._extend) == null ? void 0 : _a.order_detail_id].some((value) => Number(value) > 0) || discounts.some((discount) => isEntitlementDiscount(discount) && discount.id);
|
|
59
|
+
const previousQuantity = Number(((_b = previous == null ? void 0 : previous._extend) == null ? void 0 : _b.quantity) || 1);
|
|
60
|
+
const nextQuantity = Number(next._extend.quantity || 1);
|
|
61
|
+
if (!persisted || !hasEntitlementDiscount(previous) || nextQuantity === previousQuantity) {
|
|
62
|
+
return [next];
|
|
63
|
+
}
|
|
64
|
+
if (nextQuantity < previousQuantity) {
|
|
65
|
+
return [{
|
|
66
|
+
...previous,
|
|
67
|
+
_extend: {
|
|
68
|
+
...previous._extend,
|
|
69
|
+
quantity: nextQuantity,
|
|
70
|
+
...Array.isArray(next._extend.holder_id) ? { holder_id: next._extend.holder_id.slice(0, nextQuantity) } : {},
|
|
71
|
+
other: { ...previous._extend.other, quantity: nextQuantity }
|
|
72
|
+
},
|
|
73
|
+
discount_list: (previous.discount_list || []).map((discount) => {
|
|
74
|
+
var _a2, _b2;
|
|
75
|
+
if (!isEntitlementDiscount(discount) || ((_a2 = discount.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id)) return discount;
|
|
76
|
+
const num = Math.min(Number(((_b2 = discount.metadata) == null ? void 0 : _b2.num) ?? previousQuantity), nextQuantity);
|
|
77
|
+
return { ...discount, _num: num, metadata: { ...discount.metadata, num } };
|
|
78
|
+
})
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
const appended = (0, import_lodash.cloneDeep)(next);
|
|
82
|
+
const uid = (0, import_utils.getUniqueId)();
|
|
83
|
+
appended._id = uid;
|
|
84
|
+
appended.booking_id = 0;
|
|
85
|
+
appended.order_detail_id = 0;
|
|
86
|
+
appended.new = 0;
|
|
87
|
+
appended.discount_list = [];
|
|
88
|
+
appended.discount_amount = 0;
|
|
89
|
+
appended.metadata = { ...appended.metadata, unique_identification_number: uid };
|
|
90
|
+
delete appended.metadata.entitlement_source_identity;
|
|
91
|
+
delete appended.metadata.entitlement_source_product_uid;
|
|
92
|
+
if (appended._origin) delete appended._origin.booking_id;
|
|
93
|
+
const extend = appended._extend;
|
|
94
|
+
extend.order_detail_id = 0;
|
|
95
|
+
extend.unique_identification_number = uid;
|
|
96
|
+
extend.quantity = nextQuantity - previousQuantity;
|
|
97
|
+
if (Array.isArray(extend.holder_id)) {
|
|
98
|
+
const holders = extend.holder_id.slice(previousQuantity, nextQuantity);
|
|
99
|
+
extend.holder_id = holders.length ? holders : void 0;
|
|
100
|
+
}
|
|
101
|
+
extend.other = { ...extend.other, quantity: extend.quantity };
|
|
102
|
+
extend.other.bundle = (extend.other.bundle || []).map((bundle) => {
|
|
103
|
+
var _a2, _b2, _c2;
|
|
104
|
+
const price = bundle.original_price ?? ((_c2 = (_b2 = (_a2 = bundle.discount_list) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.discount) == null ? void 0 : _c2.original_amount) ?? bundle.product_price ?? bundle.price;
|
|
105
|
+
const bundleUid = (0, import_utils.getUniqueId)();
|
|
106
|
+
const metadata = { ...bundle.metadata, custom_product_bundle_map_id: bundleUid, unique_identification_number: bundleUid };
|
|
107
|
+
delete metadata.entitlement_source_identity;
|
|
108
|
+
return { ...bundle, _id: bundleUid, price, bundle_selling_price: price, discount_list: [], metadata };
|
|
109
|
+
});
|
|
110
|
+
const mainDiscount = (next.discount_list || []).find((discount) => {
|
|
111
|
+
var _a2, _b2;
|
|
112
|
+
return !((_a2 = discount.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id) && ((_b2 = discount.discount) == null ? void 0 : _b2.original_amount) != null;
|
|
113
|
+
});
|
|
114
|
+
if (mainDiscount && ((_d = (_c = previous == null ? void 0 : previous._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.product_variant_id) === extend.other.product_variant_id) {
|
|
115
|
+
extend.price = Number(mainDiscount.discount.original_amount);
|
|
116
|
+
if (extend.other.product_variant_id) extend.other.price = extend.price;
|
|
117
|
+
}
|
|
118
|
+
extend.main_product_selling_price = (0, import_utils3.getMainPrice)(appended);
|
|
119
|
+
extend.total = (0, import_utils3.getProductTotalPrice)(appended);
|
|
120
|
+
extend.origin_total = extend.total;
|
|
121
|
+
return [previous, appended];
|
|
122
|
+
};
|
|
43
123
|
var getAutoAllocationStorage = (id) => {
|
|
44
124
|
const value = localStorage.getItem("resource-auto-allocation");
|
|
45
125
|
if (value) {
|
|
46
126
|
const valueObj = JSON.parse(value);
|
|
47
|
-
return (0,
|
|
127
|
+
return (0, import_utils.isBoolean)(valueObj[id]) ? valueObj[id] : true;
|
|
48
128
|
}
|
|
49
129
|
return true;
|
|
50
130
|
};
|
|
@@ -58,8 +138,8 @@ var setAutoAllocationStorage = (data) => {
|
|
|
58
138
|
}
|
|
59
139
|
};
|
|
60
140
|
var setProductPrice = (cacheItem, { newTotal, origin_total }) => {
|
|
61
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
62
|
-
if ((
|
|
141
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
142
|
+
if (hasEntitlementDiscount(cacheItem) || ((cacheItem == null ? void 0 : cacheItem.discount_list) || []).some((item) => ["good_pass", "discount_card", "product_discount_card"].includes(
|
|
63
143
|
item.type
|
|
64
144
|
))) {
|
|
65
145
|
return cacheItem;
|
|
@@ -69,16 +149,16 @@ var setProductPrice = (cacheItem, { newTotal, origin_total }) => {
|
|
|
69
149
|
}
|
|
70
150
|
const discountRatio = new import_decimal.default(newTotal).div(new import_decimal.default(origin_total));
|
|
71
151
|
let subTotal = new import_decimal.default(0);
|
|
72
|
-
if (((
|
|
73
|
-
(
|
|
152
|
+
if (((_a = cacheItem._extend.other) == null ? void 0 : _a.bundle) && (0, import_utils.isArr)((_b = cacheItem._extend.other) == null ? void 0 : _b.bundle)) {
|
|
153
|
+
(_d = (_c = cacheItem._extend.other) == null ? void 0 : _c.bundle) == null ? void 0 : _d.forEach((bundle) => {
|
|
74
154
|
const newPrice = new import_decimal.default(bundle.original_price || bundle.price).mul(discountRatio).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
75
155
|
const quantity = bundle.num ?? bundle.quantity ?? 1;
|
|
76
156
|
subTotal = subTotal.add(new import_decimal.default(newPrice).mul(quantity));
|
|
77
157
|
bundle.price = newPrice;
|
|
78
158
|
});
|
|
79
159
|
}
|
|
80
|
-
if (((
|
|
81
|
-
(
|
|
160
|
+
if (((_e = cacheItem._extend.other) == null ? void 0 : _e.option) && (0, import_utils.isArr)((_f = cacheItem._extend.other) == null ? void 0 : _f.option)) {
|
|
161
|
+
(_h = (_g = cacheItem._extend.other) == null ? void 0 : _g.option) == null ? void 0 : _h.forEach((option) => {
|
|
82
162
|
const newPrice = new import_decimal.default(option.price).mul(discountRatio).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
83
163
|
const quantity = option.num ?? option.quantity ?? 1;
|
|
84
164
|
subTotal = subTotal.add(new import_decimal.default(newPrice).mul(quantity));
|
|
@@ -91,7 +171,7 @@ var setProductPrice = (cacheItem, { newTotal, origin_total }) => {
|
|
|
91
171
|
var getProductAllDiscountList = (cacheItem) => {
|
|
92
172
|
var _a, _b;
|
|
93
173
|
const discountList = [...cacheItem.discount_list || []];
|
|
94
|
-
const bundleDiscountList = (0,
|
|
174
|
+
const bundleDiscountList = (0, import_utils2.getBundleDiscountList)(((_b = (_a = cacheItem._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle) || []) || [];
|
|
95
175
|
discountList.push(...bundleDiscountList);
|
|
96
176
|
return discountList;
|
|
97
177
|
};
|
|
@@ -113,7 +193,9 @@ var mergeBundleWithOriginalPrice = (other, originalOther) => {
|
|
|
113
193
|
0 && (module.exports = {
|
|
114
194
|
getAutoAllocationStorage,
|
|
115
195
|
getProductAllDiscountList,
|
|
196
|
+
hasEntitlementDiscount,
|
|
116
197
|
mergeBundleWithOriginalPrice,
|
|
117
198
|
setAutoAllocationStorage,
|
|
118
|
-
setProductPrice
|
|
199
|
+
setProductPrice,
|
|
200
|
+
updateEntitlementQuantity
|
|
119
201
|
});
|
|
@@ -50,6 +50,8 @@ export interface DeviceProp {
|
|
|
50
50
|
* @Date: 2024-08-19 11:10
|
|
51
51
|
*/
|
|
52
52
|
export declare const getDefaultValue: (list: any) => any;
|
|
53
|
+
/** Preserve fee fields when saving unrelated device or merchant settings. */
|
|
54
|
+
export declare const preserveSurchargeValues: (values: any, list: any[]) => any;
|
|
53
55
|
/**
|
|
54
56
|
* @title: 构建通用表单配置信息,构建动态表单
|
|
55
57
|
* @description:
|
|
@@ -23,7 +23,8 @@ __export(const_exports, {
|
|
|
23
23
|
Eftpos: () => Eftpos,
|
|
24
24
|
TYPES_WITH_MERCHANT_SETTINGS: () => TYPES_WITH_MERCHANT_SETTINGS,
|
|
25
25
|
getCommByFields: () => getCommByFields,
|
|
26
|
-
getDefaultValue: () => getDefaultValue
|
|
26
|
+
getDefaultValue: () => getDefaultValue,
|
|
27
|
+
preserveSurchargeValues: () => preserveSurchargeValues
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(const_exports);
|
|
29
30
|
var import_form = require("./form");
|
|
@@ -71,6 +72,20 @@ var getDefaultValue = (list) => {
|
|
|
71
72
|
};
|
|
72
73
|
}, {});
|
|
73
74
|
};
|
|
75
|
+
var preserveSurchargeValues = (values, list) => {
|
|
76
|
+
const result = { ...values };
|
|
77
|
+
for (const item of list) {
|
|
78
|
+
if (Array.isArray(item.children) && item.children.length) {
|
|
79
|
+
result[item.__sourceName] = preserveSurchargeValues(
|
|
80
|
+
values == null ? void 0 : values[item.__sourceName],
|
|
81
|
+
item.children
|
|
82
|
+
);
|
|
83
|
+
} else if (item.Component === "Surcharge") {
|
|
84
|
+
Object.assign(result, import_form.helpMapping.Surcharge.getCommDefaultVal(item));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
74
89
|
async function getCommByFields({
|
|
75
90
|
field,
|
|
76
91
|
value,
|
|
@@ -129,5 +144,6 @@ async function getCommByFields({
|
|
|
129
144
|
Eftpos,
|
|
130
145
|
TYPES_WITH_MERCHANT_SETTINGS,
|
|
131
146
|
getCommByFields,
|
|
132
|
-
getDefaultValue
|
|
147
|
+
getDefaultValue,
|
|
148
|
+
preserveSurchargeValues
|
|
133
149
|
});
|
|
@@ -38,7 +38,7 @@ var import_utils = require("@pisell/utils");
|
|
|
38
38
|
var import_const = require("./const");
|
|
39
39
|
var import_form = __toESM(require("./form"));
|
|
40
40
|
var Device = (props) => {
|
|
41
|
-
const { onSave, children, formItemList } = props;
|
|
41
|
+
const { onSave, children, formItemList, surchargeReadOnly = false } = props;
|
|
42
42
|
const initialValues = (0, import_const.getDefaultValue)(formItemList);
|
|
43
43
|
const simpleCloudIntegrationSteps = import_utils.locales.getText(
|
|
44
44
|
"page.eftpos.text.simple.cloud.integration.steps"
|
|
@@ -54,11 +54,19 @@ var Device = (props) => {
|
|
|
54
54
|
import_antd.Form,
|
|
55
55
|
{
|
|
56
56
|
layout: "vertical",
|
|
57
|
-
onFinish: onSave
|
|
57
|
+
onFinish: (values) => onSave(
|
|
58
|
+
surchargeReadOnly ? (0, import_const.preserveSurchargeValues)(values, formItemList) : values
|
|
59
|
+
),
|
|
58
60
|
initialValues,
|
|
59
61
|
className: "pisell-lowcode__pos-device"
|
|
60
62
|
},
|
|
61
|
-
/* @__PURE__ */ import_react.default.createElement("div", { style: { flex: 1, overflow: "auto", padding: "0 0 60px 0" } }, /* @__PURE__ */ import_react.default.createElement(
|
|
63
|
+
/* @__PURE__ */ import_react.default.createElement("div", { style: { flex: 1, overflow: "auto", padding: "0 0 60px 0" } }, /* @__PURE__ */ import_react.default.createElement(
|
|
64
|
+
import_form.default,
|
|
65
|
+
{
|
|
66
|
+
formItemList,
|
|
67
|
+
surchargeReadOnly
|
|
68
|
+
}
|
|
69
|
+
), children),
|
|
62
70
|
/* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { className: "pisell-lowcode__pos-device-btn" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { htmlType: "submit", block: true, style: { height: "48px" } }, (props == null ? void 0 : props.status) === "edit" ? import_utils.locales.getText("page.eftpos.text.save") : import_utils.locales.getText("page.eftpos.text.pair")))
|
|
63
71
|
));
|
|
64
72
|
};
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* @Author: hongbing.wang
|
|
4
4
|
* @Date: 2024-08-20 13:21
|
|
5
5
|
*/
|
|
6
|
-
declare const CustomFormItem: ({ formItemList, level, onChange, }: {
|
|
6
|
+
declare const CustomFormItem: ({ formItemList, level, onChange, surchargeReadOnly, }: {
|
|
7
7
|
formItemList: any[];
|
|
8
8
|
level?: number | undefined;
|
|
9
9
|
onChange?: ((...agrn: unknown[]) => unknown) | undefined;
|
|
10
|
+
surchargeReadOnly?: boolean | undefined;
|
|
10
11
|
}) => JSX.Element;
|
|
11
12
|
export default CustomFormItem;
|
|
12
13
|
declare type helpMappingType = {
|
|
@@ -65,7 +65,8 @@ var CustomMapping = {
|
|
|
65
65
|
var CustomFormItem = ({
|
|
66
66
|
formItemList,
|
|
67
67
|
level = 0,
|
|
68
|
-
onChange
|
|
68
|
+
onChange,
|
|
69
|
+
surchargeReadOnly = false
|
|
69
70
|
}) => {
|
|
70
71
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, formItemList.map(({ __sourceName, Component, ...item }, index) => {
|
|
71
72
|
if (Array.isArray(item.children)) {
|
|
@@ -74,6 +75,7 @@ var CustomFormItem = ({
|
|
|
74
75
|
{
|
|
75
76
|
formItemList: item.children,
|
|
76
77
|
onChange,
|
|
78
|
+
surchargeReadOnly,
|
|
77
79
|
key: item.name ? `${item.name}${level}` : `${Component}${index}${level}`,
|
|
78
80
|
level: level + 1
|
|
79
81
|
}
|
|
@@ -94,7 +96,14 @@ var CustomFormItem = ({
|
|
|
94
96
|
}
|
|
95
97
|
if (CustomMapping[Component]) {
|
|
96
98
|
const Comm = CustomMapping[Component];
|
|
97
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
99
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
100
|
+
Comm,
|
|
101
|
+
{
|
|
102
|
+
...item,
|
|
103
|
+
...Component === "Surcharge" ? { surchargeReadOnly } : {},
|
|
104
|
+
key: `${item.name}${level}`
|
|
105
|
+
}
|
|
106
|
+
);
|
|
98
107
|
}
|
|
99
108
|
throw TypeError(
|
|
100
109
|
`pos物料库 输入组件类型 ${Component} 无法映射,请正确传入组件类型`
|
|
@@ -51,6 +51,7 @@ var import_const = require("./const");
|
|
|
51
51
|
var import_materials = require("@pisell/materials");
|
|
52
52
|
var import_mx51SCI = __toESM(require("./assets/mx51SCI.svg"));
|
|
53
53
|
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
|
|
54
|
+
var import_useCardSurchargeReadOnly = __toESM(require("../../hooks/useCardSurchargeReadOnly"));
|
|
54
55
|
var import_utils2 = require("../../utils");
|
|
55
56
|
var import_index = require("./index.less");
|
|
56
57
|
import_utils.locales.init(import_locales.default, (0, import_locales2.getLocale)());
|
|
@@ -150,6 +151,7 @@ var eftpos_default = (props) => {
|
|
|
150
151
|
tyroVersion,
|
|
151
152
|
useTyroLog
|
|
152
153
|
} = props;
|
|
154
|
+
const surchargeReadOnly = (0, import_useCardSurchargeReadOnly.default)(type);
|
|
153
155
|
const context = (0, import_useEngineContext.default)();
|
|
154
156
|
const utils = context.appHelper.utils || {};
|
|
155
157
|
import_utils2.request.setRequest(utils == null ? void 0 : utils.request);
|
|
@@ -431,6 +433,7 @@ var eftpos_default = (props) => {
|
|
|
431
433
|
import_pos.default,
|
|
432
434
|
{
|
|
433
435
|
eftposName: name,
|
|
436
|
+
surchargeReadOnly,
|
|
434
437
|
onSave: onSavePos,
|
|
435
438
|
formItemList: posItemList
|
|
436
439
|
}
|
|
@@ -460,6 +463,7 @@ var eftpos_default = (props) => {
|
|
|
460
463
|
import_device.default,
|
|
461
464
|
{
|
|
462
465
|
formItemList: deviceItemList,
|
|
466
|
+
surchargeReadOnly,
|
|
463
467
|
onSave,
|
|
464
468
|
key: `posdevice${type}`
|
|
465
469
|
},
|
|
@@ -539,6 +543,7 @@ var eftpos_default = (props) => {
|
|
|
539
543
|
import_device.default,
|
|
540
544
|
{
|
|
541
545
|
formItemList: deviceItemList,
|
|
546
|
+
surchargeReadOnly,
|
|
542
547
|
onSave: onSavePair,
|
|
543
548
|
key: `device${type}`,
|
|
544
549
|
type,
|
|
@@ -2,7 +2,8 @@ import { DeviceProp } from "./const";
|
|
|
2
2
|
interface PosProps {
|
|
3
3
|
eftposName: string;
|
|
4
4
|
formItemList: any[];
|
|
5
|
+
surchargeReadOnly?: boolean;
|
|
5
6
|
onSave: (device: DeviceProp) => void;
|
|
6
7
|
}
|
|
7
|
-
declare const PosForm: ({ onSave, formItemList }: PosProps) => JSX.Element;
|
|
8
|
+
declare const PosForm: ({ onSave, formItemList, surchargeReadOnly, }: PosProps) => JSX.Element;
|
|
8
9
|
export default PosForm;
|
|
@@ -38,18 +38,30 @@ var import_const = require("./const");
|
|
|
38
38
|
var import_utils = require("@pisell/utils");
|
|
39
39
|
var import_form = __toESM(require("./form"));
|
|
40
40
|
var { Title } = import_antd.Typography;
|
|
41
|
-
var PosForm = ({
|
|
41
|
+
var PosForm = ({
|
|
42
|
+
onSave,
|
|
43
|
+
formItemList,
|
|
44
|
+
surchargeReadOnly = false
|
|
45
|
+
}) => {
|
|
42
46
|
const initialValues = (0, import_const.getDefaultValue)(formItemList);
|
|
43
47
|
return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__pos-form-box" }, /* @__PURE__ */ import_react.default.createElement(Title, { level: 4, className: "pisell-lowcode__pos-title" }, import_utils.locales.getText("page.eftpos.text.setting")), /* @__PURE__ */ import_react.default.createElement(
|
|
44
48
|
import_antd.Form,
|
|
45
49
|
{
|
|
46
50
|
layout: "vertical",
|
|
47
|
-
onFinish: onSave
|
|
51
|
+
onFinish: (values) => onSave(
|
|
52
|
+
surchargeReadOnly ? (0, import_const.preserveSurchargeValues)(values, formItemList) : values
|
|
53
|
+
),
|
|
48
54
|
initialValues,
|
|
49
55
|
className: "pisell-lowcode__pos-form",
|
|
50
56
|
key: formItemList
|
|
51
57
|
},
|
|
52
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__pos-form-content" }, /* @__PURE__ */ import_react.default.createElement(
|
|
58
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__pos-form-content" }, /* @__PURE__ */ import_react.default.createElement(
|
|
59
|
+
import_form.default,
|
|
60
|
+
{
|
|
61
|
+
formItemList,
|
|
62
|
+
surchargeReadOnly
|
|
63
|
+
}
|
|
64
|
+
)),
|
|
53
65
|
/* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__pos-form-btn" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { htmlType: "submit", block: true, style: { height: "48px" } }, import_utils.locales.getText("page.eftpos.text.save"))))
|
|
54
66
|
));
|
|
55
67
|
};
|
|
@@ -61,7 +61,7 @@ var getCommDefaultVal = (commConfig) => {
|
|
|
61
61
|
};
|
|
62
62
|
var surcharge_default = (props) => {
|
|
63
63
|
var _a, _b, _c, _d;
|
|
64
|
-
const { origin, top, left, right } = props;
|
|
64
|
+
const { origin, top, left, right, surchargeReadOnly = false } = props;
|
|
65
65
|
const leftRef = (0, import_react.useRef)(left.input.default || 0);
|
|
66
66
|
const rightRef = (0, import_react.useRef)(right.input.default || 0);
|
|
67
67
|
const [statusOrigin, setStatusOrigin] = (0, import_react.useState)(origin.input.defaultValue);
|
|
@@ -70,12 +70,15 @@ var surcharge_default = (props) => {
|
|
|
70
70
|
const { store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
71
71
|
const symbol = ((_d = (_c = (_b = store == null ? void 0 : store.getState) == null ? void 0 : _b.call(store)) == null ? void 0 : _c.global) == null ? void 0 : _d.symbol) || "$";
|
|
72
72
|
const onValueChange = (e) => {
|
|
73
|
+
if (surchargeReadOnly) return;
|
|
73
74
|
setStatus(e.target.value);
|
|
74
75
|
};
|
|
75
76
|
const onChangeRate = (val) => {
|
|
77
|
+
if (surchargeReadOnly) return;
|
|
76
78
|
leftRef.current = val;
|
|
77
79
|
};
|
|
78
80
|
const onChangeMoney = (val) => {
|
|
81
|
+
if (surchargeReadOnly) return;
|
|
79
82
|
rightRef.current = val;
|
|
80
83
|
};
|
|
81
84
|
return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__pos_sur_box" }, /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -89,24 +92,52 @@ var surcharge_default = (props) => {
|
|
|
89
92
|
/* @__PURE__ */ import_react.default.createElement(
|
|
90
93
|
import_antd.Radio.Group,
|
|
91
94
|
{
|
|
95
|
+
disabled: surchargeReadOnly,
|
|
92
96
|
value: origin.input.defaultValue,
|
|
93
97
|
onChange: (e) => {
|
|
98
|
+
if (surchargeReadOnly) return;
|
|
94
99
|
setStatusOrigin(e.target.value);
|
|
95
100
|
}
|
|
96
101
|
},
|
|
97
102
|
/* @__PURE__ */ import_react.default.createElement(import_antd.Space, { direction: "vertical" }, origin.input.options.map((item) => {
|
|
98
103
|
if (typeof item === "object") {
|
|
99
104
|
const { label, value, ...other } = item;
|
|
100
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
105
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
106
|
+
import_antd.Radio,
|
|
107
|
+
{
|
|
108
|
+
...other,
|
|
109
|
+
disabled: surchargeReadOnly || other.disabled,
|
|
110
|
+
value,
|
|
111
|
+
key: `${item.value}`
|
|
112
|
+
},
|
|
113
|
+
label
|
|
114
|
+
);
|
|
101
115
|
}
|
|
102
116
|
}))
|
|
103
117
|
)
|
|
104
|
-
), /* @__PURE__ */ import_react.default.createElement("div", { style: { display: statusOrigin ? "none" : "contents" } }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { label: top.label, name: top.name, rules: top.rules || [], style: top.style || {} }, /* @__PURE__ */ import_react.default.createElement(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
), /* @__PURE__ */ import_react.default.createElement("div", { style: { display: statusOrigin ? "none" : "contents" } }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { label: top.label, name: top.name, rules: top.rules || [], style: top.style || {} }, /* @__PURE__ */ import_react.default.createElement(
|
|
119
|
+
import_antd.Radio.Group,
|
|
120
|
+
{
|
|
121
|
+
disabled: surchargeReadOnly,
|
|
122
|
+
value: top.input.defaultValue,
|
|
123
|
+
onChange: onValueChange
|
|
124
|
+
},
|
|
125
|
+
/* @__PURE__ */ import_react.default.createElement(import_antd.Space, { direction: "vertical" }, top.input.options.map((item) => {
|
|
126
|
+
if (typeof item === "object") {
|
|
127
|
+
const { label, value, ...other } = item;
|
|
128
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
129
|
+
import_antd.Radio,
|
|
130
|
+
{
|
|
131
|
+
...other,
|
|
132
|
+
disabled: surchargeReadOnly || other.disabled,
|
|
133
|
+
value,
|
|
134
|
+
key: `${item.value}`
|
|
135
|
+
},
|
|
136
|
+
label
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}))
|
|
140
|
+
)), status ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__pos_row" }, /* @__PURE__ */ import_react.default.createElement(
|
|
110
141
|
import_antd.Form.Item,
|
|
111
142
|
{
|
|
112
143
|
label: left.label,
|
|
@@ -117,6 +148,7 @@ var surcharge_default = (props) => {
|
|
|
117
148
|
/* @__PURE__ */ import_react.default.createElement(
|
|
118
149
|
import_antd.InputNumber,
|
|
119
150
|
{
|
|
151
|
+
disabled: surchargeReadOnly,
|
|
120
152
|
min: 0,
|
|
121
153
|
max: 100,
|
|
122
154
|
precision: 2,
|
|
@@ -137,6 +169,7 @@ var surcharge_default = (props) => {
|
|
|
137
169
|
/* @__PURE__ */ import_react.default.createElement(
|
|
138
170
|
import_antd.InputNumber,
|
|
139
171
|
{
|
|
172
|
+
disabled: surchargeReadOnly,
|
|
140
173
|
min: 0,
|
|
141
174
|
max: 1e5,
|
|
142
175
|
precision: 2,
|