@pisell/private-materials 3.0.151 → 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 (136) 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 +12 -12
  11. package/es/components/booking/components/footer/index.js +48 -33
  12. package/es/components/booking/components/footer/utils.js +35 -4
  13. package/es/components/booking/index.js +1 -1
  14. package/es/components/booking/info/index.d.ts +4 -12
  15. package/es/components/booking/info/index.js +12 -122
  16. package/es/components/booking/info/main.d.ts +12 -0
  17. package/es/components/booking/info/main.js +124 -0
  18. package/es/components/booking/info/model.js +0 -1
  19. package/es/components/booking/info/service/addTimeModal/index.js +4 -4
  20. package/es/components/booking/info/utils.d.ts +1 -0
  21. package/es/components/booking/info/utils.js +7 -0
  22. package/es/components/booking/info2/index.d.ts +12 -0
  23. package/es/components/booking/info2/index.js +216 -0
  24. package/es/components/booking/info2/serve.d.ts +6 -0
  25. package/es/components/booking/info2/serve.js +79 -0
  26. package/es/components/booking/info2/service/actions/index.d.ts +6 -0
  27. package/es/components/booking/info2/service/actions/index.js +86 -0
  28. package/es/components/booking/info2/service/addService/index.d.ts +6 -0
  29. package/es/components/booking/info2/service/addService/index.js +404 -0
  30. package/es/components/booking/info2/service/addService/mock.d.ts +214 -0
  31. package/es/components/booking/info2/service/addService/mock.js +332 -0
  32. package/es/components/booking/info2/service/addService/utils.d.ts +71 -0
  33. package/es/components/booking/info2/service/addService/utils.js +510 -0
  34. package/es/components/booking/info2/service/addTimeModal/index.d.ts +4 -0
  35. package/es/components/booking/info2/service/addTimeModal/index.js +681 -0
  36. package/es/components/booking/info2/service/addTimeModal/serve.d.ts +9 -0
  37. package/es/components/booking/info2/service/addTimeModal/serve.js +73 -0
  38. package/es/components/booking/info2/service/addTimeModal/utils.d.ts +31 -0
  39. package/es/components/booking/info2/service/addTimeModal/utils.js +176 -0
  40. package/es/components/booking/info2/service/editService/Capacity/index.d.ts +4 -0
  41. package/es/components/booking/info2/service/editService/Capacity/index.js +121 -0
  42. package/es/components/booking/info2/service/editService/Capacity/index.less +1 -0
  43. package/es/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.d.ts +7 -0
  44. package/es/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.js +28 -0
  45. package/es/components/booking/info2/service/editService/Resources/index.d.ts +4 -0
  46. package/es/components/booking/info2/service/editService/Resources/index.js +233 -0
  47. package/es/components/booking/info2/service/editService/Resources/index.less +21 -0
  48. package/es/components/booking/info2/service/editService/index.d.ts +7 -0
  49. package/es/components/booking/info2/service/editService/index.js +617 -0
  50. package/es/components/booking/info2/service/editService/index.less +99 -0
  51. package/es/components/booking/info2/service/editService/utils.d.ts +11 -0
  52. package/es/components/booking/info2/service/editService/utils.js +37 -0
  53. package/es/components/booking/info2/service/index.d.ts +4 -0
  54. package/es/components/booking/info2/service/index.js +55 -0
  55. package/es/components/booking/info2/service/serviceItem/index.d.ts +4 -0
  56. package/es/components/booking/info2/service/serviceItem/index.js +176 -0
  57. package/es/components/booking/info2/service/serviceItem/index.less +125 -0
  58. package/es/components/booking/info2/service/serviceList/index.d.ts +6 -0
  59. package/es/components/booking/info2/service/serviceList/index.js +106 -0
  60. package/es/components/booking/info2/service/serviceList/index.less +0 -0
  61. package/es/components/booking/info2/utilsByBooking.d.ts +34 -0
  62. package/es/components/booking/info2/utilsByBooking.js +349 -0
  63. package/es/components/booking/locales.d.ts +3 -0
  64. package/es/components/booking/locales.js +12 -3
  65. package/es/components/booking/materiels/resources/index.d.ts +2 -2
  66. package/es/components/booking/materiels/resources/index.js +11 -11
  67. package/es/components/booking/mock.d.ts +1 -0
  68. package/es/components/booking/mock.js +66 -0
  69. package/es/components/booking/notes/index.d.ts +1 -1
  70. package/es/components/index.d.ts +1 -1
  71. package/es/components/index.js +1 -1
  72. package/es/index.d.ts +1 -1
  73. package/es/index.js +1 -1
  74. package/lib/components/booking/components/footer/index.js +28 -5
  75. package/lib/components/booking/components/footer/utils.js +29 -4
  76. package/lib/components/booking/index.js +2 -2
  77. package/lib/components/booking/info/index.d.ts +4 -12
  78. package/lib/components/booking/info/index.js +14 -115
  79. package/lib/components/booking/info/main.d.ts +12 -0
  80. package/lib/components/booking/info/main.js +152 -0
  81. package/lib/components/booking/info/service/addTimeModal/index.js +1 -0
  82. package/lib/components/booking/info/utils.d.ts +1 -0
  83. package/lib/components/booking/info/utils.js +9 -0
  84. package/lib/components/booking/info2/index.d.ts +12 -0
  85. package/lib/components/booking/info2/index.js +202 -0
  86. package/lib/components/booking/info2/serve.d.ts +6 -0
  87. package/lib/components/booking/info2/serve.js +53 -0
  88. package/lib/components/booking/info2/service/actions/index.d.ts +6 -0
  89. package/lib/components/booking/info2/service/actions/index.js +102 -0
  90. package/lib/components/booking/info2/service/addService/index.d.ts +6 -0
  91. package/lib/components/booking/info2/service/addService/index.js +356 -0
  92. package/lib/components/booking/info2/service/addService/mock.d.ts +214 -0
  93. package/lib/components/booking/info2/service/addService/mock.js +398 -0
  94. package/lib/components/booking/info2/service/addService/utils.d.ts +71 -0
  95. package/lib/components/booking/info2/service/addService/utils.js +377 -0
  96. package/lib/components/booking/info2/service/addTimeModal/index.d.ts +4 -0
  97. package/lib/components/booking/info2/service/addTimeModal/index.js +558 -0
  98. package/lib/components/booking/info2/service/addTimeModal/serve.d.ts +9 -0
  99. package/lib/components/booking/info2/service/addTimeModal/serve.js +45 -0
  100. package/lib/components/booking/info2/service/addTimeModal/utils.d.ts +31 -0
  101. package/lib/components/booking/info2/service/addTimeModal/utils.js +157 -0
  102. package/lib/components/booking/info2/service/editService/Capacity/index.d.ts +4 -0
  103. package/lib/components/booking/info2/service/editService/Capacity/index.js +97 -0
  104. package/lib/components/booking/info2/service/editService/Capacity/index.less +1 -0
  105. package/lib/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.d.ts +7 -0
  106. package/lib/components/booking/info2/service/editService/Resources/MaxLengthSelect/index.js +54 -0
  107. package/lib/components/booking/info2/service/editService/Resources/index.d.ts +4 -0
  108. package/lib/components/booking/info2/service/editService/Resources/index.js +212 -0
  109. package/lib/components/booking/info2/service/editService/Resources/index.less +21 -0
  110. package/lib/components/booking/info2/service/editService/index.d.ts +7 -0
  111. package/lib/components/booking/info2/service/editService/index.js +483 -0
  112. package/lib/components/booking/info2/service/editService/index.less +99 -0
  113. package/lib/components/booking/info2/service/editService/utils.d.ts +11 -0
  114. package/lib/components/booking/info2/service/editService/utils.js +0 -0
  115. package/lib/components/booking/info2/service/index.d.ts +4 -0
  116. package/lib/components/booking/info2/service/index.js +75 -0
  117. package/lib/components/booking/info2/service/serviceItem/index.d.ts +4 -0
  118. package/lib/components/booking/info2/service/serviceItem/index.js +184 -0
  119. package/lib/components/booking/info2/service/serviceItem/index.less +125 -0
  120. package/lib/components/booking/info2/service/serviceList/index.d.ts +6 -0
  121. package/lib/components/booking/info2/service/serviceList/index.js +130 -0
  122. package/lib/components/booking/info2/service/serviceList/index.less +0 -0
  123. package/lib/components/booking/info2/utilsByBooking.d.ts +34 -0
  124. package/lib/components/booking/info2/utilsByBooking.js +257 -0
  125. package/lib/components/booking/locales.d.ts +3 -0
  126. package/lib/components/booking/locales.js +6 -3
  127. package/lib/components/booking/materiels/resources/index.d.ts +2 -2
  128. package/lib/components/booking/mock.d.ts +1 -0
  129. package/lib/components/booking/mock.js +67 -2
  130. package/lib/components/booking/notes/index.d.ts +1 -1
  131. package/lib/components/eftposPay/tyro/index.js +3 -1
  132. package/lib/components/index.d.ts +1 -1
  133. package/lib/components/index.js +1 -1
  134. package/lib/index.d.ts +1 -1
  135. package/lib/index.js +1 -1
  136. package/package.json +3 -3
