@pisell/private-materials 3.4.8 → 3.4.10

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.
Files changed (78) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.js +4 -4
  6. package/build/lowcode/view.js +4 -4
  7. package/es/components/booking/components/customSelect/index.js +1 -0
  8. package/es/components/booking/forms/single/RenderValueById.js +2 -2
  9. package/es/components/booking/hooks/useClearCart.js +11 -8
  10. package/es/components/booking/hooks/useQuotation.js +1 -1
  11. package/es/components/booking/info/client/index.js +3 -2
  12. package/es/components/booking/info/dateRange/index.d.ts +1 -0
  13. package/es/components/booking/info/hooks/useInfoHolder.d.ts +1 -0
  14. package/es/components/booking/info/hooks/useInfoHolder.js +16 -9
  15. package/es/components/booking/info/service/Lists.d.ts +1 -0
  16. package/es/components/booking/info/service/Lists.js +36 -26
  17. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  18. package/es/components/booking/info/service/editService/BookingList/index.d.ts +1 -0
  19. package/es/components/booking/info/service2/Lists.d.ts +1 -0
  20. package/es/components/booking/info/service2/utils.js +20 -21
  21. package/es/components/booking/info/utils.js +1 -1
  22. package/es/components/booking/info2/index.js +1 -0
  23. package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
  24. package/es/components/booking/info2/service/addService/utils.js +8 -4
  25. package/es/components/booking/info2/service/addTimeModal/index.js +3 -0
  26. package/es/components/booking/info2/service/editService/Resources/index.js +5 -0
  27. package/es/components/booking/info2/service/editService/index.js +266 -170
  28. package/es/components/booking/info2/service/index.js +19 -15
  29. package/es/components/booking/info2/utilsByBooking.js +3 -2
  30. package/es/components/booking/materiels/duration/index.js +9 -2
  31. package/es/components/booking/materiels/holder/index.d.ts +1 -0
  32. package/es/components/booking/materiels/startTime/index.d.ts +1 -0
  33. package/es/components/booking/materiels/startTime/index.js +2 -2
  34. package/es/components/booking/utils.js +3 -3
  35. package/es/components/schedules/components/CurrentDay/index.d.ts +1 -0
  36. package/es/components/schedules/products/index.d.ts +1 -0
  37. package/es/components/shoppingCart/components/Cart/Product.js +48 -41
  38. package/es/components/shoppingCart/components/Cart/index.js +21 -18
  39. package/es/components/ticketBooking/components/addServiceVariant/addService.js +249 -158
  40. package/es/components/ticketBooking/components/timeBar/index.js +78 -71
  41. package/es/components/ticketBooking/utils/index.d.ts +2 -0
  42. package/es/components/ticketBooking/utils/index.js +18 -1
  43. package/lib/components/booking/components/customSelect/index.js +1 -0
  44. package/lib/components/booking/forms/single/RenderValueById.js +6 -6
  45. package/lib/components/booking/hooks/useClearCart.js +16 -13
  46. package/lib/components/booking/hooks/useQuotation.js +1 -1
  47. package/lib/components/booking/info/client/index.js +5 -4
  48. package/lib/components/booking/info/dateRange/index.d.ts +1 -0
  49. package/lib/components/booking/info/hooks/useInfoHolder.d.ts +1 -0
  50. package/lib/components/booking/info/hooks/useInfoHolder.js +10 -9
  51. package/lib/components/booking/info/service/Lists.d.ts +1 -0
  52. package/lib/components/booking/info/service/Lists.js +35 -23
  53. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  54. package/lib/components/booking/info/service/editService/BookingList/index.d.ts +1 -0
  55. package/lib/components/booking/info/service2/Lists.d.ts +1 -0
  56. package/lib/components/booking/info/service2/utils.js +17 -17
  57. package/lib/components/booking/info/utils.js +2 -1
  58. package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
  59. package/lib/components/booking/info2/service/addService/utils.js +7 -5
  60. package/lib/components/booking/info2/service/addTimeModal/index.js +3 -0
  61. package/lib/components/booking/info2/service/editService/Resources/index.js +2 -0
  62. package/lib/components/booking/info2/service/editService/index.js +139 -74
  63. package/lib/components/booking/info2/service/index.js +13 -9
  64. package/lib/components/booking/info2/utilsByBooking.js +4 -4
  65. package/lib/components/booking/materiels/duration/index.js +7 -2
  66. package/lib/components/booking/materiels/holder/index.d.ts +1 -0
  67. package/lib/components/booking/materiels/startTime/index.d.ts +1 -0
  68. package/lib/components/booking/materiels/startTime/index.js +1 -1
  69. package/lib/components/booking/utils.js +3 -3
  70. package/lib/components/schedules/components/CurrentDay/index.d.ts +1 -0
  71. package/lib/components/schedules/products/index.d.ts +1 -0
  72. package/lib/components/shoppingCart/components/Cart/Product.js +31 -21
  73. package/lib/components/shoppingCart/components/Cart/index.js +18 -15
  74. package/lib/components/ticketBooking/components/addServiceVariant/addService.js +196 -127
  75. package/lib/components/ticketBooking/components/timeBar/index.js +95 -88
  76. package/lib/components/ticketBooking/utils/index.d.ts +2 -0
  77. package/lib/components/ticketBooking/utils/index.js +22 -0
  78. package/package.json +4 -4
