@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
|
@@ -513,6 +513,19 @@ var formatProducts = function formatProducts(item, quantity) {
|
|
|
513
513
|
// 非手动折扣
|
|
514
514
|
var notManualDiscount = discount_list.filter(function (item) {
|
|
515
515
|
return item.type !== 'product';
|
|
516
|
+
}).map(function (discount) {
|
|
517
|
+
var _discount$metadata, _discount$metadata$nu, _discount$metadata2;
|
|
518
|
+
// 预约按份拆成 num=1 提交时,主商品扣次也要按当前提交数量拆分。
|
|
519
|
+
if (quantity === undefined || (discount.tag || discount.type) !== 'entitlement_pass' || (_discount$metadata = discount.metadata) !== null && _discount$metadata !== void 0 && _discount$metadata.custom_product_bundle_map_id) {
|
|
520
|
+
return discount;
|
|
521
|
+
}
|
|
522
|
+
var num = Math.min(Number((_discount$metadata$nu = (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.num) !== null && _discount$metadata$nu !== void 0 ? _discount$metadata$nu : item._extend.quantity), quantity);
|
|
523
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
524
|
+
_num: num,
|
|
525
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
526
|
+
num: num
|
|
527
|
+
})
|
|
528
|
+
});
|
|
516
529
|
});
|
|
517
530
|
if (item.isCustomItem) {
|
|
518
531
|
item.product_id = 0;
|
|
@@ -107,6 +107,14 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
107
107
|
changeCustomerToGlobalState: changeCustomerToGlobalState
|
|
108
108
|
}),
|
|
109
109
|
selectCustomer = _useCustomer.selectCustomer;
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
var _shopDiscount$setEnti;
|
|
112
|
+
shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$setEnti = shopDiscount.setEntitlementPassEnabled) === null || _shopDiscount$setEnti === void 0 || _shopDiscount$setEnti.call(shopDiscount, isBooking4Shop);
|
|
113
|
+
return function () {
|
|
114
|
+
var _shopDiscount$setEnti2;
|
|
115
|
+
return shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$setEnti2 = shopDiscount.setEntitlementPassEnabled) === null || _shopDiscount$setEnti2 === void 0 ? void 0 : _shopDiscount$setEnti2.call(shopDiscount, false);
|
|
116
|
+
};
|
|
117
|
+
}, [shopDiscount, isBooking4Shop]);
|
|
110
118
|
|
|
111
119
|
// 设置client
|
|
112
120
|
useDebounceEffect(function () {
|
|
@@ -354,11 +362,42 @@ var VoucherCard = function VoucherCard(props) {
|
|
|
354
362
|
if (!isBooking4Shop) return [];
|
|
355
363
|
return discountList.filter(function (item) {
|
|
356
364
|
return !!item.isAvailable;
|
|
357
|
-
}).
|
|
358
|
-
|
|
359
|
-
|
|
365
|
+
}).flatMap(function (discount) {
|
|
366
|
+
var _discount$appliedProd, _discount$committedAp, _discount$applicableP;
|
|
367
|
+
var currentRow = _objectSpread(_objectSpread({}, discount), {}, {
|
|
368
|
+
// 原卡片仍读取 isSelected,历史扣次不代表本次勾选。
|
|
369
|
+
isSelected: discount.tag === 'entitlement_pass' && !discount.isDisabled ? !!discount.isSelected && (((_discount$appliedProd = discount.appliedProductDetails) === null || _discount$appliedProd === void 0 ? void 0 : _discount$appliedProd.length) || 0) > (((_discount$committedAp = discount.committedAppliedProductDetails) === null || _discount$committedAp === void 0 ? void 0 : _discount$committedAp.length) || 0) : discount.isSelected,
|
|
370
|
+
isDisabled: discount.isDisabled || (discount.tag === 'entitlement_pass' ? !discount.isAvailable : discount.isDisabledForProductUsed) || disabled,
|
|
360
371
|
savedAmount: shopDiscount.calcDiscountApplicableProductTotalPrice(discount)
|
|
361
372
|
});
|
|
373
|
+
var committedDetails = discount.tag === 'entitlement_pass' ? discount.committedAppliedProductDetails || [] : [];
|
|
374
|
+
if (!committedDetails.length) return [currentRow];
|
|
375
|
+
|
|
376
|
+
// 历史抵扣独立展示;卡的次数配置只影响本次使用,不影响上次结算记录。
|
|
377
|
+
var historyRow = _objectSpread(_objectSpread({}, discount), {}, {
|
|
378
|
+
displayKey: "".concat(discount.id, "-last-settlement"),
|
|
379
|
+
isEditMode: true,
|
|
380
|
+
isSelected: true,
|
|
381
|
+
isDisabled: true,
|
|
382
|
+
appliedProductDetails: committedDetails,
|
|
383
|
+
savedAmount: shopDiscount.calcDiscountApplicableProductTotalPrice(_objectSpread(_objectSpread({}, discount), {}, {
|
|
384
|
+
savedAmount: 0,
|
|
385
|
+
appliedProductDetails: committedDetails
|
|
386
|
+
}))
|
|
387
|
+
});
|
|
388
|
+
// Rules 返回的 appliedProductDetails 按“历史抵扣 + 本次抵扣”排列。
|
|
389
|
+
var currentDetails = (discount.appliedProductDetails || []).slice(committedDetails.length);
|
|
390
|
+
var canApplyToNewProducts = !discount.isDisabled && (((_discount$applicableP = discount.applicableProductDetails) === null || _discount$applicableP === void 0 ? void 0 : _discount$applicableP.length) || 0) > 0;
|
|
391
|
+
if (!currentDetails.length && !canApplyToNewProducts) return [historyRow];
|
|
392
|
+
return [historyRow, _objectSpread(_objectSpread({}, currentRow), {}, {
|
|
393
|
+
displayKey: "".concat(discount.id, "-current"),
|
|
394
|
+
isEditMode: false,
|
|
395
|
+
appliedProductDetails: currentDetails,
|
|
396
|
+
savedAmount: shopDiscount.calcDiscountApplicableProductTotalPrice(_objectSpread(_objectSpread({}, discount), {}, {
|
|
397
|
+
savedAmount: 0,
|
|
398
|
+
appliedProductDetails: currentDetails
|
|
399
|
+
}))
|
|
400
|
+
})];
|
|
362
401
|
});
|
|
363
402
|
}, [discountList, isBooking4Shop, disabled]);
|
|
364
403
|
if (!isBooking4Shop) return null;
|
|
@@ -52,7 +52,7 @@ var useClientFn = function useClientFn(_params) {
|
|
|
52
52
|
num: 5,
|
|
53
53
|
total: 0,
|
|
54
54
|
search: '',
|
|
55
|
-
with: ['
|
|
55
|
+
with: ['contactsInfo'],
|
|
56
56
|
relation_form_id: state === null || state === void 0 || (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.config) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.basic) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.appointment_subject) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.form_id
|
|
57
57
|
}),
|
|
58
58
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
@@ -76,6 +76,7 @@ var useClientFn = function useClientFn(_params) {
|
|
|
76
76
|
}, [(_state$client$value2 = state.client.value) === null || _state$client$value2 === void 0 ? void 0 : _state$client$value2.id]);
|
|
77
77
|
var getClients = /*#__PURE__*/function () {
|
|
78
78
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, returnResult) {
|
|
79
|
+
var _state$bookingConfig4;
|
|
79
80
|
var customer_id, customer_ids, resetParams, _setLoading, _state$client, api, withKey, data, list, _payload, customerItem, totalList;
|
|
80
81
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
81
82
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -109,17 +110,19 @@ var useClientFn = function useClientFn(_params) {
|
|
|
109
110
|
abort: true
|
|
110
111
|
}
|
|
111
112
|
} : {}), {}, {
|
|
112
|
-
with: withKey
|
|
113
|
+
with: withKey,
|
|
114
|
+
with_form_records: 1,
|
|
115
|
+
relation_form_id: state === null || state === void 0 || (_state$bookingConfig4 = state.bookingConfig) === null || _state$bookingConfig4 === void 0 || (_state$bookingConfig4 = _state$bookingConfig4.config) === null || _state$bookingConfig4 === void 0 || (_state$bookingConfig4 = _state$bookingConfig4.basic) === null || _state$bookingConfig4 === void 0 || (_state$bookingConfig4 = _state$bookingConfig4.appointment_subject) === null || _state$bookingConfig4 === void 0 ? void 0 : _state$bookingConfig4.form_id
|
|
113
116
|
}));
|
|
114
117
|
case 8:
|
|
115
118
|
data = _context.sent;
|
|
116
119
|
list = ((data === null || data === void 0 ? void 0 : data.list) || []).map(function (d) {
|
|
117
|
-
var _d$
|
|
120
|
+
var _d$form_record_list;
|
|
118
121
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
119
122
|
name: getNickname(d),
|
|
120
123
|
id: d.franchisee_customer_id || d.id,
|
|
121
|
-
form_record: ((_d$
|
|
122
|
-
return _objectSpread(_objectSpread(_objectSpread({}, item), item
|
|
124
|
+
form_record: ((_d$form_record_list = d.form_record_list) === null || _d$form_record_list === void 0 ? void 0 : _d$form_record_list.map(function (item) {
|
|
125
|
+
return _objectSpread(_objectSpread(_objectSpread({}, item.data), item), {}, {
|
|
123
126
|
form_record_id: item.id
|
|
124
127
|
});
|
|
125
128
|
})) || []
|
|
@@ -262,7 +262,7 @@ var VerticalClient = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
262
262
|
case 7:
|
|
263
263
|
_context.next = 9;
|
|
264
264
|
return getClients({
|
|
265
|
-
with: ['
|
|
265
|
+
with: ['contactsInfo'],
|
|
266
266
|
relation_form_id: boardConfig === null || boardConfig === void 0 ? void 0 : boardConfig.form_id,
|
|
267
267
|
skip: 1,
|
|
268
268
|
num: 20,
|
|
@@ -41,7 +41,7 @@ import { editSessionProduct } from "../../../info/utils";
|
|
|
41
41
|
import { deleteCacheParams, getDays, getProductOriginTotalPrice, getProductTotalPrice, getServiceTimes, isSessionProduct, isWalkIn } from "../../../utils";
|
|
42
42
|
import { getErrorList, getIsNoSpecAndPackage } from "../../utilsByBooking";
|
|
43
43
|
import { formatResources, getDurationProps, getFlexibleOption, getMultiDay, getTimeObj, setDefaultCapacitys } from "../addService/utils";
|
|
44
|
-
import { getProductAllDiscountList, mergeBundleWithOriginalPrice, setProductPrice } from "./utils";
|
|
44
|
+
import { getProductAllDiscountList, hasEntitlementDiscount, mergeBundleWithOriginalPrice, setProductPrice, updateEntitlementQuantity } from "./utils";
|
|
45
45
|
import NoteModal from "../../../../../plus/noteModal";
|
|
46
46
|
import { DiscountKeyboard } from "../../../../../pro/priceKeyboard";
|
|
47
47
|
import EditTabs from "../../../info/service/editService/EditTabs";
|
|
@@ -91,6 +91,7 @@ var Info = function Info(_, ref) {
|
|
|
91
91
|
var resourcesRef = useRef(null);
|
|
92
92
|
var isChangeTotal = useRef(false);
|
|
93
93
|
var shouldReallocateBundlePriceRef = useRef(false);
|
|
94
|
+
var isEntitlementPrice = hasEntitlementDiscount(state.service.cacheItem);
|
|
94
95
|
var _useState3 = useState(false),
|
|
95
96
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
96
97
|
noteModalOpen = _useState4[0],
|
|
@@ -322,7 +323,7 @@ var Info = function Info(_, ref) {
|
|
|
322
323
|
* @Date: 2024-01-09 14:04
|
|
323
324
|
*/
|
|
324
325
|
var onFinish = function onFinish(values, cacheItem) {
|
|
325
|
-
var _resourcesRef$current, _item$_extend, _item$_extend2, _item$_extend3, _item$_extend4, _item2, _item3, _item$_extend5, _state$service$cacheI3, _window$closeBookingE2, _window2;
|
|
326
|
+
var _resourcesRef$current, _item$_extend, _list$find, _previousItem$_extend, _item$_extend2, _item$_extend3, _item$_extend4, _item2, _item3, _item$_extend5, _state$service$cacheI3, _window$closeBookingE2, _window2;
|
|
326
327
|
var isSuccess = (_resourcesRef$current = resourcesRef.current) === null || _resourcesRef$current === void 0 ? void 0 : _resourcesRef$current.check();
|
|
327
328
|
if (isShowTimeAndResource && !isSuccess) {
|
|
328
329
|
return;
|
|
@@ -362,7 +363,8 @@ var Info = function Info(_, ref) {
|
|
|
362
363
|
_extend.startDate = startDate;
|
|
363
364
|
_extend.endDate = endDate;
|
|
364
365
|
}
|
|
365
|
-
var
|
|
366
|
+
var isManualPriceChange = isChangeTotal.current && !hasEntitlementDiscount(_item);
|
|
367
|
+
var shouldReallocatePrice = isManualPriceChange || shouldReallocateBundlePriceRef.current;
|
|
366
368
|
if (shouldReallocatePrice) {
|
|
367
369
|
var _extend$other, _extend$other2;
|
|
368
370
|
// 计算折扣比例
|
|
@@ -394,9 +396,16 @@ var Info = function Info(_, ref) {
|
|
|
394
396
|
_item._time = new Date().getTime();
|
|
395
397
|
_item._serviceKey = genServiceKey(_item);
|
|
396
398
|
_item._holderKey = genHolderKey(_item);
|
|
399
|
+
var previousItem = (_list$find = _list.find(function (item) {
|
|
400
|
+
return item._id === _item._id;
|
|
401
|
+
})) !== null && _list$find !== void 0 ? _list$find : _list.find(function (item) {
|
|
402
|
+
return isSameBookingServiceItem(item, _item);
|
|
403
|
+
});
|
|
404
|
+
var isEntitlementQuantityChange = hasEntitlementDiscount(previousItem) && Number(_item._extend.quantity || 1) !== Number((previousItem === null || previousItem === void 0 || (_previousItem$_extend = previousItem._extend) === null || _previousItem$_extend === void 0 ? void 0 : _previousItem$_extend.quantity) || 1);
|
|
397
405
|
// 如果holder 有多个,则需要拆分多个商品
|
|
398
406
|
// 另外一个情况 如果商品数量有多个,holder 数量小于商品数量也需要拆分
|
|
399
|
-
|
|
407
|
+
// 多次卡改量由 updateEntitlementQuantity 拆分,避免复制历史扣次。
|
|
408
|
+
if (!isEntitlementQuantityChange && (((_item$_extend2 = _item._extend) === null || _item$_extend2 === void 0 || (_item$_extend2 = _item$_extend2.holder_id) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.length) > 1 || ((_item$_extend3 = _item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.quantity) > 1 && ((_item$_extend4 = _item._extend) === null || _item$_extend4 === void 0 || (_item$_extend4 = _item$_extend4.holder_id) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.length) >= 1)) {
|
|
400
409
|
var holder_ids = _item._extend.holder_id;
|
|
401
410
|
_item._extend.holder_id = holder_ids[0];
|
|
402
411
|
holder_ids = holder_ids.slice(1);
|
|
@@ -465,10 +474,16 @@ var Info = function Info(_, ref) {
|
|
|
465
474
|
_item = deleteDiscountList(_item, true);
|
|
466
475
|
}
|
|
467
476
|
if (matchById) {
|
|
468
|
-
_list = _list.
|
|
469
|
-
|
|
477
|
+
_list = _list.flatMap(function (d) {
|
|
478
|
+
if (d._id !== _id) return [d];
|
|
479
|
+
return updateEntitlementQuantity(d, _objectSpread(_objectSpread({}, _item), {}, {
|
|
470
480
|
new: 0
|
|
471
|
-
})
|
|
481
|
+
})).map(function (item) {
|
|
482
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
483
|
+
_serviceKey: genServiceKey(item),
|
|
484
|
+
_holderKey: genHolderKey(item)
|
|
485
|
+
});
|
|
486
|
+
});
|
|
472
487
|
});
|
|
473
488
|
} else {
|
|
474
489
|
// fallback:合并同预约重复项,沿用 list 内 _id 避免再次失配
|
|
@@ -476,10 +491,15 @@ var Info = function Info(_, ref) {
|
|
|
476
491
|
_list = _list.reduce(function (acc, d) {
|
|
477
492
|
if (isSameBookingServiceItem(d, _item)) {
|
|
478
493
|
if (!replaced) {
|
|
479
|
-
acc.push(_objectSpread(_objectSpread({}, _item), {}, {
|
|
494
|
+
acc.push.apply(acc, _toConsumableArray(updateEntitlementQuantity(d, _objectSpread(_objectSpread({}, _item), {}, {
|
|
480
495
|
new: 0,
|
|
481
496
|
_id: d._id
|
|
482
|
-
}))
|
|
497
|
+
})).map(function (item) {
|
|
498
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
499
|
+
_serviceKey: genServiceKey(item),
|
|
500
|
+
_holderKey: genHolderKey(item)
|
|
501
|
+
});
|
|
502
|
+
})));
|
|
483
503
|
replaced = true;
|
|
484
504
|
}
|
|
485
505
|
} else {
|
|
@@ -952,7 +972,7 @@ var Info = function Info(_, ref) {
|
|
|
952
972
|
precision: 2,
|
|
953
973
|
prefix: state.amountSymbol,
|
|
954
974
|
onChange: handleTotalChange,
|
|
955
|
-
disabled: state.channelDisabledEdit,
|
|
975
|
+
disabled: state.channelDisabledEdit || isEntitlementPrice,
|
|
956
976
|
originalValue: ((_state$service$cacheI10 = state.service.cacheItem) === null || _state$service$cacheI10 === void 0 || (_state$service$cacheI10 = _state$service$cacheI10._extend) === null || _state$service$cacheI10 === void 0 ? void 0 : _state$service$cacheI10.origin_total) || 0,
|
|
957
977
|
placeholder: ((_state$service$cacheI11 = state.service.cacheItem) === null || _state$service$cacheI11 === void 0 || (_state$service$cacheI11 = _state$service$cacheI11._extend) === null || _state$service$cacheI11 === void 0 ? void 0 : _state$service$cacheI11.origin_total) || '0',
|
|
958
978
|
size: "large",
|
|
@@ -963,7 +983,7 @@ var Info = function Info(_, ref) {
|
|
|
963
983
|
selectType: 'dark'
|
|
964
984
|
}
|
|
965
985
|
})));
|
|
966
|
-
}, [useTotal, (_state$service$cacheI12 = state.service.cacheItem) === null || _state$service$cacheI12 === void 0 || (_state$service$cacheI12 = _state$service$cacheI12._extend) === null || _state$service$cacheI12 === void 0 ? void 0 : _state$service$cacheI12.origin_total, state.amountSymbol, state.channelDisabledEdit]);
|
|
986
|
+
}, [useTotal, (_state$service$cacheI12 = state.service.cacheItem) === null || _state$service$cacheI12 === void 0 || (_state$service$cacheI12 = _state$service$cacheI12._extend) === null || _state$service$cacheI12 === void 0 ? void 0 : _state$service$cacheI12.origin_total, state.amountSymbol, state.channelDisabledEdit, isEntitlementPrice]);
|
|
967
987
|
var reason = useMemo(function () {
|
|
968
988
|
return isReason ? /*#__PURE__*/React.createElement(Col, {
|
|
969
989
|
span: 24
|
|
@@ -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;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
2
7
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
10
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
11
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
/**
|
|
14
14
|
1. 在进入编辑服务前
|
|
15
15
|
|
|
@@ -20,16 +20,125 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
20
20
|
判断是否需要进入编辑服务页
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import { isArr } from "@pisell/utils";
|
|
24
|
-
import { isBoolean } from "@pisell/utils";
|
|
23
|
+
import { getUniqueId, isArr, isBoolean } from "@pisell/utils";
|
|
25
24
|
import Decimal from "decimal.js";
|
|
25
|
+
import { cloneDeep } from 'lodash';
|
|
26
26
|
import { getBundleDiscountList } from "../../../components/footer/utils";
|
|
27
|
+
import { getMainPrice, getProductTotalPrice } from "../../../utils";
|
|
28
|
+
var isEntitlementDiscount = function isEntitlementDiscount(discount) {
|
|
29
|
+
return ((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type)) === 'entitlement_pass';
|
|
30
|
+
};
|
|
31
|
+
var getServiceDiscounts = function getServiceDiscounts(item) {
|
|
32
|
+
var _item$_extend;
|
|
33
|
+
return [].concat(_toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []), _toConsumableArray(((item === null || item === void 0 || (_item$_extend = item._extend) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.other) === null || _item$_extend === void 0 ? void 0 : _item$_extend.bundle) || []).flatMap(function (bundle) {
|
|
34
|
+
return bundle.discount_list || [];
|
|
35
|
+
})));
|
|
36
|
+
};
|
|
37
|
+
export var hasEntitlementDiscount = function hasEntitlementDiscount(item) {
|
|
38
|
+
return getServiceDiscounts(item).some(isEntitlementDiscount);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** 已提交部分保留原扣次;增加的数量作为新商品交给 OS 重新计算。 */
|
|
42
|
+
export var updateEntitlementQuantity = function updateEntitlementQuantity(previous, next) {
|
|
43
|
+
var _previous$_extend, _previous$_extend2, _previous$_extend3;
|
|
44
|
+
var discounts = getServiceDiscounts(previous);
|
|
45
|
+
var persisted = [previous === null || previous === void 0 ? void 0 : previous.booking_id, previous === null || previous === void 0 ? void 0 : previous.order_detail_id, previous === null || previous === void 0 || (_previous$_extend = previous._extend) === null || _previous$_extend === void 0 ? void 0 : _previous$_extend.order_detail_id].some(function (value) {
|
|
46
|
+
return Number(value) > 0;
|
|
47
|
+
}) || discounts.some(function (discount) {
|
|
48
|
+
return isEntitlementDiscount(discount) && discount.id;
|
|
49
|
+
});
|
|
50
|
+
var previousQuantity = Number((previous === null || previous === void 0 || (_previous$_extend2 = previous._extend) === null || _previous$_extend2 === void 0 ? void 0 : _previous$_extend2.quantity) || 1);
|
|
51
|
+
var nextQuantity = Number(next._extend.quantity || 1);
|
|
52
|
+
if (!persisted || !hasEntitlementDiscount(previous) || nextQuantity === previousQuantity) {
|
|
53
|
+
return [next];
|
|
54
|
+
}
|
|
55
|
+
if (nextQuantity < previousQuantity) {
|
|
56
|
+
// 商品弹窗会重算原价;历史行减量只调整数量,沿用已提交的价格和商品配置。
|
|
57
|
+
return [_objectSpread(_objectSpread({}, previous), {}, {
|
|
58
|
+
_extend: _objectSpread(_objectSpread(_objectSpread({}, previous._extend), {}, {
|
|
59
|
+
quantity: nextQuantity
|
|
60
|
+
}, Array.isArray(next._extend.holder_id) ? {
|
|
61
|
+
holder_id: next._extend.holder_id.slice(0, nextQuantity)
|
|
62
|
+
} : {}), {}, {
|
|
63
|
+
other: _objectSpread(_objectSpread({}, previous._extend.other), {}, {
|
|
64
|
+
quantity: nextQuantity
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
discount_list: (previous.discount_list || []).map(function (discount) {
|
|
68
|
+
var _discount$metadata, _discount$metadata$nu, _discount$metadata2;
|
|
69
|
+
// 套餐扣次是每份主商品中的子商品次数,不能按主商品数量裁剪。
|
|
70
|
+
if (!isEntitlementDiscount(discount) || (_discount$metadata = discount.metadata) !== null && _discount$metadata !== void 0 && _discount$metadata.custom_product_bundle_map_id) return discount;
|
|
71
|
+
var num = Math.min(Number((_discount$metadata$nu = (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.num) !== null && _discount$metadata$nu !== void 0 ? _discount$metadata$nu : previousQuantity), nextQuantity);
|
|
72
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
73
|
+
_num: num,
|
|
74
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
75
|
+
num: num
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
})
|
|
79
|
+
})];
|
|
80
|
+
}
|
|
81
|
+
var appended = cloneDeep(next);
|
|
82
|
+
var uid = 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 = _objectSpread(_objectSpread({}, appended.metadata), {}, {
|
|
90
|
+
unique_identification_number: uid
|
|
91
|
+
});
|
|
92
|
+
delete appended.metadata.entitlement_source_identity;
|
|
93
|
+
delete appended.metadata.entitlement_source_product_uid;
|
|
94
|
+
if (appended._origin) delete appended._origin.booking_id;
|
|
95
|
+
var extend = appended._extend;
|
|
96
|
+
extend.order_detail_id = 0;
|
|
97
|
+
extend.unique_identification_number = uid;
|
|
98
|
+
extend.quantity = nextQuantity - previousQuantity;
|
|
99
|
+
if (Array.isArray(extend.holder_id)) {
|
|
100
|
+
var holders = extend.holder_id.slice(previousQuantity, nextQuantity);
|
|
101
|
+
extend.holder_id = holders.length ? holders : undefined;
|
|
102
|
+
}
|
|
103
|
+
extend.other = _objectSpread(_objectSpread({}, extend.other), {}, {
|
|
104
|
+
quantity: extend.quantity
|
|
105
|
+
});
|
|
106
|
+
extend.other.bundle = (extend.other.bundle || []).map(function (bundle) {
|
|
107
|
+
var _ref, _ref2, _bundle$original_pric, _bundle$discount_list;
|
|
108
|
+
var price = (_ref = (_ref2 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : (_bundle$discount_list = bundle.discount_list) === null || _bundle$discount_list === void 0 || (_bundle$discount_list = _bundle$discount_list[0]) === null || _bundle$discount_list === void 0 || (_bundle$discount_list = _bundle$discount_list.discount) === null || _bundle$discount_list === void 0 ? void 0 : _bundle$discount_list.original_amount) !== null && _ref2 !== void 0 ? _ref2 : bundle.product_price) !== null && _ref !== void 0 ? _ref : bundle.price;
|
|
109
|
+
var bundleUid = getUniqueId();
|
|
110
|
+
var metadata = _objectSpread(_objectSpread({}, bundle.metadata), {}, {
|
|
111
|
+
custom_product_bundle_map_id: bundleUid,
|
|
112
|
+
unique_identification_number: bundleUid
|
|
113
|
+
});
|
|
114
|
+
delete metadata.entitlement_source_identity;
|
|
115
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
116
|
+
_id: bundleUid,
|
|
117
|
+
price: price,
|
|
118
|
+
bundle_selling_price: price,
|
|
119
|
+
discount_list: [],
|
|
120
|
+
metadata: metadata
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
var mainDiscount = (next.discount_list || []).find(function (discount) {
|
|
124
|
+
var _discount$metadata3, _discount$discount;
|
|
125
|
+
return !((_discount$metadata3 = discount.metadata) !== null && _discount$metadata3 !== void 0 && _discount$metadata3.custom_product_bundle_map_id) && ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.original_amount) != null;
|
|
126
|
+
});
|
|
127
|
+
if (mainDiscount && (previous === null || previous === void 0 || (_previous$_extend3 = previous._extend) === null || _previous$_extend3 === void 0 || (_previous$_extend3 = _previous$_extend3.other) === null || _previous$_extend3 === void 0 ? void 0 : _previous$_extend3.product_variant_id) === extend.other.product_variant_id) {
|
|
128
|
+
extend.price = Number(mainDiscount.discount.original_amount);
|
|
129
|
+
if (extend.other.product_variant_id) extend.other.price = extend.price;
|
|
130
|
+
}
|
|
131
|
+
extend.main_product_selling_price = getMainPrice(appended);
|
|
132
|
+
extend.total = getProductTotalPrice(appended);
|
|
133
|
+
extend.origin_total = extend.total;
|
|
134
|
+
return [previous, appended];
|
|
135
|
+
};
|
|
27
136
|
var isNewService = function isNewService(service) {
|
|
28
137
|
return !service.new && service._extend.endDate;
|
|
29
138
|
};
|
|
30
|
-
var init = function init(
|
|
31
|
-
var cacheItem =
|
|
32
|
-
state =
|
|
139
|
+
var init = function init(_ref3) {
|
|
140
|
+
var cacheItem = _ref3.cacheItem,
|
|
141
|
+
state = _ref3.state;
|
|
33
142
|
var _cacheItem = _objectSpread({}, cacheItem);
|
|
34
143
|
var renderData = {};
|
|
35
144
|
var _extend = {};
|
|
@@ -74,11 +183,11 @@ export var setAutoAllocationStorage = function setAutoAllocationStorage(data) {
|
|
|
74
183
|
* @param newTotal - 折扣后的新总价
|
|
75
184
|
* @param origin_total - 原始总价
|
|
76
185
|
*/
|
|
77
|
-
export var setProductPrice = function setProductPrice(cacheItem,
|
|
78
|
-
var _cacheItem$
|
|
79
|
-
var newTotal =
|
|
80
|
-
origin_total =
|
|
81
|
-
if (
|
|
186
|
+
export var setProductPrice = function setProductPrice(cacheItem, _ref4) {
|
|
187
|
+
var _cacheItem$_extend$ot, _cacheItem$_extend$ot2, _cacheItem$_extend$ot4, _cacheItem$_extend$ot5;
|
|
188
|
+
var newTotal = _ref4.newTotal,
|
|
189
|
+
origin_total = _ref4.origin_total;
|
|
190
|
+
if (hasEntitlementDiscount(cacheItem) || ((cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.discount_list) || []).some(function (item) {
|
|
82
191
|
return ['good_pass', 'discount_card', 'product_discount_card'].includes(item.type);
|
|
83
192
|
})) {
|
|
84
193
|
return cacheItem;
|
|
@@ -97,12 +206,12 @@ export var setProductPrice = function setProductPrice(cacheItem, _ref2) {
|
|
|
97
206
|
if ((_cacheItem$_extend$ot = cacheItem._extend.other) !== null && _cacheItem$_extend$ot !== void 0 && _cacheItem$_extend$ot.bundle && isArr((_cacheItem$_extend$ot2 = cacheItem._extend.other) === null || _cacheItem$_extend$ot2 === void 0 ? void 0 : _cacheItem$_extend$ot2.bundle)) {
|
|
98
207
|
var _cacheItem$_extend$ot3;
|
|
99
208
|
(_cacheItem$_extend$ot3 = cacheItem._extend.other) === null || _cacheItem$_extend$ot3 === void 0 || (_cacheItem$_extend$ot3 = _cacheItem$_extend$ot3.bundle) === null || _cacheItem$_extend$ot3 === void 0 || _cacheItem$_extend$ot3.forEach(function (bundle) {
|
|
100
|
-
var
|
|
209
|
+
var _ref5, _bundle$num;
|
|
101
210
|
// 计算新价格,直接截取两位小数(不四舍五入)
|
|
102
211
|
var newPrice = new Decimal(bundle.original_price || bundle.price).mul(discountRatio).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
|
|
103
212
|
|
|
104
213
|
// 获取数量,优先取 num,再取 quantity,默认为 1
|
|
105
|
-
var quantity = (
|
|
214
|
+
var quantity = (_ref5 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref5 !== void 0 ? _ref5 : 1;
|
|
106
215
|
|
|
107
216
|
// 累加到子商品总价
|
|
108
217
|
subTotal = subTotal.add(new Decimal(newPrice).mul(quantity));
|
|
@@ -116,12 +225,12 @@ export var setProductPrice = function setProductPrice(cacheItem, _ref2) {
|
|
|
116
225
|
if ((_cacheItem$_extend$ot4 = cacheItem._extend.other) !== null && _cacheItem$_extend$ot4 !== void 0 && _cacheItem$_extend$ot4.option && isArr((_cacheItem$_extend$ot5 = cacheItem._extend.other) === null || _cacheItem$_extend$ot5 === void 0 ? void 0 : _cacheItem$_extend$ot5.option)) {
|
|
117
226
|
var _cacheItem$_extend$ot6;
|
|
118
227
|
(_cacheItem$_extend$ot6 = cacheItem._extend.other) === null || _cacheItem$_extend$ot6 === void 0 || (_cacheItem$_extend$ot6 = _cacheItem$_extend$ot6.option) === null || _cacheItem$_extend$ot6 === void 0 || _cacheItem$_extend$ot6.forEach(function (option) {
|
|
119
|
-
var
|
|
228
|
+
var _ref6, _option$num;
|
|
120
229
|
// 计算新价格,直接截取两位小数(不四舍五入)
|
|
121
230
|
var newPrice = new Decimal(option.price).mul(discountRatio).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
|
|
122
231
|
|
|
123
232
|
// 获取数量,优先取 num,再取 quantity,默认为 1
|
|
124
|
-
var quantity = (
|
|
233
|
+
var quantity = (_ref6 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref6 !== void 0 ? _ref6 : 1;
|
|
125
234
|
|
|
126
235
|
// 累加到子商品总价
|
|
127
236
|
subTotal = subTotal.add(new Decimal(newPrice).mul(quantity));
|
|
@@ -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:
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
2
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
6
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
8
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
14
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -63,6 +64,28 @@ export var getDefaultValue = function getDefaultValue(list) {
|
|
|
63
64
|
}, {});
|
|
64
65
|
};
|
|
65
66
|
|
|
67
|
+
/** Preserve fee fields when saving unrelated device or merchant settings. */
|
|
68
|
+
export var preserveSurchargeValues = function preserveSurchargeValues(values, list) {
|
|
69
|
+
var result = _objectSpread({}, values);
|
|
70
|
+
var _iterator = _createForOfIteratorHelper(list),
|
|
71
|
+
_step;
|
|
72
|
+
try {
|
|
73
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
74
|
+
var item = _step.value;
|
|
75
|
+
if (Array.isArray(item.children) && item.children.length) {
|
|
76
|
+
result[item.__sourceName] = preserveSurchargeValues(values === null || values === void 0 ? void 0 : values[item.__sourceName], item.children);
|
|
77
|
+
} else if (item.Component === 'Surcharge') {
|
|
78
|
+
Object.assign(result, helpMapping.Surcharge.getCommDefaultVal(item));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (err) {
|
|
82
|
+
_iterator.e(err);
|
|
83
|
+
} finally {
|
|
84
|
+
_iterator.f();
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
};
|
|
88
|
+
|
|
66
89
|
/**
|
|
67
90
|
* @title: 构建通用表单配置信息,构建动态表单
|
|
68
91
|
* @description:
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Form, Button } from 'antd';
|
|
3
3
|
import { locales } from '@pisell/utils';
|
|
4
|
-
import { Eftpos, getDefaultValue } from "./const";
|
|
4
|
+
import { Eftpos, getDefaultValue, preserveSurchargeValues } from "./const";
|
|
5
5
|
import FormItem from "./form";
|
|
6
6
|
var Device = function Device(props) {
|
|
7
7
|
var onSave = props.onSave,
|
|
8
8
|
children = props.children,
|
|
9
|
-
formItemList = props.formItemList
|
|
9
|
+
formItemList = props.formItemList,
|
|
10
|
+
_props$surchargeReadO = props.surchargeReadOnly,
|
|
11
|
+
surchargeReadOnly = _props$surchargeReadO === void 0 ? false : _props$surchargeReadO;
|
|
10
12
|
var initialValues = getDefaultValue(formItemList);
|
|
11
13
|
var simpleCloudIntegrationSteps = locales.getText('page.eftpos.text.simple.cloud.integration.steps');
|
|
12
14
|
return /*#__PURE__*/React.createElement(React.Fragment, null, (props === null || props === void 0 ? void 0 : props.type) === Eftpos.MX51 && /*#__PURE__*/React.createElement("div", {
|
|
@@ -21,7 +23,9 @@ var Device = function Device(props) {
|
|
|
21
23
|
}, step);
|
|
22
24
|
})), /*#__PURE__*/React.createElement(Form, {
|
|
23
25
|
layout: "vertical",
|
|
24
|
-
onFinish:
|
|
26
|
+
onFinish: function onFinish(values) {
|
|
27
|
+
return onSave(surchargeReadOnly ? preserveSurchargeValues(values, formItemList) : values);
|
|
28
|
+
},
|
|
25
29
|
initialValues: initialValues,
|
|
26
30
|
className: "pisell-lowcode__pos-device"
|
|
27
31
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -31,7 +35,8 @@ var Device = function Device(props) {
|
|
|
31
35
|
padding: '0 0 60px 0'
|
|
32
36
|
}
|
|
33
37
|
}, /*#__PURE__*/React.createElement(FormItem, {
|
|
34
|
-
formItemList: formItemList
|
|
38
|
+
formItemList: formItemList,
|
|
39
|
+
surchargeReadOnly: surchargeReadOnly
|
|
35
40
|
}), children), /*#__PURE__*/React.createElement(Form.Item, {
|
|
36
41
|
className: "pisell-lowcode__pos-device-btn"
|
|
37
42
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
@@ -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 = {
|