@@ -0,0 +1,349 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
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 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; }
6
+ 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; }
7
+ 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; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
+ 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); }
10
+ import dayjs from 'dayjs';
11
+ import { locales } from "@pisell/utils";
12
+ import { getCacheParams, getServeStartTime, getLastServer, flexibleObj, getServiceTimes, findNextDuration } from "../utils";
13
+
14
+ // 获取当前剩余量
15
+ var getUseableEventCount = function getUseableEventCount(eventList, current) {
16
+ return (eventList || []).reduce(function (pre, event) {
17
+ return pre - event.pax;
18
+ }, current || 0);
19
+ };
20
+
21
+ // 判断两个时间段是否有冲突
22
+ var isConflict = function isConflict(event, current) {
23
+ var eventStart = dayjs(event.start_at);
24
+ var eventEnd = dayjs(event.end_at);
25
+ var currentStart = dayjs(current.start_at);
26
+ var _isBefore = currentStart.isBefore(eventEnd);
27
+ var _isAfter = true;
28
+
29
+ // 如果传递结束时间,则比对结束时间
30
+ if (current.end_at) {
31
+ var currentEnd = dayjs(current.end_at);
32
+ _isAfter = currentEnd.isAfter(eventStart);
33
+ }
34
+
35
+ // 检查是否有重叠
36
+ return _isBefore && _isAfter;
37
+ };
38
+
39
+ // 从times中找可用的time
40
+ export var getResourceTimeIsUsable = function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
41
+ // 当前资源的开始时间
42
+ var startDate = dayjs(cacheItem._extend.start_date.format("YYYY-MM-DD") + ' ' + getServeStartTime(cacheItem._extend.start_time));
43
+
44
+ // 是否为灵活时长
45
+ var isFlexible = flexibleObj.isFlexible(cacheItem._extend.duration);
46
+
47
+ // 是否在最大预约数量的区间内
48
+ var isMaxLimitRange = false;
49
+
50
+ // 是否在日期范围内
51
+ var isDateRange = false;
52
+
53
+ // 是否在数量范围内
54
+ var isCountRange = false;
55
+ var time = _objectSpread({}, item);
56
+
57
+ // 当前time的开始时间
58
+ var timeStartDate = dayjs(time.start_date + " " + time.start_time).subtract(1, "second");
59
+
60
+ // 当前time的结束时间
61
+ var timeEndDate = dayjs(time.end_date + " " + time.end_time).add(1, "second");
62
+
63
+ // 总剩余量
64
+ var totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
65
+
66
+ // 当前预约量
67
+ var currentCount = getSumCapacity({
68
+ cacheItem: cacheItem
69
+ });
70
+
71
+ // 如果 预约人数超过总容量, 则不可用
72
+ if (totalCount < currentCount) {
73
+ isCountRange = false;
74
+ } else {
75
+ // 已预约的列表
76
+ var eventList = time.event_list || [];
77
+ var endDate = null;
78
+
79
+ /**
80
+ * 从这里为判断是否在时间范围内
81
+ */
82
+ if (isFlexible) {
83
+ // 如果有event, 那么灵活时长时间只能在 最后一个event的结束时间 ~ time的结束时间内
84
+ if (eventList.length) {
85
+ timeStartDate = eventList.reduce(function (max, event) {
86
+ var endAt = dayjs(event.end_at);
87
+ return endAt.isAfter(max) ? endAt : max;
88
+ }, dayjs(eventList[0].end_at));
89
+ }
90
+ isDateRange = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
91
+ } else {
92
+ // 其余判断 开始时间 和 结束时间 是否都在范围内
93
+ endDate = startDate.add(flexibleObj.getValue(cacheItem._extend.duration), "minute");
94
+
95
+ // 是否在time范围内
96
+ var isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
97
+ if (isTimeRange) {
98
+ isDateRange = true;
99
+ }
100
+ }
101
+
102
+ /**
103
+ * 从这里判断预约量
104
+ */
105
+
106
+ // 取出已预约列表和当前预约重叠的时间段
107
+ var conflict = (time.event_list || []).filter(function (d) {
108
+ return isConflict({
109
+ start_at: d.start_at,
110
+ end_at: d.end_at
111
+ }, {
112
+ start_at: startDate,
113
+ end_at: endDate
114
+ });
115
+ });
116
+
117
+ // 同一时间段内只能进行一个预约,无论容量是否已满。
118
+ if (resourceItem.resourceType === 'single') {
119
+ // 0代表着不重叠,则满足条件
120
+ if (conflict.length === 0) {
121
+ isCountRange = true;
122
+ } else {
123
+ isCountRange = false;
124
+ }
125
+ } else {
126
+ // 减去重叠的总量
127
+ var conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
128
+
129
+ // 当前预约量 <= 总剩余容量
130
+ if (currentCount <= conflictCount) {
131
+ isCountRange = true;
132
+ } else {
133
+ isCountRange = false;
134
+ }
135
+ }
136
+ }
137
+
138
+ // 是否可用
139
+ var isUsable = isDateRange && isCountRange;
140
+
141
+ // 储存到拓展数据内
142
+ time._extend = {
143
+ isMaxLimitRange: isMaxLimitRange,
144
+ isDateRange: isDateRange,
145
+ isCountRange: isCountRange,
146
+ isUsable: isUsable
147
+ };
148
+ return time;
149
+ };
150
+ export var getSumCapacity = function getSumCapacity(_ref) {
151
+ var cacheItem = _ref.cacheItem;
152
+ var sum = 0;
153
+ var _iterator = _createForOfIteratorHelper(cacheItem._extend.capacity || []),
154
+ _step;
155
+ try {
156
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
157
+ var item = _step.value;
158
+ sum += item.value;
159
+ }
160
+ } catch (err) {
161
+ _iterator.e(err);
162
+ } finally {
163
+ _iterator.f();
164
+ }
165
+ return sum;
166
+ };
167
+
168
+ /**
169
+ * @title: 查找是否有可用的time
170
+ * @description:
171
+ * @param {any} resourceItem
172
+ * @return {*}
173
+ * @Author: zhiwei.Wang
174
+ * @Date: 2024-01-09 13:57
175
+ */
176
+ export var formatTimes = function formatTimes(resourceItem, cacheItem) {
177
+ // 可用的time列表
178
+ var usableTimes = [];
179
+ var _resourceItem = _objectSpread({}, resourceItem);
180
+ var sum = getSumCapacity({
181
+ cacheItem: cacheItem
182
+ });
183
+
184
+ // 如果可预约数量大于等于当前预约数量
185
+ if (_resourceItem.capacity >= sum) {
186
+ // 循环times 区分可用和不可用的 并打上标记
187
+ _resourceItem.times = _resourceItem.times.map(function (time) {
188
+ var _time = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
189
+ // 取出可用的列表
190
+ if (_time !== null && _time !== void 0 && _time._extend.isUsable) {
191
+ usableTimes.push(_time);
192
+ }
193
+ return _time;
194
+ });
195
+ }
196
+
197
+ // 获取第一个最佳的time
198
+ var _time = (usableTimes || []).sort(function (a, b) {
199
+ var aEndDate = dayjs(a.end_date + " " + a.end_time).valueOf();
200
+ var bEndDate = dayjs(b.end_date + " " + b.end_time).valueOf();
201
+ return aEndDate - bEndDate;
202
+ })[0];
203
+ resourceItem._extend = _objectSpread(_objectSpread({}, resourceItem._extend), {}, {
204
+ usableTime: _time
205
+ });
206
+ return resourceItem;
207
+ };
208
+ export var getErrorList = function getErrorList(resource, cacheItem) {
209
+ if (!(cacheItem !== null && cacheItem !== void 0 && cacheItem.id)) {
210
+ return [{
211
+ label: locales.getText('pisell2.text.no-product-added'),
212
+ type: "products"
213
+ }];
214
+ }
215
+ if (!resource) {
216
+ return [];
217
+ }
218
+ var list = [];
219
+ // 当前资源不可用
220
+ if (!resource.usable) {
221
+ var _cacheItem$_data, _cacheItem$_data$reso, _cacheItem$_data$reso2, _resource$_extend;
222
+ var _getServiceTimes = getServiceTimes(cacheItem),
223
+ startDate = _getServiceTimes.startDate,
224
+ endDate = _getServiceTimes.endDate;
225
+ // 如果跨天 结束时间前面加一个明天
226
+ var startText = startDate.format("hh:mm A");
227
+ var endText = endDate.format("hh:mm A");
228
+ if (dayjs(endDate).isAfter(startDate, "day")) {
229
+ endText = locales.getText('pisell1.text.tomorrow') + endText;
230
+ }
231
+ var isSingle = (cacheItem === null || cacheItem === void 0 ? void 0 : (_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : (_cacheItem$_data$reso = _cacheItem$_data.resourceMaps) === null || _cacheItem$_data$reso === void 0 ? void 0 : (_cacheItem$_data$reso2 = _cacheItem$_data$reso[resource === null || resource === void 0 ? void 0 : resource.form_id]) === null || _cacheItem$_data$reso2 === void 0 ? void 0 : _cacheItem$_data$reso2.type) === "single";
232
+ console.log('resourceresource', resource, cacheItem);
233
+ if (!((_resource$_extend = resource._extend) !== null && _resource$_extend !== void 0 && _resource$_extend.usableTime)) {
234
+ if (isSingle) {
235
+ list.push({
236
+ label: locales.getText('pisell1.text.resource-error-message-3')(resource.labelText, startText, endText),
237
+ type: "limit"
238
+ });
239
+ } else {
240
+ list.push({
241
+ label: locales.getText('pisell1.text.resource-error-message-2')(resource.labelText, startText, endText),
242
+ type: "time"
243
+ });
244
+ }
245
+ } else {
246
+ var _resource$_extend2, _resource$_extend2$us, _resource$_extend2$us2;
247
+ if (!((_resource$_extend2 = resource._extend) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2$us = _resource$_extend2.usableTime) !== null && _resource$_extend2$us !== void 0 && (_resource$_extend2$us2 = _resource$_extend2$us._extend) !== null && _resource$_extend2$us2 !== void 0 && _resource$_extend2$us2.isCountRange)) {
248
+ list.push({
249
+ label: locales.getText('pisell1.text.resource-error-message-3')(resource.labelText, startText, endText),
250
+ type: "limit"
251
+ });
252
+ }
253
+ }
254
+ }
255
+ return list;
256
+ };
257
+
258
+ /**
259
+ * @title: 格式化资源, 添加自定义参数
260
+ * @description:
261
+ * @param {any} resourceItem
262
+ * @return {*}
263
+ * @Author: zhiwei.Wang
264
+ * @Date: 2024-01-09 13:40
265
+ */
266
+ export var formatResource = function formatResource(resourceItem, cacheItem, formatLabel) {
267
+ // 当前资源
268
+ var _resourceItem = _objectSpread({}, resourceItem);
269
+ // 格式化times里面的数据
270
+ _resourceItem = formatTimes(_resourceItem, cacheItem);
271
+
272
+ // 格式化label
273
+ _resourceItem.labelText = _resourceItem.main_field;
274
+ var usable = _resourceItem._extend.usableTime;
275
+ _resourceItem.usable = usable;
276
+ if (formatLabel) {
277
+ _resourceItem.label = formatLabel(_resourceItem);
278
+ }
279
+ return _resourceItem;
280
+ };
281
+
282
+ /**
283
+ * @title: 创建服务的开始时间和结束时间
284
+ * @description:
285
+ * @param {any} state
286
+ * @param {any} item
287
+ * @return {*}
288
+ * @Author: zhiwei.Wang
289
+ * @Date: 2024-01-26 14:09
290
+ */
291
+ export var getServiceStartTimeAndEndTime = function getServiceStartTimeAndEndTime(state, cacheItem, timeObj) {
292
+ var _cacheItem$duration;
293
+ // 获取上一个服务商品
294
+ var lastServer = getLastServer(state.service.value);
295
+
296
+ // 下一个商品的扩展参数
297
+ var _extend = {
298
+ // 时长: 当前商品时长 > 第一个时长
299
+ duration: findNextDuration(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem === null || cacheItem === void 0 ? void 0 : (_cacheItem$duration = cacheItem.duration) === null || _cacheItem$duration === void 0 ? void 0 : _cacheItem$duration.value)
300
+ };
301
+
302
+ // 如果有上一个商品, 将上一个商品的某些参数 设置到新商品上
303
+ if (lastServer) {
304
+ var lastServerStartDate = lastServer._extend.startDate;
305
+ var lastServerEndDate = lastServer._extend.endDate;
306
+ // 如果上个服务商品的结束时间跨天, 那么设置为最后一个时间段, 不跨天则取上一个的结束时间
307
+ if (dayjs(lastServerEndDate).isAfter(lastServerStartDate, "day")) {
308
+ _extend.start_time = timeObj.timeSlices[timeObj.timeSlices.length - 1].value;
309
+ } else {
310
+ _extend.start_time = lastServerEndDate.format("HH:mm");
311
+ }
312
+ } else {
313
+ // 没有上一个商品 资源为 0
314
+ // _extend.resource = 0;
315
+
316
+ var findNextSliceProps = {
317
+ date: ''
318
+ };
319
+
320
+ // 从缓存里读默认参数, 如果有 则需要默认选中某些参数, 添加完商品后则删除
321
+ var serviceParams = getCacheParams();
322
+ if (serviceParams) {
323
+ var str = serviceParams.start_date;
324
+ if (str) {
325
+ // 选中开始时间
326
+ findNextSliceProps.date = dayjs(str).format('HH:mm');
327
+ }
328
+ }
329
+
330
+ // 只有选择了带 HH:mm的日期才选中, 否则使用当前日期
331
+ if (findNextSliceProps.date && findNextSliceProps.date !== '00:00') {
332
+ _extend.start_time = findNextSliceProps.date;
333
+ } else {
334
+ // 没有预设日期, 则使用当前 https://www.yuque.com/feg4xm/manual/tzvrnt05ifihkndg
335
+ _extend.start_time = dayjs().format('HH:mm');
336
+ }
337
+ }
338
+ _extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
339
+
340
+ // 计算服务的开始和结束时间
341
+ var _getServiceTimes2 = getServiceTimes({
342
+ _extend: _extend
343
+ }),
344
+ startDate = _getServiceTimes2.startDate,
345
+ endDate = _getServiceTimes2.endDate;
346
+ _extend.startDate = startDate;
347
+ _extend.endDate = endDate;
348
+ return _extend;
349
+ };
@@ -194,6 +194,7 @@ declare const _default: {
194
194
  'page.booking.text.please-choose-an-option': string;
195
195
  'page.booking.text.please-choose-an-option-1': string;
196
196
  'page.booking.text.please-choose-an-option-2': string;
197
+ 'page.booking.text.resource.min-length-error': (x: number, y: string) => string;
197
198
  };
