@pisell/private-materials 3.0.166 → 3.0.168

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.
@@ -177,7 +177,7 @@ var formatBookings = function formatBookings(data) {
177
177
  "duration": flexibleObj.getValue(item._extend.duration),
178
178
  "number": item._extend.capacity ? getSumCapacity({
179
179
  cacheItem: item
180
- }) : 1,
180
+ }) : item._extend.number || 1,
181
181
  "resources": formatResource(item),
182
182
  "metadata": item._extend.capacity ? {
183
183
  capacity: item._extend.capacity
@@ -88,6 +88,6 @@ export var isBooking4Shop = function isBooking4Shop(shopId, renderType) {
88
88
  if (renderType === 'eventBooking') {
89
89
  return false;
90
90
  }
91
- var booking4Shops = [1350, 1401, 3013, 7154, 7572, 7007];
91
+ var booking4Shops = [1350, 1401, 3013, 7154, 7572, 7007, 8119, 7320];
92
92
  return booking4Shops.includes(shopId);
93
93
  };
@@ -80,9 +80,9 @@ export var getFlexibleOption = function getFlexibleOption(_ref2) {
80
80
  });
81
81
  var _duration = _durationProps.duration;
82
82
  if (_duration === 'flexible') {
83
- var _durationProps$usable, _durationProps$usable2;
83
+ var _durationProps$usable, _durationProps$usable2, _durationProps$usable3, _durationProps$usable4, _durationProps$usable5, _durationProps$usable6;
84
84
  // 获取结束时间
85
- var endDate = getEndDate(_durationProps.startDate, _duration, (_durationProps$usable = _durationProps.usableTime) !== null && _durationProps$usable !== void 0 && _durationProps$usable.end_at ? dayjs((_durationProps$usable2 = _durationProps.usableTime) === null || _durationProps$usable2 === void 0 ? void 0 : _durationProps$usable2.end_at) : null);
85
+ var endDate = getEndDate(_durationProps.startDate, _duration, (_durationProps$usable = _durationProps.usableTime) !== null && _durationProps$usable !== void 0 && (_durationProps$usable2 = _durationProps$usable._extend) !== null && _durationProps$usable2 !== void 0 && (_durationProps$usable3 = _durationProps$usable2.usableTime) !== null && _durationProps$usable3 !== void 0 && _durationProps$usable3.end_at ? dayjs((_durationProps$usable4 = _durationProps.usableTime) === null || _durationProps$usable4 === void 0 ? void 0 : (_durationProps$usable5 = _durationProps$usable4._extend) === null || _durationProps$usable5 === void 0 ? void 0 : (_durationProps$usable6 = _durationProps$usable5.usableTime) === null || _durationProps$usable6 === void 0 ? void 0 : _durationProps$usable6.end_at) : null);
86
86
  // 转换为分钟
87
87
  var timeValue = endDate.diff(_durationProps.startDate, 'minute');
88
88
  return {
@@ -239,7 +239,7 @@ export var setDefaultResource = function setDefaultResource(_ref6) {
239
239
  var defaultResource = item.renderList.filter(function (d) {
240
240
  return d.is_default == 1 || d.id === resourceId;
241
241
  }).map(function (d) {
242
- return {
242
+ return _objectSpread(_objectSpread({}, d), {}, {
243
243
  relation_type: d.relation_type,
244
244
  form_id: item.form_id,
245
245
  relation_id: d.id,
@@ -250,7 +250,7 @@ export var setDefaultResource = function setDefaultResource(_ref6) {
250
250
  form_name: item.title,
251
251
  resource_name: d.main_field
252
252
  }
253
- };
253
+ });
254
254
  });
255
255
  obj[item.form_id] = defaultResource;
256
256
  };
@@ -465,11 +465,13 @@ export var getProductExtend = function getProductExtend(_ref8) {
465
465
 
466
466
  // 再次计算, 灵活时长
467
467
  if (getDuration(_cacheItem === null || _cacheItem === void 0 ? void 0 : _cacheItem.duration)) {
468
- _cacheItem._data._timeObj = getTimeObj({
469
- cacheItem: cacheItem,
468
+ _cacheItem._data.timeObj = getTimeObj({
469
+ cacheItem: _cacheItem,
470
+ useStartTime: _cacheItem._extend.start_time,
470
471
  currentResource: _cacheItem._extend.resource,
471
472
  state: state
472
473
  });
474
+ _cacheItem._extend.duration = _cacheItem._data.timeObj.durationSlicesBasedOnTime[0].value;
473
475
  }
474
476
 
475
477
  // 如果只有一种类型的资源 & 单选,还按照之前的逻辑处理:自动选中,不会打开Edit service抽屉。
@@ -479,13 +481,14 @@ export var getProductExtend = function getProductExtend(_ref8) {
479
481
  }
480
482
  _cacheItem._time = new Date().getTime();
481
483
  } else {
482
- if (!_cacheItem._data._timeObj) {
483
- _cacheItem._data._timeObj = getTimeObj({
484
- cacheItem: cacheItem,
485
- currentResource: _cacheItem._extend.resource,
486
- state: state
487
- });
488
- }
484
+ // if (!_cacheItem._data.timeObj) {
485
+ // _cacheItem._data.timeObj = getTimeObj({
486
+ // cacheItem: _cacheItem,
487
+ // currentResource: _cacheItem._extend.resource,
488
+ // state,
489
+ // });
490
+ // }
491
+
489
492
  if (!_cacheItem._data.capacitys) {
490
493
  // 容量
491
494
  _cacheItem._data.capacitys = cacheItem.capacity;
@@ -504,7 +507,17 @@ export var getProductExtend = function getProductExtend(_ref8) {
504
507
  _cacheItem._data.resources = _list2;
505
508
  _cacheItem._data.resourceMaps = _maps;
506
509
  }
510
+
511
+ // if (!_cacheItem._data.timeObj) {
512
+ _cacheItem._data.timeObj = getTimeObj({
513
+ cacheItem: _cacheItem,
514
+ useStartTime: _cacheItem._extend.start_time,
515
+ currentResource: _cacheItem._extend.resource,
516
+ state: state
517
+ });
518
+ // }
507
519
  }
520
+
508
521
  console.log('_cacheItem_cacheItem', _cacheItem);
509
522
  return _cacheItem;
510
523
  };
@@ -31,10 +31,10 @@ import { useUpdateEffect, useMemoizedFn } from 'ahooks';
31
31
  // import SelectTime from "../../../../../../../materials/src/components/select-time";
32
32
  import { getServiceTimes, deleteCacheParams, getProductTotalPrice } from "../../../utils";
33
33
  import { getErrorList } from "../../utilsByBooking";
34
- import { formatResources, getDurationProps, getFlexibleOption } from "../addService/utils";
34
+ import { formatResources, getDurationProps, getFlexibleOption, getTimeObj } from "../addService/utils";
35
35
  var submitLock = false;
36
36
  var Info = function Info(_, ref) {
37
- var _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$service2, _state$service2$cache, _state$service$cacheI5, _state$service$cacheI6, _state$service$cacheI7, _state$service$cacheI8, _state$service5, _state$service5$cache, _state$service7, _state$service7$cache, _state$service7$cache2, _state$service7$cache3, _window$BaseMaterials, _state$service$cacheI9, _state$service8, _state$service8$cache, _state$service8$cache2, _state$service$cacheI10, _state$service$cacheI11, _state$service$cacheI12, _state$service$cacheI13, _state$bookingConfig5, _state$bookingConfig6, _state$bookingConfig7, _state$bookingConfig8, _state$service$resour;
37
+ var _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$service$cacheI4, _state$service$cacheI5, _state$service$cacheI6, _state$service$cacheI7, _state$service3, _state$service3$cache, _state$service5, _state$service5$cache, _state$service5$cache2, _state$service5$cache3, _window$BaseMaterials, _state$service$cacheI8, _state$service6, _state$service6$cache, _state$service6$cache2, _state$service$cacheI9, _state$service$cacheI10, _state$service$cacheI11, _state$service$cacheI12, _state$bookingConfig5, _state$bookingConfig6, _state$bookingConfig7, _state$bookingConfig8, _state$service$resour;
38
38
  var _Form$useForm = Form.useForm(),
39
39
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
40
40
  form = _Form$useForm2[0];
@@ -112,10 +112,14 @@ var Info = function Info(_, ref) {
112
112
  * @Date: 2024-01-09 13:37
113
113
  */
114
114
  var timeObj = useMemo(function () {
115
- var _state$service, _state$service$cacheI;
116
- return (_state$service = state.service) === null || _state$service === void 0 ? void 0 : (_state$service$cacheI = _state$service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._data.timeObj;
117
- }, [(_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : (_state$service2$cache = _state$service2.cacheItem) === null || _state$service2$cache === void 0 ? void 0 : _state$service2$cache._data.timeObj]);
118
-
115
+ return getTimeObj({
116
+ durationProps: durationProps,
117
+ useStartTime: useStartTime,
118
+ currentResource: currentResource,
119
+ state: state,
120
+ useDuration: useDuration
121
+ });
122
+ }, [durationProps, useStartTime, currentResource, state, useDuration]);
119
123
  // 由于灵活时长的结束时间随时变动, 这里发现如果当前选择的值没有在列表内,则选择最新的灵活时长值
120
124
  useEffect(function () {
121
125
  try {
@@ -137,12 +141,12 @@ var Info = function Info(_, ref) {
137
141
  * @Date: 2024-01-09 13:59
138
142
  */
139
143
  var handleDeleteProduct = function handleDeleteProduct() {
140
- var _state$service$cacheI2;
144
+ var _state$service$cacheI;
141
145
  if (state.channelDisabledEdit) {
142
146
  return;
143
147
  }
144
148
  var _list = _toConsumableArray(state.service.value);
145
- var _id = (_state$service$cacheI2 = state.service.cacheItem) === null || _state$service$cacheI2 === void 0 ? void 0 : _state$service$cacheI2._id;
149
+ var _id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
146
150
  _list = _list.filter(function (d) {
147
151
  return d._id !== _id;
148
152
  });
@@ -165,8 +169,8 @@ var Info = function Info(_, ref) {
165
169
  * @Date: 2024-01-09 14:03
166
170
  */
167
171
  var getDiscount = function getDiscount() {
168
- var _state$service$cacheI3;
169
- var oPrice = Number(((_state$service$cacheI3 = state.service.cacheItem) === null || _state$service$cacheI3 === void 0 ? void 0 : _state$service$cacheI3._extend.origin_total) || 0);
172
+ var _state$service$cacheI2;
173
+ var oPrice = Number(((_state$service$cacheI2 = state.service.cacheItem) === null || _state$service$cacheI2 === void 0 ? void 0 : _state$service$cacheI2._extend.origin_total) || 0);
170
174
  var cPrice = Number(useTotal || 0);
171
175
  var discount = '';
172
176
  // 原价 = 现价 为无折扣
@@ -273,12 +277,12 @@ var Info = function Info(_, ref) {
273
277
  * @Date: 2024-01-09 14:06
274
278
  */
275
279
  var isReason = useMemo(function () {
276
- var _state$service$cacheI4;
277
- var oPrice = Number(((_state$service$cacheI4 = state.service.cacheItem) === null || _state$service$cacheI4 === void 0 ? void 0 : _state$service$cacheI4._extend.origin_total) || 0);
280
+ var _state$service$cacheI3;
281
+ var oPrice = Number(((_state$service$cacheI3 = state.service.cacheItem) === null || _state$service$cacheI3 === void 0 ? void 0 : _state$service$cacheI3._extend.origin_total) || 0);
278
282
  var cPrice = Number(useTotal || 0);
279
283
  // 原价 !== 现价
280
284
  return cPrice !== oPrice;
281
- }, [useTotal, (_state$service$cacheI5 = state.service.cacheItem) === null || _state$service$cacheI5 === void 0 ? void 0 : (_state$service$cacheI6 = _state$service$cacheI5._extend) === null || _state$service$cacheI6 === void 0 ? void 0 : _state$service$cacheI6.origin_total]);
285
+ }, [useTotal, (_state$service$cacheI4 = state.service.cacheItem) === null || _state$service$cacheI4 === void 0 ? void 0 : (_state$service$cacheI5 = _state$service$cacheI4._extend) === null || _state$service$cacheI5 === void 0 ? void 0 : _state$service$cacheI5.origin_total]);
282
286
  var getResources = function getResources() {
283
287
  var res = formatResources({
284
288
  cacheItem: getCurrentCacheItem(),
@@ -352,18 +356,18 @@ var Info = function Info(_, ref) {
352
356
  */
353
357
  useEffect(function () {
354
358
  getDiscount();
355
- }, [useTotal, (_state$service$cacheI7 = state.service.cacheItem) === null || _state$service$cacheI7 === void 0 ? void 0 : (_state$service$cacheI8 = _state$service$cacheI7._extend) === null || _state$service$cacheI8 === void 0 ? void 0 : _state$service$cacheI8.origin_total]);
359
+ }, [useTotal, (_state$service$cacheI6 = state.service.cacheItem) === null || _state$service$cacheI6 === void 0 ? void 0 : (_state$service$cacheI7 = _state$service$cacheI6._extend) === null || _state$service$cacheI7 === void 0 ? void 0 : _state$service$cacheI7.origin_total]);
356
360
  var isDiscount = useMemo(function () {
357
- var _state$service3, _state$service4, _state$service4$cache;
358
- if (!((_state$service3 = state.service) !== null && _state$service3 !== void 0 && _state$service3.cacheItem)) {
361
+ var _state$service, _state$service2, _state$service2$cache;
362
+ if (!((_state$service = state.service) !== null && _state$service !== void 0 && _state$service.cacheItem)) {
359
363
  return false;
360
364
  }
361
- return useTotal != ((_state$service4 = state.service) === null || _state$service4 === void 0 ? void 0 : (_state$service4$cache = _state$service4.cacheItem) === null || _state$service4$cache === void 0 ? void 0 : _state$service4$cache._extend.origin_total);
362
- }, [useTotal, (_state$service5 = state.service) === null || _state$service5 === void 0 ? void 0 : (_state$service5$cache = _state$service5.cacheItem) === null || _state$service5$cache === void 0 ? void 0 : _state$service5$cache._extend.origin_total]);
365
+ return useTotal != ((_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : (_state$service2$cache = _state$service2.cacheItem) === null || _state$service2$cache === void 0 ? void 0 : _state$service2$cache._extend.origin_total);
366
+ }, [useTotal, (_state$service3 = state.service) === null || _state$service3 === void 0 ? void 0 : (_state$service3$cache = _state$service3.cacheItem) === null || _state$service3$cache === void 0 ? void 0 : _state$service3$cache._extend.origin_total]);
363
367
  var bundles = useMemo(function () {
364
- var _state$service6, _state$service6$cache, _state$service6$cache2, _state$service6$cache3;
365
- return ((_state$service6 = state.service) === null || _state$service6 === void 0 ? void 0 : (_state$service6$cache = _state$service6.cacheItem) === null || _state$service6$cache === void 0 ? void 0 : (_state$service6$cache2 = _state$service6$cache._extend) === null || _state$service6$cache2 === void 0 ? void 0 : (_state$service6$cache3 = _state$service6$cache2.other) === null || _state$service6$cache3 === void 0 ? void 0 : _state$service6$cache3.bundle) || [];
366
- }, [(_state$service7 = state.service) === null || _state$service7 === void 0 ? void 0 : (_state$service7$cache = _state$service7.cacheItem) === null || _state$service7$cache === void 0 ? void 0 : (_state$service7$cache2 = _state$service7$cache._extend) === null || _state$service7$cache2 === void 0 ? void 0 : (_state$service7$cache3 = _state$service7$cache2.other) === null || _state$service7$cache3 === void 0 ? void 0 : _state$service7$cache3.bundle]);
368
+ var _state$service4, _state$service4$cache, _state$service4$cache2, _state$service4$cache3;
369
+ return ((_state$service4 = state.service) === null || _state$service4 === void 0 ? void 0 : (_state$service4$cache = _state$service4.cacheItem) === null || _state$service4$cache === void 0 ? void 0 : (_state$service4$cache2 = _state$service4$cache._extend) === null || _state$service4$cache2 === void 0 ? void 0 : (_state$service4$cache3 = _state$service4$cache2.other) === null || _state$service4$cache3 === void 0 ? void 0 : _state$service4$cache3.bundle) || [];
370
+ }, [(_state$service5 = state.service) === null || _state$service5 === void 0 ? void 0 : (_state$service5$cache = _state$service5.cacheItem) === null || _state$service5$cache === void 0 ? void 0 : (_state$service5$cache2 = _state$service5$cache._extend) === null || _state$service5$cache2 === void 0 ? void 0 : (_state$service5$cache3 = _state$service5$cache2.other) === null || _state$service5$cache3 === void 0 ? void 0 : _state$service5$cache3.bundle]);
367
371
 
368
372
  /**
369
373
  * @title: 编辑商品
@@ -470,7 +474,7 @@ var Info = function Info(_, ref) {
470
474
  ,
471
475
  zIndex: state.service.changeService ? 999 : 1000,
472
476
  forceRender: true,
473
- open: state.service.editModal && !((_state$service$cacheI9 = state.service.cacheItem) !== null && _state$service$cacheI9 !== void 0 && _state$service$cacheI9.autoClose),
477
+ open: state.service.editModal && !((_state$service$cacheI8 = state.service.cacheItem) !== null && _state$service$cacheI8 !== void 0 && _state$service$cacheI8.autoClose),
474
478
  title: locales.getText('pisell2.text.edit-service'),
475
479
  onClose: function onClose() {
476
480
  dispatch({
@@ -503,7 +507,7 @@ var Info = function Info(_, ref) {
503
507
  className: "current-service-info-name-wrap"
504
508
  }, /*#__PURE__*/React.createElement("div", {
505
509
  className: "current-service-info-name"
506
- }, ((_state$service8 = state.service) === null || _state$service8 === void 0 ? void 0 : (_state$service8$cache = _state$service8.cacheItem) === null || _state$service8$cache === void 0 ? void 0 : (_state$service8$cache2 = _state$service8$cache._extend) === null || _state$service8$cache2 === void 0 ? void 0 : _state$service8$cache2.product_name) || '-'), /*#__PURE__*/React.createElement(Button, {
510
+ }, ((_state$service6 = state.service) === null || _state$service6 === void 0 ? void 0 : (_state$service6$cache = _state$service6.cacheItem) === null || _state$service6$cache === void 0 ? void 0 : (_state$service6$cache2 = _state$service6$cache._extend) === null || _state$service6$cache2 === void 0 ? void 0 : _state$service6$cache2.product_name) || '-'), /*#__PURE__*/React.createElement(Button, {
507
511
  onClick: handleEdit
508
512
  }, locales.getText('pisell2.text.edit')), !state.isBookingCreatePage && /*#__PURE__*/React.createElement(Button, {
509
513
  onClick: handleChange
@@ -532,8 +536,8 @@ var Info = function Info(_, ref) {
532
536
  width: '100%'
533
537
  },
534
538
  min: 0,
535
- max: ((_state$service$cacheI10 = state.service.cacheItem) === null || _state$service$cacheI10 === void 0 ? void 0 : (_state$service$cacheI11 = _state$service$cacheI10._extend) === null || _state$service$cacheI11 === void 0 ? void 0 : _state$service$cacheI11.origin_total) || 0,
536
- placeholder: ((_state$service$cacheI12 = state.service.cacheItem) === null || _state$service$cacheI12 === void 0 ? void 0 : (_state$service$cacheI13 = _state$service$cacheI12._extend) === null || _state$service$cacheI13 === void 0 ? void 0 : _state$service$cacheI13.origin_total) || '0'
539
+ max: ((_state$service$cacheI9 = state.service.cacheItem) === null || _state$service$cacheI9 === void 0 ? void 0 : (_state$service$cacheI10 = _state$service$cacheI9._extend) === null || _state$service$cacheI10 === void 0 ? void 0 : _state$service$cacheI10.origin_total) || 0,
540
+ placeholder: ((_state$service$cacheI11 = state.service.cacheItem) === null || _state$service$cacheI11 === void 0 ? void 0 : (_state$service$cacheI12 = _state$service$cacheI11._extend) === null || _state$service$cacheI12 === void 0 ? void 0 : _state$service$cacheI12.origin_total) || '0'
537
541
  }))), /*#__PURE__*/React.createElement(Col, {
538
542
  span: 12
539
543
  }, /*#__PURE__*/React.createElement(Form.Item, {
@@ -71,6 +71,8 @@ export var getResourceTimeIsUsable = function getResourceTimeIsUsable(item, cach
71
71
  // 已预约的列表
72
72
  var eventList = time.event_list || [];
73
73
  var endDate = null;
74
+ // 是否去计算数量
75
+ var isCalcCount = true;
74
76
 
75
77
  /**
76
78
  * 从这里为判断是否在时间范围内
@@ -84,6 +86,14 @@ export var getResourceTimeIsUsable = function getResourceTimeIsUsable(item, cach
84
86
  }, dayjs(eventList[0].end_at));
85
87
  }
86
88
  isDateRange = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
89
+
90
+ // 如果灵活时长不在范围内, 则认为是已约满
91
+ if (!isDateRange && eventList.length) {
92
+ isCalcCount = false;
93
+ isDateRange = true;
94
+ isCountRange = false;
95
+ }
96
+ // debugger
87
97
  } else {
88
98
  // 其余判断 开始时间 和 结束时间 是否都在范围内
89
99
  endDate = startDate.add(flexibleObj.getValue(cacheItem._extend.duration), "minute");
@@ -94,46 +104,48 @@ export var getResourceTimeIsUsable = function getResourceTimeIsUsable(item, cach
94
104
  isDateRange = true;
95
105
  }
96
106
  }
97
- // 如果 预约人数超过总容量, 则不可用
98
- // if (totalCount < currentCount) {
99
- // isCountRange = false;
100
- // } else {
101
- /**
102
- * 从这里判断预约量
103
- */
104
-
105
- // 取出已预约列表和当前预约重叠的时间段
106
- var conflict = (time.event_list || []).filter(function (d) {
107
- return isConflict({
108
- start_at: d.start_at,
109
- end_at: d.end_at
110
- }, {
111
- start_at: startDate,
112
- end_at: endDate
107
+ if (isCalcCount) {
108
+ // 如果 预约人数超过总容量, 则不可用
109
+ // if (totalCount < currentCount) {
110
+ // isCountRange = false;
111
+ // } else {
112
+ /**
113
+ * 从这里判断预约量
114
+ */
115
+
116
+ // 取出已预约列表和当前预约重叠的时间段
117
+ var conflict = (time.event_list || []).filter(function (d) {
118
+ return isConflict({
119
+ start_at: d.start_at,
120
+ end_at: d.end_at
121
+ }, {
122
+ start_at: startDate,
123
+ end_at: endDate
124
+ });
113
125
  });
114
- });
115
126
 
116
- // 同一时间段内只能进行一个预约,无论容量是否已满。
117
- if (resourceItem.resourceType === 'single') {
118
- // 0代表着不重叠,则满足条件
119
- if (conflict.length === 0) {
120
- isCountRange = true;
127
+ // 同一时间段内只能进行一个预约,无论容量是否已满。
128
+ if (resourceItem.resourceType === 'single') {
129
+ // 0代表着不重叠,则满足条件
130
+ if (conflict.length === 0) {
131
+ isCountRange = true;
132
+ } else {
133
+ isCountRange = false;
134
+ }
121
135
  } else {
122
- isCountRange = false;
123
- }
124
- } else {
125
- // 减去重叠的总量
126
- var conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
136
+ // 减去重叠的总量
137
+ var conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
127
138
 
128
- // 当前预约量 <= 总剩余容量
129
- if (currentCount <= conflictCount) {
130
- isCountRange = true;
131
- } else {
132
- isCountRange = false;
139
+ // 当前预约量 <= 总剩余容量
140
+ if (currentCount <= conflictCount) {
141
+ isCountRange = true;
142
+ } else {
143
+ isCountRange = false;
144
+ }
133
145
  }
134
- }
135
146
 
136
- // }
147
+ // }
148
+ }
137
149
 
138
150
  // 是否可用 只判断是否在日期范围内,
139
151
  var isUsable = isDateRange && isCountRange;
@@ -1,5 +1,5 @@
1
- import { SelectProps } from "antd";
2
- import React from "react";
1
+ import { SelectProps } from 'antd';
2
+ import React from 'react';
3
3
  interface DurationProps extends SelectProps {
4
4
  locale?: string;
5
5
  slice?: number;
@@ -3,14 +3,14 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
- import { Select } from "antd";
7
- import React, { useCallback, useEffect, useMemo } from "react";
6
+ import { Select } from 'antd';
7
+ import React, { useCallback, useEffect, useMemo } from 'react';
8
8
  import { sliceDayIntoFiveMinutes, getEndDate, flexibleObj, getDiscountTime } from "../../utils";
9
- import dayjs from "dayjs";
10
- import { locales } from "@pisell/utils";
9
+ import dayjs from 'dayjs';
10
+ import { locales } from '@pisell/utils';
11
11
  var Duration = function Duration(props) {
12
12
  var _props$locale = props.locale,
13
- locale = _props$locale === void 0 ? "en" : _props$locale,
13
+ locale = _props$locale === void 0 ? 'en' : _props$locale,
14
14
  _props$slice = props.slice,
15
15
  slice = _props$slice === void 0 ? 5 : _props$slice,
16
16
  timeObjChange = props.timeObjChange,
@@ -34,15 +34,15 @@ var Duration = function Duration(props) {
34
34
  }
35
35
  var _sliceDayIntoFiveMinu = sliceDayIntoFiveMinutes(slice, locale),
36
36
  durationSlicesBasedOnTime = _sliceDayIntoFiveMinu.durationSlicesBasedOnTime;
37
- var _duration = _typeof(duration) === "object" ? duration.type : duration;
37
+ var _duration = _typeof(duration) === 'object' ? duration.type : duration;
38
38
  // 灵活时长
39
- if (_duration === "flexible") {
39
+ if (_duration === 'flexible') {
40
40
  var endDate = getEndDate(startDate, _duration, usableTime !== null && usableTime !== void 0 && usableTime.end_at ? dayjs(usableTime === null || usableTime === void 0 ? void 0 : usableTime.end_at) : null);
41
- var timeValue = endDate.diff(startDate, "minute");
41
+ var timeValue = endDate.diff(startDate, 'minute');
42
42
 
43
43
  // 动态获取结束时间
44
44
  durationSlicesBasedOnTime.unshift({
45
- label: locales.getText("pisell2.text.flexible"),
45
+ label: locales.getText('pisell2.text.flexible'),
46
46
  value: flexibleObj.create(timeValue)
47
47
  });
48
48
  }
@@ -62,8 +62,8 @@ var Duration = function Duration(props) {
62
62
  timeObjChange === null || timeObjChange === void 0 ? void 0 : timeObjChange(times);
63
63
  }, [times]);
64
64
  var renderOptions = useCallback(function (array) {
65
- var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "value";
66
- var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "label";
65
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
66
+ var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'label';
67
67
  return array.map(function (d) {
68
68
  return /*#__PURE__*/React.createElement(Select.Option, {
69
69
  value: d[value],
@@ -160,7 +160,7 @@ var formatBookings = (data) => {
160
160
  "end_date": end_date,
161
161
  "start_date": start_date,
162
162
  "duration": import_utils.flexibleObj.getValue(item._extend.duration),
163
- "number": item._extend.capacity ? (0, import_utilsByBooking.getSumCapacity)({ cacheItem: item }) : 1,
163
+ "number": item._extend.capacity ? (0, import_utilsByBooking.getSumCapacity)({ cacheItem: item }) : item._extend.number || 1,
164
164
  "resources": formatResource(item),
165
165
  "metadata": item._extend.capacity ? {
166
166
  capacity: item._extend.capacity
@@ -83,7 +83,7 @@ var isBooking4Shop = (shopId, renderType) => {
83
83
  if (renderType === "eventBooking") {
84
84
  return false;
85
85
  }
86
- const booking4Shops = [1350, 1401, 3013, 7154, 7572, 7007];
86
+ const booking4Shops = [1350, 1401, 3013, 7154, 7572, 7007, 8119, 7320];
87
87
  return booking4Shops.includes(shopId);
88
88
  };
89
89
  // Annotate the CommonJS export names for ESM import in node:
@@ -90,7 +90,7 @@ var getFlexibleOption = ({
90
90
  slice,
91
91
  durationProps
92
92
  }) => {
93
- var _a, _b;
93
+ var _a, _b, _c, _d, _e, _f;
94
94
  const _durationProps = durationProps || getDurationProps({
95
95
  cacheItem,
96
96
  useStartTime,
@@ -102,7 +102,7 @@ var getFlexibleOption = ({
102
102
  let endDate = (0, import_utils.getEndDate)(
103
103
  _durationProps.startDate,
104
104
  _duration,
105
- ((_a = _durationProps.usableTime) == null ? void 0 : _a.end_at) ? (0, import_dayjs.default)((_b = _durationProps.usableTime) == null ? void 0 : _b.end_at) : null
105
+ ((_c = (_b = (_a = _durationProps.usableTime) == null ? void 0 : _a._extend) == null ? void 0 : _b.usableTime) == null ? void 0 : _c.end_at) ? (0, import_dayjs.default)((_f = (_e = (_d = _durationProps.usableTime) == null ? void 0 : _d._extend) == null ? void 0 : _e.usableTime) == null ? void 0 : _f.end_at) : null
106
106
  );
107
107
  let timeValue = endDate.diff(_durationProps.startDate, "minute");
108
108
  return {
@@ -197,6 +197,7 @@ var setDefaultResource = ({ cacheItem, resources }) => {
197
197
  for (let item of resources) {
198
198
  let defaultResource = item.renderList.filter((d) => d.is_default == 1 || d.id === resourceId).map((d) => {
199
199
  return {
200
+ ...d,
200
201
  relation_type: d.relation_type,
201
202
  form_id: item.form_id,
202
203
  relation_id: d.id,
@@ -324,11 +325,13 @@ var getProductExtend = ({ cacheItem, state }) => {
324
325
  resources: _cacheItem._data.resources
325
326
  });
326
327
  if ((0, import_utils.getDuration)(_cacheItem == null ? void 0 : _cacheItem.duration)) {
327
- _cacheItem._data._timeObj = getTimeObj({
328
- cacheItem,
328
+ _cacheItem._data.timeObj = getTimeObj({
329
+ cacheItem: _cacheItem,
330
+ useStartTime: _cacheItem._extend.start_time,
329
331
  currentResource: _cacheItem._extend.resource,
330
332
  state
331
333
  });
334
+ _cacheItem._extend.duration = _cacheItem._data.timeObj.durationSlicesBasedOnTime[0].value;
332
335
  }
333
336
  _cacheItem.autoClose = getIsAutoClose(_cacheItem);
334
337
  if (_cacheItem._extend.bundle_edit !== void 0) {
@@ -336,13 +339,6 @@ var getProductExtend = ({ cacheItem, state }) => {
336
339
  }
337
340
  _cacheItem._time = (/* @__PURE__ */ new Date()).getTime();
338
341
  } else {
339
- if (!_cacheItem._data._timeObj) {
340
- _cacheItem._data._timeObj = getTimeObj({
341
- cacheItem,
342
- currentResource: _cacheItem._extend.resource,
343
- state
344
- });
345
- }
346
342
  if (!_cacheItem._data.capacitys) {
347
343
  _cacheItem._data.capacitys = cacheItem.capacity;
348
344
  }
@@ -360,6 +356,12 @@ var getProductExtend = ({ cacheItem, state }) => {
360
356
  _cacheItem._data.resources = list;
361
357
  _cacheItem._data.resourceMaps = maps;
362
358
  }
359
+ _cacheItem._data.timeObj = getTimeObj({
360
+ cacheItem: _cacheItem,
361
+ useStartTime: _cacheItem._extend.start_time,
362
+ currentResource: _cacheItem._extend.resource,
363
+ state
364
+ });
363
365
  }
364
366
  console.log("_cacheItem_cacheItem", _cacheItem);
365
367
  return _cacheItem;
@@ -50,7 +50,7 @@ var import_utilsByBooking = require("../../utilsByBooking");
50
50
  var import_utils4 = require("../addService/utils");
51
51
  var submitLock = false;
52
52
  var Info = (_, ref) => {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
54
54
  const [form] = import_antd.Form.useForm();
55
55
  const useTotal = import_antd.Form.useWatch("total", form);
56
56
  const useResource = import_antd.Form.useWatch("resource", form);
@@ -94,9 +94,14 @@ var Info = (_, ref) => {
94
94
  });
95
95
  }, [durationProps, import_utils.locales.locale]);
96
96
  const timeObj = (0, import_react.useMemo)(() => {
97
- var _a2, _b2;
98
- return (_b2 = (_a2 = state.service) == null ? void 0 : _a2.cacheItem) == null ? void 0 : _b2._data.timeObj;
99
- }, [(_e = (_d = state.service) == null ? void 0 : _d.cacheItem) == null ? void 0 : _e._data.timeObj]);
97
+ return (0, import_utils4.getTimeObj)({
98
+ durationProps,
99
+ useStartTime,
100
+ currentResource,
101
+ state,
102
+ useDuration
103
+ });
104
+ }, [durationProps, useStartTime, currentResource, state, useDuration]);
100
105
  (0, import_react.useEffect)(() => {
101
106
  try {
102
107
  if (useDuration.indexOf("flexible_") == 0) {
@@ -206,7 +211,7 @@ var Info = (_, ref) => {
206
211
  let oPrice = Number(((_a2 = state.service.cacheItem) == null ? void 0 : _a2._extend.origin_total) || 0);
207
212
  let cPrice = Number(useTotal || 0);
208
213
  return cPrice !== oPrice;
209
- }, [useTotal, (_g = (_f = state.service.cacheItem) == null ? void 0 : _f._extend) == null ? void 0 : _g.origin_total]);
214
+ }, [useTotal, (_e = (_d = state.service.cacheItem) == null ? void 0 : _d._extend) == null ? void 0 : _e.origin_total]);
210
215
  const getResources = () => {
211
216
  let res = (0, import_utils4.formatResources)({
212
217
  cacheItem: getCurrentCacheItem(),
@@ -269,18 +274,18 @@ var Info = (_, ref) => {
269
274
  }, [state.service.editModal, state.isBookingCreatePage]);
270
275
  (0, import_react.useEffect)(() => {
271
276
  getDiscount();
272
- }, [useTotal, (_i = (_h = state.service.cacheItem) == null ? void 0 : _h._extend) == null ? void 0 : _i.origin_total]);
277
+ }, [useTotal, (_g = (_f = state.service.cacheItem) == null ? void 0 : _f._extend) == null ? void 0 : _g.origin_total]);
273
278
  const isDiscount = (0, import_react.useMemo)(() => {
274
279
  var _a2, _b2, _c2;
275
280
  if (!((_a2 = state.service) == null ? void 0 : _a2.cacheItem)) {
276
281
  return false;
277
282
  }
278
283
  return useTotal != ((_c2 = (_b2 = state.service) == null ? void 0 : _b2.cacheItem) == null ? void 0 : _c2._extend.origin_total);
279
- }, [useTotal, (_k = (_j = state.service) == null ? void 0 : _j.cacheItem) == null ? void 0 : _k._extend.origin_total]);
284
+ }, [useTotal, (_i = (_h = state.service) == null ? void 0 : _h.cacheItem) == null ? void 0 : _i._extend.origin_total]);
280
285
  const bundles = (0, import_react.useMemo)(() => {
281
286
  var _a2, _b2, _c2, _d2;
282
287
  return ((_d2 = (_c2 = (_b2 = (_a2 = state.service) == null ? void 0 : _a2.cacheItem) == null ? void 0 : _b2._extend) == null ? void 0 : _c2.other) == null ? void 0 : _d2.bundle) || [];
283
- }, [(_o = (_n = (_m = (_l = state.service) == null ? void 0 : _l.cacheItem) == null ? void 0 : _m._extend) == null ? void 0 : _n.other) == null ? void 0 : _o.bundle]);
288
+ }, [(_m = (_l = (_k = (_j = state.service) == null ? void 0 : _j.cacheItem) == null ? void 0 : _k._extend) == null ? void 0 : _l.other) == null ? void 0 : _m.bundle]);
284
289
  const handleEdit = (e) => {
285
290
  const item = state.service.cacheItem;
286
291
  let values = form.getFieldsValue();
@@ -348,14 +353,14 @@ var Info = (_, ref) => {
348
353
  };
349
354
  });
350
355
  console.log("state.service.value", state.service.value);
351
- const SelectTime = (_p = window.BaseMaterials) == null ? void 0 : _p.SelectTime;
356
+ const SelectTime = (_n = window.BaseMaterials) == null ? void 0 : _n.SelectTime;
352
357
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
353
358
  import_drawer.default,
354
359
  {
355
360
  titleNoWrap: true,
356
361
  zIndex: state.service.changeService ? 999 : 1e3,
357
362
  forceRender: true,
358
- open: state.service.editModal && !((_q = state.service.cacheItem) == null ? void 0 : _q.autoClose),
363
+ open: state.service.editModal && !((_o = state.service.cacheItem) == null ? void 0 : _o.autoClose),
359
364
  title: import_utils.locales.getText("pisell2.text.edit-service"),
360
365
  onClose: () => {
361
366
  dispatch({
@@ -368,7 +373,7 @@ var Info = (_, ref) => {
368
373
  });
369
374
  }
370
375
  },
371
- /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-body-edit" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { layout: "vertical", form, onFinish }, /* @__PURE__ */ import_react.default.createElement(import_antd.Row, { style: { width: "100%" }, gutter: [16, 0] }, /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "product_name" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info-name-wrap" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info-name" }, ((_t = (_s = (_r = state.service) == null ? void 0 : _r.cacheItem) == null ? void 0 : _s._extend) == null ? void 0 : _t.product_name) || "-"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleEdit }, import_utils.locales.getText("pisell2.text.edit")), !state.isBookingCreatePage && /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleChange }, import_utils.locales.getText("pisell2.text.change"))), /* @__PURE__ */ import_react.default.createElement(
376
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-body-edit" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { layout: "vertical", form, onFinish }, /* @__PURE__ */ import_react.default.createElement(import_antd.Row, { style: { width: "100%" }, gutter: [16, 0] }, /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "product_name" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info-name-wrap" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info-name" }, ((_r = (_q = (_p = state.service) == null ? void 0 : _p.cacheItem) == null ? void 0 : _q._extend) == null ? void 0 : _r.product_name) || "-"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleEdit }, import_utils.locales.getText("pisell2.text.edit")), !state.isBookingCreatePage && /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleChange }, import_utils.locales.getText("pisell2.text.change"))), /* @__PURE__ */ import_react.default.createElement(
372
377
  import_collapsibleList.default,
373
378
  {
374
379
  style: { marginTop: bundles.length ? "8px" : 0 },
@@ -391,8 +396,8 @@ var Info = (_, ref) => {
391
396
  precision: 2,
392
397
  style: { width: "100%" },
393
398
  min: 0,
394
- max: ((_v = (_u = state.service.cacheItem) == null ? void 0 : _u._extend) == null ? void 0 : _v.origin_total) || 0,
395
- placeholder: ((_x = (_w = state.service.cacheItem) == null ? void 0 : _w._extend) == null ? void 0 : _x.origin_total) || "0"
399
+ max: ((_t = (_s = state.service.cacheItem) == null ? void 0 : _s._extend) == null ? void 0 : _t.origin_total) || 0,
400
+ placeholder: ((_v = (_u = state.service.cacheItem) == null ? void 0 : _u._extend) == null ? void 0 : _v.origin_total) || "0"
396
401
  }
397
402
  )
398
403
  )), /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 12 }, /* @__PURE__ */ import_react.default.createElement(
@@ -432,7 +437,7 @@ var Info = (_, ref) => {
432
437
  SelectTime ? /* @__PURE__ */ import_react.default.createElement(
433
438
  SelectTime,
434
439
  {
435
- slice: (_B = (_A = (_z = (_y = state.bookingConfig) == null ? void 0 : _y.config) == null ? void 0 : _z.basic) == null ? void 0 : _A.service_time) == null ? void 0 : _B.value,
440
+ slice: (_z = (_y = (_x = (_w = state.bookingConfig) == null ? void 0 : _w.config) == null ? void 0 : _x.basic) == null ? void 0 : _y.service_time) == null ? void 0 : _z.value,
436
441
  timePickerProps: {
437
442
  style: { width: "100%" }
438
443
  },
@@ -477,7 +482,7 @@ var Info = (_, ref) => {
477
482
  {
478
483
  type: "primary",
479
484
  className: "pisell-lowcode__booking-service-body-edit-footer-apple",
480
- disabled: !((_C = state.service.resourcesOrigin) == null ? void 0 : _C.length),
485
+ disabled: !((_A = state.service.resourcesOrigin) == null ? void 0 : _A.length),
481
486
  onClick: () => {
482
487
  form.submit();
483
488
  }