@pisell/private-materials 3.0.152-gray → 3.0.152

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 (186) 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/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +142 -142
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +12 -12
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +11 -11
  11. package/es/components/booking/addons/model.d.ts +1 -2
  12. package/es/components/booking/components/footer/index.js +51 -36
  13. package/es/components/booking/components/footer/utils.js +35 -4
  14. package/es/components/booking/forms/forms.d.ts +0 -1
  15. package/es/components/booking/forms/forms.js +2 -4
  16. package/es/components/booking/forms/model.d.ts +1 -2
  17. package/es/components/booking/forms/single/index.d.ts +1 -1
  18. package/es/components/booking/forms/single/index.js +3 -4
  19. package/es/components/booking/index.js +1 -1
  20. package/es/components/booking/info/index.d.ts +4 -12
  21. package/es/components/booking/info/index.js +12 -123
  22. package/es/components/booking/info/index.less +0 -9
  23. package/es/components/booking/info/main.d.ts +12 -0
  24. package/es/components/booking/info/main.js +124 -0
  25. package/es/components/booking/info/model.js +0 -1
  26. package/es/components/booking/info/pet/index.js +1 -1
  27. package/es/components/booking/info/service/addService/index.d.ts +2 -8
  28. package/es/components/booking/info/service/addService/index.js +36 -82
  29. package/es/components/booking/info/service/addService/index.less +1 -27
  30. package/es/components/booking/info/service/addTimeModal/index.js +4 -4
  31. package/es/components/booking/info/service/editService/index.js +13 -11
  32. package/es/components/booking/info/utils.d.ts +1 -0
  33. package/es/components/booking/info/utils.js +7 -0
  34. package/es/components/booking/info2/index.d.ts +12 -0
  35. package/es/components/booking/{dashboard → info2}/index.js +196 -222
  36. package/es/components/booking/info2/serve.d.ts +6 -0
  37. package/es/components/booking/info2/serve.js +79 -0
  38. package/es/components/booking/info2/service/actions/index.d.ts +6 -0
  39. package/es/components/booking/info2/service/actions/index.js +86 -0
  40. package/es/components/booking/info2/service/addService/index.d.ts +6 -0
  41. package/es/components/booking/info2/service/addService/index.js +404 -0
  42. package/es/components/booking/info2/service/addService/mock.d.ts +214 -0
  43. package/es/components/booking/info2/service/addService/mock.js +332 -0
  44. package/es/components/booking/info2/service/addService/utils.d.ts +71 -0
  45. package/es/components/booking/info2/service/addService/utils.js +510 -0
  46. package/es/components/booking/info2/service/addTimeModal/index.d.ts +4 -0
  47. package/es/components/booking/info2/service/addTimeModal/index.js +681 -0
  48. package/es/components/booking/info2/service/addTimeModal/serve.d.ts +9 -0
  49. package/es/components/booking/{dashboard → info2/service/addTimeModal}/serve.js +51 -5
  50. package/es/components/booking/info2/service/addTimeModal/utils.d.ts +31 -0
  51. package/es/components/booking/info2/service/addTimeModal/utils.js +176 -0
  52. package/es/components/booking/info2/service/editService/Capacity/index.d.ts +4 -0
  53. package/es/components/booking/info2/service/editService/Capacity/index.js +121 -0
  54. package/es/components/booking/info2/service/editService/Capacity/index.less +1 -0
  55. package/es/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.d.ts +7 -0
  56. package/es/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.js +28 -0
  57. package/es/components/booking/info2/service/editService/Resources/index.d.ts +4 -0
  58. package/es/components/booking/info2/service/editService/Resources/index.js +233 -0
  59. package/es/components/booking/info2/service/editService/Resources/index.less +21 -0
  60. package/es/components/booking/info2/service/editService/index.d.ts +7 -0
  61. package/es/components/booking/info2/service/editService/index.js +617 -0
  62. package/es/components/booking/info2/service/editService/index.less +99 -0
  63. package/es/components/booking/info2/service/editService/utils.d.ts +11 -0
  64. package/es/components/booking/{info/addServiceVariant/index.js → info2/service/editService/utils.js} +30 -26
  65. package/es/components/booking/info2/service/index.d.ts +4 -0
  66. package/es/components/booking/info2/service/index.js +55 -0
  67. package/es/components/booking/info2/service/serviceItem/index.d.ts +4 -0
  68. package/es/components/booking/info2/service/serviceItem/index.js +176 -0
  69. package/es/components/booking/info2/service/serviceItem/index.less +125 -0
  70. package/es/components/booking/info2/service/serviceList/index.d.ts +6 -0
  71. package/es/components/booking/info2/service/serviceList/index.js +106 -0
  72. package/es/components/booking/info2/service/serviceList/index.less +0 -0
  73. package/es/components/booking/info2/utilsByBooking.d.ts +34 -0
  74. package/es/components/booking/info2/utilsByBooking.js +349 -0
  75. package/es/components/booking/locales.d.ts +3 -48
  76. package/es/components/booking/locales.js +9 -48
  77. package/es/components/booking/materiels/resources/index.d.ts +2 -2
  78. package/es/components/booking/materiels/resources/index.js +11 -11
  79. package/es/components/booking/mock.d.ts +1 -0
  80. package/es/components/booking/mock.js +66 -0
  81. package/es/components/booking/model.d.ts +0 -2
  82. package/es/components/booking/notes/index.d.ts +1 -1
  83. package/es/components/booking/notes/model.d.ts +1 -2
  84. package/es/components/booking/payments/model.d.ts +1 -2
  85. package/es/components/booking/utils.d.ts +1 -1
  86. package/es/components/booking/utils.js +51 -54
  87. package/es/components/index.d.ts +1 -1
  88. package/es/components/index.js +1 -1
  89. package/es/components/schedules/index.d.ts +1 -1
  90. package/es/components/schedules/model.d.ts +1 -2
  91. package/es/index.d.ts +1 -3
  92. package/es/index.js +2 -4
  93. package/lib/components/booking/addons/model.d.ts +1 -2
  94. package/lib/components/booking/components/footer/index.js +31 -8
  95. package/lib/components/booking/components/footer/utils.js +29 -4
  96. package/lib/components/booking/forms/forms.d.ts +0 -1
  97. package/lib/components/booking/forms/forms.js +2 -5
  98. package/lib/components/booking/forms/model.d.ts +1 -2
  99. package/lib/components/booking/forms/single/index.d.ts +1 -1
  100. package/lib/components/booking/forms/single/index.js +2 -4
  101. package/lib/components/booking/index.js +2 -2
  102. package/lib/components/booking/info/client/index.js +8 -1
  103. package/lib/components/booking/info/index.d.ts +4 -12
  104. package/lib/components/booking/info/index.js +14 -118
  105. package/lib/components/booking/info/index.less +0 -9
  106. package/lib/components/booking/info/main.d.ts +12 -0
  107. package/lib/components/booking/info/main.js +152 -0
  108. package/lib/components/booking/info/pet/index.js +1 -2
  109. package/lib/components/booking/info/service/addService/index.d.ts +2 -8
  110. package/lib/components/booking/info/service/addService/index.js +29 -66
  111. package/lib/components/booking/info/service/addService/index.less +1 -27
  112. package/lib/components/booking/info/service/addTimeModal/index.js +1 -0
  113. package/lib/components/booking/info/service/editService/index.js +6 -9
  114. package/lib/components/booking/info/utils.d.ts +1 -0
  115. package/lib/components/booking/info/utils.js +9 -0
  116. package/lib/components/booking/info2/index.d.ts +12 -0
  117. package/lib/components/booking/info2/index.js +202 -0
  118. package/lib/components/booking/info2/serve.d.ts +6 -0
  119. package/lib/components/booking/{dashboard → info2}/serve.js +25 -5
  120. package/lib/components/booking/info2/service/actions/index.d.ts +6 -0
  121. package/lib/components/booking/info2/service/actions/index.js +102 -0
  122. package/lib/components/booking/info2/service/addService/index.d.ts +6 -0
  123. package/lib/components/booking/info2/service/addService/index.js +356 -0
  124. package/lib/components/booking/info2/service/addService/mock.d.ts +214 -0
  125. package/lib/components/booking/info2/service/addService/mock.js +398 -0
  126. package/lib/components/booking/info2/service/addService/utils.d.ts +71 -0
  127. package/lib/components/booking/info2/service/addService/utils.js +377 -0
  128. package/lib/components/booking/info2/service/addTimeModal/index.d.ts +4 -0
  129. package/lib/components/booking/info2/service/addTimeModal/index.js +558 -0
  130. package/lib/components/booking/info2/service/addTimeModal/serve.d.ts +9 -0
  131. package/lib/components/booking/info2/service/addTimeModal/serve.js +45 -0
  132. package/lib/components/booking/info2/service/addTimeModal/utils.d.ts +31 -0
  133. package/lib/components/booking/info2/service/addTimeModal/utils.js +157 -0
  134. package/lib/components/booking/info2/service/editService/Capacity/index.d.ts +4 -0
  135. package/lib/components/booking/info2/service/editService/Capacity/index.js +97 -0
  136. package/lib/components/booking/info2/service/editService/Capacity/index.less +1 -0
  137. package/lib/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.d.ts +7 -0
  138. package/lib/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.js +54 -0
  139. package/lib/components/booking/info2/service/editService/Resources/index.d.ts +4 -0
  140. package/lib/components/booking/info2/service/editService/Resources/index.js +212 -0
  141. package/lib/components/booking/info2/service/editService/Resources/index.less +21 -0
  142. package/lib/components/booking/info2/service/editService/index.d.ts +7 -0
  143. package/lib/components/booking/info2/service/editService/index.js +483 -0
  144. package/lib/components/booking/info2/service/editService/index.less +99 -0
  145. package/lib/components/booking/info2/service/editService/utils.d.ts +11 -0
  146. package/lib/components/booking/info2/service/editService/utils.js +0 -0
  147. package/lib/components/booking/info2/service/index.d.ts +4 -0
  148. package/lib/components/booking/info2/service/index.js +75 -0
  149. package/lib/components/booking/info2/service/serviceItem/index.d.ts +4 -0
  150. package/lib/components/booking/info2/service/serviceItem/index.js +184 -0
  151. package/lib/components/booking/info2/service/serviceItem/index.less +125 -0
  152. package/lib/components/booking/info2/service/serviceList/index.d.ts +6 -0
  153. package/lib/components/booking/info2/service/serviceList/index.js +130 -0
  154. package/lib/components/booking/info2/service/serviceList/index.less +0 -0
  155. package/lib/components/booking/info2/utilsByBooking.d.ts +34 -0
  156. package/lib/components/booking/info2/utilsByBooking.js +257 -0
  157. package/lib/components/booking/locales.d.ts +3 -48
  158. package/lib/components/booking/locales.js +3 -48
  159. package/lib/components/booking/materiels/resources/index.d.ts +2 -2
  160. package/lib/components/booking/mock.d.ts +1 -0
  161. package/lib/components/booking/mock.js +67 -2
  162. package/lib/components/booking/model.d.ts +0 -2
  163. package/lib/components/booking/notes/index.d.ts +1 -1
  164. package/lib/components/booking/notes/model.d.ts +1 -2
  165. package/lib/components/booking/payments/model.d.ts +1 -2
  166. package/lib/components/booking/utils.d.ts +1 -1
  167. package/lib/components/booking/utils.js +22 -57
  168. package/lib/components/eftposPay/tyro/index.js +3 -1
  169. package/lib/components/index.d.ts +1 -1
  170. package/lib/components/index.js +1 -1
  171. package/lib/components/schedules/index.d.ts +1 -1
  172. package/lib/components/schedules/model.d.ts +1 -2
  173. package/lib/index.d.ts +1 -3
  174. package/lib/index.js +1 -7
  175. package/package.json +2 -2
  176. package/es/components/booking/dashboard/index.d.ts +0 -10
  177. package/es/components/booking/dashboard/serve.d.ts +0 -1
  178. package/es/components/booking/info/addServiceVariant/index.d.ts +0 -7
  179. package/lib/components/booking/dashboard/index.d.ts +0 -10
  180. package/lib/components/booking/dashboard/index.js +0 -225
  181. package/lib/components/booking/dashboard/serve.d.ts +0 -1
  182. package/lib/components/booking/info/addServiceVariant/index.d.ts +0 -7
  183. package/lib/components/booking/info/addServiceVariant/index.js +0 -58
  184. package/lowcode/booking-dashboard/meta.ts +0 -130
  185. package/lowcode/booking-vertical-add-service/meta.ts +0 -124
  186. package/lowcode/vertical-add-service/meta.ts +0 -71