@@ -29,11 +29,11 @@ import { getProductDetail } from "../../../booking/info/service/serve";
29
29
  import { useService } from "../../../booking/info/service/serviceManager";
30
30
  import ProductSelect from "../../../productSelect";
31
31
  import "./index.less";
32
- import { addService, addServiceScroll, genServiceKey, getIsShowNumber } from "../../utils";
32
+ import { addService, addServiceScroll, createSimpleCacheItem, genServiceKey, getIsShowNumber, isSameProduct } from "../../utils";
33
33
  import NotAvailable from "../notAvailable";
34
34
  import dayjs from 'dayjs';
35
35
  var AddSerivce = function AddSerivce(props) {
36
- var _context$appHelper, _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _state$bookingConfig2, _state$client2, _state$service3, _state$service4;
36
+ var _context$appHelper, _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _state$bookingConfig2, _state$client2, _state$service3;
37
37
  var onEdit = props.onEdit,
38
38
  state = props.state,
39
39
  dispatch = props.dispatch,
@@ -63,6 +63,21 @@ var AddSerivce = function AddSerivce(props) {
63
63
  setCurrentProduct = _useState4[1];
64
64
  var stateRef = useRef(state);
65
65
  stateRef.current = state;
66
+
67
+ // 组件卸载时清理所有定时器
68
+ useEffect(function () {
69
+ return function () {
70
+ Object.values(debounceTimersRef.current).forEach(function (timer) {
71
+ if (timer) clearTimeout(timer);
72
+ });
73
+ debounceTimersRef.current = {};
74
+ };
75
+ }, []);
76
+
77
+ // 防抖相关的 refs
78
+ var pendingCacheValuesRef = useRef({});
79
+ var clickCountRef = useRef({});
80
+ var debounceTimersRef = useRef({});
66
81
  var menuList = useMemo(function () {
67
82
  var _state$bookingConfig;
68
83
  return (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.menu_list_tab) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.menu_list) || [];
@@ -257,6 +272,35 @@ var AddSerivce = function AddSerivce(props) {
257
272
  return _ref2.apply(this, arguments);
258
273
  };
259
274
  }();
275
+ var executeCacheValues = useMemoizedFn(function (productId, originalCacheValues, item, originalCallback) {
276
+ var clickCount = clickCountRef.current[productId] || 1;
277
+
278
+ // 更新 quantity 为累积的点击次数
279
+ var finalCacheValues = _objectSpread(_objectSpread({}, originalCacheValues), {}, {
280
+ quantity: clickCount
281
+ });
282
+
283
+ // 清理当前商品的缓存数据
284
+ delete pendingCacheValuesRef.current[productId];
285
+ delete clickCountRef.current[productId];
286
+ delete debounceTimersRef.current[productId];
287
+
288
+ // 执行原始的回调函数
289
+ originalCallback(finalCacheValues, '', item, true);
290
+ });
291
+
292
+ // 为每个商品单独创建防抖函数
293
+ var debouncedExecuteCacheValues = useMemoizedFn(function (productId, cacheValues, item, callback) {
294
+ // 清除该商品的旧定时器
295
+ if (debounceTimersRef.current[productId]) {
296
+ clearTimeout(debounceTimersRef.current[productId]);
297
+ }
298
+
299
+ // 创建新的防抖定时器
300
+ debounceTimersRef.current[productId] = setTimeout(function () {
301
+ executeCacheValues(productId, cacheValues, item, callback);
302
+ }, 0);
303
+ });
260
304
  var handleSelectProduct = useMemoizedFn(function (item) {
261
305
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
262
306
  var isSession = isSessionProduct(item);
@@ -264,10 +308,211 @@ var AddSerivce = function AddSerivce(props) {
264
308
  var isEject = getIsEject(item, type);
265
309
  var isOnlySession = getIsOnlySession(item);
266
310
  var lock = false;
311
+ // 对于不需要打开弹窗的商品, 直接模拟数据, 不走弹窗
312
+ var cacheValues = null;
267
313
  if (isEject) {
268
314
  setCurrentProduct(item);
269
315
  } else {
270
316
  setCurrentProduct(null);
317
+ if ((item === null || item === void 0 ? void 0 : item.extension_type) === 'normal') {
318
+ cacheValues = {
319
+ bundle: [],
320
+ key: item.id,
321
+ option: [],
322
+ product_id: item.id,
323
+ product_variant_id: 0,
324
+ quantity: 1,
325
+ rowKey: item.id,
326
+ session: null,
327
+ unique: '08974625397',
328
+ _originalItem: item // 保存原始商品信息
329
+ };
330
+ }
331
+ }
332
+ var callback = /*#__PURE__*/function () {
333
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e, extension_type, detail, notShowToast) {
334
+ var data, _detail, other, cacheItem, _total, _isEdit, _state$service$cacheI, _addService, _list, quantity, _Toast$success, _context$appHelper$ut4, _context$appHelper$ut5, val, sendData;
335
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
336
+ while (1) switch (_context3.prev = _context3.next) {
337
+ case 0:
338
+ setCurrentProduct(null);
339
+ // 防止选择商品弹窗多次触发callback
340
+ if (!lock) {
341
+ _context3.next = 3;
342
+ break;
343
+ }
344
+ return _context3.abrupt("return");
345
+ case 3:
346
+ lock = true;
347
+
348
+ // 2秒后解除
349
+ setTimeout(function () {
350
+ lock = false;
351
+ }, 2000);
352
+ if (isBooking4) {
353
+ _context3.next = 11;
354
+ break;
355
+ }
356
+ _context3.next = 8;
357
+ return createBookingData({
358
+ product: _objectSpread(_objectSpread({}, detail || item), {}, {
359
+ _params: e
360
+ })
361
+ });
362
+ case 8:
363
+ data = _context3.sent;
364
+ // 创建预约
365
+ createBooking({
366
+ booking: data
367
+ });
368
+ return _context3.abrupt("return");
369
+ case 11:
370
+ // info2 addService 逻辑
371
+ _detail = detail || item;
372
+ other = JSON.parse(JSON.stringify(e));
373
+ other.session = e.session;
374
+ cacheItem = _objectSpread(_objectSpread({}, _detail), {}, {
375
+ product_id: item.id,
376
+ _id: getUniqueId(),
377
+ _key: e.key,
378
+ _extend: {
379
+ start_date: state.date.value,
380
+ quantity: (e === null || e === void 0 ? void 0 : e.quantity) || 1,
381
+ price: _detail.price,
382
+ product_name: item.title,
383
+ other: other
384
+ },
385
+ new: 1
386
+ });
387
+ _total = getProductTotalPrice(cacheItem); // 用于折扣 可修改
388
+ cacheItem._extend.total = _total;
389
+ // 用于储存原价
390
+ cacheItem._extend.origin_total = _total;
391
+ _isEdit = !!state.service.cacheItem;
392
+ if (_isEdit) {
393
+ cacheItem._id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
394
+ cacheItem.new = 0;
395
+ }
396
+ // 渲染到当前位置模式时,默认无资源 时间默认取顶部设置的时间
397
+ if (renderMode === 'current') {
398
+ // cacheItem._extend.resource = 0;
399
+ cacheItem.currentDefaultTime = state.date.value.format('HH:mm');
400
+ }
401
+ cacheItem = getProductExtend({
402
+ cacheItem: cacheItem,
403
+ state: state,
404
+ isDisabledTime: true
405
+ });
406
+ if (state.renderType === 'eventBooking') {
407
+ cacheItem.autoClose = false;
408
+ }
409
+ if (cacheItem.autoClose) {
410
+ cacheItem.autoClose = false;
411
+ cacheItem._serviceKey = genServiceKey(cacheItem);
412
+ _addService = addService(_toConsumableArray(state.service.value), cacheItem, state), _list = _addService.list, quantity = _addService.quantity;
413
+ if (!notShowToast) {
414
+ Toast === null || Toast === void 0 || (_Toast$success = Toast.success) === null || _Toast$success === void 0 || _Toast$success.call(Toast, /*#__PURE__*/React.createElement("div", {
415
+ className: "add-toast-wrap"
416
+ }, /*#__PURE__*/React.createElement("div", {
417
+ className: "add-toast-title"
418
+ }, cacheItem.title), /*#__PURE__*/React.createElement("div", {
419
+ className: "add-toast-quantity"
420
+ }, locales.getText('pisell2.ticket-booking.in-cart')(quantity || 1))));
421
+ }
422
+ addServiceScroll(e.rowKey, cacheItem);
423
+ try {
424
+ if (((_context$appHelper$ut4 = context.appHelper.utils.store) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut4.getState) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.call(_context$appHelper$ut4)) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.global) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.globalConfig) === null || _context$appHelper$ut5 === void 0 ? void 0 : _context$appHelper$ut5.id) === 2155) {
425
+ val = _list === null || _list === void 0 ? void 0 : _list.map(function (s) {
426
+ return {
427
+ product_id: s === null || s === void 0 ? void 0 : s.product_id,
428
+ detailId: s === null || s === void 0 ? void 0 : s.id,
429
+ detailProductId: s === null || s === void 0 ? void 0 : s.product_id,
430
+ product_name: s === null || s === void 0 ? void 0 : s.title,
431
+ price: s === null || s === void 0 ? void 0 : s.price,
432
+ _id: s === null || s === void 0 ? void 0 : s._id,
433
+ _key: s === null || s === void 0 ? void 0 : s._key,
434
+ _serviceKey: s === null || s === void 0 ? void 0 : s._serviceKey
435
+ };
436
+ });
437
+ sendData = {
438
+ product_id: item === null || item === void 0 ? void 0 : item.id,
439
+ detailId: _detail === null || _detail === void 0 ? void 0 : _detail.id,
440
+ detailProductId: _detail === null || _detail === void 0 ? void 0 : _detail.product_id,
441
+ product_name: item === null || item === void 0 ? void 0 : item.title,
442
+ price: _detail === null || _detail === void 0 ? void 0 : _detail.price,
443
+ serviceVal: val
444
+ };
445
+ sendWarningLog({
446
+ title: 'addService',
447
+ content: [{
448
+ key: '添加数据',
449
+ value: JSON.stringify(sendData)
450
+ }, {
451
+ key: '日期',
452
+ value: dayjs().format('YYYY-MM-DD HH:mm:ss')
453
+ }]
454
+ });
455
+ }
456
+ } catch (error) {}
457
+ dispatch({
458
+ type: 'setService',
459
+ payload: {
460
+ addModal: false,
461
+ value: _list,
462
+ edit: true,
463
+ changeService: false
464
+ }
465
+ });
466
+ } else {
467
+ dispatch({
468
+ type: 'setService',
469
+ payload: {
470
+ editModal: true,
471
+ cacheItem: cacheItem,
472
+ addModal: !cacheItem.autoClose,
473
+ changeService: false
474
+ }
475
+ });
476
+ onEdit === null || onEdit === void 0 || onEdit(cacheItem);
477
+ }
478
+ case 24:
479
+ case "end":
480
+ return _context3.stop();
481
+ }
482
+ }, _callee3);
483
+ }));
484
+ return function callback(_x3, _x4, _x5, _x6) {
485
+ return _ref3.apply(this, arguments);
486
+ };
487
+ }();
488
+
489
+ // 如果不需要打开弹窗, 直接添加数据
490
+ if (cacheValues) {
491
+ var _state$service$value, _detail$_extend, _Toast$success2;
492
+ var productId = item.id.toString();
493
+
494
+ // 如果已经有pending的同商品,增加点击次数
495
+ if (pendingCacheValuesRef.current[productId]) {
496
+ clickCountRef.current[productId] = (clickCountRef.current[productId] || 1) + 1;
497
+ } else {
498
+ // 第一次点击,初始化数据
499
+ pendingCacheValuesRef.current[productId] = cacheValues;
500
+ clickCountRef.current[productId] = 1;
501
+ }
502
+ var cacheItem = createSimpleCacheItem(item, cacheValues, state);
503
+ var detail = (_state$service$value = state.service.value) === null || _state$service$value === void 0 ? void 0 : _state$service$value.find(function (val) {
504
+ return isSameProduct(val, cacheItem);
505
+ });
506
+ var originalQuantity = (detail === null || detail === void 0 || (_detail$_extend = detail._extend) === null || _detail$_extend === void 0 ? void 0 : _detail$_extend.quantity) || 0;
507
+ Toast === null || Toast === void 0 || (_Toast$success2 = Toast.success) === null || _Toast$success2 === void 0 || _Toast$success2.call(Toast, /*#__PURE__*/React.createElement("div", {
508
+ className: "add-toast-wrap"
509
+ }, /*#__PURE__*/React.createElement("div", {
510
+ className: "add-toast-title"
511
+ }, item.title), /*#__PURE__*/React.createElement("div", {
512
+ className: "add-toast-quantity"
513
+ }, locales.getText('pisell2.ticket-booking.in-cart')((clickCountRef.current[productId] || 1) + originalQuantity))));
514
+ debouncedExecuteCacheValues(productId, cacheValues, item, callback);
515
+ return;
271
516
  }
