@pisell/private-materials 6.3.74 → 6.3.76

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 (50) 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/render/default/view.js +1 -1
  7. package/build/lowcode/view.js +1 -1
  8. package/es/components/appointmentBooking/components/Header/index.js +12 -12
  9. package/es/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.d.ts +2 -0
  10. package/es/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.js +82 -0
  11. package/es/components/appointmentBooking/components/TimeSlicing/index.js +46 -5
  12. package/es/components/appointmentBooking/components/Voucher/index.js +12 -2
  13. package/es/components/appointmentBooking/hooks.d.ts +1 -1
  14. package/es/components/appointmentBooking/hooks.js +6 -13
  15. package/es/components/appointmentBooking/utils.d.ts +23 -0
  16. package/es/components/appointmentBooking/utils.js +159 -0
  17. package/es/components/booking/addons/model.d.ts +1 -10
  18. package/es/components/booking/forms/model.d.ts +1 -10
  19. package/es/components/booking/info/model.d.ts +1 -10
  20. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  21. package/es/components/booking/info/service2/utils.js +38 -36
  22. package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
  23. package/es/components/booking/model.d.ts +1 -9
  24. package/es/components/booking/notes/model.d.ts +1 -10
  25. package/es/components/booking/payments/model.d.ts +1 -10
  26. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/index.d.ts +0 -1
  27. package/es/components/pay/toC/model.d.ts +1 -9
  28. package/es/components/schedules/model.d.ts +1 -9
  29. package/lib/components/appointmentBooking/components/Header/index.js +3 -8
  30. package/lib/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.d.ts +2 -0
  31. package/lib/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.js +89 -0
  32. package/lib/components/appointmentBooking/components/TimeSlicing/index.js +27 -7
  33. package/lib/components/appointmentBooking/components/Voucher/index.js +12 -2
  34. package/lib/components/appointmentBooking/hooks.d.ts +1 -1
  35. package/lib/components/appointmentBooking/hooks.js +6 -11
  36. package/lib/components/appointmentBooking/utils.d.ts +23 -0
  37. package/lib/components/appointmentBooking/utils.js +103 -0
  38. package/lib/components/booking/addons/model.d.ts +1 -10
  39. package/lib/components/booking/forms/model.d.ts +1 -10
  40. package/lib/components/booking/info/model.d.ts +1 -10
  41. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  42. package/lib/components/booking/info/service2/utils.js +3 -1
  43. package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
  44. package/lib/components/booking/model.d.ts +1 -9
  45. package/lib/components/booking/notes/model.d.ts +1 -10
  46. package/lib/components/booking/payments/model.d.ts +1 -10
  47. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/index.d.ts +0 -1
  48. package/lib/components/pay/toC/model.d.ts +1 -9
  49. package/lib/components/schedules/model.d.ts +1 -9
  50. package/package.json +3 -3
