@pisell/pisellos 3.0.34 → 3.0.35
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.
- package/dist/modules/Schedule/index.d.ts +2 -0
- package/dist/modules/Schedule/index.js +10 -0
- package/dist/modules/Schedule/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -3
- package/dist/solution/BookingByStep/index.js +96 -70
- package/lib/modules/Schedule/index.d.ts +2 -0
- package/lib/modules/Schedule/index.js +6 -0
- package/lib/modules/Schedule/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -3
- package/lib/solution/BookingByStep/index.js +51 -36
- package/package.json +1 -1
|
@@ -14,5 +14,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
14
14
|
getScheduleListByIds(ids: number[]): ScheduleItem[];
|
|
15
15
|
setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
|
|
16
16
|
getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
|
|
17
|
+
setOtherProductsIds(ids: number[]): void;
|
|
18
|
+
getOtherProductsIds(): number[];
|
|
17
19
|
storeChange(): void;
|
|
18
20
|
}
|
|
@@ -92,6 +92,16 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
92
92
|
value: function getAvailabilityScheduleDateList() {
|
|
93
93
|
return this.store.availabilityDateList;
|
|
94
94
|
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "setOtherProductsIds",
|
|
97
|
+
value: function setOtherProductsIds(ids) {
|
|
98
|
+
this.store.otherProductsIds = ids;
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "getOtherProductsIds",
|
|
102
|
+
value: function getOtherProductsIds() {
|
|
103
|
+
return this.store.otherProductsIds;
|
|
104
|
+
}
|
|
95
105
|
}, {
|
|
96
106
|
key: "storeChange",
|
|
97
107
|
value: function storeChange() {
|
|
@@ -42,12 +42,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
42
42
|
* 更新step
|
|
43
43
|
*/
|
|
44
44
|
updateStep(key: string, step: IStep): void;
|
|
45
|
-
loadProducts({ category_ids, product_ids, collection,
|
|
45
|
+
loadProducts({ category_ids, product_ids, collection, }: {
|
|
46
46
|
category_ids?: number[];
|
|
47
47
|
product_ids?: number[];
|
|
48
48
|
collection?: number | string[];
|
|
49
|
-
schedule_ids?: number[];
|
|
50
|
-
schedule_date?: string;
|
|
51
49
|
}): Promise<any>;
|
|
52
50
|
loadProductByScheduleDate({ date, product_ids, category_ids, }: {
|
|
53
51
|
date: string;
|
|
@@ -200,6 +198,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
200
198
|
start_at: dayjs.Dayjs;
|
|
201
199
|
end_at: dayjs.Dayjs;
|
|
202
200
|
count: number;
|
|
201
|
+
left: number;
|
|
203
202
|
}[];
|
|
204
203
|
addProductToCart({ product, date, account, }: {
|
|
205
204
|
product: ProductData;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
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; } } }; }
|
|
2
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _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
6
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
7
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
-
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; } } }; }
|
|
7
|
-
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); }
|
|
8
8
|
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; }
|
|
9
9
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -208,24 +208,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
208
208
|
key: "loadProducts",
|
|
209
209
|
value: function () {
|
|
210
210
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
211
|
-
var
|
|
212
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
211
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
213
212
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
214
213
|
while (1) switch (_context2.prev = _context2.next) {
|
|
215
214
|
case 0:
|
|
216
|
-
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection
|
|
217
|
-
// 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
218
|
-
if (!
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
215
|
+
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection;
|
|
216
|
+
// // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
217
|
+
// if (!schedule_ids?.length) {
|
|
218
|
+
// const schedule_ids_data = this.store.schedule
|
|
219
|
+
// .getScheduleListByIds(schedule_ids)
|
|
220
|
+
// .map((n) => n.id);
|
|
221
|
+
// if (schedule_ids_data.length) {
|
|
222
|
+
// schedule_ids = schedule_ids_data;
|
|
223
|
+
// } else if (schedule_date) {
|
|
224
|
+
// // 后端说如果 schedule_ids 如果为空,需要给[0]
|
|
225
|
+
// schedule_ids = [0];
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
229
228
|
userPlugin = this.core.getPlugin('user');
|
|
230
229
|
customer_id = undefined;
|
|
231
230
|
try {
|
|
@@ -234,7 +233,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
234
233
|
console.error(error);
|
|
235
234
|
}
|
|
236
235
|
// 如果没传schedule_date,则从
|
|
237
|
-
_context2.next =
|
|
236
|
+
_context2.next = 6;
|
|
238
237
|
return this.request.post("/product/query", {
|
|
239
238
|
open_quotation: 1,
|
|
240
239
|
open_bundle: 0,
|
|
@@ -247,17 +246,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
246
|
category_ids: category_ids,
|
|
248
247
|
ids: product_ids,
|
|
249
248
|
collection: collection,
|
|
250
|
-
front_end_cache_id: this.cacheId
|
|
251
|
-
client_schedule_ids: schedule_ids,
|
|
252
|
-
|
|
249
|
+
front_end_cache_id: this.cacheId
|
|
250
|
+
// client_schedule_ids: schedule_ids,
|
|
251
|
+
// schedule_date,
|
|
253
252
|
}, {
|
|
254
253
|
useCache: true
|
|
255
254
|
});
|
|
256
|
-
case
|
|
255
|
+
case 6:
|
|
257
256
|
productsData = _context2.sent;
|
|
258
257
|
this.store.products.addProduct(productsData.data.list);
|
|
259
258
|
return _context2.abrupt("return", productsData.data.list);
|
|
260
|
-
case
|
|
259
|
+
case 9:
|
|
261
260
|
case "end":
|
|
262
261
|
return _context2.stop();
|
|
263
262
|
}
|
|
@@ -273,11 +272,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
273
272
|
value: function () {
|
|
274
273
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
275
274
|
var _product_ids;
|
|
276
|
-
var date, product_ids, _ref2$category_ids, category_ids, scheduleList,
|
|
275
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, _schedule$product_ids, schedule, otherProductsIds, allProductIds;
|
|
277
276
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
278
277
|
while (1) switch (_context3.prev = _context3.next) {
|
|
279
278
|
case 0:
|
|
280
|
-
date = _ref2.date, product_ids = _ref2.product_ids, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids;
|
|
279
|
+
date = _ref2.date, _ref2$product_ids = _ref2.product_ids, product_ids = _ref2$product_ids === void 0 ? [] : _ref2$product_ids, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids;
|
|
281
280
|
scheduleList = this.store.schedule.getAvailabilityScheduleDateList(); // 缓存下这次选择的结果,如果是先选日期再选 duration 类商品,后面用得到
|
|
282
281
|
this.setDateRange([{
|
|
283
282
|
date: date,
|
|
@@ -290,13 +289,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
290
289
|
week: '',
|
|
291
290
|
weekNum: 0
|
|
292
291
|
}]);
|
|
293
|
-
scheduleIds = scheduleList
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}); // 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
292
|
+
// const scheduleIds = scheduleList
|
|
293
|
+
// .filter((n) => n.date === date)
|
|
294
|
+
// .flatMap((n) => n.schedule_id)
|
|
295
|
+
// .filter((n) => n !== null && n !== undefined);
|
|
296
|
+
|
|
297
|
+
// 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
300
298
|
if (!((_product_ids = product_ids) !== null && _product_ids !== void 0 && _product_ids.length)) {
|
|
301
299
|
schedule = scheduleList.find(function (n) {
|
|
302
300
|
return n.date === date;
|
|
@@ -305,16 +303,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
305
303
|
product_ids = schedule.product_ids;
|
|
306
304
|
}
|
|
307
305
|
}
|
|
308
|
-
|
|
306
|
+
// 尝试去拿schedule 里的 other_product_ids 和 product_ids 拼在一起去重
|
|
307
|
+
otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
308
|
+
allProductIds = [].concat(_toConsumableArray(product_ids), _toConsumableArray(otherProductsIds)).filter(function (n, index, self) {
|
|
309
|
+
return self.indexOf(n) === index;
|
|
310
|
+
});
|
|
311
|
+
_context3.next = 8;
|
|
309
312
|
return this.loadProducts({
|
|
310
|
-
schedule_ids: scheduleIds,
|
|
311
|
-
product_ids:
|
|
312
|
-
category_ids: category_ids
|
|
313
|
-
schedule_date: date
|
|
313
|
+
// schedule_ids: scheduleIds,
|
|
314
|
+
product_ids: allProductIds,
|
|
315
|
+
category_ids: category_ids
|
|
316
|
+
// schedule_date: date,
|
|
314
317
|
});
|
|
315
|
-
case 7:
|
|
316
|
-
return _context3.abrupt("return", _context3.sent);
|
|
317
318
|
case 8:
|
|
319
|
+
return _context3.abrupt("return", _context3.sent);
|
|
320
|
+
case 9:
|
|
318
321
|
case "end":
|
|
319
322
|
return _context3.stop();
|
|
320
323
|
}
|
|
@@ -472,7 +475,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
472
475
|
key: "loadScheduleAvailableDate",
|
|
473
476
|
value: function () {
|
|
474
477
|
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
|
|
475
|
-
var _res$data$date_list;
|
|
478
|
+
var _res$data$date_list, _res$data$other_produ, _res$data$other_produ2;
|
|
476
479
|
var startDate, endDate, custom_page_id, channel, dates, res;
|
|
477
480
|
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
|
478
481
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -493,7 +496,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
493
496
|
return _context7.abrupt("return", dates);
|
|
494
497
|
case 6:
|
|
495
498
|
_context7.next = 8;
|
|
496
|
-
return this.request.get("/schedule/product/availability", {
|
|
499
|
+
return this.request.get("/schedule/product/availability/v2", {
|
|
497
500
|
start_date: startDate,
|
|
498
501
|
end_date: endDate,
|
|
499
502
|
custom_page_id: custom_page_id,
|
|
@@ -502,24 +505,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
502
505
|
case 8:
|
|
503
506
|
res = _context7.sent;
|
|
504
507
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
508
|
+
this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
|
|
505
509
|
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
506
|
-
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
507
|
-
_context7.next =
|
|
510
|
+
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) && !((_res$data$other_produ = res.data.other_product_ids) !== null && _res$data$other_produ !== void 0 && _res$data$other_produ.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
511
|
+
_context7.next = 13;
|
|
508
512
|
break;
|
|
509
513
|
}
|
|
510
514
|
return _context7.abrupt("return", dates);
|
|
511
|
-
case
|
|
512
|
-
res.data.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
+
case 13:
|
|
516
|
+
if ((_res$data$other_produ2 = res.data.other_product_ids) !== null && _res$data$other_produ2 !== void 0 && _res$data$other_produ2.length) {
|
|
517
|
+
// 如果后端有返回 other_product_ids ,意味着有 duration 商品,则今天以及今天以后的日期均可用
|
|
518
|
+
dates.forEach(function (n) {
|
|
519
|
+
n.status = 'available';
|
|
515
520
|
});
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
521
|
+
} else {
|
|
522
|
+
res.data.date_list.forEach(function (n) {
|
|
523
|
+
var index = dates.findIndex(function (m) {
|
|
524
|
+
return m.date === n.date;
|
|
525
|
+
});
|
|
526
|
+
if (index !== -1) {
|
|
527
|
+
dates[index].status = 'available';
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
520
531
|
dates = disableDatesBeforeOneDay(dates);
|
|
521
532
|
return _context7.abrupt("return", dates);
|
|
522
|
-
case
|
|
533
|
+
case 16:
|
|
523
534
|
case "end":
|
|
524
535
|
return _context7.stop();
|
|
525
536
|
}
|
|
@@ -1957,9 +1968,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1957
1968
|
var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
|
|
1958
1969
|
return n.code === resources_code;
|
|
1959
1970
|
});
|
|
1960
|
-
var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
|
|
1961
1971
|
// 只有 duration 类商品需要这个操作
|
|
1962
|
-
if (index !== 0 && recordTimeSlots &&
|
|
1972
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
|
|
1963
1973
|
var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
|
|
1964
1974
|
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1965
1975
|
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
@@ -2382,6 +2392,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2382
2392
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
2383
2393
|
var resourcesUseableMap = {};
|
|
2384
2394
|
var count = 0;
|
|
2395
|
+
var bookingLeft = 0;
|
|
2385
2396
|
// 遍历所有资源
|
|
2386
2397
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2387
2398
|
// 遍历所有资源的上工时间片
|
|
@@ -2423,8 +2434,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2423
2434
|
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
2424
2435
|
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
2425
2436
|
return n === false;
|
|
2426
|
-
})
|
|
2427
|
-
count
|
|
2437
|
+
})) {
|
|
2438
|
+
if (currentResourcesCount >= count) {
|
|
2439
|
+
count = currentResourcesCount;
|
|
2440
|
+
}
|
|
2441
|
+
if (!m.onlyComputed) {
|
|
2442
|
+
bookingLeft += 1;
|
|
2443
|
+
}
|
|
2428
2444
|
}
|
|
2429
2445
|
});
|
|
2430
2446
|
var startDayJs = dayjs(item.start);
|
|
@@ -2434,7 +2450,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2434
2450
|
end_time: endDayJs.format('HH:mm'),
|
|
2435
2451
|
start_at: startDayJs,
|
|
2436
2452
|
end_at: endDayJs,
|
|
2437
|
-
count: count
|
|
2453
|
+
count: count,
|
|
2454
|
+
left: bookingLeft
|
|
2438
2455
|
};
|
|
2439
2456
|
});
|
|
2440
2457
|
return formatScheduleTimeSlots;
|
|
@@ -2850,7 +2867,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2850
2867
|
openResources = ((_tempProducts = tempProducts) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.product_resource) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.resources) === null || _tempProducts === void 0 ? void 0 : _tempProducts.filter(function (m) {
|
|
2851
2868
|
return m.status === 1;
|
|
2852
2869
|
})) || []; // res.data 返回的一定是启用商品的资源列表,不需要再过滤了
|
|
2853
|
-
allProductResources = sortCombinedResources(res.data);
|
|
2870
|
+
allProductResources = sortCombinedResources(res.data); // allProductResources 需要根据商品里的资源的单个预约多个预约补充resourceType
|
|
2871
|
+
allProductResources.forEach(function (m) {
|
|
2872
|
+
var _tempProducts2;
|
|
2873
|
+
var resource = (_tempProducts2 = tempProducts) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.product_resource) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.resources) === null || _tempProducts2 === void 0 ? void 0 : _tempProducts2.find(function (n) {
|
|
2874
|
+
return n.id === m.form_id;
|
|
2875
|
+
});
|
|
2876
|
+
if (resource) {
|
|
2877
|
+
m.resourceType = resource.type;
|
|
2878
|
+
}
|
|
2879
|
+
});
|
|
2854
2880
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
2855
2881
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
2856
2882
|
var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
|
|
@@ -2907,7 +2933,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2907
2933
|
return;
|
|
2908
2934
|
}
|
|
2909
2935
|
var targetCanUseTimes = mTimes.some(function (childTiem) {
|
|
2910
|
-
var
|
|
2936
|
+
var _tempProducts3;
|
|
2911
2937
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
2912
2938
|
var res = getIsUsableByTimeItem({
|
|
2913
2939
|
timeSlice: {
|
|
@@ -2920,7 +2946,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2920
2946
|
resource: m,
|
|
2921
2947
|
currentCount: 1,
|
|
2922
2948
|
resourcesUseableMap: resourcesUseableMap,
|
|
2923
|
-
cut_off_time: (
|
|
2949
|
+
cut_off_time: (_tempProducts3 = tempProducts) === null || _tempProducts3 === void 0 ? void 0 : _tempProducts3.cut_off_time
|
|
2924
2950
|
});
|
|
2925
2951
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2926
2952
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -2959,22 +2985,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2959
2985
|
}
|
|
2960
2986
|
}, _loop3);
|
|
2961
2987
|
});
|
|
2962
|
-
case
|
|
2988
|
+
case 23:
|
|
2963
2989
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
2964
|
-
_context32.next =
|
|
2990
|
+
_context32.next = 29;
|
|
2965
2991
|
break;
|
|
2966
2992
|
}
|
|
2967
|
-
return _context32.delegateYield(_loop3(), "t0",
|
|
2968
|
-
case
|
|
2993
|
+
return _context32.delegateYield(_loop3(), "t0", 25);
|
|
2994
|
+
case 25:
|
|
2969
2995
|
if (!_context32.t0) {
|
|
2970
|
-
_context32.next =
|
|
2996
|
+
_context32.next = 27;
|
|
2971
2997
|
break;
|
|
2972
2998
|
}
|
|
2973
|
-
return _context32.abrupt("break",
|
|
2974
|
-
case
|
|
2975
|
-
_context32.next =
|
|
2999
|
+
return _context32.abrupt("break", 29);
|
|
3000
|
+
case 27:
|
|
3001
|
+
_context32.next = 23;
|
|
2976
3002
|
break;
|
|
2977
|
-
case
|
|
3003
|
+
case 29:
|
|
2978
3004
|
// 最终把资源数据也加到日期内
|
|
2979
3005
|
dates = handleAvailableDateByResource(res.data, dates);
|
|
2980
3006
|
this.store.date.setDateList(dates);
|
|
@@ -2990,7 +3016,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2990
3016
|
dateList: dates,
|
|
2991
3017
|
firstAvailableDate: firstAvailableDate
|
|
2992
3018
|
});
|
|
2993
|
-
case
|
|
3019
|
+
case 33:
|
|
2994
3020
|
case "end":
|
|
2995
3021
|
return _context32.stop();
|
|
2996
3022
|
}
|
|
@@ -14,5 +14,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
14
14
|
getScheduleListByIds(ids: number[]): ScheduleItem[];
|
|
15
15
|
setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
|
|
16
16
|
getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
|
|
17
|
+
setOtherProductsIds(ids: number[]): void;
|
|
18
|
+
getOtherProductsIds(): number[];
|
|
17
19
|
storeChange(): void;
|
|
18
20
|
}
|
|
@@ -63,6 +63,12 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
63
63
|
getAvailabilityScheduleDateList() {
|
|
64
64
|
return this.store.availabilityDateList;
|
|
65
65
|
}
|
|
66
|
+
setOtherProductsIds(ids) {
|
|
67
|
+
this.store.otherProductsIds = ids;
|
|
68
|
+
}
|
|
69
|
+
getOtherProductsIds() {
|
|
70
|
+
return this.store.otherProductsIds;
|
|
71
|
+
}
|
|
66
72
|
storeChange() {
|
|
67
73
|
if (this.openCache) {
|
|
68
74
|
const store = (0, import_lodash_es.cloneDeep)(this.store);
|
|
@@ -42,12 +42,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
42
42
|
* 更新step
|
|
43
43
|
*/
|
|
44
44
|
updateStep(key: string, step: IStep): void;
|
|
45
|
-
loadProducts({ category_ids, product_ids, collection,
|
|
45
|
+
loadProducts({ category_ids, product_ids, collection, }: {
|
|
46
46
|
category_ids?: number[];
|
|
47
47
|
product_ids?: number[];
|
|
48
48
|
collection?: number | string[];
|
|
49
|
-
schedule_ids?: number[];
|
|
50
|
-
schedule_date?: string;
|
|
51
49
|
}): Promise<any>;
|
|
52
50
|
loadProductByScheduleDate({ date, product_ids, category_ids, }: {
|
|
53
51
|
date: string;
|
|
@@ -200,6 +198,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
200
198
|
start_at: dayjs.Dayjs;
|
|
201
199
|
end_at: dayjs.Dayjs;
|
|
202
200
|
count: number;
|
|
201
|
+
left: number;
|
|
203
202
|
}[];
|
|
204
203
|
addProductToCart({ product, date, account, }: {
|
|
205
204
|
product: ProductData;
|
|
@@ -162,19 +162,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
162
162
|
async loadProducts({
|
|
163
163
|
category_ids = [],
|
|
164
164
|
product_ids = [],
|
|
165
|
-
collection = []
|
|
166
|
-
schedule_ids = [],
|
|
167
|
-
schedule_date
|
|
165
|
+
collection = []
|
|
166
|
+
// schedule_ids = [],
|
|
167
|
+
// schedule_date,
|
|
168
168
|
}) {
|
|
169
169
|
var _a;
|
|
170
|
-
if (!(schedule_ids == null ? void 0 : schedule_ids.length)) {
|
|
171
|
-
const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
|
|
172
|
-
if (schedule_ids_data.length) {
|
|
173
|
-
schedule_ids = schedule_ids_data;
|
|
174
|
-
} else if (schedule_date) {
|
|
175
|
-
schedule_ids = [0];
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
170
|
let userPlugin = this.core.getPlugin("user");
|
|
179
171
|
let customer_id = void 0;
|
|
180
172
|
try {
|
|
@@ -202,9 +194,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
202
194
|
category_ids,
|
|
203
195
|
ids: product_ids,
|
|
204
196
|
collection,
|
|
205
|
-
front_end_cache_id: this.cacheId
|
|
206
|
-
client_schedule_ids: schedule_ids,
|
|
207
|
-
schedule_date
|
|
197
|
+
front_end_cache_id: this.cacheId
|
|
198
|
+
// client_schedule_ids: schedule_ids,
|
|
199
|
+
// schedule_date,
|
|
208
200
|
},
|
|
209
201
|
{ useCache: true }
|
|
210
202
|
);
|
|
@@ -213,7 +205,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
213
205
|
}
|
|
214
206
|
async loadProductByScheduleDate({
|
|
215
207
|
date,
|
|
216
|
-
product_ids,
|
|
208
|
+
product_ids = [],
|
|
217
209
|
category_ids = []
|
|
218
210
|
}) {
|
|
219
211
|
var _a;
|
|
@@ -222,18 +214,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
222
214
|
{ date, status: "available", week: "", weekNum: 0 },
|
|
223
215
|
{ date, status: "available", week: "", weekNum: 0 }
|
|
224
216
|
]);
|
|
225
|
-
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id).filter((n) => n !== null && n !== void 0);
|
|
226
217
|
if (!(product_ids == null ? void 0 : product_ids.length)) {
|
|
227
218
|
const schedule = scheduleList.find((n) => n.date === date);
|
|
228
219
|
if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
|
|
229
220
|
product_ids = schedule.product_ids;
|
|
230
221
|
}
|
|
231
222
|
}
|
|
223
|
+
const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
224
|
+
const allProductIds = [...product_ids, ...otherProductsIds].filter(
|
|
225
|
+
(n, index, self) => self.indexOf(n) === index
|
|
226
|
+
);
|
|
232
227
|
return await this.loadProducts({
|
|
233
|
-
schedule_ids: scheduleIds,
|
|
234
|
-
product_ids,
|
|
235
|
-
category_ids
|
|
236
|
-
schedule_date: date
|
|
228
|
+
// schedule_ids: scheduleIds,
|
|
229
|
+
product_ids: allProductIds,
|
|
230
|
+
category_ids
|
|
231
|
+
// schedule_date: date,
|
|
237
232
|
});
|
|
238
233
|
}
|
|
239
234
|
async updateQuotationPriceAndCart(date) {
|
|
@@ -305,7 +300,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
305
300
|
custom_page_id,
|
|
306
301
|
channel
|
|
307
302
|
}) {
|
|
308
|
-
var _a;
|
|
303
|
+
var _a, _b, _c;
|
|
309
304
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
310
305
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
311
306
|
}
|
|
@@ -315,7 +310,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
315
310
|
return dates;
|
|
316
311
|
}
|
|
317
312
|
const res = await this.request.get(
|
|
318
|
-
`/schedule/product/availability`,
|
|
313
|
+
`/schedule/product/availability/v2`,
|
|
319
314
|
{
|
|
320
315
|
start_date: startDate,
|
|
321
316
|
end_date: endDate,
|
|
@@ -324,15 +319,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
324
319
|
}
|
|
325
320
|
);
|
|
326
321
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
327
|
-
|
|
322
|
+
this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
|
|
323
|
+
if (!((_a = res.data.date_list) == null ? void 0 : _a.length) && !((_b = res.data.other_product_ids) == null ? void 0 : _b.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
328
324
|
return dates;
|
|
329
325
|
}
|
|
330
|
-
res.data.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
326
|
+
if ((_c = res.data.other_product_ids) == null ? void 0 : _c.length) {
|
|
327
|
+
dates.forEach((n) => {
|
|
328
|
+
n.status = "available";
|
|
329
|
+
});
|
|
330
|
+
} else {
|
|
331
|
+
res.data.date_list.forEach((n) => {
|
|
332
|
+
const index = dates.findIndex((m) => m.date === n.date);
|
|
333
|
+
if (index !== -1) {
|
|
334
|
+
dates[index].status = "available";
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
336
338
|
dates = (0, import_utils3.disableDatesBeforeOneDay)(dates);
|
|
337
339
|
return dates;
|
|
338
340
|
}
|
|
@@ -1276,8 +1278,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1276
1278
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1277
1279
|
(n) => n.code === resources_code
|
|
1278
1280
|
);
|
|
1279
|
-
|
|
1280
|
-
if (index !== 0 && recordTimeSlots && resourceBookingType === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1281
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1281
1282
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1282
1283
|
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
|
|
1283
1284
|
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
|
|
@@ -1668,6 +1669,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1668
1669
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1669
1670
|
const resourcesUseableMap = {};
|
|
1670
1671
|
let count = 0;
|
|
1672
|
+
let bookingLeft = 0;
|
|
1671
1673
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1672
1674
|
let currentResourcesCount = 0;
|
|
1673
1675
|
const currentResourcesTimeSlotCanUsedArr = [];
|
|
@@ -1699,10 +1701,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1699
1701
|
}
|
|
1700
1702
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1701
1703
|
});
|
|
1702
|
-
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
1703
|
-
(
|
|
1704
|
-
|
|
1705
|
-
|
|
1704
|
+
if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
|
|
1705
|
+
if (currentResourcesCount >= count) {
|
|
1706
|
+
count = currentResourcesCount;
|
|
1707
|
+
}
|
|
1708
|
+
if (!m.onlyComputed) {
|
|
1709
|
+
bookingLeft += 1;
|
|
1710
|
+
}
|
|
1706
1711
|
}
|
|
1707
1712
|
});
|
|
1708
1713
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
@@ -1712,7 +1717,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1712
1717
|
end_time: endDayJs.format("HH:mm"),
|
|
1713
1718
|
start_at: startDayJs,
|
|
1714
1719
|
end_at: endDayJs,
|
|
1715
|
-
count
|
|
1720
|
+
count,
|
|
1721
|
+
left: bookingLeft
|
|
1716
1722
|
};
|
|
1717
1723
|
});
|
|
1718
1724
|
return formatScheduleTimeSlots;
|
|
@@ -2017,6 +2023,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2017
2023
|
(m) => m.status === 1
|
|
2018
2024
|
)) || [];
|
|
2019
2025
|
const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
|
|
2026
|
+
allProductResources.forEach((m) => {
|
|
2027
|
+
var _a2, _b2;
|
|
2028
|
+
const resource = (_b2 = (_a2 = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _a2.resources) == null ? void 0 : _b2.find(
|
|
2029
|
+
(n) => n.id === m.form_id
|
|
2030
|
+
);
|
|
2031
|
+
if (resource) {
|
|
2032
|
+
m.resourceType = resource.type;
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2020
2035
|
const targetSchedules = this.store.schedule.getScheduleListByIds(
|
|
2021
2036
|
tempProducts["schedule.ids"]
|
|
2022
2037
|
);
|