272
517
  state.action({
273
518
  type: 'pisell1.handleOpenProductModal',
@@ -289,161 +534,7 @@ var AddSerivce = function AddSerivce(props) {
289
534
  onCancel: function onCancel() {
290
535
  setCurrentProduct(null);
291
536
  },
292
- callback: function () {
293
- var _callback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e, extension_type, detail) {
294
- var data, _detail, other, cacheItem, _total, _isEdit, _state$service$cacheI, _Toast$success, _addService, _list, quantity, _context$appHelper$ut4, _context$appHelper$ut5, val, sendData;
295
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
296
- while (1) switch (_context3.prev = _context3.next) {
297
- case 0:
298
- setCurrentProduct(null);
299
- // 防止选择商品弹窗多次触发callback
300
- if (!lock) {
301
- _context3.next = 3;
302
- break;
303
- }
304
- return _context3.abrupt("return");
305
- case 3:
306
- lock = true;
307
-
308
- // 2秒后解除
309
- setTimeout(function () {
310
- lock = false;
311
- }, 2000);
312
- if (isBooking4) {
313
- _context3.next = 11;
314
- break;
315
- }
316
- _context3.next = 8;
317
- return createBookingData({
318
- product: _objectSpread(_objectSpread({}, detail || item), {}, {
319
- _params: e
320
- })
321
- });
322
- case 8:
323
- data = _context3.sent;
324
- // 创建预约
325
- createBooking({
326
- booking: data
327
- });
328
- return _context3.abrupt("return");
329
- case 11:
330
- // info2 addService 逻辑
331
- _detail = detail || item;
332
- other = JSON.parse(JSON.stringify(e));
333
- other.session = e.session;
334
- cacheItem = _objectSpread(_objectSpread({}, _detail), {}, {
335
- product_id: item.id,
336
- _id: getUniqueId(),
337
- _key: e.key,
338
- _extend: {
339
- start_date: state.date.value,
340
- quantity: (e === null || e === void 0 ? void 0 : e.quantity) || 1,
341
- price: _detail.price,
342
- product_name: item.title,
343
- other: other
344
- },
345
- new: 1
346
- });
347
- _total = getProductTotalPrice(cacheItem); // 用于折扣 可修改
348
- cacheItem._extend.total = _total;
349
- // 用于储存原价
350
- cacheItem._extend.origin_total = _total;
351
- _isEdit = !!state.service.cacheItem;
352
- if (_isEdit) {
353
- cacheItem._id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
354
- cacheItem.new = 0;
355
- }
356
- // 渲染到当前位置模式时,默认无资源 时间默认取顶部设置的时间
357
- if (renderMode === 'current') {
358
- // cacheItem._extend.resource = 0;
359
- cacheItem.currentDefaultTime = state.date.value.format('HH:mm');
360
- }
361
- cacheItem = getProductExtend({
362
- cacheItem: cacheItem,
363
- state: state,
364
- isDisabledTime: true
365
- });
366
- if (state.renderType === 'eventBooking') {
367
- cacheItem.autoClose = false;
368
- }
369
- if (cacheItem.autoClose) {
370
- cacheItem.autoClose = false;
371
- cacheItem._serviceKey = genServiceKey(cacheItem);
372
- _addService = addService(_toConsumableArray(state.service.value), cacheItem, state), _list = _addService.list, quantity = _addService.quantity;
373
- Toast === null || Toast === void 0 || (_Toast$success = Toast.success) === null || _Toast$success === void 0 || _Toast$success.call(Toast, /*#__PURE__*/React.createElement("div", {
374
- className: "add-toast-wrap"
375
- }, /*#__PURE__*/React.createElement("div", {
376
- className: "add-toast-title"
377
- }, cacheItem.title), /*#__PURE__*/React.createElement("div", {
378
- className: "add-toast-quantity"
379
- }, locales.getText('pisell2.ticket-booking.in-cart')(quantity || 1))));
380
- addServiceScroll(e.rowKey, cacheItem);
381
- try {
382
- if (((_context$appHelper$ut4 = context.appHelper.utils.store) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut4.getState) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.call(_context$appHelper$ut4)) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.global) === null || _context$appHelper$ut5 === void 0 || (_context$appHelper$ut5 = _context$appHelper$ut5.globalConfig) === null || _context$appHelper$ut5 === void 0 ? void 0 : _context$appHelper$ut5.id) === 2155) {
383
- val = _list === null || _list === void 0 ? void 0 : _list.map(function (s) {
384
- return {
385
- product_id: s === null || s === void 0 ? void 0 : s.product_id,
386
- detailId: s === null || s === void 0 ? void 0 : s.id,
387
- detailProductId: s === null || s === void 0 ? void 0 : s.product_id,
388
- product_name: s === null || s === void 0 ? void 0 : s.title,
389
- price: s === null || s === void 0 ? void 0 : s.price,
390
- _id: s === null || s === void 0 ? void 0 : s._id,
391
- _key: s === null || s === void 0 ? void 0 : s._key,
392
- _serviceKey: s === null || s === void 0 ? void 0 : s._serviceKey
393
- };
394
- });
395
- sendData = {
396
- product_id: item === null || item === void 0 ? void 0 : item.id,
397
- detailId: _detail === null || _detail === void 0 ? void 0 : _detail.id,
398
- detailProductId: _detail === null || _detail === void 0 ? void 0 : _detail.product_id,
399
- product_name: item === null || item === void 0 ? void 0 : item.title,
400
- price: _detail === null || _detail === void 0 ? void 0 : _detail.price,
401
- serviceVal: val
402
- };
403
- sendWarningLog({
404
- title: 'addService',
405
- content: [{
406
- key: '添加数据',
407
- value: JSON.stringify(sendData)
408
- }, {
409
- key: '日期',
410
- value: dayjs().format('YYYY-MM-DD HH:mm:ss')
411
- }]
412
- });
413
- }
414
- } catch (error) {}
415
- dispatch({
416
- type: 'setService',
417
- payload: {
418
- addModal: false,
419
- value: _list,
420
- edit: true,
421
- changeService: false
422
- }
423
- });
424
- } else {
425
- dispatch({
426
- type: 'setService',
427
- payload: {
428
- editModal: true,
429
- cacheItem: cacheItem,
430
- addModal: !cacheItem.autoClose,
431
- changeService: false
432
- }
433
- });
434
- onEdit === null || onEdit === void 0 || onEdit(cacheItem);
435
- }
436
- case 24:
437
- case "end":
438
- return _context3.stop();
439
- }
440
- }, _callee3);
441
- }));
442
- function callback(_x3, _x4, _x5) {
443
- return _callback.apply(this, arguments);
444
- }
445
- return callback;
446
- }()
537
+ callback: callback
447
538
  });
