@pisell/private-materials 3.0.201 → 3.0.203

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 (129) 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 -27
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +18 -33
  11. package/es/components/booking/addons/model.d.ts +1 -1
  12. package/es/components/booking/components/footer/amount.js +5 -4
  13. package/es/components/booking/components/footer/utils.js +49 -29
  14. package/es/components/booking/forms/model.d.ts +1 -1
  15. package/es/components/booking/info/Provider.d.ts +0 -0
  16. package/es/components/booking/info/Provider.js +54 -0
  17. package/es/components/booking/info/clientVariant/vertical/index.js +93 -7
  18. package/es/components/booking/info/main.js +10 -9
  19. package/es/components/booking/info/pet/ChangePetModal/index.js +38 -23
  20. package/es/components/booking/info/service/addService/index.js +70 -99
  21. package/es/components/booking/info/service/addService/utils.d.ts +1 -0
  22. package/es/components/booking/info/service/addService/utils.js +55 -3
  23. package/es/components/booking/info/service/editService/BookingList/index.d.ts +5 -0
  24. package/es/components/booking/info/service/editService/BookingList/index.js +39 -0
  25. package/es/components/booking/info/service/editService/EditTabs/index.d.ts +3 -0
  26. package/es/components/booking/info/service/editService/EditTabs/index.js +35 -0
  27. package/es/components/booking/info/service/editService/index.js +234 -142
  28. package/es/components/booking/info/service/serve.d.ts +10 -0
  29. package/es/components/booking/info/service/serve.js +28 -0
  30. package/es/components/booking/info/service/serviceManager/distributeDiscount.d.ts +11 -0
  31. package/es/components/booking/info/service/serviceManager/distributeDiscount.js +55 -0
  32. package/es/components/booking/info/service/serviceManager/index.d.ts +20 -0
  33. package/es/components/booking/info/service/serviceManager/index.js +277 -0
  34. package/es/components/booking/info/service/serviceManager/utils.d.ts +0 -0
  35. package/es/components/booking/info/service/serviceManager/utils.js +0 -0
  36. package/es/components/booking/info/service2/Group/utils.d.ts +14 -0
  37. package/es/components/booking/info/service2/Group/utils.js +146 -0
  38. package/es/components/booking/info/service2/Lists.js +27 -33
  39. package/es/components/booking/info/service2/index.d.ts +4 -1
  40. package/es/components/booking/info/service2/index.js +5 -6
  41. package/es/components/booking/info/service2/status.js +1 -1
  42. package/es/components/booking/info/service2/utils.d.ts +95 -3
  43. package/es/components/booking/info/service2/utils.js +678 -52
  44. package/es/components/booking/info/utils.d.ts +11 -0
  45. package/es/components/booking/info/utils.js +24 -0
  46. package/es/components/booking/locales.d.ts +6 -0
  47. package/es/components/booking/locales.js +9 -3
  48. package/es/components/booking/model.d.ts +1 -0
  49. package/es/components/booking/notes/index.d.ts +1 -1
  50. package/es/components/booking/notes/model.d.ts +1 -1
  51. package/es/components/booking/payments/index.d.ts +1 -1
  52. package/es/components/booking/payments/model.d.ts +1 -1
  53. package/es/components/booking/utils.js +5 -4
  54. package/es/components/eftpos/hooks.d.ts +4 -4
  55. package/es/components/eftposPay/amount.d.ts +1 -1
  56. package/es/components/eftposPay/component/step/index.d.ts +6 -6
  57. package/es/components/eftposPay/component/step/step.d.ts +4 -4
  58. package/es/components/eftposPay/hooks.d.ts +1 -1
  59. package/es/components/eftposPay/store/index.d.ts +1 -1
  60. package/es/components/eftposPay/tyro/hooks.d.ts +2 -2
  61. package/es/components/eftposPay/windcave/helper.d.ts +1 -1
  62. package/es/components/schedules/index.d.ts +1 -1
  63. package/es/components/schedules/model.d.ts +1 -1
  64. package/es/components/shoppingCart/components/Cart/Product.js +11 -39
  65. package/es/components/shoppingCart/components/Render/index.js +8 -7
  66. package/es/components/shoppingCart/components/SelectHolderModal/index.js +12 -4
  67. package/es/components/shoppingCart/hooks/useClearCart.js +10 -5
  68. package/es/components/shoppingCart/type.d.ts +1 -1
  69. package/es/components/shoppingCart/utils.js +2 -5
  70. package/lib/components/booking/addons/model.d.ts +1 -1
  71. package/lib/components/booking/components/footer/amount.js +4 -3
  72. package/lib/components/booking/components/footer/utils.js +28 -28
  73. package/lib/components/booking/forms/model.d.ts +1 -1
  74. package/lib/components/booking/info/Provider.d.ts +0 -0
  75. package/lib/components/booking/info/Provider.js +0 -0
  76. package/lib/components/booking/info/clientVariant/vertical/index.js +51 -1
  77. package/lib/components/booking/info/main.js +6 -5
  78. package/lib/components/booking/info/pet/ChangePetModal/index.js +33 -23
  79. package/lib/components/booking/info/service/addService/index.js +50 -92
  80. package/lib/components/booking/info/service/addService/utils.d.ts +1 -0
  81. package/lib/components/booking/info/service/addService/utils.js +27 -0
  82. package/lib/components/booking/info/service/editService/BookingList/index.d.ts +5 -0
  83. package/lib/components/booking/info/service/editService/BookingList/index.js +55 -0
  84. package/lib/components/booking/info/service/editService/EditTabs/index.d.ts +3 -0
  85. package/lib/components/booking/info/service/editService/EditTabs/index.js +75 -0
  86. package/lib/components/booking/info/service/editService/index.js +309 -234
  87. package/lib/components/booking/info/service/serve.d.ts +10 -0
  88. package/lib/components/booking/info/service/serve.js +7 -2
  89. package/lib/components/booking/info/service/serviceManager/distributeDiscount.d.ts +11 -0
  90. package/lib/components/booking/info/service/serviceManager/distributeDiscount.js +70 -0
  91. package/lib/components/booking/info/service/serviceManager/index.d.ts +20 -0
  92. package/lib/components/booking/info/service/serviceManager/index.js +207 -0
  93. package/lib/components/booking/info/service/serviceManager/utils.d.ts +0 -0
  94. package/lib/components/booking/info/service/serviceManager/utils.js +0 -0
  95. package/lib/components/booking/info/service2/Group/utils.d.ts +14 -0
  96. package/lib/components/booking/info/service2/Group/utils.js +142 -0
  97. package/lib/components/booking/info/service2/Lists.js +14 -12
  98. package/lib/components/booking/info/service2/index.d.ts +4 -1
  99. package/lib/components/booking/info/service2/index.js +5 -5
  100. package/lib/components/booking/info/service2/status.js +1 -1
  101. package/lib/components/booking/info/service2/utils.d.ts +95 -3
  102. package/lib/components/booking/info/service2/utils.js +404 -48
  103. package/lib/components/booking/info/utils.d.ts +11 -0
  104. package/lib/components/booking/info/utils.js +35 -0
  105. package/lib/components/booking/locales.d.ts +6 -0
  106. package/lib/components/booking/locales.js +9 -3
  107. package/lib/components/booking/model.d.ts +1 -0
  108. package/lib/components/booking/notes/index.d.ts +1 -1
  109. package/lib/components/booking/notes/model.d.ts +1 -1
  110. package/lib/components/booking/payments/index.d.ts +1 -1
  111. package/lib/components/booking/payments/model.d.ts +1 -1
  112. package/lib/components/booking/utils.js +3 -4
  113. package/lib/components/eftpos/hooks.d.ts +4 -4
  114. package/lib/components/eftposPay/amount.d.ts +1 -1
  115. package/lib/components/eftposPay/component/step/index.d.ts +6 -6
  116. package/lib/components/eftposPay/component/step/step.d.ts +4 -4
  117. package/lib/components/eftposPay/hooks.d.ts +1 -1
  118. package/lib/components/eftposPay/store/index.d.ts +1 -1
  119. package/lib/components/eftposPay/tyro/hooks.d.ts +2 -2
  120. package/lib/components/eftposPay/windcave/helper.d.ts +1 -1
  121. package/lib/components/schedules/index.d.ts +1 -1
  122. package/lib/components/schedules/model.d.ts +1 -1
  123. package/lib/components/shoppingCart/components/Cart/Product.js +6 -22
  124. package/lib/components/shoppingCart/components/Render/index.js +6 -10
  125. package/lib/components/shoppingCart/components/SelectHolderModal/index.js +12 -4
  126. package/lib/components/shoppingCart/hooks/useClearCart.js +4 -9
  127. package/lib/components/shoppingCart/type.d.ts +1 -1
  128. package/lib/components/shoppingCart/utils.js +2 -8
  129. package/package.json +4 -4
