@pisell/private-materials 6.8.36 → 6.8.37
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/booking/info2/service/openNormalService.d.ts +2 -0
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +7 -4
- package/es/pro/skuDetailModal/index.js +111 -59
- package/es/pro/skuDetailModal/types.d.ts +1 -0
- package/lib/components/booking/info2/service/openNormalService.d.ts +2 -0
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +5 -2
- package/lib/pro/skuDetailModal/index.js +39 -6
- package/lib/pro/skuDetailModal/types.d.ts +1 -0
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ export interface OpenNormalServiceCreatePayload {
|
|
|
3
3
|
productId: number;
|
|
4
4
|
date: string;
|
|
5
5
|
isEject: 0 | 1;
|
|
6
|
+
productData?: any;
|
|
6
7
|
/**
|
|
7
8
|
* @description 弹窗关闭回调(用于外部清理状态,例如清空当前选中商品)
|
|
8
9
|
*/
|
|
@@ -15,6 +16,7 @@ export interface OpenNormalServiceCreatePayload {
|
|
|
15
16
|
export interface OpenNormalServiceEditPayload {
|
|
16
17
|
mode: 'edit';
|
|
17
18
|
cacheItem: any;
|
|
19
|
+
productData?: any;
|
|
18
20
|
/**
|
|
19
21
|
* @description 弹窗关闭回调(用于外部清理状态,例如清空当前选中商品)
|
|
20
22
|
*/
|
|
@@ -355,14 +355,16 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
355
355
|
|
|
356
356
|
// 处理自动关闭的服务添加(带防抖)
|
|
357
357
|
var processAutoCloseService = useMemoizedFn(function (cacheItem, item, detail, notShowToast) {
|
|
358
|
+
var _cacheItem$_extend4;
|
|
358
359
|
console.time('processAutoCloseService2');
|
|
359
360
|
cacheItem.autoClose = false;
|
|
360
361
|
cacheItem._serviceKey = genServiceKey(cacheItem);
|
|
361
362
|
var productKey = getProductKey(item, cacheItem);
|
|
363
|
+
var addCount = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend4 = cacheItem._extend) === null || _cacheItem$_extend4 === void 0 ? void 0 : _cacheItem$_extend4.quantity) || 1;
|
|
362
364
|
|
|
363
365
|
// 如果已经有待处理的同商品,增加点击次数
|
|
364
366
|
if (pendingCacheValuesRef.current[productKey]) {
|
|
365
|
-
clickCountRef.current[productKey] = (clickCountRef.current[productKey] || 1) +
|
|
367
|
+
clickCountRef.current[productKey] = (clickCountRef.current[productKey] || 1) + addCount;
|
|
366
368
|
} else {
|
|
367
369
|
// 第一次点击,初始化数据
|
|
368
370
|
pendingCacheValuesRef.current[productKey] = {
|
|
@@ -371,7 +373,7 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
371
373
|
detail: detail,
|
|
372
374
|
notShowToast: notShowToast
|
|
373
375
|
};
|
|
374
|
-
clickCountRef.current[productKey] =
|
|
376
|
+
clickCountRef.current[productKey] = addCount;
|
|
375
377
|
}
|
|
376
378
|
|
|
377
379
|
// 立即显示 toast
|
|
@@ -401,7 +403,7 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
401
403
|
|
|
402
404
|
// 执行实际的 dispatch 操作
|
|
403
405
|
var executeServiceDispatch = useMemoizedFn(function (productKey) {
|
|
404
|
-
var _cacheItem$
|
|
406
|
+
var _cacheItem$_extend5;
|
|
405
407
|
console.time('executeServiceDispatch');
|
|
406
408
|
console.time('executeServiceDispatch1');
|
|
407
409
|
var pendingData = pendingCacheValuesRef.current[productKey];
|
|
@@ -409,7 +411,7 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
409
411
|
var cacheItem = pendingData.cacheItem,
|
|
410
412
|
item = pendingData.item,
|
|
411
413
|
detail = pendingData.detail;
|
|
412
|
-
var clickCount = clickCountRef.current[productKey] || (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
414
|
+
var clickCount = clickCountRef.current[productKey] || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.quantity) || 1;
|
|
413
415
|
|
|
414
416
|
// 更新 quantity 为累积的点击次数
|
|
415
417
|
var finalCacheItem = _objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
@@ -637,6 +639,7 @@ var AddSerivce = function AddSerivce(props) {
|
|
|
637
639
|
openNormalService({
|
|
638
640
|
mode: 'create',
|
|
639
641
|
productId: item.id,
|
|
642
|
+
productData: item,
|
|
640
643
|
date: state.date.value.format('YYYY-MM-DD'),
|
|
641
644
|
isEject: isEject ? 1 : 0,
|
|
642
645
|
onClose: function onClose() {
|
|
@@ -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 _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; }
|
|
3
2
|
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; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
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; }
|
|
8
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
9
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
10
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -29,6 +29,7 @@ import { getProductDetail } from "../../components/booking/info/service/serve";
|
|
|
29
29
|
import { checkSkuStockCanSell } from "./utils";
|
|
30
30
|
import { Context as BookingContext } from "../../components/booking/info/model";
|
|
31
31
|
import useToast from "../../hooks/useToast";
|
|
32
|
+
import useLogger from "../../hooks/useLogger";
|
|
32
33
|
var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
33
34
|
var _context$appHelper, _store$getState, _context$engine, _productData$_extend2, _bookingState$booking10, _bookingState$booking11;
|
|
34
35
|
var onConfirm = _ref.onConfirm,
|
|
@@ -93,6 +94,7 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
93
94
|
setSkuDefaultValue = _useState20[1];
|
|
94
95
|
var openParamsRef = useRef(null);
|
|
95
96
|
var Toast = useToast();
|
|
97
|
+
var logger = useLogger();
|
|
96
98
|
/**
|
|
97
99
|
* @description SKUOptionsSelection ref,用于触发内部校验与读取最终值
|
|
98
100
|
*/
|
|
@@ -118,7 +120,8 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
118
120
|
var context = useEngineContext();
|
|
119
121
|
var _ref2 = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
|
|
120
122
|
store = _ref2.store,
|
|
121
|
-
getData = _ref2.getData
|
|
123
|
+
getData = _ref2.getData,
|
|
124
|
+
isWebPos = _ref2.isWebPos;
|
|
122
125
|
/**
|
|
123
126
|
* @description
|
|
124
127
|
* booking state 需要从 Booking 的 Context 读取(与 editService 保持一致),不要用 store.getState()
|
|
@@ -127,31 +130,70 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
127
130
|
bookingState = _ref3.state;
|
|
128
131
|
var symbol = (store === null || store === void 0 || (_store$getState = store.getState) === null || _store$getState === void 0 || (_store$getState = _store$getState.call(store)) === null || _store$getState === void 0 || (_store$getState = _store$getState.global) === null || _store$getState === void 0 ? void 0 : _store$getState.symbol) || '$';
|
|
129
132
|
locales.init(localeTexts, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || 'en');
|
|
133
|
+
var getDetailData = /*#__PURE__*/function () {
|
|
134
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, open_deposit) {
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
136
|
+
while (1) switch (_context.prev = _context.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
if (!(isWebPos && data.productData)) {
|
|
139
|
+
_context.next = 4;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return _context.abrupt("return", {
|
|
143
|
+
data: data.productData
|
|
144
|
+
});
|
|
145
|
+
case 4:
|
|
146
|
+
_context.next = 6;
|
|
147
|
+
return getProductDetail(String(data.id), {
|
|
148
|
+
schedule_date: data.date,
|
|
149
|
+
is_eject: data.is_eject,
|
|
150
|
+
open_deposit: open_deposit
|
|
151
|
+
});
|
|
152
|
+
case 6:
|
|
153
|
+
return _context.abrupt("return", _context.sent);
|
|
154
|
+
case 7:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context.stop();
|
|
157
|
+
}
|
|
158
|
+
}, _callee);
|
|
159
|
+
}));
|
|
160
|
+
return function getDetailData(_x, _x2) {
|
|
161
|
+
return _ref4.apply(this, arguments);
|
|
162
|
+
};
|
|
163
|
+
}();
|
|
130
164
|
useImperativeHandle(ref, function () {
|
|
131
165
|
return {
|
|
132
166
|
open: function () {
|
|
133
|
-
var _open = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
167
|
+
var _open = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
|
|
134
168
|
var _data$_extend, _data$_extend2, _data$_extend3, _data$_extend4, _data$_extend5, _data$_extend6, _data$_extend7, _data$_extend8, _data$_extend9;
|
|
135
|
-
var
|
|
136
|
-
return _regeneratorRuntime().wrap(function
|
|
137
|
-
while (1) switch (
|
|
169
|
+
var _ref5, _is_eject, _hydratedData$_extend, open_deposit, productDetail, apiData, basePrice, hydratedData, isEject, _data;
|
|
170
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
171
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
138
172
|
case 0:
|
|
139
173
|
setCurrentStep(1);
|
|
174
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
175
|
+
type: 'info',
|
|
176
|
+
title: 'sku_detail_modal_open',
|
|
177
|
+
metadata: {
|
|
178
|
+
data: data
|
|
179
|
+
}
|
|
180
|
+
});
|
|
140
181
|
// create 模式:只有 id/date/is_eject,先请求详情再打开
|
|
141
182
|
if (!('date' in data && !('_extend' in data))) {
|
|
142
|
-
|
|
183
|
+
_context2.next = 27;
|
|
143
184
|
break;
|
|
144
185
|
}
|
|
186
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
187
|
+
type: 'info',
|
|
188
|
+
title: 'sku_detail_modal_open_create',
|
|
189
|
+
metadata: {}
|
|
190
|
+
});
|
|
145
191
|
openParamsRef.current = data;
|
|
146
192
|
open_deposit = (getData === null || getData === void 0 ? void 0 : getData('bookingv2_deposit')) || 0;
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
open_deposit: open_deposit
|
|
152
|
-
});
|
|
153
|
-
case 6:
|
|
154
|
-
productDetail = _context.sent;
|
|
193
|
+
_context2.next = 8;
|
|
194
|
+
return getDetailData(data, open_deposit);
|
|
195
|
+
case 8:
|
|
196
|
+
productDetail = _context2.sent;
|
|
155
197
|
apiData = (productDetail === null || productDetail === void 0 ? void 0 : productDetail.data) || {};
|
|
156
198
|
basePrice = Number((apiData === null || apiData === void 0 ? void 0 : apiData.price) || 0);
|
|
157
199
|
hydratedData = _objectSpread(_objectSpread({}, apiData), {}, {
|
|
@@ -172,15 +214,15 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
172
214
|
}
|
|
173
215
|
})
|
|
174
216
|
}); // 如果该商品不需要弹窗(is_eject !== 1),则直接走确认回调,不再展示弹窗
|
|
175
|
-
isEject = Number((
|
|
217
|
+
isEject = Number((_ref5 = (_is_eject = apiData === null || apiData === void 0 ? void 0 : apiData.is_eject) !== null && _is_eject !== void 0 ? _is_eject : data.is_eject) !== null && _ref5 !== void 0 ? _ref5 : 0) === 1;
|
|
176
218
|
if (isEject) {
|
|
177
|
-
|
|
219
|
+
_context2.next = 17;
|
|
178
220
|
break;
|
|
179
221
|
}
|
|
180
222
|
onConfirm === null || onConfirm === void 0 || onConfirm(hydratedData);
|
|
181
223
|
modalCloseAction();
|
|
182
|
-
return
|
|
183
|
-
case
|
|
224
|
+
return _context2.abrupt("return");
|
|
225
|
+
case 17:
|
|
184
226
|
setProductData(hydratedData);
|
|
185
227
|
setNote('');
|
|
186
228
|
setQuantity((apiData === null || apiData === void 0 ? void 0 : apiData.min_num_unit) || 1);
|
|
@@ -201,8 +243,13 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
201
243
|
setPriceOverride(null);
|
|
202
244
|
setShowPriceAdjustModal(false);
|
|
203
245
|
setOpen(true);
|
|
204
|
-
return
|
|
205
|
-
case
|
|
246
|
+
return _context2.abrupt("return");
|
|
247
|
+
case 27:
|
|
248
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
249
|
+
type: 'info',
|
|
250
|
+
title: 'sku_detail_modal_open_edit',
|
|
251
|
+
metadata: {}
|
|
252
|
+
});
|
|
206
253
|
// edit 模式:直接使用传入的 ProductData
|
|
207
254
|
openParamsRef.current = null;
|
|
208
255
|
_data = safeClone(data);
|
|
@@ -235,15 +282,20 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
235
282
|
}));
|
|
236
283
|
setShowPriceAdjustModal(false);
|
|
237
284
|
setTimeout(function () {
|
|
285
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
286
|
+
type: 'info',
|
|
287
|
+
title: 'sku_detail_modal_open_edit_show',
|
|
288
|
+
metadata: {}
|
|
289
|
+
});
|
|
238
290
|
setOpen(true);
|
|
239
291
|
}, 0);
|
|
240
|
-
case
|
|
292
|
+
case 40:
|
|
241
293
|
case "end":
|
|
242
|
-
return
|
|
294
|
+
return _context2.stop();
|
|
243
295
|
}
|
|
244
|
-
},
|
|
296
|
+
}, _callee2);
|
|
245
297
|
}));
|
|
246
|
-
function open(
|
|
298
|
+
function open(_x3) {
|
|
247
299
|
return _open.apply(this, arguments);
|
|
248
300
|
}
|
|
249
301
|
return open;
|
|
@@ -402,19 +454,19 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
402
454
|
return true;
|
|
403
455
|
};
|
|
404
456
|
var handleConfirm = /*#__PURE__*/function () {
|
|
405
|
-
var
|
|
457
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
406
458
|
var _bookingState$booking;
|
|
407
459
|
var _procedureRef$current, _procedureRef$current2, requiredOptionValidation, shouldValidate, _skuOptionsSelectionR, _skuOptionsSelectionR2, isValid, _skuOptionsSelectionR3, _skuOptionsSelectionR4, _bookingState$booking2, _bookingState$booking3, _bookingState$booking4, _bookingState$booking5, _bookingState$booking6, _bookingState$booking7, latestSkuValue, updatedData, stockValidation, allowAddToCartWhenOutStock, enableDontShowAgainToday, hasStock, productId, shouldSkipAlert;
|
|
408
|
-
return _regeneratorRuntime().wrap(function
|
|
409
|
-
while (1) switch (
|
|
460
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
461
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
410
462
|
case 0:
|
|
411
463
|
if (!(currentStep === 0)) {
|
|
412
|
-
|
|
464
|
+
_context3.next = 4;
|
|
413
465
|
break;
|
|
414
466
|
}
|
|
415
467
|
(_procedureRef$current = procedureRef.current) === null || _procedureRef$current === void 0 || (_procedureRef$current2 = _procedureRef$current.goToStep) === null || _procedureRef$current2 === void 0 || _procedureRef$current2.call(_procedureRef$current, 1);
|
|
416
468
|
setCurrentStep(1);
|
|
417
|
-
return
|
|
469
|
+
return _context3.abrupt("return");
|
|
418
470
|
case 4:
|
|
419
471
|
/**
|
|
420
472
|
* @description Confirm 前是否需要触发 SKU 选择校验
|
|
@@ -426,31 +478,31 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
426
478
|
requiredOptionValidation = bookingState === null || bookingState === void 0 || (_bookingState$booking = bookingState.bookingConfig) === null || _bookingState$booking === void 0 || (_bookingState$booking = _bookingState$booking.config) === null || _bookingState$booking === void 0 || (_bookingState$booking = _bookingState$booking.product_setting_tab) === null || _bookingState$booking === void 0 ? void 0 : _bookingState$booking.required_option_validation;
|
|
427
479
|
shouldValidate = Number(requiredOptionValidation !== null && requiredOptionValidation !== void 0 ? requiredOptionValidation : 1) !== 0;
|
|
428
480
|
if (!shouldValidate) {
|
|
429
|
-
|
|
481
|
+
_context3.next = 19;
|
|
430
482
|
break;
|
|
431
483
|
}
|
|
432
|
-
|
|
433
|
-
|
|
484
|
+
_context3.prev = 7;
|
|
485
|
+
_context3.next = 10;
|
|
434
486
|
return (_skuOptionsSelectionR = skuOptionsSelectionRef.current) === null || _skuOptionsSelectionR === void 0 || (_skuOptionsSelectionR2 = _skuOptionsSelectionR.validate) === null || _skuOptionsSelectionR2 === void 0 ? void 0 : _skuOptionsSelectionR2.call(_skuOptionsSelectionR);
|
|
435
487
|
case 10:
|
|
436
|
-
isValid =
|
|
488
|
+
isValid = _context3.sent;
|
|
437
489
|
if (isValid) {
|
|
438
|
-
|
|
490
|
+
_context3.next = 13;
|
|
439
491
|
break;
|
|
440
492
|
}
|
|
441
|
-
return
|
|
493
|
+
return _context3.abrupt("return");
|
|
442
494
|
case 13:
|
|
443
|
-
|
|
495
|
+
_context3.next = 19;
|
|
444
496
|
break;
|
|
445
497
|
case 15:
|
|
446
|
-
|
|
447
|
-
|
|
498
|
+
_context3.prev = 15;
|
|
499
|
+
_context3.t0 = _context3["catch"](7);
|
|
448
500
|
// 预期外错误:阻断提交,避免提交不合法数据
|
|
449
|
-
console.log('sku_detail_modal_validate_error>>>>>',
|
|
450
|
-
return
|
|
501
|
+
console.log('sku_detail_modal_validate_error>>>>>', _context3.t0);
|
|
502
|
+
return _context3.abrupt("return");
|
|
451
503
|
case 19:
|
|
452
504
|
if (!(productData && onConfirm)) {
|
|
453
|
-
|
|
505
|
+
_context3.next = 40;
|
|
454
506
|
break;
|
|
455
507
|
}
|
|
456
508
|
/**
|
|
@@ -484,7 +536,7 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
484
536
|
allowAddToCartWhenOutStock = Number((_bookingState$booking4 = bookingState === null || bookingState === void 0 || (_bookingState$booking5 = bookingState.bookingConfig) === null || _bookingState$booking5 === void 0 || (_bookingState$booking5 = _bookingState$booking5.config) === null || _bookingState$booking5 === void 0 || (_bookingState$booking5 = _bookingState$booking5.stock_setting) === null || _bookingState$booking5 === void 0 ? void 0 : _bookingState$booking5.allow_add_to_cart_when_out_stock) !== null && _bookingState$booking4 !== void 0 ? _bookingState$booking4 : 0);
|
|
485
537
|
enableDontShowAgainToday = Number((_bookingState$booking6 = bookingState === null || bookingState === void 0 || (_bookingState$booking7 = bookingState.bookingConfig) === null || _bookingState$booking7 === void 0 || (_bookingState$booking7 = _bookingState$booking7.config) === null || _bookingState$booking7 === void 0 || (_bookingState$booking7 = _bookingState$booking7.stock_setting) === null || _bookingState$booking7 === void 0 ? void 0 : _bookingState$booking7.do_not_show_again_today) !== null && _bookingState$booking6 !== void 0 ? _bookingState$booking6 : 0);
|
|
486
538
|
if (!(stockValidation === 1)) {
|
|
487
|
-
|
|
539
|
+
_context3.next = 38;
|
|
488
540
|
break;
|
|
489
541
|
}
|
|
490
542
|
hasStock = handleCheckStock({
|
|
@@ -492,15 +544,15 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
492
544
|
data: productData
|
|
493
545
|
});
|
|
494
546
|
if (hasStock) {
|
|
495
|
-
|
|
547
|
+
_context3.next = 38;
|
|
496
548
|
break;
|
|
497
549
|
}
|
|
498
550
|
if (!(allowAddToCartWhenOutStock !== 1)) {
|
|
499
|
-
|
|
551
|
+
_context3.next = 31;
|
|
500
552
|
break;
|
|
501
553
|
}
|
|
502
554
|
Toast === null || Toast === void 0 || Toast.fail(locales.getText('pisell2.skuOptionsSelection.variantItemCard.soldOut'));
|
|
503
|
-
return
|
|
555
|
+
return _context3.abrupt("return");
|
|
504
556
|
case 31:
|
|
505
557
|
// 缺货允许加入购物车:命中「今天不再提示」则直接提交
|
|
506
558
|
productId = Number((productData === null || productData === void 0 ? void 0 : productData.product_id) || 0);
|
|
@@ -508,24 +560,24 @@ var SkuDetailModal = function SkuDetailModal(_ref, ref) {
|
|
|
508
560
|
productId: productId
|
|
509
561
|
});
|
|
510
562
|
if (shouldSkipAlert) {
|
|
511
|
-
|
|
563
|
+
_context3.next = 38;
|
|
512
564
|
break;
|
|
513
565
|
}
|
|
514
566
|
pendingConfirmDataRef.current = updatedData;
|
|
515
567
|
setStockAlertDontShowAgainChecked(false);
|
|
516
568
|
setStockAlertOpen(true);
|
|
517
|
-
return
|
|
569
|
+
return _context3.abrupt("return");
|
|
518
570
|
case 38:
|
|
519
571
|
onConfirm(updatedData);
|
|
520
572
|
modalCloseAction();
|
|
521
573
|
case 40:
|
|
522
574
|
case "end":
|
|
523
|
-
return
|
|
575
|
+
return _context3.stop();
|
|
524
576
|
}
|
|
525
|
-
},
|
|
577
|
+
}, _callee3, null, [[7, 15]]);
|
|
526
578
|
}));
|
|
527
579
|
return function handleConfirm() {
|
|
528
|
-
return
|
|
580
|
+
return _ref6.apply(this, arguments);
|
|
529
581
|
};
|
|
530
582
|
}();
|
|
531
583
|
var handleStockAlertCancel = function handleStockAlertCancel() {
|
|
@@ -949,21 +1001,21 @@ function safeClone(value) {
|
|
|
949
1001
|
* 计算规则与 booking/utils.ts 的 getProductTotalPrice 保持一致。
|
|
950
1002
|
*/
|
|
951
1003
|
function getSelectedUnitPrice(params) {
|
|
952
|
-
var
|
|
1004
|
+
var _ref7, _productData$_extend$, _productData$_extend3;
|
|
953
1005
|
var productData = params.productData,
|
|
954
1006
|
skuValue = params.skuValue;
|
|
955
1007
|
if (!productData) return 0;
|
|
956
1008
|
|
|
957
1009
|
// base price(默认商品基础价;如果选了组合规格则用对应 variant.price/base_price)
|
|
958
|
-
var price = new Decimal((
|
|
1010
|
+
var price = new Decimal((_ref7 = (_productData$_extend$ = productData === null || productData === void 0 || (_productData$_extend3 = productData._extend) === null || _productData$_extend3 === void 0 ? void 0 : _productData$_extend3.price) !== null && _productData$_extend$ !== void 0 ? _productData$_extend$ : productData === null || productData === void 0 ? void 0 : productData.price) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
959
1011
|
if (skuValue !== null && skuValue !== void 0 && skuValue.product_variant_id) {
|
|
960
1012
|
var _variant2;
|
|
961
1013
|
var variantItem = productData === null || productData === void 0 || (_variant2 = productData.variant) === null || _variant2 === void 0 ? void 0 : _variant2.find(function (item) {
|
|
962
1014
|
return Number(item === null || item === void 0 ? void 0 : item.id) === Number(skuValue.product_variant_id);
|
|
963
1015
|
});
|
|
964
1016
|
if (variantItem) {
|
|
965
|
-
var
|
|
966
|
-
price = new Decimal((
|
|
1017
|
+
var _ref8, _variantItem$price;
|
|
1018
|
+
price = new Decimal((_ref8 = (_variantItem$price = variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) !== null && _variantItem$price !== void 0 ? _variantItem$price : variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _ref8 !== void 0 ? _ref8 : 0);
|
|
967
1019
|
}
|
|
968
1020
|
}
|
|
969
1021
|
|
|
@@ -1005,8 +1057,8 @@ function getOtherFromSkuValue(params) {
|
|
|
1005
1057
|
return Number(item === null || item === void 0 ? void 0 : item.id) === Number(other.product_variant_id);
|
|
1006
1058
|
});
|
|
1007
1059
|
if (variantItem) {
|
|
1008
|
-
var
|
|
1009
|
-
other.price = Number((
|
|
1060
|
+
var _ref9, _variantItem$price2;
|
|
1061
|
+
other.price = Number((_ref9 = (_variantItem$price2 = variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) !== null && _variantItem$price2 !== void 0 ? _variantItem$price2 : variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
1010
1062
|
}
|
|
1011
1063
|
}
|
|
1012
1064
|
return other;
|
|
@@ -1019,12 +1071,12 @@ function getOtherFromSkuValue(params) {
|
|
|
1019
1071
|
* - 否则返回 null(表示未设置手动改价)
|
|
1020
1072
|
*/
|
|
1021
1073
|
function getInitialPriceOverrideFromProductData(params) {
|
|
1022
|
-
var _extend, _extend2,
|
|
1074
|
+
var _extend, _extend2, _ref10, _extend$price, _extend3;
|
|
1023
1075
|
var data = params.productData;
|
|
1024
1076
|
if (!data) return null;
|
|
1025
1077
|
var total = Number(data === null || data === void 0 || (_extend = data._extend) === null || _extend === void 0 ? void 0 : _extend.total);
|
|
1026
1078
|
var originTotal = Number(data === null || data === void 0 || (_extend2 = data._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total);
|
|
1027
|
-
var basePrice = Number((
|
|
1079
|
+
var basePrice = Number((_ref10 = (_extend$price = data === null || data === void 0 || (_extend3 = data._extend) === null || _extend3 === void 0 ? void 0 : _extend3.price) !== null && _extend$price !== void 0 ? _extend$price : data === null || data === void 0 ? void 0 : data.price) !== null && _ref10 !== void 0 ? _ref10 : 0);
|
|
1028
1080
|
if (!Number.isFinite(total)) return null;
|
|
1029
1081
|
if (Number.isFinite(originTotal) && total !== originTotal) return total;
|
|
1030
1082
|
if (Number.isFinite(basePrice) && total !== basePrice) return total;
|
|
@@ -3,6 +3,7 @@ export interface OpenNormalServiceCreatePayload {
|
|
|
3
3
|
productId: number;
|
|
4
4
|
date: string;
|
|
5
5
|
isEject: 0 | 1;
|
|
6
|
+
productData?: any;
|
|
6
7
|
/**
|
|
7
8
|
* @description 弹窗关闭回调(用于外部清理状态,例如清空当前选中商品)
|
|
8
9
|
*/
|
|
@@ -15,6 +16,7 @@ export interface OpenNormalServiceCreatePayload {
|
|
|
15
16
|
export interface OpenNormalServiceEditPayload {
|
|
16
17
|
mode: 'edit';
|
|
17
18
|
cacheItem: any;
|
|
19
|
+
productData?: any;
|
|
18
20
|
/**
|
|
19
21
|
* @description 弹窗关闭回调(用于外部清理状态,例如清空当前选中商品)
|
|
20
22
|
*/
|
|
@@ -316,15 +316,17 @@ var AddSerivce = (props) => {
|
|
|
316
316
|
return ((_b2 = existingService == null ? void 0 : existingService._extend) == null ? void 0 : _b2.quantity) || 0;
|
|
317
317
|
});
|
|
318
318
|
const processAutoCloseService = (0, import_ahooks.useMemoizedFn)((cacheItem, item, detail, notShowToast) => {
|
|
319
|
+
var _a2;
|
|
319
320
|
console.time("processAutoCloseService2");
|
|
320
321
|
cacheItem.autoClose = false;
|
|
321
322
|
cacheItem._serviceKey = (0, import_utils6.genServiceKey)(cacheItem);
|
|
322
323
|
const productKey = getProductKey(item, cacheItem);
|
|
324
|
+
const addCount = ((_a2 = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a2.quantity) || 1;
|
|
323
325
|
if (pendingCacheValuesRef.current[productKey]) {
|
|
324
|
-
clickCountRef.current[productKey] = (clickCountRef.current[productKey] || 1) +
|
|
326
|
+
clickCountRef.current[productKey] = (clickCountRef.current[productKey] || 1) + addCount;
|
|
325
327
|
} else {
|
|
326
328
|
pendingCacheValuesRef.current[productKey] = { cacheItem, item, detail, notShowToast };
|
|
327
|
-
clickCountRef.current[productKey] =
|
|
329
|
+
clickCountRef.current[productKey] = addCount;
|
|
328
330
|
}
|
|
329
331
|
if (!notShowToast) {
|
|
330
332
|
const originalQuantity = getServiceQuantity(cacheItem);
|
|
@@ -500,6 +502,7 @@ var AddSerivce = (props) => {
|
|
|
500
502
|
openNormalService({
|
|
501
503
|
mode: "create",
|
|
502
504
|
productId: item.id,
|
|
505
|
+
productData: item,
|
|
503
506
|
date: state.date.value.format("YYYY-MM-DD"),
|
|
504
507
|
isEject: isEject ? 1 : 0,
|
|
505
508
|
onClose: () => {
|
|
@@ -48,6 +48,7 @@ var import_serve = require("../../components/booking/info/service/serve");
|
|
|
48
48
|
var import_utils2 = require("./utils");
|
|
49
49
|
var import_model = require("../../components/booking/info/model");
|
|
50
50
|
var import_useToast = __toESM(require("../../hooks/useToast"));
|
|
51
|
+
var import_useLogger = __toESM(require("../../hooks/useLogger"));
|
|
51
52
|
var SkuDetailModal = ({ onConfirm, onRemove, onClose }, ref) => {
|
|
52
53
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
53
54
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
@@ -74,6 +75,7 @@ var SkuDetailModal = ({ onConfirm, onRemove, onClose }, ref) => {
|
|
|
74
75
|
});
|
|
75
76
|
const openParamsRef = (0, import_react.useRef)(null);
|
|
76
77
|
const Toast = (0, import_useToast.default)();
|
|
78
|
+
const logger = (0, import_useLogger.default)();
|
|
77
79
|
const skuOptionsSelectionRef = (0, import_react.useRef)(null);
|
|
78
80
|
const [stockAlertOpen, setStockAlertOpen] = (0, import_react.useState)(false);
|
|
79
81
|
const [stockAlertDontShowAgainChecked, setStockAlertDontShowAgainChecked] = (0, import_react.useState)(false);
|
|
@@ -81,22 +83,43 @@ var SkuDetailModal = ({ onConfirm, onRemove, onClose }, ref) => {
|
|
|
81
83
|
const [currentStep, setCurrentStep] = (0, import_react.useState)(0);
|
|
82
84
|
const procedureRef = (0, import_react.useRef)(null);
|
|
83
85
|
const context = (0, import_useEngineContext.default)();
|
|
84
|
-
const { store, getData } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
86
|
+
const { store, getData, isWebPos } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
85
87
|
const { state: bookingState } = (0, import_react.useContext)(import_model.Context) || {};
|
|
86
88
|
const symbol = ((_d = (_c = (_b = store == null ? void 0 : store.getState) == null ? void 0 : _b.call(store)) == null ? void 0 : _c.global) == null ? void 0 : _d.symbol) || "$";
|
|
87
89
|
import_utils.locales.init(import_locales.default, ((_f = (_e = context == null ? void 0 : context.engine) == null ? void 0 : _e.props) == null ? void 0 : _f.locale) || "en");
|
|
90
|
+
const getDetailData = async (data, open_deposit) => {
|
|
91
|
+
if (isWebPos && data.productData) {
|
|
92
|
+
return {
|
|
93
|
+
data: data.productData
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
return await (0, import_serve.getProductDetail)(String(data.id), {
|
|
97
|
+
schedule_date: data.date,
|
|
98
|
+
is_eject: data.is_eject,
|
|
99
|
+
open_deposit
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
88
103
|
(0, import_react.useImperativeHandle)(ref, () => ({
|
|
89
104
|
open: async (data) => {
|
|
90
105
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k, _l, _m, _n, _o, _p;
|
|
91
106
|
setCurrentStep(1);
|
|
107
|
+
logger == null ? void 0 : logger.addLog({
|
|
108
|
+
type: "info",
|
|
109
|
+
title: "sku_detail_modal_open",
|
|
110
|
+
metadata: {
|
|
111
|
+
data
|
|
112
|
+
}
|
|
113
|
+
});
|
|
92
114
|
if ("date" in data && !("_extend" in data)) {
|
|
115
|
+
logger == null ? void 0 : logger.addLog({
|
|
116
|
+
type: "info",
|
|
117
|
+
title: "sku_detail_modal_open_create",
|
|
118
|
+
metadata: {}
|
|
119
|
+
});
|
|
93
120
|
openParamsRef.current = data;
|
|
94
121
|
const open_deposit = (getData == null ? void 0 : getData("bookingv2_deposit")) || 0;
|
|
95
|
-
const productDetail = await (
|
|
96
|
-
schedule_date: data.date,
|
|
97
|
-
is_eject: data.is_eject,
|
|
98
|
-
open_deposit
|
|
99
|
-
});
|
|
122
|
+
const productDetail = await getDetailData(data, open_deposit);
|
|
100
123
|
const apiData = (productDetail == null ? void 0 : productDetail.data) || {};
|
|
101
124
|
const basePrice = Number((apiData == null ? void 0 : apiData.price) || 0);
|
|
102
125
|
const hydratedData = {
|
|
@@ -147,6 +170,11 @@ var SkuDetailModal = ({ onConfirm, onRemove, onClose }, ref) => {
|
|
|
147
170
|
setOpen(true);
|
|
148
171
|
return;
|
|
149
172
|
}
|
|
173
|
+
logger == null ? void 0 : logger.addLog({
|
|
174
|
+
type: "info",
|
|
175
|
+
title: "sku_detail_modal_open_edit",
|
|
176
|
+
metadata: {}
|
|
177
|
+
});
|
|
150
178
|
openParamsRef.current = null;
|
|
151
179
|
const _data = safeClone(data);
|
|
152
180
|
setProductData(_data);
|
|
@@ -170,6 +198,11 @@ var SkuDetailModal = ({ onConfirm, onRemove, onClose }, ref) => {
|
|
|
170
198
|
setPriceOverride(getInitialPriceOverrideFromProductData({ productData: _data }));
|
|
171
199
|
setShowPriceAdjustModal(false);
|
|
172
200
|
setTimeout(() => {
|
|
201
|
+
logger == null ? void 0 : logger.addLog({
|
|
202
|
+
type: "info",
|
|
203
|
+
title: "sku_detail_modal_open_edit_show",
|
|
204
|
+
metadata: {}
|
|
205
|
+
});
|
|
173
206
|
setOpen(true);
|
|
174
207
|
}, 0);
|
|
175
208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.8.
|
|
3
|
+
"version": "6.8.37",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"styled-components": "^6.0.0-rc.3",
|
|
79
79
|
"@pisell/date-picker": "3.0.7",
|
|
80
80
|
"@pisell/materials": "6.8.7",
|
|
81
|
-
"@pisell/
|
|
82
|
-
"@pisell/
|
|
81
|
+
"@pisell/utils": "3.0.2",
|
|
82
|
+
"@pisell/icon": "0.0.11"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"react": "^18.0.0",
|