448
539
  });
449
540
  var renderList = useMemo(function () {
@@ -501,6 +592,6 @@ var AddSerivce = function AddSerivce(props) {
501
592
  }));
502
593
  }
503
594
  return null;
504
- }, [(_state$service4 = state.service) === null || _state$service4 === void 0 || (_state$service4 = _state$service4.cacheItem) === null || _state$service4 === void 0 ? void 0 : _state$service4.autoClose, state.service.addModal, locales, renderList, state.amountSymbol, state.renderType, state === null || state === void 0 ? void 0 : state.activeCartId, holderId(state), loading, currentProduct, isBooking4]);
595
+ }, [state.service.addModal, locales, renderList, state.amountSymbol, state.renderType, state === null || state === void 0 ? void 0 : state.activeCartId, holderId(state), loading, currentProduct, isBooking4]);
505
596
  };
506
597
  export default AddSerivce;
@@ -4,45 +4,49 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  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; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React from 'react';
7
+ import React, { useMemo } from 'react';
8
8
  import { LeftOutlined, RightOutlined } from '@ant-design/icons';
9
9
  import { DatePicker, SelectTime } from '@pisell/materials';
10
+ import { useMemoizedFn } from "ahooks";
10
11
  import { Button } from 'antd';
11
12
  import classNames from 'classnames';