@@ -0,0 +1,617 @@
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 _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ 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."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ 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; }
9
+ 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; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ 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); }
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ 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); }
15
+ 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; }
16
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+ import React, { useContext, useEffect, useMemo, useImperativeHandle, forwardRef, useRef } from 'react';
19
+ import Delete_wght300_24px from '@pisell/icon/es/Delete_wght300_24px';
20
+ import Drawer from "../../../components/drawer";
21
+ import { Context } from "../../../info/model";
22
+ import { formatAmount, locales } from '@pisell/utils';
23
+ import Duration from "../../../materiels/duration";
24
+ import Capacity from "./Capacity";
25
+ import Resources from "./Resources";
26
+ import { Input, Button, Select, Row, Col, Form, InputNumber } from 'antd';
27
+ import "./index.less";
28
+ import CollapsibleList from "../../../components/collapsibleList";
29
+ import { renderBundles } from "../../../components/collapsibleList/utils";
30
+ import { useUpdateEffect, useMemoizedFn } from 'ahooks';
31
+ // import SelectTime from "../../../../../../../materials/src/components/select-time";
32
+ import { getServiceTimes, deleteCacheParams, getProductTotalPrice } from "../../../utils";
33
+ import { getErrorList } from "../../utilsByBooking";
34
+ import { formatResources, getDurationProps, getFlexibleOption } from "../addService/utils";
35
+ var submitLock = false;
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;
38
+ var _Form$useForm = Form.useForm(),
39
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
40
+ form = _Form$useForm2[0];
41
+ var useTotal = Form.useWatch('total', form);
42
+ var useResource = Form.useWatch('resource', form);
43
+ var useStartTime = Form.useWatch('start_time', form);
44
+ var useDuration = Form.useWatch('duration', form);
45
+ var _useContext = useContext(Context),
46
+ state = _useContext.state,
47
+ dispatch = _useContext.dispatch;
48
+ var resourcesRef = useRef(null);
49
+
50
+ // 当前商品信息+ 表单信息
51
+ var getCurrentCacheItem = function getCurrentCacheItem(_cacheItem) {
52
+ // 获取当前表单数据
53
+ var values = form.getFieldsValue();
54
+ var _item = _cacheItem || state.service.cacheItem;
55
+ return _objectSpread(_objectSpread({}, _item), {}, {
56
+ _extend: _objectSpread(_objectSpread({}, _item === null || _item === void 0 ? void 0 : _item._extend), values)
57
+ });
58
+ };
59
+
60
+ /**
61
+ * @title: 当前的资源
62
+ * @description:
63
+ * @param {*} useMemo
64
+ * @return {*}
65
+ * @Author: zhiwei.Wang
66
+ * @Date: 2024-01-09 14:06
67
+ */
68
+ var currentResource = useMemo(function () {
69
+ // let item =
70
+ // resources.find((d: any) => d.form_record_id == useResource) || {};
71
+ return null;
72
+ }, [useResource]);
73
+
74
+ /**
75
+ * @title: 持续时长组件的props
76
+ * @description:
77
+ * @param {*} useMemo
78
+ * @return {*}
79
+ * @Author: zhiwei.Wang
80
+ * @Date: 2024-02-23 09:59
81
+ */
82
+ var durationProps = useMemo(function () {
83
+ var _state$bookingConfig, _state$bookingConfig$, _state$bookingConfig$2;
84
+ var _cacheItem = getCurrentCacheItem();
85
+ return getDurationProps({
86
+ cacheItem: _cacheItem,
87
+ useStartTime: useStartTime,
88
+ currentResource: currentResource,
89
+ slice: (_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
90
+ });
91
+ }, [currentResource, state.service.cacheItem, useStartTime, useResource, (_state$bookingConfig2 = state.bookingConfig) === null || _state$bookingConfig2 === void 0 ? void 0 : (_state$bookingConfig3 = _state$bookingConfig2.config) === null || _state$bookingConfig3 === void 0 ? void 0 : (_state$bookingConfig4 = _state$bookingConfig3.basic) === null || _state$bookingConfig4 === void 0 ? void 0 : _state$bookingConfig4.service_time]);
92
+
93
+ /**
94
+ * @title: 灵活时长选项
95
+ * @description:
96
+ * @param {*} useMemo
97
+ * @return {*}
98
+ * @Author: zhiwei.Wang
99
+ * @Date: 2024-02-23 10:10
100
+ */
101
+ var flexibleOption = useMemo(function () {
102
+ return getFlexibleOption({
103
+ durationProps: durationProps
104
+ });
105
+ }, [durationProps, locales.locale]);
106
+
107
+ /**
108
+ * @title: 时间切片
109
+ * @description:
110
+ * @return {*}
111
+ * @Author: zhiwei.Wang
112
+ * @Date: 2024-01-09 13:37
113
+ */
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
+
119
+ // 由于灵活时长的结束时间随时变动, 这里发现如果当前选择的值没有在列表内,则选择最新的灵活时长值
120
+ useEffect(function () {
121
+ try {
122
+ if (useDuration.indexOf('flexible_') == 0) {
123
+ if (flexibleOption) {
124
+ form.setFieldsValue({
125
+ duration: flexibleOption.value
126
+ });
127
+ }
128
+ }
129
+ } catch (err) {}
130
+ }, [useDuration, flexibleOption]);
131
+
132
+ /**
133
+ * @title: 删除服务商品
134
+ * @description:
135
+ * @return {*}
136
+ * @Author: zhiwei.Wang
137
+ * @Date: 2024-01-09 13:59
138
+ */
139
+ var handleDeleteProduct = function handleDeleteProduct() {
140
+ var _state$service$cacheI2;
141
+ if (state.channelDisabledEdit) {
142
+ return;
143
+ }
144
+ 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;
146
+ _list = _list.filter(function (d) {
147
+ return d._id !== _id;
148
+ });
149
+ dispatch({
150
+ type: 'setService',
151
+ payload: {
152
+ editModal: false,
153
+ value: _list,
154
+ edit: true,
155
+ cacheItem: null
156
+ }
157
+ });
158
+ };
159
+
160
+ /**
161
+ * @title: 计算折扣
162
+ * @description: 仅是文案展示
163
+ * @return {*}
164
+ * @Author: zhiwei.Wang
165
+ * @Date: 2024-01-09 14:03
166
+ */
167
+ 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);
170
+ var cPrice = Number(useTotal || 0);
171
+ var discount = '';
172
+ // 原价 = 现价 为无折扣
173
+ if (cPrice === oPrice) {
174
+ discount = locales.getText('pisell2.text.status.no-discount');
175
+ } else {
176
+ // 判断加价还是减价
177
+ discount = "".concat(locales.getText('pisell2.text.status.manual'), " ");
178
+ if (cPrice < oPrice) {
179
+ discount += formatAmount(cPrice - oPrice, 2, state.amountSymbol) + '';
180
+ } else {
181
+ discount += '+' + formatAmount(cPrice - oPrice, 2, state.amountSymbol) + '';
182
+ }
183
+ }
184
+ // 赋值文案
185
+ form.setFieldsValue({
186
+ discount: discount
187
+ });
188
+ };
189
+
190
+ /**
191
+ * @title: 提交,
192
+ * @description:
193
+ * @param {any} values
194
+ * @return {*}
195
+ * @Author: zhiwei.Wang
196
+ * @Date: 2024-01-09 14:04
197
+ */
198
+ var onFinish = function onFinish(values) {
199
+ var _resourcesRef$current;
200
+ var isSuccess = (_resourcesRef$current = resourcesRef.current) === null || _resourcesRef$current === void 0 ? void 0 : _resourcesRef$current.check();
201
+ if (!isSuccess) {
202
+ return;
203
+ }
204
+ // 防止多次提交, 增加锁
205
+ if (submitLock) {
206
+ return;
207
+ }
208
+ submitLock = true;
209
+
210
+ // 1500毫秒后解除
211
+ setTimeout(function () {
212
+ submitLock = false;
213
+ }, 1500);
214
+ var _list = _toConsumableArray(state.service.value);
215
+ var _item = _objectSpread(_objectSpread({}, state.service.cacheItem), {}, {
216
+ autoClose: false
217
+ });
218
+ var _extend = _objectSpread(_objectSpread({}, _item._extend), values);
219
+ var _getServiceTimes = getServiceTimes({
220
+ _extend: _extend
221
+ }),
222
+ startDate = _getServiceTimes.startDate,
223
+ endDate = _getServiceTimes.endDate;
224
+ _extend.startDate = startDate;
225
+ _extend.endDate = endDate;
226
+ if (_extend.bundle_edit !== undefined) {
227
+ _extend.bundle_edit = 1;
228
+ }
229
+ _item._extend = _extend;
230
+ _item._time = new Date().getTime();
231
+ var _id = _item === null || _item === void 0 ? void 0 : _item._id;
232
+
233
+ // 判断是新增还是编辑
234
+ if (!_list.some(function (d) {
235
+ return d._id === _id;
236
+ })) {
237
+ _list.push(_item);
238
+ } else {
239
+ _list = _list.map(function (d) {
240
+ return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
241
+ new: 0
242
+ }) : d;
243
+ });
244
+ }
245
+ deleteCacheParams();
246
+ console.log('_onFinish', _list);
247
+ form.resetFields();
248
+ dispatch({
249
+ type: 'setService',
250
+ payload: {
251
+ editModal: false,
252
+ addModal: false,
253
+ value: _list,
254
+ edit: true,
255
+ cacheItem: null,
256
+ changeService: false
257
+ }
258
+ });
259
+ };
260
+ var setEditData = useMemoizedFn(function (_cacheItem) {
261
+ form.resetFields();
262
+ var cacheItem = _cacheItem || state.service.cacheItem;
263
+ var values = cacheItem._extend;
264
+ form.setFieldsValue(values);
265
+ });
266
+
267
+ /**
268
+ * @title: 是否显示折扣原因
269
+ * @description:
270
+ * @param {*} useMemo
271
+ * @return {*}
272
+ * @Author: zhiwei.Wang
273
+ * @Date: 2024-01-09 14:06
274
+ */
275
+ 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);
278
+ var cPrice = Number(useTotal || 0);
279
+ // 原价 !== 现价
280
+ 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]);
282
+ var getResources = function getResources() {
283
+ var res = formatResources({
284
+ cacheItem: getCurrentCacheItem(),
285
+ resourcesOrigin: state.service.cacheItem._data.resourcesOrigin
286
+ });
287
+ dispatch({
288
+ type: 'setService',
289
+ payload: {
290
+ cacheItem: _objectSpread(_objectSpread({}, state.service.cacheItem), {}, {
291
+ _data: _objectSpread(_objectSpread({}, state.service.cacheItem._data), {}, {
292
+ resources: res.list,
293
+ resourceMaps: res.maps
294
+ })
295
+ })
296
+ }
297
+ });
298
+ updateResourceErrors(res.maps);
299
+ };
300
+ var updateResourceErrors = function updateResourceErrors(resourceMaps) {
301
+ var _form$getFieldsValue = form.getFieldsValue(),
302
+ resource = _form$getFieldsValue.resource;
303
+ if (resource) {
304
+ var _resource = _objectSpread({}, resource);
305
+ // 拿当前value 和 resources
306
+ var _loop = function _loop(form_id) {
307
+ _resource[form_id] = _resource[form_id].map(function (d) {
308
+ var _resourceMaps$form_id, _resourceMaps$form_id2;
309
+ return _objectSpread(_objectSpread({}, d), {}, {
310
+ errors: getErrorList(resourceMaps === null || resourceMaps === void 0 ? void 0 : (_resourceMaps$form_id = resourceMaps[form_id]) === null || _resourceMaps$form_id === void 0 ? void 0 : (_resourceMaps$form_id2 = _resourceMaps$form_id.renderListMaps) === null || _resourceMaps$form_id2 === void 0 ? void 0 : _resourceMaps$form_id2[d === null || d === void 0 ? void 0 : d.relation_id], getCurrentCacheItem())
311
+ });
312
+ });
313
+ };
314
+ for (var form_id in _resource) {
315
+ _loop(form_id);
316
+ }
317
+ form.setFieldsValue({
318
+ resource: _resource
319
+ });
320
+ return _resource;
321
+ }
322
+ };
323
+
324
+ /**
325
+ * @title: 开始时间 和 服务时间 发生变化时,重新计算资源
326
+ * @description:
327
+ * @return {*}
328
+ * @Author: zhiwei.Wang
329
+ * @Date: 2024-01-09 14:07
330
+ */
331
+ useUpdateEffect(function () {
332
+ if (!state.service.cacheItem) {
333
+ return;
334
+ }
335
+ if (useStartTime && useDuration && state.renderType !== 'eventBooking') {
336
+ getResources();
337
+ }
338
+ }, [useStartTime, useDuration, state.renderType, state.service.resourcesOrigin]);
339
+
340
+ /**
341
+ * @title: 价格发生变化,重新计算折扣
342
+ * @description:
343
+ * @return {*}
344
+ * @Author: zhiwei.Wang
345
+ * @Date: 2024-01-09 14:08
346
+ */
347
+ useEffect(function () {
348
+ getDiscount();
349
+ }, [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]);
350
+ var isDiscount = useMemo(function () {
351
+ var _state$service3, _state$service4, _state$service4$cache;
352
+ if (!((_state$service3 = state.service) !== null && _state$service3 !== void 0 && _state$service3.cacheItem)) {
353
+ return false;
354
+ }
355
+ 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);
356
+ }, [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]);
357
+ var bundles = useMemo(function () {
358
+ var _state$service6, _state$service6$cache, _state$service6$cache2, _state$service6$cache3;
359
+ 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) || [];
360
+ }, [(_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]);
361
+
362
+ /**
363
+ * @title: 编辑商品
364
+ * @description:
365
+ * @param {any} e
366
+ * @return {*}
367
+ * @Author: zhiwei.Wang
368
+ * @Date: 2024-08-28 17:08
369
+ */
370
+ var handleEdit = function handleEdit(e) {
371
+ // 当前商品
372
+ var item = state.service.cacheItem;
373
+
374
+ // 表单数据
375
+ var values = form.getFieldsValue();
376
+
377
+ // 打开商品详情弹窗
378
+ state.action({
379
+ type: 'pisell1.handleOpenProductModal',
380
+ data: {
381
+ id: item.id,
382
+ date: state.date.value.format('YYYY-MM-DD'),
383
+ showConfig: {
384
+ option: false,
385
+ session: false,
386
+ variant: false,
387
+ package: true
388
+ },
389
+ value: item._extend.other
390
+ },
391
+ callback: function callback(e) {
392
+ // 重新生成商品
393
+ var cacheItem = _objectSpread(_objectSpread({}, item), {}, {
394
+ product_id: item.id,
395
+ _id: item === null || item === void 0 ? void 0 : item._id,
396
+ _key: e.key,
397
+ _extend: _objectSpread(_objectSpread(_objectSpread({}, item._extend), values), {}, {
398
+ // 覆盖选择的规格和套餐
399
+ other: JSON.parse(JSON.stringify(e))
400
+ }),
401
+ new: 0
402
+ });
403
+
404
+ // 获取商品总价
405
+ var _total = getProductTotalPrice(cacheItem);
406
+
407
+ // 用于折扣 可修改
408
+ cacheItem._extend.total = _total;
409
+
410
+ // 用于储存原价
411
+ cacheItem._extend.origin_total = _total;
412
+
413
+ // 覆盖商品
414
+ dispatch({
415
+ type: 'setService',
416
+ payload: {
417
+ cacheItem: cacheItem
418
+ }
419
+ });
420
+
421
+ // 更新表单内的商品价格
422
+ form.setFieldsValue({
423
+ total: _total
424
+ });
425
+ }
426
+ });
427
+ };
428
+
429
+ /**
430
+ * @title: 更换商品
431
+ * @description:
432
+ * @param {any} e
433
+ * @return {*}
434
+ * @Author: zhiwei.Wang
435
+ * @Date: 2024-08-28 17:10
436
+ */
437
+ var handleChange = function handleChange(e) {
438
+ if (state.channelDisabledEdit) {
439
+ return;
440
+ }
441
+ form.resetFields();
442
+ dispatch({
443
+ type: 'setService',
444
+ payload: {
445
+ addModal: true,
446
+ editModal: false
447
+
448
+ //用于控制 添加商品 和 编辑服务弹窗的上下层级
449
+ // changeService: true,
450
+ }
451
+ });
452
+ };
453
+
454
+ useImperativeHandle(ref, function () {
455
+ return {
456
+ init: setEditData
457
+ };
458
+ });
459
+ console.log('state.service.value', state.service.value);
460
+ var SelectTime = (_window$BaseMaterials = window.BaseMaterials) === null || _window$BaseMaterials === void 0 ? void 0 : _window$BaseMaterials.SelectTime;
461
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Drawer
462
+ //通过zIndex的方式控制 添加商品 和 编辑服务弹窗的上下层级
463
+ , {
464
+ zIndex: state.service.changeService ? 999 : 1000,
465
+ forceRender: true,
466
+ open: state.service.editModal && !((_state$service$cacheI9 = state.service.cacheItem) !== null && _state$service$cacheI9 !== void 0 && _state$service$cacheI9.autoClose),
467
+ title: locales.getText('pisell2.text.edit-service'),
468
+ onClose: function onClose() {
469
+ dispatch({
470
+ type: 'setService',
471
+ payload: {
472
+ editModal: false,
473
+ cacheItem: null,
474
+ changeService: false
475
+ }
476
+ });
477
+ }
478
+ }, /*#__PURE__*/React.createElement("div", {
479
+ className: "pisell-lowcode__booking-service-body-edit"
480
+ }, /*#__PURE__*/React.createElement(Form, {
481
+ layout: "vertical",
482
+ form: form,
483
+ onFinish: onFinish
484
+ }, /*#__PURE__*/React.createElement(Row, {
485
+ style: {
486
+ width: '100%'
487
+ },
488
+ gutter: [16, 0]
489
+ }, /*#__PURE__*/React.createElement(Col, {
490
+ span: 24
491
+ }, /*#__PURE__*/React.createElement(Form.Item, {
492
+ name: "product_name"
493
+ }, /*#__PURE__*/React.createElement("div", {
494
+ className: "current-service-info"
495
+ }, /*#__PURE__*/React.createElement("div", {
496
+ className: "current-service-info-name-wrap"
497
+ }, /*#__PURE__*/React.createElement("div", {
498
+ className: "current-service-info-name"
499
+ }, ((_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, {
500
+ onClick: handleEdit
501
+ }, locales.getText('pisell2.text.edit')), /*#__PURE__*/React.createElement(Button, {
502
+ onClick: handleChange
503
+ }, locales.getText('pisell2.text.change'))), /*#__PURE__*/React.createElement(CollapsibleList, {
504
+ style: {
505
+ marginTop: bundles.length ? '8px' : 0
506
+ },
507
+ list: bundles,
508
+ renderItem: function renderItem(item) {
509
+ return renderBundles(item, state.amountSymbol);
510
+ }
511
+ })))), /*#__PURE__*/React.createElement(Col, {
512
+ span: 12
513
+ }, /*#__PURE__*/React.createElement(Form.Item, {
514
+ label: locales.getText('pisell2.text.price'),
515
+ name: "total",
516
+ rules: [{
517
+ required: true
518
+ }]
519
+ }, /*#__PURE__*/React.createElement(InputNumber, {
520
+ disabled: state.channelDisabledEdit,
521
+ prefix: state.amountSymbol,
522
+ size: "large",
523
+ precision: 2,
524
+ style: {
525
+ width: '100%'
526
+ },
527
+ min: 0,
528
+ 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,
529
+ 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'
530
+ }))), /*#__PURE__*/React.createElement(Col, {
531
+ span: 12
532
+ }, /*#__PURE__*/React.createElement(Form.Item, {
533
+ label: locales.getText('pisell2.text.discount'),
534
+ name: "discount"
535
+ }, /*#__PURE__*/React.createElement(Select, {
536
+ disabled: state.channelDisabledEdit,
537
+ size: "large",
538
+ open: false,
539
+ allowClear: isDiscount,
540
+ onChange: function onChange(e) {
541
+ form.setFieldsValue({
542
+ total: state.service.cacheItem._extend.origin_total
543
+ });
544
+ }
545
+ }))), isReason ? /*#__PURE__*/React.createElement(Col, {
546
+ span: 24
547
+ }, /*#__PURE__*/React.createElement(Form.Item, {
548
+ label: locales.getText('pisell2.text.discount-reason'),
549
+ name: "discount_reason"
550
+ }, /*#__PURE__*/React.createElement(Input.TextArea, {
551
+ size: "large"
552
+ }))) : null, state.renderType !== 'eventBooking' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Col, {
553
+ span: 12
554
+ }, /*#__PURE__*/React.createElement(Form.Item, {
555
+ label: locales.getText('pisell2.text.start_time'),
556
+ name: "start_time",
557
+ rules: [{
558
+ required: true
559
+ }]
560
+ }, SelectTime ? /*#__PURE__*/React.createElement(SelectTime, {
561
+ slice: (_state$bookingConfig5 = state.bookingConfig) === null || _state$bookingConfig5 === void 0 ? void 0 : (_state$bookingConfig6 = _state$bookingConfig5.config) === null || _state$bookingConfig6 === void 0 ? void 0 : (_state$bookingConfig7 = _state$bookingConfig6.basic) === null || _state$bookingConfig7 === void 0 ? void 0 : (_state$bookingConfig8 = _state$bookingConfig7.service_time) === null || _state$bookingConfig8 === void 0 ? void 0 : _state$bookingConfig8.value,
562
+ timePickerProps: {
563
+ style: {
564
+ width: '100%'
565
+ }
566
+ },
567
+ timeProps: {
568
+ style: {
569
+ zoom: 0.8
570
+ }
571
+ }
572
+ }) : null)), /*#__PURE__*/React.createElement(Col, {
573
+ span: 12
574
+ }, /*#__PURE__*/React.createElement(Form.Item, {
575
+ label: locales.getText('pisell2.text.duration'),
576
+ name: "duration",
577
+ rules: [{
578
+ required: true
579
+ }]
580
+ }, /*#__PURE__*/React.createElement(Duration, _extends({}, durationProps, {
581
+ timeObj: timeObj
582
+ })))), /*#__PURE__*/React.createElement(Form.Item, {
583
+ noStyle: true,
584
+ name: "resource"
585
+ }, /*#__PURE__*/React.createElement(Resources, {
586
+ ref: resourcesRef,
587
+ state: state,
588
+ cacheItem: state.service.cacheItem,
589
+ getCurrentCacheItem: getCurrentCacheItem,
590
+ useDuration: useDuration,
591
+ useStartTime: useStartTime
592
+ })), /*#__PURE__*/React.createElement(Form.Item, {
593
+ noStyle: true,
594
+ name: "capacity"
595
+ }, /*#__PURE__*/React.createElement(Capacity, {
596
+ state: state,
597
+ cacheItem: state.service.cacheItem
598
+ })), /*#__PURE__*/React.createElement(Form.Item, {
599
+ hidden: true,
600
+ name: "quantity"
601
+ }, /*#__PURE__*/React.createElement(InputNumber, null))))), /*#__PURE__*/React.createElement("div", {
602
+ className: "pisell-lowcode__booking-service-body-edit-footer"
603
+ }, /*#__PURE__*/React.createElement("div", {
604
+ className: "pisell-lowcode__booking-service-delete-wrap",
605
+ onClick: handleDeleteProduct
606
+ }, /*#__PURE__*/React.createElement(Delete_wght300_24px, {
607
+ className: "pisell-lowcode__booking-service-delete-icon"
608
+ })), /*#__PURE__*/React.createElement(Button, {
609
+ type: "primary",
610
+ className: "pisell-lowcode__booking-service-body-edit-footer-apple",
611
+ disabled: !((_state$service$resour = state.service.resourcesOrigin) !== null && _state$service$resour !== void 0 && _state$service$resour.length),
612
+ onClick: function onClick() {
613
+ form.submit();
614
+ }
615
+ }, locales.getText('pisell2.text.apply'))))));
616
+ };
617
+ export default /*#__PURE__*/forwardRef(Info);