198
199
  'zh-CN': {
199
200
  'pisell2.text.refunded-amount': string;
@@ -390,6 +391,7 @@ declare const _default: {
390
391
  'page.booking.text.please-choose-an-option': string;
391
392
  'page.booking.text.please-choose-an-option-1': string;
392
393
  'page.booking.text.please-choose-an-option-2': string;
394
+ 'page.booking.text.resource.min-length-error': (x: number, y: string) => string;
393
395
  };
394
396
  'zh-HK': {
395
397
  'pisell2.text.refunded-amount': string;
@@ -586,6 +588,7 @@ declare const _default: {
586
588
  'page.booking.text.please-choose-an-option': string;
587
589
  'page.booking.text.please-choose-an-option-1': string;
588
590
  'page.booking.text.please-choose-an-option-2': string;
591
+ 'page.booking.text.resource.min-length-error': (x: number, y: string) => string;
589
592
  };
590
593
  };
591
594
  export default _default;
@@ -222,7 +222,10 @@ export default {
222
222
  },
223
223
  'page.booking.text.please-choose-an-option': "Please choose an option:",
224
224
  'page.booking.text.please-choose-an-option-1': "Refund: Cancel the appointment and process a refund.",
225
- 'page.booking.text.please-choose-an-option-2': "Cancel only: Cancel the appointment without processing a refund. (You can still process a refund after cancellation if needed)"
225
+ 'page.booking.text.please-choose-an-option-2': "Cancel only: Cancel the appointment without processing a refund. (You can still process a refund after cancellation if needed)",
226
+ 'page.booking.text.resource.min-length-error': function pageBookingTextResourceMinLengthError(x, y) {
227
+ return "Select at least ".concat(x, " ").concat(y);
228
+ }
226
229
  },