@@ -1 +1,11 @@
1
1
  export declare const getProductDetail: (id: string, params: any) => Promise<any>;
2
+ /**
3
+ * @title: 跨日预约获取预约商品报价单
4
+ * @description:
5
+ * @param {string} id
6
+ * @param {any} params
7
+ * @return {*}
8
+ * @Author: WangHan
9
+ * @Date: 2024-12-23 17:06
10
+ */
11
+ export declare const postMultiDay: (id: string, params: any) => Promise<any>;
@@ -19,12 +19,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/components/booking/info/service/serve.ts
20
20
  var serve_exports = {};
21
21
  __export(serve_exports, {
22
- getProductDetail: () => getProductDetail
22
+ getProductDetail: () => getProductDetail,
23
+ postMultiDay: () => postMultiDay
23
24
  });
24
25
  module.exports = __toCommonJS(serve_exports);
25
26
  var import_utils = require("../../utils");
26
27
  var getProductDetail = async (id, params) => import_utils.request.getRequest().get(`/shop/product/query/${id}`, params);
28
+ var postMultiDay = async (id, params) => import_utils.request.getRequest().post(`/shop/product/multi-day/detail/${id}`, params, {
29
+ useCache: true
30
+ });
27
31
  // Annotate the CommonJS export names for ESM import in node:
28
32
  0 && (module.exports = {
29
- getProductDetail
33
+ getProductDetail,
34
+ postMultiDay
30
35
  });
@@ -0,0 +1,11 @@
1
+ interface Product {
2
+ _id: string;
3
+ _extend: {
4
+ origin_total: number;
5
+ total: number;
6
+ };
7
+ }
8
+ export declare function distributeDiscountOrIncrease(products: Product[], // 商品列表
9
+ totalAdjustment: number, // 总折扣或加价金额,可能为负数(折扣)或正数(加价)
10
+ totalPrice: number): Product[];
11
+ export {};
@@ -0,0 +1,70 @@
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/info/service/serviceManager/distributeDiscount.ts
30
+ var distributeDiscount_exports = {};
31
+ __export(distributeDiscount_exports, {
32
+ distributeDiscountOrIncrease: () => distributeDiscountOrIncrease
33
+ });
34
+ module.exports = __toCommonJS(distributeDiscount_exports);
35
+ var import_decimal = __toESM(require("decimal.js"));
36
+ function distributeDiscountOrIncrease(products, totalAdjustment, totalPrice) {
37
+ const totalAdjustmentDecimal = new import_decimal.default(totalAdjustment);
38
+ let totalAdjustmentApplied = new import_decimal.default(0);
39
+ const adjustedProducts = [];
40
+ products.forEach((product) => {
41
+ const productPrice = new import_decimal.default(product._extend.origin_total);
42
+ let adjustmentAmount = productPrice.div(totalPrice).times(totalAdjustmentDecimal).toFixed(2, import_decimal.default.ROUND_HALF_UP);
43
+ const newPrice = productPrice.plus(adjustmentAmount).toFixed(2, import_decimal.default.ROUND_HALF_UP);
44
+ const adjustedPrice = new import_decimal.default(newPrice).lessThan(0) ? "0.00" : newPrice;
45
+ adjustedProducts.push({
46
+ ...product,
47
+ _extend: {
48
+ ...product._extend,
49
+ total: parseFloat(adjustedPrice)
50
+ }
51
+ });
52
+ totalAdjustmentApplied = totalAdjustmentApplied.plus(new import_decimal.default(adjustmentAmount));
53
+ });
54
+ const finalTotalPrice = adjustedProducts.reduce(
55
+ (sum, product) => sum.plus(new import_decimal.default(product._extend.total)),
56
+ new import_decimal.default(0)
57
+ );
58
+ const adjustmentDifference = new import_decimal.default(totalPrice).minus(finalTotalPrice).plus(new import_decimal.default(totalAdjustment));
59
+ if (!adjustmentDifference.isZero()) {
60
+ let lastProduct = adjustedProducts[adjustedProducts.length - 1];
61
+ let lastPrice = new import_decimal.default(lastProduct._extend.total).plus(adjustmentDifference).toFixed(2, import_decimal.default.ROUND_HALF_UP);
62
+ lastPrice = new import_decimal.default(lastPrice).lessThan(0) ? "0.00" : lastPrice;
63
+ lastProduct._extend.total = parseFloat(lastPrice);
64
+ }
65
+ return adjustedProducts;
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ distributeDiscountOrIncrease
70
+ });
@@ -0,0 +1,20 @@
1
+ export declare const useService: ({ renderMode, onEdit, state, dispatch, }: {
2
+ renderMode?: any;
3
+ onEdit?: any;
4
+ state?: any;
5
+ dispatch?: any;
6
+ }) => {
7
+ createBookingData: ({ product }: any) => Promise<any>;
8
+ editBookingData: ({ changeValues }: {
9
+ changeValues: any;
10
+ }) => Promise<any>;
11
+ createBooking: ({ booking }: {
12
+ booking: any;
13
+ }) => Promise<void>;
14
+ editBooking: ({ booking }: {
15
+ booking: any;
16
+ }) => Promise<void>;
17
+ goEditPanel: ({ booking }: {
18
+ booking: any;
19
+ }) => void;
20
+ };
@@ -0,0 +1,207 @@
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/info/service/serviceManager/index.tsx
20
+ var serviceManager_exports = {};
21
+ __export(serviceManager_exports, {
22
+ useService: () => useService
23
+ });
24
+ module.exports = __toCommonJS(serviceManager_exports);
25
+ var import_react = require("react");
26
+ var import_utils = require("@pisell/utils");
27
+ var import_utils2 = require("../addService/utils");
28
+ var import_utils3 = require("../../service2/utils");
29
+ var import_utils4 = require("../../service2/Group/utils");
30
+ var import_utils5 = require("../../../utils");
31
+ var lock = false;
32
+ var useService = ({
33
+ renderMode,
34
+ onEdit,
35
+ state,
36
+ dispatch
37
+ }) => {
38
+ var _a;
39
+ const holderId = (0, import_react.useMemo)(() => {
40
+ var _a2;
41
+ return Number(((_a2 = state == null ? void 0 : state.activeCartId) == null ? void 0 : _a2[0]) || 0);
42
+ }, [state == null ? void 0 : state.activeCartId]);
43
+ const isDayBookingMode = (0, import_react.useMemo)(() => {
44
+ return (0, import_utils3.isDayBooking)(state);
45
+ }, [state == null ? void 0 : state.renderType]);
46
+ const createBookingData = async ({ product }) => {
47
+ var _a2, _b;
48
+ if (lock) {
49
+ return;
50
+ }
51
+ lock = true;
52
+ setTimeout(() => {
53
+ lock = false;
54
+ }, 2e3);
55
+ const { _params } = product;
56
+ let cacheItem = {
57
+ ...product,
58
+ product_id: product.id,
59
+ _id: (0, import_utils.getUniqueId)(),
60
+ _key: _params.key,
61
+ _extend: {
62
+ start_date: state.date.value,
63
+ quantity: 1,
64
+ price: product.price,
65
+ product_name: product.title,
66
+ other: JSON.parse(JSON.stringify(_params))
67
+ },
68
+ new: 1
69
+ };
70
+ if (isDayBookingMode) {
71
+ cacheItem._extend.holder_id = holderId;
72
+ cacheItem._extend.end_date = state.date.end_date;
73
+ cacheItem._extend.sub_type = "days";
74
+ }
75
+ let _total = (0, import_utils5.getProductTotalPrice)(cacheItem);
76
+ cacheItem._extend.total = _total;
77
+ cacheItem._extend.origin_total = _total;
78
+ const _isEdit = !!state.service.cacheItem;
79
+ if (_isEdit) {
80
+ cacheItem._id = (_a2 = state.service.cacheItem) == null ? void 0 : _a2._id;
81
+ cacheItem.new = 0;
82
+ }
83
+ if (renderMode === "current") {
84
+ cacheItem.currentDefaultTime = state.date.value.format("HH:mm");
85
+ }
86
+ cacheItem._extend = (0, import_utils2.getProductExtend)({ cacheItem, state });
87
+ if (isDayBookingMode) {
88
+ cacheItem = await (0, import_utils2.getMultiDay)({
89
+ start_date: cacheItem._extend.startDate,
90
+ end_date: cacheItem._extend.endDate,
91
+ state,
92
+ cacheItem
93
+ });
94
+ if ((0, import_utils3.isDayBookingProduct)(cacheItem, state)) {
95
+ cacheItem = (0, import_utils4.concatBookings)((0, import_utils4.createBookingItemsByGroup)(cacheItem));
96
+ }
97
+ }
98
+ if (isDayBookingMode && !(0, import_utils3.isDayBookingProduct)(cacheItem, state)) {
99
+ cacheItem.autoClose = true;
100
+ } else if (state.renderType === "eventBooking") {
101
+ cacheItem.autoClose = false;
102
+ } else {
103
+ cacheItem.autoClose = !_isEdit && (cacheItem._extend.resource || cacheItem._extend.resource === 0 || (((_b = state.service) == null ? void 0 : _b.resourcesOrigin) || []).length === 1);
104
+ }
105
+ debugger;
106
+ return cacheItem;
107
+ };
108
+ const currentResource = (0, import_react.useCallback)(
109
+ (useResource) => {
110
+ const list = state.service.resources;
111
+ let item = list.find((d) => d.form_record_id == useResource) || {};
112
+ return item;
113
+ },
114
+ [(_a = state == null ? void 0 : state.service) == null ? void 0 : _a.resources]
115
+ );
116
+ const editBookingData = async ({ changeValues }) => {
117
+ var _a2;
118
+ let _item = {
119
+ ...state.service.cacheItem,
120
+ autoClose: false
121
+ };
122
+ let _extend = {
123
+ ..._item._extend,
124
+ ...changeValues
125
+ };
126
+ if ((0, import_utils3.isDayBookingProduct)(state.service.cacheItem, state)) {
127
+ _extend.quantity = 1;
128
+ _extend.startDate = _extend == null ? void 0 : _extend.start_date;
129
+ _extend.endDate = _extend == null ? void 0 : _extend.end_date;
130
+ } else {
131
+ const { startDate, endDate } = (0, import_utils5.getServiceTimes)({ _extend });
132
+ _extend.startDate = startDate;
133
+ _extend.endDate = endDate;
134
+ }
135
+ const resourceItem = currentResource(changeValues.resource);
136
+ const { relation_type, item_id, schedule_id } = ((_a2 = resourceItem == null ? void 0 : resourceItem._extend) == null ? void 0 : _a2.usableTime) || {};
137
+ _extend.relation_type = relation_type || "form";
138
+ _extend.relation_id = item_id || (resourceItem == null ? void 0 : resourceItem.form_record_id) || 0;
139
+ _extend.schedule_id = schedule_id || 0;
140
+ if (_extend.bundle_edit !== void 0) {
141
+ _extend.bundle_edit = 1;
142
+ }
143
+ _item._extend = _extend;
144
+ _item._time = (/* @__PURE__ */ new Date()).getTime();
145
+ return _item;
146
+ };
147
+ const createBooking = async ({ booking }) => {
148
+ goEditPanel({ booking });
149
+ };
150
+ const editBooking = async ({ booking }) => {
151
+ var _a2;
152
+ let _list = state.service.value;
153
+ let _id = booking == null ? void 0 : booking._id;
154
+ let groupId = (_a2 = booking == null ? void 0 : booking._extend) == null ? void 0 : _a2.groupId;
155
+ if (groupId) {
156
+ _list = _list.filter((d) => {
157
+ var _a3;
158
+ return ((_a3 = d._extend) == null ? void 0 : _a3.groupId) !== groupId;
159
+ });
160
+ _list = _list.concat((0, import_utils4.createBookingItemsByGroup)(booking, true));
161
+ } else {
162
+ if (!_list.some((d) => d._id === _id)) {
163
+ if (!(0, import_utils3.isBookingProduct)(booking == null ? void 0 : booking.extension_type) || !isDayBookingMode) {
164
+ _list.push(booking);
165
+ } else {
166
+ }
167
+ } else {
168
+ _list = _list.map((d) => d._id === _id ? { ...booking, new: 0 } : d);
169
+ }
170
+ }
171
+ (0, import_utils5.deleteCacheParams)();
172
+ dispatch({
173
+ type: "setService",
174
+ payload: {
175
+ editModal: false,
176
+ addModal: false,
177
+ value: _list,
178
+ edit: true,
179
+ cacheItem: null,
180
+ changeService: false
181
+ }
182
+ });
183
+ };
184
+ const goEditPanel = ({ booking }) => {
185
+ dispatch({
186
+ type: "setService",
187
+ payload: {
188
+ editModal: true,
189
+ cacheItem: booking,
190
+ addModal: !booking.autoClose,
191
+ changeService: false
192
+ }
193
+ });
194
+ onEdit(booking);
195
+ };
196
+ return {
197
+ createBookingData,
198
+ editBookingData,
199
+ createBooking,
200
+ editBooking,
201
+ goEditPanel
202
+ };
203
+ };
204
+ // Annotate the CommonJS export names for ESM import in node:
205
+ 0 && (module.exports = {
206
+ useService
207
+ });
@@ -0,0 +1,14 @@
1
+ export declare const getGroupTotalPrice: (items: any[]) => any;
2
+ /**
3
+ * @title: 创建一个虚拟的组
4
+ * @description:
5
+ * @param {any} items
6
+ * @return {*}
7
+ * @Author: zhiwei.Wang
8
+ */
9
+ export declare const concatBookings: (items: any[]) => any;
10
+ export declare const createBookingItemsByGroup: (item: any, isBatchEdit?: any) => any[];
11
+ export declare const isGroupBooking: (_id: any) => boolean;
12
+ export declare const getProductByGroupId: (groupId: string, items: any[]) => any[];
13
+ export declare const getGroupBooking: (groupId: string, items: any[]) => any;
14
+ export declare const filterItemByGroupId: (groupId: string, items: any[]) => any[];
@@ -0,0 +1,142 @@
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/info/service2/Group/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ concatBookings: () => concatBookings,
23
+ createBookingItemsByGroup: () => createBookingItemsByGroup,
24
+ filterItemByGroupId: () => filterItemByGroupId,
25
+ getGroupBooking: () => getGroupBooking,
26
+ getGroupTotalPrice: () => getGroupTotalPrice,
27
+ getProductByGroupId: () => getProductByGroupId,
28
+ isGroupBooking: () => isGroupBooking
29
+ });
30
+ module.exports = __toCommonJS(utils_exports);
31
+ var import_utils = require("@pisell/utils");
32
+ var import_utils2 = require("../../../utils");
33
+ var import_distributeDiscount = require("../../service/serviceManager/distributeDiscount");
34
+ var getGroupTotalPrice = (items) => {
35
+ return items.reduce((prev, next) => {
36
+ prev.duration += next._extend.duration;
37
+ prev.total += next._extend.total;
38
+ prev.origin_total += next._extend.origin_total;
39
+ return prev;
40
+ }, { total: 0, origin_total: 0 });
41
+ };
42
+ var concatBookings = (items) => {
43
+ let firstItem = items[0];
44
+ let lastItem = items[items.length - 1];
45
+ let { total, duration, startDate, endDate, origin_total } = items.reduce((prev, next) => {
46
+ prev.duration += next._extend.duration;
47
+ prev.total += next._extend.total;
48
+ prev.origin_total += next._extend.origin_total;
49
+ return prev;
50
+ }, { price: 0, total: 0, origin_total: 0, duration: 0, startDate: firstItem._extend.startDate, endDate: lastItem._extend.endDate });
51
+ return {
52
+ ...firstItem,
53
+ // 虚拟组, id使用组id
54
+ _id: firstItem._extend.groupId,
55
+ _extend: {
56
+ ...firstItem._extend,
57
+ items,
58
+ duration,
59
+ // price: total,
60
+ total,
61
+ origin_total,
62
+ startDate,
63
+ endDate,
64
+ start_date: startDate,
65
+ end_date: endDate
66
+ }
67
+ };
68
+ };
69
+ var createBookingItemsByGroup = (item, isBatchEdit) => {
70
+ var _a;
71
+ const groupId = item._extend.groupId || (0, import_utils.getUniqueId)("bookingGroup_");
72
+ let bookings = [];
73
+ for (let i = 0; i < item._extend.duration; i++) {
74
+ const _extend = { ...item._extend };
75
+ const startDate = _extend.start_date.add(i, "day");
76
+ const endDate = _extend.start_date.add(i + 1, "day");
77
+ const price = ((_a = _extend.multiDayPrices[startDate.format("YYYY-MM-DD")]) == null ? void 0 : _a.total) || item._extend.price;
78
+ const cacheItem = {
79
+ ...item,
80
+ // 编辑时组商品需要清空booking_id 否则会重复
81
+ booking_id: isBatchEdit ? 0 : item.booking_id,
82
+ _id: `${item._id}-${i + 1}`,
83
+ price,
84
+ _extend: {
85
+ ..._extend,
86
+ order_detail_id: isBatchEdit ? 0 : item.order_detail_id,
87
+ groupId,
88
+ duration: 1,
89
+ price,
90
+ startDate,
91
+ endDate,
92
+ start_date: startDate,
93
+ end_date: endDate,
94
+ dateKey: `${startDate.format("YYYY-MM-DD")}~${endDate.format("YYYY-MM-DD")}}`
95
+ }
96
+ };
97
+ const totalPrice = (0, import_utils2.getProductTotalPrice)(cacheItem);
98
+ cacheItem._extend.total = totalPrice;
99
+ cacheItem._extend.origin_total = totalPrice;
100
+ cacheItem._extend.items = void 0;
101
+ bookings.push(cacheItem);
102
+ }
103
+ if (isBatchEdit) {
104
+ const groupTotalPrice = item._extend.total;
105
+ const groupOriginTotalPrice = item._extend.origin_total;
106
+ const discountAmount = (groupOriginTotalPrice - groupTotalPrice) * -1;
107
+ if (discountAmount !== 0) {
108
+ bookings = (0, import_distributeDiscount.distributeDiscountOrIncrease)(bookings, discountAmount, groupOriginTotalPrice);
109
+ }
110
+ }
111
+ console.log("bookings", bookings);
112
+ return bookings;
113
+ };
114
+ var isGroupBooking = (_id) => {
115
+ return (_id == null ? void 0 : _id.indexOf("bookingGroup_")) === 0;
116
+ };
117
+ var getProductByGroupId = (groupId, items) => {
118
+ return items.filter((item) => {
119
+ var _a;
120
+ return ((_a = item._extend) == null ? void 0 : _a.groupId) === groupId;
121
+ }).map((item) => item._id);
122
+ };
123
+ var getGroupBooking = (groupId, items) => {
124
+ let products = getProductByGroupId(groupId, items);
125
+ return concatBookings(products);
126
+ };
127
+ var filterItemByGroupId = (groupId, items) => {
128
+ return items.filter((item) => {
129
+ var _a;
130
+ return ((_a = item._extend) == null ? void 0 : _a.groupId) !== groupId;
131
+ });
132
+ };
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ concatBookings,
136
+ createBookingItemsByGroup,
137
+ filterItemByGroupId,
138
+ getGroupBooking,
139
+ getGroupTotalPrice,
140
+ getProductByGroupId,
141
+ isGroupBooking
142
+ });
@@ -45,27 +45,30 @@ var Lists = ({ onEdit, onChange }) => {
45
45
  const [params, setParams] = (0, import_react.useState)(import_status.defaultData);
46
46
  const { holderLists } = (0, import_useSelectPet.default)(state);
47
47
  (0, import_react.useEffect)(() => {
48
- const keys = (0, import_utils.formatActiveKey)(holderLists, params == null ? void 0 : params.platform);
48
+ const keys = (0, import_utils.formatActiveKey)(
49
+ holderLists,
50
+ params == null ? void 0 : params.platform,
51
+ !!state.bookingId
52
+ );
49
53
  onChange({ activeCartId: keys }, "setActiveCartId");
50
54
  setParams({
51
55
  ...params,
52
56
  activeKey: keys
53
57
  });
54
58
  }, [holderLists, params == null ? void 0 : params.platform]);
55
- const handleCard = (item) => {
59
+ const handleChange = (currentItem, type, other) => {
56
60
  if (state.disabledEdit || state.disableEventBookingEdit) {
57
61
  return;
58
62
  }
59
- onChange({ editModal: true, cacheItem: { ...item, new: 0 } });
60
- onEdit == null ? void 0 : onEdit({ ...item, new: 0 });
61
- };
62
- const handleChange = (newState) => {
63
- if (state.disabledEdit || state.disableEventBookingEdit || state.channelDisabledEdit) {
64
- return;
63
+ let products = (0, import_utils.updateServices)(state, currentItem, type, other);
64
+ if (type === "view") {
65
+ let product = currentItem._origin;
66
+ onChange({ editModal: true, cacheItem: { ...product, new: 0 } });
67
+ return onEdit == null ? void 0 : onEdit({ ...product, new: 0 });
65
68
  }
66
69
  const params2 = {
67
70
  editModal: false,
68
- value: newState,
71
+ value: products,
69
72
  edit: true,
70
73
  cacheItem: null
71
74
  };
@@ -88,7 +91,7 @@ var Lists = ({ onEdit, onChange }) => {
88
91
  const productParams = (0, import_react.useMemo)(() => {
89
92
  return {
90
93
  hideAddBtn: state.isTerminalDayBookingPage,
91
- isShowNote: true,
94
+ isShowNote: false,
92
95
  isShowPackageNote: false,
93
96
  holders: holderLists,
94
97
  isEdit: !!(state == null ? void 0 : state.bookingId),
@@ -98,8 +101,7 @@ var Lists = ({ onEdit, onChange }) => {
98
101
  return /* @__PURE__ */ import_react.default.createElement(import_Provider.CartContext.Provider, { value: { state } }, /* @__PURE__ */ import_react.default.createElement(
99
102
  import_shoppingCart.default,
100
103
  {
101
- onCard: handleCard,
102
- onChange: (e) => handleChange(e),
104
+ onChange: handleChange,
103
105
  onAddProduct: () => onChange({ addModal: true }),
104
106
  onActiveKey: handleActiveKey,
105
107
  collapseParams: CollapseParams,
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
2
  export declare const Service2Context: React.Context<any>;
3
- export declare const Service2Cart: () => React.JSX.Element;
3
+ export declare const Service2Cart: ({ hideAdd, hideEdit, }: {
4
+ hideAdd?: boolean | undefined;
5
+ hideEdit?: boolean | undefined;
6
+ }) => React.JSX.Element;
@@ -39,15 +39,15 @@ var import_editService = __toESM(require("../service/editService"));
39
39
  var import_model = require("../model");
40
40
  var import_Lists = __toESM(require("./Lists"));
41
41
  var Service2Context = (0, import_react.createContext)({});
42
- var Service2Cart = () => {
42
+ var Service2Cart = ({
43
+ hideAdd,
44
+ hideEdit
45
+ }) => {
43
46
  const detailRef = (0, import_react.useRef)();
44
47
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
45
48
  (0, import_react.useEffect)(() => {
46
49
  document.body.id = "body";
47
50
  }, []);
48
- (0, import_react.useEffect)(() => {
49
- console.log(state, "wh_state33");
50
- }, [state]);
51
51
  const dispatchService = (type, payload) => {
52
52
  dispatch({
53
53
  type,
@@ -66,7 +66,7 @@ var Service2Cart = () => {
66
66
  onEdit: handleEdit,
67
67
  onChange: (e, type) => dispatchService(type || "setService", e)
68
68
  }
69
- ), /* @__PURE__ */ import_react.default.createElement(import_addService.default, { onEdit: handleEdit })), /* @__PURE__ */ import_react.default.createElement(import_editService.default, { ref: detailRef }));
69
+ ), !hideAdd && /* @__PURE__ */ import_react.default.createElement(import_addService.default, { onEdit: handleEdit })), !hideEdit && /* @__PURE__ */ import_react.default.createElement(import_editService.default, { ref: detailRef }));
70
70
  };
71
71
  // Annotate the CommonJS export names for ESM import in node:
72
72
  0 && (module.exports = {
@@ -67,7 +67,7 @@ var inputDateCol = (isDayBooking, isTerminal) => {
67
67
  }
68
68
  return params;
69
69
  };
70
- var appointmentTypes = ["product_appointment", "product_add_time"];
70
+ var appointmentTypes = ["product_appointment"];
71
71
  var openingTime = () => {
72
72
  const openingTime2 = localStorage.getItem("shopOpeningHours");
73
73
  return openingTime2 || "00:00";