@pisell/private-materials 3.0.61 → 3.0.63

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.
@@ -40,7 +40,7 @@ import { DownOutlined } from "@ant-design/icons";
40
40
  * @Date: 2024-01-30 16:51
41
41
  */
42
42
  var Footer = function Footer(props) {
43
- var _context$appHelper, _store$getState, _store$getState$call, _store$getState$call$, _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$addons2, _state$addons4, _state$bookingDetail10;
43
+ var _context$appHelper, _store$getState, _store$getState$call, _store$getState$call$, _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$addons2, _state$addons4, _state$bookingDetail11;
44
44
  var state = props.state,
45
45
  buttons = props.buttons,
46
46
  dispatch = props.dispatch,
@@ -444,7 +444,7 @@ var Footer = function Footer(props) {
444
444
  }, [isEdit, checkoutLoading, isDisabled, state, source]);
445
445
  var handleMenuClick = /*#__PURE__*/function () {
446
446
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(e) {
447
- var id, customer, res, _state$bookingDetail;
447
+ var id, customer, res, _state$bookingDetail, _state$bookingDetail2;
448
448
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
449
449
  while (1) switch (_context6.prev = _context6.next) {
450
450
  case 0:
@@ -473,7 +473,8 @@ var Footer = function Footer(props) {
473
473
  id: id,
474
474
  is_deposit: state.bookingDetail.is_deposit || Number((_state$bookingDetail = state.bookingDetail) === null || _state$bookingDetail === void 0 ? void 0 : _state$bookingDetail.deposit_amount),
475
475
  deposit_payment_time: state.bookingDetail.deposit_payment_time,
476
- customer: customer
476
+ customer: customer,
477
+ contacts: (_state$bookingDetail2 = state.bookingDetail) === null || _state$bookingDetail2 === void 0 ? void 0 : _state$bookingDetail2.contacts
477
478
  },
478
479
  callback: function callback() {}
479
480
  });
@@ -586,10 +587,10 @@ var Footer = function Footer(props) {
586
587
  * @Date: 2024-01-30 16:58
587
588
  */
588
589
  var isCheckout = useMemo(function () {
589
- var _state$bookingDetail2, _state$bookingDetail3, _state$bookingDetail4;
590
+ var _state$bookingDetail3, _state$bookingDetail4, _state$bookingDetail5;
590
591
  var list = ["unfulfilled", "partially_paid", "unpaid", "payment_processing"];
591
592
  // (支付状态 = 已支付 || 部分付款 || 未付款 || 支付处理中) && 预约状态 !== 已取消
592
- if (!state.bookingId || ((_state$bookingDetail2 = state.bookingDetail) === null || _state$bookingDetail2 === void 0 ? void 0 : (_state$bookingDetail3 = _state$bookingDetail2.bookings) === null || _state$bookingDetail3 === void 0 ? void 0 : _state$bookingDetail3.appointment_status) !== "cancelled" && list.includes(state === null || state === void 0 ? void 0 : (_state$bookingDetail4 = state.bookingDetail) === null || _state$bookingDetail4 === void 0 ? void 0 : _state$bookingDetail4.payment_status) && !state.disabledEdit) {
593
+ if (!state.bookingId || ((_state$bookingDetail3 = state.bookingDetail) === null || _state$bookingDetail3 === void 0 ? void 0 : (_state$bookingDetail4 = _state$bookingDetail3.bookings) === null || _state$bookingDetail4 === void 0 ? void 0 : _state$bookingDetail4.appointment_status) !== "cancelled" && list.includes(state === null || state === void 0 ? void 0 : (_state$bookingDetail5 = state.bookingDetail) === null || _state$bookingDetail5 === void 0 ? void 0 : _state$bookingDetail5.payment_status) && !state.disabledEdit) {
593
594
  return true;
594
595
  } else {
595
596
  if (total.notPaidAmount > 0) {
@@ -664,8 +665,8 @@ var Footer = function Footer(props) {
664
665
  * 是否只有定金支付
665
666
  */
666
667
  var isOnlyDeposit = useMemo(function () {
667
- var _state$bookingDetail5, _state$bookingDetail6, _state$bookingDetail7, _state$bookingDetail8;
668
- if (state !== null && state !== void 0 && (_state$bookingDetail5 = state.bookingDetail) !== null && _state$bookingDetail5 !== void 0 && _state$bookingDetail5.deposit_payment_time && state !== null && state !== void 0 && (_state$bookingDetail6 = state.bookingDetail) !== null && _state$bookingDetail6 !== void 0 && (_state$bookingDetail7 = _state$bookingDetail6.payment_types) !== null && _state$bookingDetail7 !== void 0 && (_state$bookingDetail8 = _state$bookingDetail7.every) !== null && _state$bookingDetail8 !== void 0 && _state$bookingDetail8.call(_state$bookingDetail7, function (item) {
668
+ var _state$bookingDetail6, _state$bookingDetail7, _state$bookingDetail8, _state$bookingDetail9;
669
+ if (state !== null && state !== void 0 && (_state$bookingDetail6 = state.bookingDetail) !== null && _state$bookingDetail6 !== void 0 && _state$bookingDetail6.deposit_payment_time && state !== null && state !== void 0 && (_state$bookingDetail7 = state.bookingDetail) !== null && _state$bookingDetail7 !== void 0 && (_state$bookingDetail8 = _state$bookingDetail7.payment_types) !== null && _state$bookingDetail8 !== void 0 && (_state$bookingDetail9 = _state$bookingDetail8.every) !== null && _state$bookingDetail9 !== void 0 && _state$bookingDetail9.call(_state$bookingDetail8, function (item) {
669
670
  return item === 'deposit';
670
671
  })) {
671
672
  return true;
@@ -686,8 +687,8 @@ var Footer = function Footer(props) {
686
687
 
687
688
  // 只有定金支付时,直接展示
688
689
  if (isOnlyDeposit) {
689
- var _state$bookingDetail9;
690
- return "".concat(locales.getText("pisell2.text.deposit-paid"), " ").concat(formatAmount(state === null || state === void 0 ? void 0 : (_state$bookingDetail9 = state.bookingDetail) === null || _state$bookingDetail9 === void 0 ? void 0 : _state$bookingDetail9.deposit_amount, 2, (state === null || state === void 0 ? void 0 : state.amountSymbol) || "$"), " ").concat(total.duration ? "(".concat(total.duration, ")") : "");
690
+ var _state$bookingDetail10;
691
+ return "".concat(locales.getText("pisell2.text.deposit-paid"), " ").concat(formatAmount(state === null || state === void 0 ? void 0 : (_state$bookingDetail10 = state.bookingDetail) === null || _state$bookingDetail10 === void 0 ? void 0 : _state$bookingDetail10.deposit_amount, 2, (state === null || state === void 0 ? void 0 : state.amountSymbol) || "$"), " ").concat(total.duration ? "(".concat(total.duration, ")") : "");
691
692
  }
692
693
 
693
694
  // 有退款金额时, 直接展示 退款:$8.00
@@ -811,7 +812,7 @@ var Footer = function Footer(props) {
811
812
  className: "order-total-item-label"
812
813
  }, locales.getText("pisell1.text.subtotal")), /*#__PURE__*/React.createElement("span", {
813
814
  className: "order-total-item-value"
814
- }, formatAmount(total.productAmount, 2, (state === null || state === void 0 ? void 0 : state.amountSymbol) || "$"))), (((_state$bookingDetail10 = state.bookingDetail) === null || _state$bookingDetail10 === void 0 ? void 0 : _state$bookingDetail10.surcharge) || []).map(function (d) {
815
+ }, formatAmount(total.productAmount, 2, (state === null || state === void 0 ? void 0 : state.amountSymbol) || "$"))), (((_state$bookingDetail11 = state.bookingDetail) === null || _state$bookingDetail11 === void 0 ? void 0 : _state$bookingDetail11.surcharge) || []).map(function (d) {
815
816
  return /*#__PURE__*/React.createElement("div", {
816
817
  className: "order-total-item",
817
818
  key: d.id
@@ -54,7 +54,8 @@ var Deposit = function Deposit(props) {
54
54
  id: id,
55
55
  is_deposit: 1,
56
56
  deposit_payment_time: bookingDetail.deposit_payment_time,
57
- customer: bookingDetail.customer
57
+ customer: bookingDetail.customer,
58
+ contacts: bookingDetail === null || bookingDetail === void 0 ? void 0 : bookingDetail.contacts
58
59
  },
59
60
  callback: function callback() {}
60
61
  });
@@ -28,18 +28,13 @@ import "./index.less";
28
28
  import useEngineContext from "../../../../../hooks/useEngineContext";
29
29
  import { getProductDetail } from "../serve";
30
30
  import { getIsBundleOrCombination } from "../../utils";
31
- import { formatProductListByCategory, getProductTotalPrice, request, getCacheParams, deleteCacheParams } from "../../../utils";
31
+ import { getProductExtend } from "./utils";
32
+ import { formatProductListByCategory, getProductTotalPrice, request } from "../../../utils";
32
33
  import { locales, getUniqueId } from "@pisell/utils";
33
34
  import { useUpdateEffect } from "ahooks";
34
35
  var shopList = [2886, 4422, 5538, 6930, 6814, 6813, 6812, 6087, 6303];
35
- var getCacheResourceId = function getCacheResourceId() {
36
- var serviceParams = getCacheParams();
37
- var resId = Number(serviceParams === null || serviceParams === void 0 ? void 0 : serviceParams.resource_id);
38
- console.log("resIdresIdresId", resId);
39
- return resId;
40
- };
41
36
  var Info = function Info() {
42
- var _state$service2, _state$service3, _state$service3$cache;
37
+ var _state$service3, _state$service4, _state$service4$cache;
43
38
  var _useState = useState(""),
44
39
  _useState2 = _slicedToArray(_useState, 2),
45
40
  search = _useState2[0],
@@ -147,43 +142,15 @@ var Info = function Info() {
147
142
  return _ref.apply(this, arguments);
148
143
  };
149
144
  }();
150
-
151
- /**
152
- * @title: 如果选择了资源, 则直接添加商品
153
- * @description:
154
- * @param {any} cacheItem
155
- * @return {*}
156
- * @Author: zhiwei.Wang
157
- * @Date: 2024-05-14 14:02
158
- */
159
- var autoAddProduct = /*#__PURE__*/function () {
160
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cacheItem) {
161
- var resId, _cacheItem;
162
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
163
- while (1) switch (_context2.prev = _context2.next) {
164
- case 0:
165
- resId = getCacheResourceId();
166
- _cacheItem = _objectSpread({}, cacheItem);
167
- deleteCacheParams();
168
- case 3:
169
- case "end":
170
- return _context2.stop();
171
- }
172
- }, _callee2);
173
- }));
174
- return function autoAddProduct(_x3) {
175
- return _ref2.apply(this, arguments);
176
- };
177
- }();
178
145
  var getServices = /*#__PURE__*/function () {
179
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
146
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
180
147
  var _state$eventOtherPara;
181
148
  var data;
182
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
183
- while (1) switch (_context3.prev = _context3.next) {
149
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
150
+ while (1) switch (_context2.prev = _context2.next) {
184
151
  case 0:
185
152
  setLoading(true);
186
- _context3.next = 3;
153
+ _context2.next = 3;
187
154
  return state.apis.getServices({
188
155
  skip: 1,
189
156
  num: 500,
@@ -198,7 +165,7 @@ var Info = function Info() {
198
165
  }
199
166
  });
200
167
  case 3:
201
- data = _context3.sent;
168
+ data = _context2.sent;
202
169
  setLoading(false);
203
170
 
204
171
  // 只有自动获取列表的时候才设置商品, 手动点击添加按钮的时候不设置
@@ -213,12 +180,12 @@ var Info = function Info() {
213
180
  });
214
181
  case 7:
215
182
  case "end":
216
- return _context3.stop();
183
+ return _context2.stop();
217
184
  }
218
- }, _callee3);
185
+ }, _callee2);
219
186
  }));
220
187
  return function getServices() {
221
- return _ref3.apply(this, arguments);
188
+ return _ref2.apply(this, arguments);
222
189
  };
223
190
  }();
224
191
  var handleSelectService = function handleSelectService() {
@@ -252,6 +219,7 @@ var Info = function Info() {
252
219
  is_eject: isEject ? 1 : 0
253
220
  },
254
221
  callback: function callback(e) {
222
+ var _state$service;
255
223
  var cacheItem = _objectSpread(_objectSpread({}, item), {}, {
256
224
  product_id: item.id,
257
225
  _id: getUniqueId(),
@@ -276,15 +244,11 @@ var Info = function Info() {
276
244
  cacheItem._id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
277
245
  cacheItem.new = 0;
278
246
  }
279
- console.log("_total", cacheItem);
280
-
281
- // 如果已经有资源id,则不跳转详情页, 直接返回
282
- // if (getCacheResourceId()) {
283
- // autoAddProduct(cacheItem);
284
- // return;
285
- // }
286
- var resId = getCacheResourceId();
287
- cacheItem.autoClose = !!resId;
247
+ cacheItem._extend = getProductExtend({
248
+ cacheItem: cacheItem,
249
+ state: state
250
+ });
251
+ cacheItem.autoClose = cacheItem._extend.resource || cacheItem._extend.resource === 0 || (((_state$service = state.service) === null || _state$service === void 0 ? void 0 : _state$service.resourcesOrigin) || []).length === 1;
288
252
  dispatch({
289
253
  type: "setService",
290
254
  payload: {
@@ -296,16 +260,17 @@ var Info = function Info() {
296
260
  }
297
261
  });
298
262
  };
263
+ console.log("state.service.cacheItem", state.service.cacheItem);
299
264
  var renderList = useMemo(function () {
300
- var _state$service;
301
- var _list = ((_state$service = state.service) === null || _state$service === void 0 ? void 0 : _state$service.services) || [];
265
+ var _state$service2;
266
+ var _list = ((_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : _state$service2.services) || [];
302
267
  var isIncludes = function isIncludes(str) {
303
268
  return str.toLowerCase().indexOf(search.toLowerCase()) !== -1;
304
269
  };
305
270
  return formatProductListByCategory(_list, search ? function (item) {
306
271
  return isIncludes(item.title);
307
272
  } : undefined);
308
- }, [search, (_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : _state$service2.services]);
273
+ }, [search, (_state$service3 = state.service) === null || _state$service3 === void 0 ? void 0 : _state$service3.services]);
309
274
  var isService = useMemo(function () {
310
275
  return state.service.value.length > 0;
311
276
  }, [state.service.value]);
@@ -360,7 +325,7 @@ var Info = function Info() {
360
325
  }
361
326
  });
362
327
  }, [state.renderType, showAddButton, isService, state.service.value, loading]);
363
- return /*#__PURE__*/React.createElement(React.Fragment, null, ((_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.autoClose) && /*#__PURE__*/React.createElement(Skeleton, {
328
+ return /*#__PURE__*/React.createElement(React.Fragment, null, ((_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.autoClose) && /*#__PURE__*/React.createElement(Skeleton, {
364
329
  loading: true,
365
330
  active: true,
366
331
  round: true
@@ -0,0 +1,61 @@
1
+ import dayjs from "dayjs";
2
+ export declare const getDurationProps: ({ cacheItem, useStartTime, currentResource, slice, }: any) => {
3
+ startDate: dayjs.Dayjs;
4
+ usableTime: any;
5
+ duration: string | number | {
6
+ type: string;
7
+ value: number;
8
+ };
9
+ locale: string;
10
+ slice: any;
11
+ selectProps: {
12
+ size: string;
13
+ };
14
+ };
15
+ /**
16
+ * @title: 灵活时长选项
17
+ * @description:
18
+ * @param {*} useMemo
19
+ * @return {*}
20
+ * @Author: zhiwei.Wang
21
+ * @Date: 2024-02-23 10:10
22
+ */
23
+ export declare const getFlexibleOption: ({ cacheItem, useStartTime, currentResource, slice, durationProps, }: any) => {
24
+ label: any;
25
+ value: any;
26
+ } | null;
27
+ /**
28
+ * @title: 时间切片
29
+ * @description:
30
+ * @return {*}
31
+ * @Author: zhiwei.Wang
32
+ * @Date: 2024-01-09 13:37
33
+ */
34
+ export declare const getTimeObj: ({ cacheItem, useStartTime, currentResource, state, useDuration, durationProps, }: any) => {
35
+ timeSlices: {
36
+ label: string;
37
+ value: string;
38
+ }[];
39
+ durationSlicesBasedOnTime: {
40
+ label: string;
41
+ value: number;
42
+ }[];
43
+ };
44
+ /**
45
+ * @title: 获取资源列表
46
+ * @description:
47
+ * @return {*}
48
+ * @Author: zhiwei.Wang
49
+ * @Date: 2024-01-09 13:38
50
+ */
51
+ export declare const formatResources: ({ cacheItem, resourcesOrigin }: any) => any[];
52
+ export declare const checkCacheItemResource: ({ cacheItem, resources }: any) => any;
53
+ /**
54
+ * @title: 预生成服务的 extend
55
+ * @description:
56
+ * @param {any} param1
57
+ * @return {*}
58
+ * @Author: zhiwei.Wang
59
+ * @Date: 2024-06-01 13:25
60
+ */
61
+ export declare const getProductExtend: ({ cacheItem, state }: any) => any;
@@ -0,0 +1,256 @@
1
+ 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); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
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); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
13
+ import React from "react";
14
+ import { getServeStartTime, getDuration, getEndDate, flexibleObj, sliceDayIntoFiveMinutes, getDiscountTime, getServerItemExtend, formatResource } from "../../../utils";
15
+ import dayjs from "dayjs";
16
+ import { locales } from "@pisell/utils";
17
+ import AlertTriangle from "@pisell/icon/es/AlertTriangle";
18
+ export var getDurationProps = function getDurationProps(_ref) {
19
+ var _currentResource$_ext;
20
+ var cacheItem = _ref.cacheItem,
21
+ useStartTime = _ref.useStartTime,
22
+ currentResource = _ref.currentResource,
23
+ slice = _ref.slice;
24
+ var _cacheItem = cacheItem;
25
+ return {
26
+ startDate: dayjs(dayjs(_cacheItem._extend.start_date).format("YYYY-MM-DD ") + (getServeStartTime(useStartTime) || "00:00")),
27
+ usableTime: currentResource === null || currentResource === void 0 ? void 0 : (_currentResource$_ext = currentResource._extend) === null || _currentResource$_ext === void 0 ? void 0 : _currentResource$_ext.usableTime,
28
+ duration: getDuration(_cacheItem === null || _cacheItem === void 0 ? void 0 : _cacheItem.duration),
29
+ locale: locales.locale,
30
+ slice: slice,
31
+ selectProps: {
32
+ size: "large"
33
+ }
34
+ };
35
+ };
36
+
37
+ /**
38
+ * @title: 灵活时长选项
39
+ * @description:
40
+ * @param {*} useMemo
41
+ * @return {*}
42
+ * @Author: zhiwei.Wang
43
+ * @Date: 2024-02-23 10:10
44
+ */
45
+ export var getFlexibleOption = function getFlexibleOption(_ref2) {
46
+ var cacheItem = _ref2.cacheItem,
47
+ useStartTime = _ref2.useStartTime,
48
+ currentResource = _ref2.currentResource,
49
+ slice = _ref2.slice,
50
+ durationProps = _ref2.durationProps;
51
+ var _durationProps = durationProps || getDurationProps({
52
+ cacheItem: cacheItem,
53
+ useStartTime: useStartTime,
54
+ currentResource: currentResource,
55
+ slice: slice
56
+ });
57
+ var _duration = _durationProps.duration;
58
+ if (_duration === "flexible") {
59
+ var _durationProps$usable, _durationProps$usable2;
60
+ // 获取结束时间
61
+ 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);
62
+ // 转换为分钟
63
+ var timeValue = endDate.diff(_durationProps.startDate, "minute");
64
+ return {
65
+ label: locales.getText("pisell2.text.flexible"),
66
+ value: flexibleObj.create(timeValue)
67
+ };
68
+ }
69
+ return null;
70
+ };
71
+
72
+ /**
73
+ * @title: 时间切片
74
+ * @description:
75
+ * @return {*}
76
+ * @Author: zhiwei.Wang
77
+ * @Date: 2024-01-09 13:37
78
+ */
79
+ export var getTimeObj = function getTimeObj(_ref3) {
80
+ var _state$bookingConfig, _state$bookingConfig$, _state$bookingConfig$2;
81
+ var cacheItem = _ref3.cacheItem,
82
+ useStartTime = _ref3.useStartTime,
83
+ currentResource = _ref3.currentResource,
84
+ state = _ref3.state,
85
+ useDuration = _ref3.useDuration,
86
+ durationProps = _ref3.durationProps;
87
+ var flexibleOption = getFlexibleOption({
88
+ cacheItem: cacheItem,
89
+ useStartTime: useStartTime,
90
+ currentResource: currentResource,
91
+ state: state,
92
+ durationProps: durationProps
93
+ });
94
+ var obj = sliceDayIntoFiveMinutes((_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 ? void 0 : (_state$bookingConfig$ = _state$bookingConfig.config) === null || _state$bookingConfig$ === void 0 ? void 0 : (_state$bookingConfig$2 = _state$bookingConfig$.basic) === null || _state$bookingConfig$2 === void 0 ? void 0 : _state$bookingConfig$2.service_time, locales.locale);
95
+ var timeSlices = _toConsumableArray(obj.timeSlices);
96
+ var durationSlicesBasedOnTime = _toConsumableArray(obj.durationSlicesBasedOnTime);
97
+
98
+ // 如果商品是灵活时长, 则增加灵活的选项
99
+ if (flexibleOption) {
100
+ durationSlicesBasedOnTime.unshift(flexibleOption);
101
+ }
102
+
103
+ // 如果当前设置的时长没有在列表内, 则在列表的最上面添加此项
104
+ if (useDuration && !durationSlicesBasedOnTime.some(function (d) {
105
+ return d.value === useDuration;
106
+ })) {
107
+ durationSlicesBasedOnTime.unshift({
108
+ label: getDiscountTime(useDuration),
109
+ value: useDuration,
110
+ //@ts-ignore
111
+ disabled: true
112
+ });
113
+ }
114
+ // 如果有选择时间, 但是不在列表内 则需要在列表内添加上此值
115
+ if (useStartTime && useStartTime !== "now" && !timeSlices.some(function (d) {
116
+ return d.value === useStartTime;
117
+ })) {
118
+ timeSlices.unshift({
119
+ label: dayjs(useStartTime, "HH:mm").format("hh:mm A"),
120
+ value: useStartTime
121
+ });
122
+ }
123
+
124
+ // 增加当前
125
+ timeSlices.unshift({
126
+ label: locales.getText("pisell2.text.now"),
127
+ value: "now"
128
+ });
129
+ return _objectSpread(_objectSpread({}, obj), {}, {
130
+ timeSlices: timeSlices,
131
+ durationSlicesBasedOnTime: durationSlicesBasedOnTime
132
+ });
133
+ };
134
+
135
+ /**
136
+ * @title: 获取资源列表
137
+ * @description:
138
+ * @return {*}
139
+ * @Author: zhiwei.Wang
140
+ * @Date: 2024-01-09 13:38
141
+ */
142
+ export var formatResources = function formatResources(_ref4) {
143
+ var cacheItem = _ref4.cacheItem,
144
+ resourcesOrigin = _ref4.resourcesOrigin;
145
+ try {
146
+ // 合并无资源
147
+ var _list = _toConsumableArray(resourcesOrigin);
148
+ var _cacheItem = cacheItem;
149
+ // 格式化, 添加自定义参数
150
+ _list = _list.map(function (d) {
151
+ return formatResource(d, _cacheItem, function (item) {
152
+ return /*#__PURE__*/React.createElement("div", {
153
+ className: "resource-option"
154
+ }, /*#__PURE__*/React.createElement("div", {
155
+ className: "like-wrap"
156
+ }), item.labelText, !item.usable && /*#__PURE__*/React.createElement(AlertTriangle, {
157
+ className: "resource-option-alert-icon"
158
+ }));
159
+ });
160
+ });
161
+ // 排序, 将可用资源放在最前面
162
+ _list = _list.sort(function (a, b) {
163
+ return b.usable ? 1 : -1;
164
+ });
165
+ return _list;
166
+ } catch (err) {
167
+ console.log("formatResourcesErr", err);
168
+ }
169
+ return [];
170
+ };
171
+ export var checkCacheItemResource = function checkCacheItemResource(_ref5) {
172
+ var cacheItem = _ref5.cacheItem,
173
+ resources = _ref5.resources;
174
+ var resourceId = cacheItem._extend.resource;
175
+ if (resourceId || resourceId === 0) {
176
+ // 校验, 如果当前选择的资源 在列表里没找到, 则恢复成无资源, 防止数据错乱
177
+ if (!resources.find(function (d) {
178
+ return d.form_record_id === resourceId;
179
+ })) {
180
+ resourceId = undefined;
181
+ }
182
+ } else {
183
+ if (cacheItem.new) {
184
+ if (resources.length === 2) {
185
+ resourceId = resources[1].form_record_id;
186
+ }
187
+ if (resources.length > 2) {
188
+ var usableList = resources.filter(function (d) {
189
+ return d.usable && d.form_id !== 0;
190
+ });
191
+ if (usableList.length === 1) {
192
+ resourceId = usableList[0].form_record_id;
193
+ }
194
+ }
195
+ }
196
+ }
197
+ return resourceId;
198
+ };
199
+
200
+ /**
201
+ * @title: 预生成服务的 extend
202
+ * @description:
203
+ * @param {any} param1
204
+ * @return {*}
205
+ * @Author: zhiwei.Wang
206
+ * @Date: 2024-06-01 13:25
207
+ */
208
+ export var getProductExtend = function getProductExtend(_ref6) {
209
+ var cacheItem = _ref6.cacheItem,
210
+ state = _ref6.state;
211
+ // 获取资源源列表
212
+ var resourcesOrigin = state.service.resourcesOrigin || [];
213
+ var currentResource = null;
214
+
215
+ // 编辑时,找到当前选择的资源
216
+ if (!cacheItem.new) {
217
+ // 格式化资源列表
218
+ var _resources = formatResources({
219
+ cacheItem: cacheItem,
220
+ resourcesOrigin: resourcesOrigin
221
+ });
222
+ var item = _resources.find(function (d) {
223
+ return d.form_record_id == cacheItem._extend.resource;
224
+ }) || {};
225
+ if (item) {
226
+ currentResource = item;
227
+ }
228
+ }
229
+
230
+ // 时间切片
231
+ var timeObj = getTimeObj({
232
+ cacheItem: cacheItem,
233
+ currentResource: currentResource,
234
+ state: state
235
+ });
236
+
237
+ // 生成数据
238
+ var _extend = getServerItemExtend(state, cacheItem, timeObj);
239
+
240
+ // 格式化资源列表
241
+ var resources = formatResources({
242
+ cacheItem: _objectSpread(_objectSpread({}, cacheItem), {}, {
243
+ _extend: _extend
244
+ }),
245
+ resourcesOrigin: resourcesOrigin
246
+ });
247
+
248
+ // 最终根据资源列表 决定是否设置默认的资源
249
+ _extend.resource = checkCacheItemResource({
250
+ cacheItem: _objectSpread(_objectSpread({}, cacheItem), {}, {
251
+ _extend: _extend
252
+ }),
253
+ resources: resources
254
+ });
255
+ return _extend;
256
+ };