@@ -71,7 +71,7 @@ var Header = function Header() {
71
71
  var handleBack = /*#__PURE__*/function () {
72
72
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
73
73
  var _currentStep$step4;
74
- var key, types, form_key, booking_form, prevStepData, currentStepData, _key;
74
+ var key, types, form_key, booking_form, prevStepData, currentStepData, _key, isServiceStep, isResourceStep;
75
75
  return _regeneratorRuntime().wrap(function _callee$(_context) {
76
76
  while (1) switch (_context.prev = _context.next) {
77
77
  case 0:
@@ -130,9 +130,9 @@ var Header = function Header() {
130
130
  isSkip: false
131
131
  });
132
132
  }
133
-
134
- // 如果前一步是选择服务步骤,则移除表单和资源开头的步骤, 防止每个商品配置的资源不一样,导致步骤会有上次的数据
135
- if ((prevStepData === null || prevStepData === void 0 ? void 0 : prevStepData.key) === 'select-service') {
133
+ isServiceStep = (prevStepData === null || prevStepData === void 0 ? void 0 : prevStepData.key) === 'select-service';
134
+ isResourceStep = (prevStepData === null || prevStepData === void 0 ? void 0 : prevStepData.key) === 'select-resource'; // 如果前一步是选择服务步骤,则移除表单和资源开头的步骤, 防止每个商品配置的资源不一样,导致步骤会有上次的数据
135
+ if (isServiceStep || isResourceStep) {
136
136
  stepList.forEach(function (item) {
137
137
  if (item.key.startsWith('select-resource_') || item.key.startsWith('fill-form_')) {
138
138
  removeStep(item.key);
@@ -141,13 +141,13 @@ var Header = function Header() {
141
141
  }
142
142
 
143
143
  // 如果前一步是选择资源,则清空表单步骤,不然表单步骤会累加
144
- if ((prevStepData === null || prevStepData === void 0 ? void 0 : prevStepData.key) === 'select-resource') {
145
- stepList.forEach(function (item) {
146
- if (item.key.startsWith('fill-form_')) {
147
- removeStep(item.key);
148
- }
149
- });
150
- }
144
+ // if (prevStepData?.key === 'select-resource') {
145
+ // stepList.forEach((item: any) => {
146
+ // if (item.key.startsWith('fill-form_')) {
147
+ // removeStep(item.key);
148
+ // }
149
+ // });
150
+ // }
151
151
 
152
152
  // 再次将步骤更新为false, 增加这个判断为了跳过那一步没有设置holder,但是直接后退了
153
153
  // if (
@@ -160,7 +160,7 @@ var Header = function Header() {
160
160
  // isSkip: false,
161
161
  // });
162
162
  // }
163
- case 13:
163
+ case 14:
164
164
  case "end":
165
165
  return _context.stop();
166
166
  }
@@ -0,0 +1,2 @@
1
+ declare const SelectDate: (props: any) => JSX.Element | null;
2
+ export default SelectDate;
@@ -0,0 +1,82 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useMemo } from 'react';
8
+ import { useAppointmentBooking } from "../../../hooks";
9
+ import { useAppointmentBookingContext } from "../../../context";
10
+ import useComponents from "../../../../../hooks/useComponents";
11
+ import { processResourceList, getResourceTitle } from "../../../utils";
12
+ import { contextUtils } from "../../../hooks";
13
+ import { clearDataByStepKey } from "../../../utils";
14
+ var SelectDate = function SelectDate(props) {
15
+ var onDateChange = props.onDateChange,
16
+ times = props.times,
17
+ currentDate = props.currentDate;
18
+ var appointmentBooking = useAppointmentBooking();
19
+ var _useAppointmentBookin = useAppointmentBookingContext(),
20
+ currentSelectedResources = _useAppointmentBookin.currentSelectedResources,
21
+ setTimes = _useAppointmentBookin.setTimes;
22
+ var utils = contextUtils();
23
+ var _useComponents = useComponents({
24
+ components: ['SelectDateOS']
25
+ }),
26
+ _useComponents2 = _slicedToArray(_useComponents, 1),
27
+ SelectDateOS = _useComponents2[0];
28
+
29
+ /**
30
+ * @description: 获取资源代码
31
+ * @param {*}
32
+ * @return {*}
33
+ */
34
+ var resourceCode = useMemo(function () {
35
+ var _ref = (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.otherParams) || {},
36
+ resourceSort = _ref.resourceSort;
37
+ var resources = appointmentBooking.getResourcesList();
38
+ var _processResourceList = processResourceList(resources, resourceSort),
39
+ resourceCodes = _processResourceList.resourceCodes;
40
+ return (resourceCodes === null || resourceCodes === void 0 ? void 0 : resourceCodes[0]) || '';
41
+ }, []);
42
+
43
+ /**
44
+ * @description: 获取资源名称
45
+ * @param {*} useMemo
46
+ * @return {*}
47
+ */
48
+ var currentResourceName = useMemo(function () {
49
+ var _currentSelectedResou;
50
+ var currentResource = currentSelectedResources === null || currentSelectedResources === void 0 || (_currentSelectedResou = currentSelectedResources[0]) === null || _currentSelectedResou === void 0 ? void 0 : _currentSelectedResou.currentSelectedResource;
51
+ var resourceItem = (currentResource === null || currentResource === void 0 ? void 0 : currentResource.resourceItem) || {};
52
+ var name = getResourceTitle(appointmentBooking, resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.code, utils, resourceItem);
53
+ return name;
54
+ }, [currentSelectedResources]);
55
+
56
+ /**
57
+ * @description: 跳转到服务步骤
58
+ * @param {any} step
59
+ * @return {*}
60
+ */
61
+ var onStepChange = function onStepChange() {
62
+ // 清空数据
63
+ clearDataByStepKey('select-service', appointmentBooking, setTimes);
64
+
65
+ // 跳转到服务步骤
66
+ var stepLists = appointmentBooking.getStepList();
67
+ var serviceIndex = stepLists.findIndex(function (item) {
68
+ return (item === null || item === void 0 ? void 0 : item.key) === 'select-service';
69
+ });
70
+ appointmentBooking.gotoStep(serviceIndex);
71
+ };
72
+ return SelectDateOS ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SelectDateOS, {
73
+ isTimeSlicing: true,
74
+ currentDate: currentDate,
75
+ resourceCode: resourceCode,
76
+ resourceName: currentResourceName,
77
+ onDateChange: onDateChange,
78
+ onStepChange: onStepChange,
79
+ times: times
80
+ })) : null;
81
+ };
82
+ export default SelectDate;
@@ -9,12 +9,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import React, { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
12
- import { Iconfont, PisellEmpty } from '@pisell/materials';
12
+ import { Iconfont } from '@pisell/materials';
13
13
  import { locales } from '@pisell/utils';
14
14
  import { useAppointmentBookingContext } from "../../context";
15
15
  import { scrollToFirstErrorCard } from "../Resource/utils";
16
16
  import { useAppointmentBookingResource, useAppointmentBookingStep } from "../../hooks";
17
17
  import { Toast } from "../../utils";
18
+ import SelectDate from "./components/SelectDateOS";
18
19
  import "./index.less";
19
20
  var TimeSlicing = /*#__PURE__*/forwardRef(function (props, ref) {
20
21
  var _useState = useState(''),
@@ -32,6 +33,10 @@ var TimeSlicing = /*#__PURE__*/forwardRef(function (props, ref) {
32
33
  getResourceList = _useAppointmentBookin.getResourceList;
33
34
  var _useAppointmentBookin2 = useAppointmentBookingStep(),
34
35
  nextStep = _useAppointmentBookin2.nextStep;
36
+ var _useState3 = useState(undefined),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ currentDate = _useState4[0],
39
+ setCurrentDate = _useState4[1];
35
40
  useImperativeHandle(ref, function () {
36
41
  return {
37
42
  next: function next() {
@@ -102,7 +107,45 @@ var TimeSlicing = /*#__PURE__*/forwardRef(function (props, ref) {
102
107
  return _ref3.apply(this, arguments);
103
108
  };
104
109
  }();
105
- return (times === null || times === void 0 ? void 0 : times.length) > 0 ? /*#__PURE__*/React.createElement("div", {
110
+ useEffect(function () {
111
+ var getCurrentDate = /*#__PURE__*/function () {
112
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
113
+ var _res$;
114
+ var res, date;
115
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
116
+ while (1) switch (_context3.prev = _context3.next) {
117
+ case 0:
118
+ _context3.next = 2;
119
+ return appointmentBooking.getDateRange();
120
+ case 2:
121
+ res = _context3.sent;
122
+ date = res === null || res === void 0 || (_res$ = res[0]) === null || _res$ === void 0 ? void 0 : _res$.date;
123
+ setCurrentDate(date);
124
+ case 5:
125
+ case "end":
126
+ return _context3.stop();
127
+ }
128
+ }, _callee3);
129
+ }));
130
+ return function getCurrentDate() {
131
+ return _ref4.apply(this, arguments);
132
+ };
133
+ }();
134
+ getCurrentDate();
135
+ }, []);
136
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SelectDate, {
137
+ onDateChange: function onDateChange(currentData) {
138
+ if ((times === null || times === void 0 ? void 0 : times.length) > 0) {
139
+ // 如果已经选择了日期,再触发选择,则清空上次选择的时间
140
+ appointmentBooking.deleteCartItemInfo('time');
141
+ }
142
+ setCurrentDate(currentData === null || currentData === void 0 ? void 0 : currentData.date);
143
+ appointmentBooking.setDateRange([currentData]);
144
+ getResourceTimeSlot();
145
+ },
146
+ times: times,
147
+ currentDate: currentDate
148
+ }), (times === null || times === void 0 ? void 0 : times.length) > 0 ? /*#__PURE__*/React.createElement("div", {
106
149
  className: 'appointment-time-slicing-wrap'
107
150
  }, times.map(function (item, index) {
108
151
  return /*#__PURE__*/React.createElement("div", {
@@ -115,8 +158,6 @@ var TimeSlicing = /*#__PURE__*/forwardRef(function (props, ref) {
115
158
  type: "pisell2-chevron-right",
116
159
  className: "icon"
117
160
  }));
118
- })) : /*#__PURE__*/React.createElement(PisellEmpty, {
119
- description: locales.getText('pisell2.appointment.unselect.time')
120
- });
161
+ })) : null);
121
162
  });
122
163
  export default TimeSlicing;
@@ -28,6 +28,7 @@ import { PisellInput, PisellGoodPassCard, PisellText, PisellToast } from '@pisel
28
28
  import { useAppointmentBooking, useShopDiscount, useAppointmentBookingLogin, useAppointmentBookingAccount } from "../../hooks";
29
29
  import "../../../booking/components/voucher/index.less";
30
30
  import "./index.less";
31
+ import { useDebounceFn } from 'ahooks';
31
32
  var ShopDiscountHooks = {
32
33
  onInited: 'shopDiscount:onInited',
33
34
  onDestroy: 'shopDiscount:onDestroy',
@@ -95,6 +96,12 @@ var VoucherCard = function VoucherCard(props) {
95
96
  useEffect(function () {
96
97
  shopDiscount.setProductList(products);
97
98
  }, [products]);
99
+ var _useDebounceFn = useDebounceFn(function () {
100
+ onCartChangeFn();
101
+ }, {
102
+ wait: 300
103
+ }),
104
+ onCartChange = _useDebounceFn.run;
98
105
  var batchUpdateCart = function batchUpdateCart(productList) {
99
106
  var _appointmentBooking$b;
100
107
  var items = productList.map(function (item) {
@@ -110,10 +117,13 @@ var VoucherCard = function VoucherCard(props) {
110
117
  });
111
118
  appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$b = appointmentBooking.batchUpdateCart) === null || _appointmentBooking$b === void 0 || _appointmentBooking$b.call(appointmentBooking, items);
112
119
  };
113
- var onCartChange = function onCartChange() {
114
- var _shopDiscount$setBook, _appointmentBooking$o;
120
+ var onCartChangeFn = function onCartChangeFn() {
121
+ var _shopDiscount$setBook, _appointmentBooking$o, _shopDiscount$getDisc;
115
122
  var products = cart === null || cart === void 0 ? void 0 : cart.getItems();
116
123
  shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$setBook = shopDiscount.setBookingSubject) === null || _shopDiscount$setBook === void 0 || _shopDiscount$setBook.call(shopDiscount, appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o = appointmentBooking.otherParams) === null || _appointmentBooking$o === void 0 || (_appointmentBooking$o = _appointmentBooking$o.bookingSetting) === null || _appointmentBooking$o === void 0 ? void 0 : _appointmentBooking$o.bookingSubject);
124
+ if (Array.isArray(shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$getDisc = shopDiscount.getDiscountList) === null || _shopDiscount$getDisc === void 0 ? void 0 : _shopDiscount$getDisc.call(shopDiscount)) && !(shopDiscount !== null && shopDiscount !== void 0 && shopDiscount.getDiscountList().length)) {
125
+ return;
126
+ }
117
127
  var val = shopDiscount.calcDiscount(products);
118
128
  batchUpdateCart(val.productList);
119
129
  };
@@ -72,7 +72,7 @@ export declare const useAppointmentBookingAccount: () => {
72
72
  export declare const useAppointmentBookingResource: () => {
73
73
  getResourceTimeSlot: (index?: number) => Promise<void>;
74
74
  getResourceList: () => {
75
- resources: any;
75
+ resources: any[];
76
76
  resourceCodes: any;
77
77
  };
78
78
  };
@@ -17,7 +17,7 @@ import { useState, useEffect, useMemo } from 'react';
17
17
  import { locales } from '@pisell/utils';
18
18
  import { usePisellOS } from "../../hooks/useEngineContext";
19
19
  import useEngineContext from "../../hooks/useEngineContext";
20
- import { sortResources, getCustomer, currentAppointmentBoard, currentRenderLists, getFormInsertBeforeKey, checkAndGoNext, checkAndMarkCartRenderError, formatHolder, Toast } from "./utils";
20
+ import { processResourceList, getCustomer, currentAppointmentBoard, currentRenderLists, getFormInsertBeforeKey, checkAndGoNext, checkAndMarkCartRenderError, formatHolder, Toast } from "./utils";
21
21
  import { useAppointmentBookingContext } from "./context";
22
22
  import { scrollToFirstErrorCard } from "./components/Resource/utils";
23
23
  export var useAppointmentBooking = function useAppointmentBooking() {
@@ -809,20 +809,13 @@ export var useAppointmentBookingResource = function useAppointmentBookingResourc
809
809
 
810
810
  // 设置资源列表
811
811
  var getResourceList = function getResourceList() {
812
- var _resources2;
813
812
  var resources = appointmentBooking.getResourcesList();
814
- resources = resources.map(function (item) {
815
- return _objectSpread(_objectSpread({}, item), {}, {
816
- resources: sortResources((item === null || item === void 0 ? void 0 : item.resources) || [], resourceSort)
817
- });
818
- });
819
- var _resources = ((_resources2 = resources) === null || _resources2 === void 0 || (_resources2 = _resources2[0]) === null || _resources2 === void 0 ? void 0 : _resources2.resources) || [];
820
- var resourceCodes = _resources.map(function (item) {
821
- return item.code;
822
- });
823
- setResources(resources || []);
813
+ var _processResourceList = processResourceList(resources, resourceSort),
814
+ processedResources = _processResourceList.resources,
815
+ resourceCodes = _processResourceList.resourceCodes;
816
+ setResources(processedResources || []);
824
817
  return {
825
- resources: resources,
818
+ resources: processedResources,
826
819
  resourceCodes: resourceCodes
827
820
  };
828
821
  };
@@ -39,6 +39,19 @@ export declare const formatCarts: (data: any[], resources: any[], utils: any, ac
39
39
  * @Date: 2025-04-14 11:16
40
40
  */
41
41
  export declare const sortResources: (resources: any[], resourceSort: any[]) => any[] | undefined;
42
+ /**
43
+ * @title: 处理资源列表并提取资源代码
44
+ * @description: 对资源列表进行排序,并提取 resourceCodes
45
+ * @param {any[]} resources - 原始资源列表
46
+ * @param {any[]} resourceSort - 资源排序配置
47
+ * @return {*} 返回处理后的资源列表和资源代码数组
48
+ * @Author: WangHan
49
+ * @Date: 2025-11-21 15:33
50
+ */
51
+ export declare const processResourceList: (resources: any[], resourceSort: any[]) => {
52
+ resources: any[];
53
+ resourceCodes: any;
54
+ };
42
55
  export declare const getMeAccount: (val: any[]) => any;
43
56
  export declare const getCustomer: (utils: any) => any;
44
57
  export declare const formatCustomer: (val: any) => {
@@ -201,3 +214,13 @@ export declare const currentRenderLists: (resources: any[], code: any) => any;
201
214
  * @Date: 2025-05-25 23:17
202
215
  */
203
216
  export declare const updateCartResources: (item: any, value?: any, currentSelectedResources?: any) => any;
217
+ /**
218
+ * @title: 根据步骤key清空数据
219
+ * @param {string} key - 当前步骤的key
220
+ * @param {any} appointmentBooking - 预约预订实例
221
+ * @param {(times: any[]) => void} setTimes - 设置时间列表的回调函数
222
+ * @return {string[]} 返回需要清空的数据类型数组
223
+ * @Author: WangHan
224
+ * @Date: 2025-11-21 15:40
225
+ */
226
+ export declare const clearDataByStepKey: (key: string, appointmentBooking: any, setTimes?: ((times: any[]) => void) | undefined) => string[] | undefined;
@@ -174,6 +174,32 @@ export var sortResources = function sortResources(resources, resourceSort) {
174
174
  console.log(error, 'wh2222');
175
175
  }
176
176
  };
177
+
178
+ /**
179
+ * @title: 处理资源列表并提取资源代码
180
+ * @description: 对资源列表进行排序,并提取 resourceCodes
181
+ * @param {any[]} resources - 原始资源列表
182
+ * @param {any[]} resourceSort - 资源排序配置
183
+ * @return {*} 返回处理后的资源列表和资源代码数组
184
+ * @Author: WangHan
185
+ * @Date: 2025-11-21 15:33
186
+ */
187
+ export var processResourceList = function processResourceList(resources, resourceSort) {
188
+ var _processedResources$;
189
+ var processedResources = resources.map(function (item) {
190
+ return _objectSpread(_objectSpread({}, item), {}, {
191
+ resources: sortResources((item === null || item === void 0 ? void 0 : item.resources) || [], resourceSort)
192
+ });
193
+ });
194
+ var _resources = (processedResources === null || processedResources === void 0 || (_processedResources$ = processedResources[0]) === null || _processedResources$ === void 0 ? void 0 : _processedResources$.resources) || [];
195
+ var resourceCodes = _resources.map(function (item) {
196
+ return item.code;
197
+ });
198
+ return {
199
+ resources: processedResources,
200
+ resourceCodes: resourceCodes
201
+ };
202
+ };
177
203
  export var getMeAccount = function getMeAccount(val) {
178
204
  return val === null || val === void 0 ? void 0 : val.find(function (d) {
179
205
  return !(d !== null && d !== void 0 && d.isGuest);
@@ -765,4 +791,137 @@ export var updateCartResources = function updateCartResources(item, value, curre
765
791
  });
766
792
  }
767
793
  return newResource || [];
794
+ };
795
+
796
+ // 步骤配置:定义每个步骤需要清空的数据类型(从后往前,越往前步骤清的越多)
797
+ var STEP_CLEAR_CONFIG = {
798
+ 'select-time': ['time'],
799
+ 'fill-form': ['time', 'form'],
800
+ 'select-resource': ['time', 'form', 'resource'],
801
+ 'select-date': ['time', 'form', 'resource', 'date'],
802
+ 'select-service': ['time', 'form', 'resource', 'date']
803
+ };
804
+
805
+ // 数据类型枚举
806
+
807
+ /**
808
+ * 根据key匹配步骤(支持精确匹配和startsWith匹配)
809
+ * @param key - 步骤key
810
+ * @returns 匹配到的步骤key,未匹配到返回null
811
+ */
812
+ var getMatchedStepKey = function getMatchedStepKey(key) {
813
+ // 精确匹配
814
+ if (STEP_CLEAR_CONFIG[key]) {
815
+ return key;
816
+ }
817
+ // startsWith匹配(支持 select-resource_@xxx 和 fill-form_@xxx 等)
818
+ var matchedKey = Object.keys(STEP_CLEAR_CONFIG).find(function (stepKey) {
819
+ return key.startsWith(stepKey);
820
+ });
821
+ return matchedKey || null;
822
+ };
823
+
824
+ /**
825
+ * 创建清空操作的映射
826
+ */
827
+ var createClearActions = function createClearActions(appointmentBooking, setTimes) {
828
+ return {
829
+ time: function time() {
830
+ appointmentBooking.deleteCartItemInfo('time');
831
+ setTimes === null || setTimes === void 0 || setTimes([]);
832
+ },
833
+ resource: function resource() {
834
+ appointmentBooking.deleteCartItemInfo('resource');
835
+ },
836
+ form: function form() {
837
+ appointmentBooking.deleteCartItemInfo('relationForms');
838
+ appointmentBooking.removeStep('fill-form');
839
+ },
840
+ date: function date() {
841
+ var _appointmentBooking$o2;
842
+ var _ref4 = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o2 = appointmentBooking.otherParams) === null || _appointmentBooking$o2 === void 0 ? void 0 : _appointmentBooking$o2.productModuleParams) || {},
843
+ bookingProcess = _ref4.bookingProcess;
844
+
845
+ // 如果不是先选择日期步骤,则清空日期
846
+ if (bookingProcess !== 'date_first') {
847
+ appointmentBooking.clearDateRange();
848
+ }
849
+ }
850
+ };
851
+ };
852
+
853
+ /**
854
+ * 处理选择服务步骤的特殊逻辑:清空所有相关的资源和表单步骤
855
+ */
856
+ var clearServiceRelatedSteps = function clearServiceRelatedSteps(appointmentBooking) {
857
+ var stepList = (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.getStepList()) || [];
858
+ var stepKeysToRemove = ['select-resource_', 'fill-form_'];
859
+ stepList.forEach(function (item) {
860
+ // 如果某个步骤是跳过的,则取消跳过
861
+ if (item !== null && item !== void 0 && item.isSkip) {
862
+ appointmentBooking.updateStep(item.key, {
863
+ key: item.key,
864
+ isSkip: false
865
+ });
866
+ }
867
+ var shouldRemove = stepKeysToRemove.some(function (prefix) {
868
+ var _item$key;
869
+ return (_item$key = item.key) === null || _item$key === void 0 ? void 0 : _item$key.startsWith(prefix);
870
+ });
871
+ if (shouldRemove) {
872
+ appointmentBooking.removeStep(item.key);
873
+ }
874
+ });
875
+ };
876
+
877
+ /**
878
+ * 执行清空操作
879
+ */
880
+ var executeClearActions = function executeClearActions(dataTypes, clearActions) {
881
+ // 去重后执行
882
+ var uniqueTypes = Array.from(new Set(dataTypes));
883
+ uniqueTypes.forEach(function (type) {
884
+ var action = clearActions[type];
885
+ if (action) {
886
+ action();
887
+ }
888
+ });
889
+ };
890
+
891
+ /**
892
+ * @title: 根据步骤key清空数据
893
+ * @param {string} key - 当前步骤的key
894
+ * @param {any} appointmentBooking - 预约预订实例
895
+ * @param {(times: any[]) => void} setTimes - 设置时间列表的回调函数
896
+ * @return {string[]} 返回需要清空的数据类型数组
897
+ * @Author: WangHan
898
+ * @Date: 2025-11-21 15:40
899
+ */
900
+ export var clearDataByStepKey = function clearDataByStepKey(key, appointmentBooking, setTimes) {
901
+ // 参数校验
902
+ if (!key || !appointmentBooking) {
903
+ return;
904
+ }
905
+
906
+ // 选择服务步骤的特殊处理
907
+ if (key === 'select-service') {
908
+ clearServiceRelatedSteps(appointmentBooking);
909
+ }
910
+
911
+ // 匹配步骤key
912
+ var stepKey = getMatchedStepKey(key);
913
+ if (!stepKey) {
914
+ return;
915
+ }
916
+
917
+ // 获取需要清空的数据类型
918
+ var clearDataTypes = STEP_CLEAR_CONFIG[stepKey] || [];
919
+ if (clearDataTypes.length === 0) {
920
+ return clearDataTypes;
921
+ }
922
+
923
+ // 创建清空操作并执行
924
+ var clearActions = createClearActions(appointmentBooking, setTimes);
925
+ executeClearActions(clearDataTypes, clearActions);
926
+ return clearDataTypes;
768
927
  };
@@ -1,10 +1 @@
1
- /// <reference types="react" />
2
- import { FormState } from "../model";
3
- export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
- state: FormState;
5
- } & {
6
- dispatch: (params: {
7
- type: string;
8
- payload: any;
9
- }) => void;
10
- }>;
1
+ export declare const Provider: any, Context: any;
@@ -1,10 +1 @@
1
- /// <reference types="react" />
2
- import { FormState } from "../model";
3
- export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
- state: FormState;
5
- } & {
6
- dispatch: (params: {
7
- type: string;
8
- payload: any;
9
- }) => void;
10
- }>;
1
+ export declare const Provider: any, Context: any;
@@ -1,14 +1,5 @@
1
- /// <reference types="react" />
2
- import { FormState } from '../model';
3
1
  export declare const walkInData: {
4
2
  id: number;
5
3
  nickname: string;
6
4
  };
7
- export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
8
- state: FormState;
9
- } & {
10
- dispatch: (params: {
11
- type: string;
12
- payload: any;
13
- }) => void;
14
- }>;
5
+ export declare const Provider: any, Context: any;
@@ -6,7 +6,7 @@ export declare const getDurationProps: ({ cacheItem, useStartTime, currentResour
6
6
  type: string;
7
7
  value: number;
8
8
  };
9
- locale: string;
9
+ locale: any;
10
10
  slice: any;
11
11
  selectProps: {
12
12
  size: string;