@pisell/private-materials 3.0.152-gray → 3.0.153

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 +403 -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 +355 -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 +3 -3
  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,558 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/booking/info2/service/addTimeModal/index.tsx
30
+ var addTimeModal_exports = {};
31
+ __export(addTimeModal_exports, {
32
+ default: () => addTimeModal_default
33
+ });
34
+ module.exports = __toCommonJS(addTimeModal_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_drawer = __toESM(require("../../../components/drawer"));
37
+ var import_model = require("../../../info/model");
38
+ var import_antd = require("antd");
39
+ var import_addTimeModal = require("../../../info/service/addTimeModal/index.less");
40
+ var import_utils = require("@pisell/utils");
41
+ var import_ahooks = require("ahooks");
42
+ var import_footer = __toESM(require("../../../components/footer"));
43
+ var import_serve = require("./serve");
44
+ var import_utils2 = require("./utils");
45
+ var import_classnames = __toESM(require("classnames"));
46
+ var import_browserSelect = __toESM(require("../../../components/browserSelect"));
47
+ var import_utils3 = require("../../../utils");
48
+ var import_utilsByBooking = require("../../utilsByBooking");
49
+ var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
50
+ var import_utils4 = require("../../../info/utils");
51
+ var numberList = (0, import_utils.createArray)(100, (d, i) => {
52
+ let item = {
53
+ label: i + 1,
54
+ value: i + 1
55
+ };
56
+ return item;
57
+ });
58
+ var AddTimeModal = () => {
59
+ var _a, _b, _c, _d, _e, _f, _g, _h;
60
+ const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
61
+ const [isEdit, setIsEdit] = (0, import_react.useState)(false);
62
+ const [loading, setLoading] = (0, import_react.useState)("");
63
+ const [recordKey, setRecordKey] = (0, import_react.useState)("");
64
+ const [number, setNumber] = (0, import_react.useState)(1);
65
+ const originServices = (0, import_react.useRef)([]);
66
+ const [renderList, setRenderList] = (0, import_react.useState)([]);
67
+ const context = (0, import_useEngineContext.default)();
68
+ const { interaction } = (_a = context.appHelper) == null ? void 0 : _a.utils;
69
+ const statusMap = {
70
+ available: {
71
+ label: import_utils.locales.getText("page.booking.text.available"),
72
+ color: "#079455"
73
+ },
74
+ fully_booked: {
75
+ label: import_utils.locales.getText("page.booking.text.fully-booked"),
76
+ color: "#DC6803"
77
+ },
78
+ unavailable: {
79
+ label: import_utils.locales.getText("page.booking.text.unavailable"),
80
+ color: "#98A2B3"
81
+ }
82
+ };
83
+ const updateServices = (0, import_ahooks.useDebounceFn)(
84
+ () => {
85
+ createNewServices();
86
+ },
87
+ { wait: 200 }
88
+ );
89
+ const transaction_habit_selection = (0, import_react.useMemo)(() => {
90
+ var _a2, _b2, _c2;
91
+ return ((_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.information_tab) == null ? void 0 : _c2.transaction_habit_selection) || {
92
+ type: "service_now_pay_later",
93
+ button_rows: 1
94
+ };
95
+ }, [(_c = (_b = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _b.config) == null ? void 0 : _c.information_tab]);
96
+ const currentProductId = (0, import_react.useMemo)(() => {
97
+ return import_utils2.addTimeRowKey.getValue(recordKey).product_id;
98
+ }, [recordKey]);
99
+ const currentTime = (0, import_react.useMemo)(() => {
100
+ let _time = import_utils2.addTimeRowKey.getValue(recordKey).time || "";
101
+ return _time;
102
+ }, [recordKey]);
103
+ const currentProduct = (0, import_react.useMemo)(() => {
104
+ return (renderList || []).find((d) => d.id == currentProductId);
105
+ }, [renderList, currentProductId]);
106
+ console.log("renderList", renderList);
107
+ const currentTimeItem = (0, import_react.useMemo)(() => {
108
+ var _a2;
109
+ return ((_a2 = currentProduct == null ? void 0 : currentProduct.times) == null ? void 0 : _a2.find((d) => d.value == currentTime)) || {
110
+ price: 0
111
+ };
112
+ }, [currentTime, currentProduct]);
113
+ const currentResource = (0, import_react.useMemo)(() => {
114
+ var _a2, _b2;
115
+ const resource = (_b2 = (_a2 = state.service.cacheItem) == null ? void 0 : _a2._extend) == null ? void 0 : _b2.resource;
116
+ let arr = [];
117
+ for (let form_id in resource) {
118
+ arr = [
119
+ ...arr,
120
+ ...resource[form_id].map((d) => {
121
+ var _a3;
122
+ return (_a3 = state.service.cacheItem) == null ? void 0 : _a3._data.resourceMaps[form_id].renderListMaps[d.relation_id];
123
+ })
124
+ ];
125
+ }
126
+ return arr;
127
+ }, [(_f = (_e = (_d = state.service) == null ? void 0 : _d.cacheItem) == null ? void 0 : _e._extend) == null ? void 0 : _f.resource]);
128
+ console.log("currentResource", currentResource);
129
+ const getTimeUsableStatus = (time) => {
130
+ var _a2, _b2;
131
+ if (!((_a2 = state.service.cacheItem) == null ? void 0 : _a2._extend) || !currentResource.length) {
132
+ return { status: statusMap.unavailable };
133
+ }
134
+ try {
135
+ let _extend = { ...state.service.cacheItem._extend };
136
+ _extend.endDate = _extend.endDate.add(time, "minutes");
137
+ _extend.start_date = _extend.startDate;
138
+ _extend.end_date = _extend.endDate;
139
+ _extend.end_time = _extend.endDate.format("HH:mm");
140
+ _extend.start_time = _extend.startDate.format("HH:mm");
141
+ _extend.duration = import_utils3.flexibleObj.add(_extend.duration, time);
142
+ if ((0, import_utils3.isNowTime)(_extend.start_time)) {
143
+ _extend.start_time = (0, import_utils3.getNowTime)();
144
+ }
145
+ const startText = _extend.startDate.format("hh:mm A");
146
+ let endText = _extend.endDate.format("hh:mm A");
147
+ if (_extend.endDate.isAfter(_extend.startDate, "day")) {
148
+ endText = import_utils.locales.getText("pisell1.text.tomorrow") + endText;
149
+ }
150
+ let errorList = [];
151
+ for (let resourceItem of currentResource) {
152
+ let timeItem = resourceItem == null ? void 0 : resourceItem.times.find(
153
+ (_time) => _time.item_id === resourceItem.id
154
+ );
155
+ const res = (0, import_utilsByBooking.getResourceTimeIsUsable)(
156
+ timeItem,
157
+ {
158
+ ...state.service.cacheItem,
159
+ _extend: {
160
+ ...state.service.cacheItem._extend,
161
+ ..._extend
162
+ }
163
+ },
164
+ resourceItem
165
+ );
166
+ if (!((_b2 = res._extend) == null ? void 0 : _b2.isUsable)) {
167
+ errorList.push(resourceItem);
168
+ }
169
+ }
170
+ if (errorList.length) {
171
+ return {
172
+ // maxEndTime:
173
+ status: statusMap.unavailable,
174
+ message: `${errorList.map((d) => d.labelText).join(", ")} ${import_utils.locales.getText(
175
+ "pisell2.text.status.service-error-2"
176
+ )}`
177
+ };
178
+ }
179
+ } catch (err) {
180
+ }
181
+ return { status: statusMap.available };
182
+ };
183
+ const _getAddTimeProducts = async () => {
184
+ var _a2, _b2, _c2, _d2;
185
+ const data = await (0, import_serve.getAddTimeProducts)(
186
+ {
187
+ skip: 1,
188
+ num: 500,
189
+ open_quotation: 1,
190
+ schedule_date: state.date.value.format("YYYY-MM-DD"),
191
+ customer_id: (0, import_utils3.isWalkIn)((_b2 = (_a2 = state.client) == null ? void 0 : _a2.value) == null ? void 0 : _b2.id) ? void 0 : (_d2 = (_c2 = state.client) == null ? void 0 : _c2.value) == null ? void 0 : _d2.id,
192
+ extension_type: ["product_add_time"],
193
+ status: "published"
194
+ },
195
+ {
196
+ useCache: true
197
+ }
198
+ );
199
+ return (data == null ? void 0 : data.list) || [];
200
+ };
201
+ const getTimeProducts = async () => {
202
+ setLoading("list");
203
+ const newList = await _getAddTimeProducts();
204
+ let list = newList.map((d) => {
205
+ let isUsable = (0, import_utils2.isUsableProduct)(d.add_time, state.service.cacheItem);
206
+ return {
207
+ ...d,
208
+ usable: isUsable,
209
+ // 可用的商品生成加时列表
210
+ times: isUsable ? (0, import_utils2.getAddTimeSplits)(d, state.service.cacheItem).map((time) => {
211
+ return {
212
+ ...time,
213
+ status: getTimeUsableStatus(time.value)
214
+ };
215
+ }) : void 0
216
+ };
217
+ }).filter((d) => d.usable && d.times.length).sort((a, b) => b.sort - a.sort);
218
+ setRenderList(list);
219
+ if (list.length) {
220
+ setDefaultProduct(list);
221
+ }
222
+ setLoading("");
223
+ setIsEdit(true);
224
+ };
225
+ const setDefaultProduct = (list) => {
226
+ try {
227
+ let productId = list[0].id;
228
+ let time = list[0].times[0].value;
229
+ setRecordKey(import_utils2.addTimeRowKey.create(productId, time));
230
+ } catch (err) {
231
+ }
232
+ };
233
+ (0, import_ahooks.useUpdateEffect)(() => {
234
+ if (state.service.addTimeModal) {
235
+ getTimeProducts();
236
+ originServices.current = state.service;
237
+ } else {
238
+ updateServices.run();
239
+ }
240
+ }, [state.service.addTimeModal]);
241
+ const onSelectItem = (pItem, item) => {
242
+ setRecordKey(import_utils2.addTimeRowKey.create(pItem.id, item.value));
243
+ setIsEdit(true);
244
+ updateServices.run();
245
+ };
246
+ const newService = (0, import_react.useMemo)(() => {
247
+ if (!currentProduct || !state.service.cacheItem) {
248
+ return null;
249
+ }
250
+ const relation_product = {
251
+ product_add_schedule_time: currentTime,
252
+ num: number,
253
+ price: currentTimeItem.price || 0,
254
+ product_id: currentProduct.id,
255
+ discount_amount: 0,
256
+ product_discount_reason: "",
257
+ is_charge_tax: currentProduct.is_charge_tax,
258
+ discountway: "num",
259
+ discount_type: "discount"
260
+ };
261
+ let _extend = { ...state.service.cacheItem._extend };
262
+ let relation_products = [relation_product];
263
+ _extend.endDate = _extend.endDate.add(
264
+ relation_product.product_add_schedule_time,
265
+ "minutes"
266
+ );
267
+ const start_date = _extend.startDate.format("YYYY-MM-DD");
268
+ const end_date = _extend.endDate.format("YYYY-MM-DD");
269
+ const end_time = _extend.endDate.format("HH:mm");
270
+ let start_time = _extend.startDate.format("HH:mm");
271
+ let duration = import_utils3.flexibleObj.add(
272
+ _extend.duration,
273
+ relation_product.product_add_schedule_time
274
+ );
275
+ if ((0, import_utils3.isNowTime)(_extend.start_time)) {
276
+ start_time = (0, import_utils3.getNowTime)();
277
+ }
278
+ _extend.relation_details = (_extend.relation_details || []).concat(
279
+ relation_products
280
+ );
281
+ _extend.duration = duration;
282
+ _extend.start_time = start_time;
283
+ _extend.end_time = end_time;
284
+ _extend.start_date = start_date;
285
+ _extend.end_date = end_date;
286
+ let data = {
287
+ id: _extend.id,
288
+ relation_id: _extend.relation_id,
289
+ like_status: _extend.like_status,
290
+ relation_type: _extend.relation_type,
291
+ is_all: _extend.is_all,
292
+ schedule_id: _extend.schedule_id,
293
+ end_time,
294
+ sub_type: _extend.sub_type,
295
+ select_date: start_date,
296
+ start_time,
297
+ end_date,
298
+ start_date,
299
+ duration,
300
+ number: _extend.number || 1,
301
+ relation_products,
302
+ _extend,
303
+ resources: _extend.event_resources,
304
+ metadata: _extend.metadata
305
+ };
306
+ return data;
307
+ }, [
308
+ currentTime,
309
+ state.service.cacheItem,
310
+ currentProduct,
311
+ number,
312
+ currentTimeItem
313
+ ]);
314
+ const resetService = () => {
315
+ var _a2, _b2;
316
+ let _val = ((_a2 = originServices.current) == null ? void 0 : _a2.value) || [];
317
+ let _edit = (_b2 = originServices.current) == null ? void 0 : _b2.edit;
318
+ originServices.current = null;
319
+ dispatch({
320
+ type: "setService",
321
+ payload: {
322
+ value: _val,
323
+ edit: _edit
324
+ }
325
+ });
326
+ };
327
+ const createNewServices = () => {
328
+ var _a2;
329
+ let _list = ((_a2 = state.service) == null ? void 0 : _a2.value) || [];
330
+ if (!originServices.current) {
331
+ return;
332
+ }
333
+ if (state.service.addTimeModal) {
334
+ _list = _list.map((d) => {
335
+ let _item = {
336
+ ...d
337
+ };
338
+ if (_item._extend.id === (newService == null ? void 0 : newService.id)) {
339
+ _item = {
340
+ ..._item,
341
+ ...newService || {},
342
+ _extend: newService == null ? void 0 : newService._extend
343
+ };
344
+ }
345
+ return _item;
346
+ });
347
+ dispatch({
348
+ type: "setService",
349
+ payload: {
350
+ value: _list,
351
+ edit: true
352
+ }
353
+ });
354
+ } else {
355
+ resetService();
356
+ }
357
+ };
358
+ const goCheckout = async () => {
359
+ var _a2, _b2;
360
+ if (state.isTerminal) {
361
+ return (_b2 = (_a2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _a2.postMessageToApp) == null ? void 0 : _b2.call(_a2, {
362
+ module: "booking",
363
+ key: "booking_checkout",
364
+ data: {
365
+ order_id: state.bookingId
366
+ }
367
+ });
368
+ }
369
+ state.action({
370
+ type: "pisell1.handlePayment",
371
+ data: {
372
+ orderId: state.bookingId
373
+ },
374
+ callback: () => {
375
+ state == null ? void 0 : state.callback();
376
+ }
377
+ });
378
+ };
379
+ const handleCheckout = async () => {
380
+ if (isEdit) {
381
+ await handleSave("checkout");
382
+ }
383
+ goCheckout();
384
+ };
385
+ const handleSave = async (loadingType = "save") => {
386
+ var _a2, _b2, _c2, _d2, _e2;
387
+ if (currentTime === null) {
388
+ return;
389
+ }
390
+ setLoading(loadingType);
391
+ const api = (0, import_utils4.isBooking4Shop)(
392
+ (_e2 = (_d2 = (_c2 = (_b2 = (_a2 = context.appHelper.utils.store) == null ? void 0 : _a2.getState) == null ? void 0 : _b2.call(_a2)) == null ? void 0 : _c2.global) == null ? void 0 : _d2.globalConfig) == null ? void 0 : _e2.id,
393
+ state.renderType
394
+ ) ? import_serve.saveAddTimeProduct2 : import_serve.saveAddTimeProduct;
395
+ await api({
396
+ orderId: state.bookingId,
397
+ params: {
398
+ ...newService,
399
+ _extend: void 0
400
+ }
401
+ });
402
+ setLoading("");
403
+ import_antd.message.success(import_utils.locales.getText("page.booking.text.add-time-success"));
404
+ onCancel();
405
+ if (loadingType === "checkout") {
406
+ return;
407
+ }
408
+ state == null ? void 0 : state.action("init");
409
+ };
410
+ (0, import_react.useEffect)(() => {
411
+ if (!state.modalOpen) {
412
+ onCancel();
413
+ }
414
+ }, [state.modalOpen]);
415
+ const onCancel = () => {
416
+ setIsEdit(false);
417
+ setRecordKey("");
418
+ resetService();
419
+ setTimeout(() => {
420
+ dispatch({
421
+ type: "setService",
422
+ payload: {
423
+ addTimeModal: false
424
+ }
425
+ });
426
+ }, 50);
427
+ };
428
+ const updateTime = (0, import_react.useMemo)(() => {
429
+ if (!newService) {
430
+ return "";
431
+ }
432
+ let startTime = newService.start_time;
433
+ let endTime = newService.end_time;
434
+ let hours = (0, import_utils3.getDiscountTime)(import_utils3.flexibleObj.getValue(newService.duration));
435
+ if (newService.start_date !== newService.end_date) {
436
+ const locale = state.locale;
437
+ const format = locale === "en" || locale === "en-US" ? "HH:mm DD/MM" : "MM-DD HH:mm";
438
+ startTime = (0, import_utils.formatDate)(
439
+ `${newService.start_date} ${newService.start_time}`,
440
+ format
441
+ );
442
+ endTime = (0, import_utils.formatDate)(
443
+ `${newService.end_date} ${newService.end_time}`,
444
+ format
445
+ );
446
+ }
447
+ return `${import_utils.locales.getText(
448
+ "page.booking.text.update-time"
449
+ )}: ${startTime} ~ ${endTime} (${hours})`;
450
+ }, [newService, state.locale]);
451
+ return /* @__PURE__ */ import_react.default.createElement(
452
+ import_drawer.default,
453
+ {
454
+ open: state.service.addTimeModal,
455
+ title: import_utils.locales.getText("page.booking.text.add-time"),
456
+ rootClassName: "booking-server-wrap",
457
+ onClose: onCancel,
458
+ footerStyle: { padding: "10px 32px 20px" },
459
+ hideScrollBar: false,
460
+ bodyStyle: { position: "relative" },
461
+ footer: /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-total-wrap" }, currentTimeItem && ((_g = currentTimeItem == null ? void 0 : currentTimeItem.status) == null ? void 0 : _g.message) ? /* @__PURE__ */ import_react.default.createElement(
462
+ import_antd.Alert,
463
+ {
464
+ message: currentTimeItem.status.message,
465
+ type: "warning",
466
+ showIcon: true,
467
+ style: { marginBottom: 12 }
468
+ }
469
+ ) : null, newService ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-summary-wrap" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-summary" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-summary-time" }, updateTime), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-summary-total" }, import_utils.locales.getText("pisell1.text.subtotal"), ":", " ", (0, import_utils.formatAmount)(
470
+ (currentTimeItem.price || 0) * number,
471
+ 2,
472
+ state.amountSymbol
473
+ ))), ((_h = currentProduct == null ? void 0 : currentProduct.add_time) == null ? void 0 : _h.calculate_type) === "select_quantity" && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-quantity-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-add-time-quantity" }, import_utils.locales.getText("page.booking.text.quantity")), " ", /* @__PURE__ */ import_react.default.createElement(
474
+ import_browserSelect.default,
475
+ {
476
+ value: number,
477
+ onChange: (e) => {
478
+ setNumber(Number(e.target.value));
479
+ updateServices.run();
480
+ },
481
+ className: "pisell-lowcode__booking-add-time-quantity-select",
482
+ options: numberList
483
+ }
484
+ ))) : null), /* @__PURE__ */ import_react.default.createElement(
485
+ import_footer.default,
486
+ {
487
+ state,
488
+ dispatch,
489
+ source: "addTime",
490
+ buttons: [
491
+ /* @__PURE__ */ import_react.default.createElement(
492
+ import_antd.Button,
493
+ {
494
+ className: "pisell-lowcode__booking-footer-buttons-item",
495
+ type: transaction_habit_selection.type === "service_now_pay_later" ? "default" : "primary",
496
+ disabled: loading === "list" || !isEdit || !currentTime,
497
+ onClick: handleCheckout,
498
+ loading: loading === "checkout"
499
+ },
500
+ import_utils.locales.getText("pisell2.text.checkout")
501
+ ),
502
+ /* @__PURE__ */ import_react.default.createElement(
503
+ import_antd.Button,
504
+ {
505
+ className: "pisell-lowcode__booking-footer-buttons-item",
506
+ type: transaction_habit_selection.type === "service_now_pay_later" ? "primary" : "default",
507
+ disabled: loading === "list" || !isEdit || !currentTime,
508
+ loading: loading === "save",
509
+ onClick: () => {
510
+ handleSave("save");
511
+ }
512
+ },
513
+ import_utils.locales.getText("pisell2.text.save")
514
+ )
515
+ ]
516
+ }
517
+ ))
518
+ },
519
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-body" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton, { loading: loading === "list", active: true, round: true }, /* @__PURE__ */ import_react.default.createElement("div", { className: "" }, renderList.map((d) => {
520
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-hours" }, d.title), d.times ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-child-card-list" }, d.times.map((child) => {
521
+ var _a2, _b2, _c2, _d2;
522
+ return /* @__PURE__ */ import_react.default.createElement(
523
+ "div",
524
+ {
525
+ className: (0, import_classnames.default)(
526
+ "pisell-lowcode__booking-add-time-child-card",
527
+ {
528
+ "pisell-lowcode__booking-add-time-child-card-active": recordKey === import_utils2.addTimeRowKey.create(d.id, child.value)
529
+ }
530
+ ),
531
+ onClick: () => {
532
+ if (!child.value) {
533
+ return;
534
+ }
535
+ onSelectItem(d, child);
536
+ }
537
+ },
538
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-child-card-left" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-child-card-left-time" }, child.label), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-add-time-child-card-left-price" }, (0, import_utils.formatAmount)(
539
+ child.price,
540
+ 2,
541
+ state.amountSymbol
542
+ ))),
543
+ /* @__PURE__ */ import_react.default.createElement(
544
+ "div",
545
+ {
546
+ className: "pisell-lowcode__booking-add-time-child-card-right",
547
+ style: {
548
+ color: (_b2 = (_a2 = child.status) == null ? void 0 : _a2.status) == null ? void 0 : _b2.color
549
+ }
550
+ },
551
+ (_d2 = (_c2 = child.status) == null ? void 0 : _c2.status) == null ? void 0 : _d2.label
552
+ )
553
+ );
554
+ })) : null);
555
+ }))), /* @__PURE__ */ import_react.default.createElement("div", { className: "" }))
556
+ );
557
+ };
558
+ var addTimeModal_default = AddTimeModal;
@@ -0,0 +1,9 @@
1
+ export declare const getAddTimeProducts: (params: any, config: any) => Promise<any>;
2
+ export declare const saveAddTimeProduct: ({ orderId, params }: {
3
+ orderId: number | string;
4
+ params: any;
5
+ }) => Promise<any>;
6
+ export declare const saveAddTimeProduct2: ({ orderId, params }: {
7
+ orderId: number | string;
8
+ params: any;
9
+ }) => Promise<any>;
@@ -0,0 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/booking/info2/service/addTimeModal/serve.ts
20
+ var serve_exports = {};
21
+ __export(serve_exports, {
22
+ getAddTimeProducts: () => getAddTimeProducts,
23
+ saveAddTimeProduct: () => saveAddTimeProduct,
24
+ saveAddTimeProduct2: () => saveAddTimeProduct2
25
+ });
26
+ module.exports = __toCommonJS(serve_exports);
27
+ var import_utils = require("../../../utils");
28
+ var getAddTimeProducts = async (params, config) => {
29
+ let { data } = await import_utils.request.getRequest().post(`/shop/product/query`, params, config);
30
+ return data;
31
+ };
32
+ var saveAddTimeProduct = async ({ orderId, params }) => {
33
+ let { data } = await import_utils.request.getRequest().put(`/shop/order/appointment/child-booking/${orderId}`, params);
34
+ return data;
35
+ };
36
+ var saveAddTimeProduct2 = async ({ orderId, params }) => {
37
+ let { data } = await import_utils.request.getRequest().put(`/shop/v1.1/order/appointment/child-booking/${orderId}`, params);
38
+ return data;
39
+ };
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ getAddTimeProducts,
43
+ saveAddTimeProduct,
44
+ saveAddTimeProduct2
45
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @title: 根据商品生成加时列表
3
+ * @description:
4
+ * @param {any} config
5
+ * @param {number} price
6
+ * @return {*}
7
+ * @Author: zhiwei.Wang
8
+ * @Date: 2024-07-01 09:34
9
+ */
10
+ export declare const getAddTimeSplits: (product: any, cacheItem: any) => {
11
+ label: any;
12
+ value: any;
13
+ price: any;
14
+ }[];
15
+ /**
16
+ * @title: 判断当前商品是否可用
17
+ * @description:
18
+ * @param {any} relationProduct
19
+ * @param {any} currentItem
20
+ * @return {*}
21
+ * @Author: zhiwei.Wang
22
+ * @Date: 2024-07-01 09:33
23
+ */
24
+ export declare const isUsableProduct: (addTime: any, currentItem: any) => any;
25
+ export declare const addTimeRowKey: {
26
+ create: (product_id: number, time: number) => string;
27
+ getValue: (str: string) => {
28
+ product_id: number;
29
+ time: number | string;
30
+ };
31
+ };