227
230
  'zh-CN': {
228
231
  'pisell2.text.refunded-amount': '已退金额',
@@ -451,7 +454,10 @@ export default {
451
454
  },
452
455
  'page.booking.text.please-choose-an-option': "请选择:",
453
456
  'page.booking.text.please-choose-an-option-1': "退款:取消预约,同时处理退款。",
454
- 'page.booking.text.please-choose-an-option-2': "仅取消:仅取消预约,但不进行退款处理。(您仍然可以在取消后再进行退款操作)"
457
+ 'page.booking.text.please-choose-an-option-2': "仅取消:仅取消预约,但不进行退款处理。(您仍然可以在取消后再进行退款操作)",
458
+ 'page.booking.text.resource.min-length-error': function pageBookingTextResourceMinLengthError(x, y) {
459
+ return "\u81F3\u5C11\u9009\u62E9".concat(x, "\u9879").concat(y);
460
+ }
455
461
  },
456
462
  'zh-HK': {
457
463
  'pisell2.text.refunded-amount': '已退金額',
@@ -680,6 +686,9 @@ export default {
680
686
  },
681
687
  'page.booking.text.please-choose-an-option': '請選擇:',
682
688
  'page.booking.text.please-choose-an-option-1': '退款:取消預約,同時處理退款。',
683
- 'page.booking.text.please-choose-an-option-2': '僅取消:僅取消預約,但不進行退款處理。(您仍然可以在取消後再進行退款操作)'
689
+ 'page.booking.text.please-choose-an-option-2': '僅取消:僅取消預約,但不進行退款處理。(您仍然可以在取消後再進行退款操作)',
690
+ 'page.booking.text.resource.min-length-error': function pageBookingTextResourceMinLengthError(x, y) {
691
+ return "\u81F3\u5C11\u9078\u64C7".concat(x, "\u9805").concat(y);
692
+ }
684
693
  }