12
13
  import { locales } from '@pisell/utils';
13
14
  import "./index.less";
14
15
  var TimeBar = function TimeBar(props) {
15
- var _state$modalState4, _state$modalState5;
16
+ var _state$modalState7;
16
17
  var state = props.globalState,
17
18
  setGlobalState = props.setGlobalState,
18
19
  locale = props.locale;
19
- var _onClickNext = function _onClickNext() {
20
+ var _onClickNext = useMemoizedFn(function () {
20
21
  var _state$modalState, _props$onDateChange, _props$setIntervalTim;
21
22
  var currentTime = (_state$modalState = state.modalState) === null || _state$modalState === void 0 || (_state$modalState = _state$modalState.date) === null || _state$modalState === void 0 ? void 0 : _state$modalState.value;
22
23
  var newTime = currentTime['add'](1, 'day');
23
24
  (_props$onDateChange = props.onDateChange) === null || _props$onDateChange === void 0 || _props$onDateChange.call(props, newTime, newTime.format('YYYY-MM-DD HH:mm:ss'));
24
25
  (_props$setIntervalTim = props.setIntervalTime) === null || _props$setIntervalTim === void 0 || _props$setIntervalTim.call(props, false);
25
- };
26
- var _onClickPre = function _onClickPre() {
26
+ });
27
+ var _onClickPre = useMemoizedFn(function () {
27
28
  var _state$modalState2, _props$onDateChange2, _props$setIntervalTim2;
28
29
  var currentTime = (_state$modalState2 = state.modalState) === null || _state$modalState2 === void 0 || (_state$modalState2 = _state$modalState2.date) === null || _state$modalState2 === void 0 ? void 0 : _state$modalState2.value;
29
30
  var newTime = currentTime['subtract'](1, 'day');
30
31
  (_props$onDateChange2 = props.onDateChange) === null || _props$onDateChange2 === void 0 || _props$onDateChange2.call(props, newTime, newTime.format('YYYY-MM-DD HH:mm:ss'));
31
32
  (_props$setIntervalTim2 = props.setIntervalTime) === null || _props$setIntervalTim2 === void 0 || _props$setIntervalTim2.call(props, false);
32
- };
33
- var _onClickToday = function _onClickToday() {
34
- var _props$setIntervalTim3;
35
- (_props$setIntervalTim3 = props.setIntervalTime) === null || _props$setIntervalTim3 === void 0 || _props$setIntervalTim3.call(props, true);
36
- };
37
- var _onClickNow = function _onClickNow() {
33
+ });
34
+ var _onClickToday = useMemoizedFn(function () {
35
+ var _state$modalState3, _props$onDateChange3, _props$setIntervalTim3;
36
+ var currentTime = (_state$modalState3 = state.modalState) === null || _state$modalState3 === void 0 || (_state$modalState3 = _state$modalState3.date) === null || _state$modalState3 === void 0 ? void 0 : _state$modalState3.value;
37
+ var newTime = currentTime['subtract'](1, 'day');
38
+ (_props$onDateChange3 = props.onDateChange) === null || _props$onDateChange3 === void 0 || _props$onDateChange3.call(props, newTime, newTime.format('YYYY-MM-DD HH:mm:ss'));
39
+ (_props$setIntervalTim3 = props.setIntervalTime) === null || _props$setIntervalTim3 === void 0 || _props$setIntervalTim3.call(props, false);
40
+ });
41
+ var _onClickNow = useMemoizedFn(function () {
38
42
  var _props$setIntervalTim4;
39
43
  (_props$setIntervalTim4 = props.setIntervalTime) === null || _props$setIntervalTim4 === void 0 || _props$setIntervalTim4.call(props, true);
40
- };
44
+ });
41
45
 
42
46
  // 时间选择变更事件
43
- var _onDateTimeChange = function _onDateTimeChange(timeString) {
44
- var _state$modalState3, _props$onDateTimeChan, _props$setIntervalTim5;
45
- var currentTime = (_state$modalState3 = state.modalState) === null || _state$modalState3 === void 0 || (_state$modalState3 = _state$modalState3.date) === null || _state$modalState3 === void 0 ? void 0 : _state$modalState3.value;
47
+ var _onDateTimeChange = useMemoizedFn(function (timeString) {
48
+ var _state$modalState4, _props$onDateTimeChan, _props$setIntervalTim5;
49
+ var currentTime = (_state$modalState4 = state.modalState) === null || _state$modalState4 === void 0 || (_state$modalState4 = _state$modalState4.date) === null || _state$modalState4 === void 0 ? void 0 : _state$modalState4.value;
46
50
  var _timeString$split$map = timeString.split(':').map(Number),
47
51
  _timeString$split$map2 = _slicedToArray(_timeString$split$map, 2),
48
52
  hours = _timeString$split$map2[0],
@@ -53,63 +57,66 @@ var TimeBar = function TimeBar(props) {
53
57
  isTimeChange: true
54
58
  });
55
59
  (_props$setIntervalTim5 = props.setIntervalTime) === null || _props$setIntervalTim5 === void 0 || _props$setIntervalTim5.call(props, false);
56
- };
57
- return /*#__PURE__*/React.createElement("div", {
58
- className: "pisell-ticket-booking-time-bar"
59
- }, /*#__PURE__*/React.createElement(Button, {
60
- icon: /*#__PURE__*/React.createElement(LeftOutlined, null),
61
- onClick: _onClickPre,
62
- size: "large"
63
- }), /*#__PURE__*/React.createElement(Button, {
64
- onClick: _onClickToday,
65
- size: "large",
66
- style: state.intervalSetTime ? {
67
- background: '#000',
68
- color: '#fff'
69
- } : undefined
70
- }, locales.getText('pisell2.ticket-booking.today')), /*#__PURE__*/React.createElement("div", {
71
- className: classNames({
72
- 'booking-page-date-picker-select': state.isDateChange
73
- }),
74
- style: {
75
- width: 200,
76
- flexShrink: 0
77
- }
78
- }, /*#__PURE__*/React.createElement(DatePicker, {
79
- inputReadOnly: true,
80
- value: state === null || state === void 0 || (_state$modalState4 = state.modalState) === null || _state$modalState4 === void 0 || (_state$modalState4 = _state$modalState4.date) === null || _state$modalState4 === void 0 ? void 0 : _state$modalState4.value,
81
- format: locale === 'en' ? 'dddd, DD MMM YYYY' : 'YYYY年MM月DD日',
82
- onChange: props === null || props === void 0 ? void 0 : props.onDateChange,
83
- size: "large",
84
- style: {
85
- width: '100%'
86
- }
87
- })), /*#__PURE__*/React.createElement(Button, {
88
- icon: /*#__PURE__*/React.createElement(RightOutlined, null),
89
- onClick: _onClickNext,
90
- size: "large"
91
- }), /*#__PURE__*/React.createElement("div", {
92
- className: classNames({
93
- 'booking-page-date-picker-select': state.isTimeChange
94
- })
95
- }, /*#__PURE__*/React.createElement(SelectTime, {
96
- value: state === null || state === void 0 || (_state$modalState5 = state.modalState) === null || _state$modalState5 === void 0 || (_state$modalState5 = _state$modalState5.date) === null || _state$modalState5 === void 0 ? void 0 : _state$modalState5.value.format('HH:mm'),
97
- onChange: _onDateTimeChange,
98
- popoverProps: {
60
+ });
61
+ return useMemo(function () {
62
+ var _state$modalState5, _state$modalState6;
63
+ return /*#__PURE__*/React.createElement("div", {
64
+ className: "pisell-ticket-booking-time-bar"
65
+ }, /*#__PURE__*/React.createElement(Button, {
66
+ icon: /*#__PURE__*/React.createElement(LeftOutlined, null),
67
+ onClick: _onClickPre,
68
+ size: "large"
69
+ }), /*#__PURE__*/React.createElement(Button, {
70
+ onClick: _onClickToday,
71
+ size: "large",
72
+ style: state.intervalSetTime ? {
73
+ background: '#000',
74
+ color: '#fff'
75
+ } : undefined
76
+ }, locales.getText('pisell2.ticket-booking.today')), /*#__PURE__*/React.createElement("div", {
77
+ className: classNames({
78
+ 'booking-page-date-picker-select': state.isDateChange
79
+ }),
80
+ style: {
81
+ width: 200,
82
+ flexShrink: 0
83
+ }
84
+ }, /*#__PURE__*/React.createElement(DatePicker, {
85
+ inputReadOnly: true,
86
+ value: state === null || state === void 0 || (_state$modalState5 = state.modalState) === null || _state$modalState5 === void 0 || (_state$modalState5 = _state$modalState5.date) === null || _state$modalState5 === void 0 ? void 0 : _state$modalState5.value,
87
+ format: locale === 'en' ? 'dddd, DD MMM YYYY' : 'YYYY年MM月DD日',
88
+ onChange: props === null || props === void 0 ? void 0 : props.onDateChange,
89
+ size: "large",
99
90
  style: {
100
- zoom: 0.8
91
+ width: '100%'
101
92
  }
102
- },
103
- timePickerProps: {},
104
- timeProps: {},
105
- slice: 5
106
- })), /*#__PURE__*/React.createElement(Button, {
107
- onClick: _onClickNow,
108
- size: "large",
109
- style: state.intervalSetTime ? {
110
- background: '#000',
111
- color: '#fff'
112
- } : undefined
113
- }, locales.getText('pisell2.ticket-booking.now')));
93
+ })), /*#__PURE__*/React.createElement(Button, {
94
+ icon: /*#__PURE__*/React.createElement(RightOutlined, null),
95
+ onClick: _onClickNext,
96
+ size: "large"
97
+ }), /*#__PURE__*/React.createElement("div", {
98
+ className: classNames({
99
+ 'booking-page-date-picker-select': state.isTimeChange
100
+ })
101
+ }, /*#__PURE__*/React.createElement(SelectTime, {
102
+ value: state === null || state === void 0 || (_state$modalState6 = state.modalState) === null || _state$modalState6 === void 0 || (_state$modalState6 = _state$modalState6.date) === null || _state$modalState6 === void 0 ? void 0 : _state$modalState6.value.format('HH:mm'),
103
+ onChange: _onDateTimeChange,
104
+ popoverProps: {
105
+ style: {
106
+ zoom: 0.8
107
+ }
108
+ },
109
+ timePickerProps: {},
110
+ timeProps: {},
111
+ slice: 5
112
+ })), /*#__PURE__*/React.createElement(Button, {
113
+ onClick: _onClickNow,
114
+ size: "large",
115
+ style: state.intervalSetTime ? {
116
+ background: '#000',
117
+ color: '#fff'
118
+ } : undefined
119
+ }, locales.getText('pisell2.ticket-booking.now')));
120
+ }, [(_state$modalState7 = state.modalState) === null || _state$modalState7 === void 0 || (_state$modalState7 = _state$modalState7.date) === null || _state$modalState7 === void 0 ? void 0 : _state$modalState7.value, state.intervalSetTime, state.isTimeChange, state.isDateChange, locale]);
114
121
  };
115
122
  export default TimeBar;
@@ -12,6 +12,7 @@ export declare const restoreProductOtherData: (data: any) => {
12
12
  product_variant_id: number;
13
13
  quantity: number;
14
14
  } | undefined;
15
+ export declare const isSameProduct: (a: any, b: any) => boolean;
15
16
  export declare const addService: (list: any[], addItem: any, state: any) => {
16
17
  list: any[];
17
18
  quantity: any;
@@ -21,3 +22,4 @@ export declare const getCartProductOverlay: (state: any) => any;
21
22
  export declare const getIsOverlayProduct: (item: any, state: any) => any;
22
23
  export declare const getIsShowNumber: (item: any, state: any) => any;
23
24
  export declare const genServiceKey: (item: any) => string;
25
+ export declare const createSimpleCacheItem: (item: any, e: any, state: any) => any;