685
694
  };
@@ -1,5 +1,5 @@
1
- import { SelectProps } from "antd";
2
- import React from "react";
1
+ import { SelectProps } from 'antd';
2
+ import React from 'react';
3
3
  interface ResourcesProps extends SelectProps {
4
4
  locale?: string;
5
5
  resources?: any[];
@@ -17,15 +17,15 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
19
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
- import { Select } from "antd";
21
- import React, { useCallback, useEffect, useState, forwardRef } from "react";
22
- import AlertTriangle from "@pisell/icon/es/AlertTriangle";
20
+ import { Select } from 'antd';
21
+ import React, { useCallback, useEffect, useState, forwardRef } from 'react';
22
+ import AlertTriangle from '@pisell/icon/es/AlertTriangle';
23
23
  import { getNoResource } from "../../mock";
24
24
  import { formatResource } from "../../utils";
25
- import { isFunction } from "@pisell/utils";
25
+ import { isFunction } from '@pisell/utils';
26
26
  var Resources = /*#__PURE__*/forwardRef(function (props, ref) {
27
27
  var _props$locale = props.locale,
28
- locale = _props$locale === void 0 ? "en" : _props$locale,
28
+ locale = _props$locale === void 0 ? 'en' : _props$locale,
29
29
  _props$resources = props.resources,
30
30
  resources = _props$resources === void 0 ? [] : _props$resources,
31
31
  watch = props.watch,
@@ -44,12 +44,12 @@ var Resources = /*#__PURE__*/forwardRef(function (props, ref) {
44
44
  _resources = _useState4[0],
45
45
  set_resources = _useState4[1];
46
46
  var renderOptions = useCallback(function (array) {
47
- var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "value";
48
- var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "label";
47
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
48
+ var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'label';
49
49
  var type = arguments.length > 3 ? arguments[3] : undefined;
50
50
  return array.map(function (d) {
51
51
  var props = {};
52
- if (type === "resource") {
52
+ if (type === 'resource') {
53
53
  props.labelText = d.labelText;
54
54
  }
55
55
  return /*#__PURE__*/React.createElement(Select.Option, _extends({
@@ -86,7 +86,7 @@ var Resources = /*#__PURE__*/forwardRef(function (props, ref) {
86
86
  skip: 1,
87
87
  num: 1000,
88
88
  with_date_times: currentDate,
89
- codes: ["resources", "therapist", "table"]
89
+ codes: ['resources', 'therapist', 'table']
90
90
  });
91
91
  case 4:
92
92
  data = _context.sent;
@@ -148,11 +148,11 @@ var Resources = /*#__PURE__*/forwardRef(function (props, ref) {
148
148
  allowClear: true,
149
149
  showSearch: true,
150
150
  filterOption: function filterOption(str, option) {
151
- return (option.labelText || "").toLowerCase().includes((str || "").toLowerCase());
151
+ return (option.labelText || '').toLowerCase().includes((str || '').toLowerCase());
152
152
  },
153
153
  loading: loading
154
154
  }, selectProps, resetProps, {
155
155
  ref: ref
156
- }), renderOptions(_resources || [], "form_record_id", "label", "resource"));
156
+ }), renderOptions(_resources || [], 'form_record_id', 'label', 'resource'));
157
157
  });
158
158
  export default Resources;
@@ -54,3 +54,4 @@ export declare const getNoResource: () => {
54
54
  unique: string;
55
55
  }[];
56
56
  };
57
+ export declare const getNoResource2: (other: any) => any;
@@ -1,3 +1,9 @@
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); }
1
7
  import { locales } from '@pisell/utils';
2
8
  export var getNoResource = function getNoResource() {
3
9
  return {
@@ -56,4 +62,64 @@ export var getNoResource = function getNoResource() {
56
62
  "unique": "IomNIL9OPQsSjosiu7EqhhgXGviqUxk1"
57
63
  }]
58
64
  };
65
+ };
66
+ export var getNoResource2 = function getNoResource2(other) {
67
+ return _objectSpread({
68
+ "form_tag": null,
69
+ "policy": 148,
70
+ "partyroom_package": {
71
+ "type": "product_all"
72
+ },
73
+ "sort": "2",
74
+ "status": "active",
75
+ "description": "<p>1</p>",
76
+ "media": "",
77
+ "main_field": locales.getText('pisell1.text.no-resource'),
78
+ "subtitle": "无资源",
79
+ "room_name": locales.getText('pisell1.text.no-resource'),
80
+ "labelText": locales.getText('pisell1.text.no-resource'),
81
+ "form_record_id": 0,
82
+ "item_type": "resources",
83
+ "form_id": 0,
84
+ "id": 0,
85
+ "form_resource_sort": 0,
86
+ "form_title": "资源",
87
+ "capacity": 999999,
88
+ "form": {
89
+ "id": 0,
90
+ "shop_id": 265,
91
+ "title": "资源",
92
+ "navigation_display": 1,
93
+ "button": "保存",
94
+ "describe": "",
95
+ "status": "published",
96
+ "resource_sort": 0,
97
+ "code": "resources",
98
+ "type": "manual",
99
+ "version": 1,
100
+ "setting": null,
101
+ "created_at": "2023-08-08 20:10:13",
102
+ "updated_at": "2023-10-13 15:21:02"
103
+ },
104
+ "times": [{
105
+ "keys": "20c04d77e571b082fe504777879f7261",
106
+ "schedule_id": 0,
107
+ "item_type": "resources",
108
+ "item_id": 0,
109
+ "start_date": "2000-01-01",
110
+ "end_date": "2300-01-01",
111
+ "start_time": "00:00",
112
+ "end_time": "23:59",
113
+ "is_all": 1,
114
+ "max_participants_type": "custom-limit",
115
+ "max_participants_limit": 0,
116
+ "relation_type": "form",
117
+ "start_at": "2000-01-01 00:00",
118
+ "end_at": "2300-01-05 23:59",
119
+ "is_blocked": 0,
120
+ "blocked_times": [],
121
+ "order_event_count": 3,
122
+ "unique": "IomNIL9OPQsSjosiu7EqhhgXGviqUxk1"
123
+ }]
124
+ }, other);
59
125
  };
@@ -4,5 +4,5 @@ export interface InfoProps {
4
4
  globalState: any;
5
5
  setGlobalState: any;
6
6
  }
7
- declare const Notes: (props: any) => JSX.Element;
7
+ declare const Notes: any;
8
8
  export default Notes;
@@ -1,5 +1,5 @@
1
1
  import Login from './login';
2
- import BookingInfo from './booking/info';
2
+ import BookingInfo from './booking/info/index';
3
3
  import Booking from './booking';
4
4
  import BookingNotes from './booking/notes';
5
5
  import BookingAddons from './booking/addons';
@@ -1,5 +1,5 @@
1
1
  import Login from "./login";
2
- import BookingInfo from "./booking/info";
2
+ import BookingInfo from "./booking/info/index";
3
3
  import Booking from "./booking";
4
4
  import BookingNotes from "./booking/notes";
5
5
  import BookingAddons from "./booking/addons";
package/es/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as Login } from './components/login';
2
2
  export type { LoginProps } from './components/login';
3
- export { default as BookingInfo } from './components/booking/info';
3
+ export { default as BookingInfo } from './components/booking/info/index';
4
4
  export { default as BookingNotes } from './components/booking/notes';
5
5
  export { default as BookingAddons } from './components/booking/addons';
6
6
  export { default as BookingForms } from './components/booking/forms';
package/es/index.js CHANGED
@@ -4,7 +4,7 @@ import localeData from 'dayjs/plugin/localeData';
4
4
  dayjs.extend(weekday);
5
5
  dayjs.extend(localeData);
6
6
  export { default as Login } from "./components/login";
7
- export { default as BookingInfo } from "./components/booking/info";
7
+ export { default as BookingInfo } from "./components/booking/info/index";
8
8
  export { default as BookingNotes } from "./components/booking/notes";
9
9
  export { default as BookingAddons } from "./components/booking/addons";
10
10
  export { default as BookingForms } from "./components/booking/forms";