@pisell/pisellos 2.3.42 → 2.3.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Discount/index.d.ts +1 -0
  3. package/dist/modules/Discount/index.js +40 -11
  4. package/dist/modules/Discount/types.d.ts +1 -0
  5. package/dist/modules/Holder/index.d.ts +48 -0
  6. package/dist/modules/Holder/index.js +640 -0
  7. package/dist/modules/Holder/types.d.ts +123 -0
  8. package/dist/modules/Holder/types.js +1 -0
  9. package/dist/modules/Holder/utils.d.ts +13 -0
  10. package/dist/modules/Holder/utils.js +34 -0
  11. package/dist/modules/OpenData/index.js +2 -2
  12. package/dist/modules/Order/index.d.ts +3 -1
  13. package/dist/modules/Order/index.js +54 -25
  14. package/dist/modules/Order/types.d.ts +9 -0
  15. package/dist/modules/Order/utils.d.ts +10 -0
  16. package/dist/modules/Order/utils.js +35 -3
  17. package/dist/modules/Product/types.d.ts +1 -0
  18. package/dist/modules/ProductList/index.js +33 -14
  19. package/dist/modules/Quotation/index.d.ts +1 -1
  20. package/dist/modules/Quotation/index.js +2 -2
  21. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  22. package/dist/modules/ResourcePlanner/index.js +181 -0
  23. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  24. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  25. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  26. package/dist/modules/ResourcePlanner/types.js +1 -0
  27. package/dist/modules/Rules/index.js +47 -13
  28. package/dist/modules/SalesSummary/index.js +12 -13
  29. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  30. package/dist/modules/ScanOrderLogger/index.js +15 -2
  31. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  32. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  33. package/dist/modules/Schedule/index.d.ts +3 -1
  34. package/dist/modules/Schedule/index.js +21 -16
  35. package/dist/modules/Summary/utils.js +38 -13
  36. package/dist/modules/index.d.ts +2 -0
  37. package/dist/modules/index.js +3 -1
  38. package/dist/plugins/window.d.ts +1 -0
  39. package/dist/server/index.d.ts +14 -0
  40. package/dist/server/index.js +772 -657
  41. package/dist/solution/BaseSales/index.d.ts +7 -0
  42. package/dist/solution/BaseSales/index.js +64 -42
  43. package/dist/solution/BookingByStep/index.d.ts +17 -2
  44. package/dist/solution/BookingByStep/index.js +294 -215
  45. package/dist/solution/BookingByStep/types.d.ts +2 -1
  46. package/dist/solution/BookingByStep/types.js +3 -1
  47. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  48. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  49. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  50. package/dist/solution/BookingTicket/index.d.ts +1 -1
  51. package/dist/solution/BookingTicket/index.js +2 -2
  52. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  53. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  54. package/dist/solution/ScanOrder/index.d.ts +26 -14
  55. package/dist/solution/ScanOrder/index.js +1142 -739
  56. package/dist/solution/ScanOrder/types.d.ts +21 -1
  57. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  58. package/dist/solution/ScanOrder/utils.js +66 -25
  59. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  60. package/dist/solution/ShopDiscount/index.js +125 -87
  61. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  62. package/dist/solution/UnifiedBookingSales/index.js +1891 -0
  63. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  64. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  65. package/dist/solution/VenueBooking/index.d.ts +39 -11
  66. package/dist/solution/VenueBooking/index.js +1167 -841
  67. package/dist/solution/VenueBooking/types.d.ts +3 -0
  68. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  69. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  70. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  71. package/dist/solution/index.d.ts +1 -0
  72. package/dist/solution/index.js +2 -1
  73. package/dist/types/index.d.ts +1 -0
  74. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  75. package/lib/modules/Discount/index.d.ts +1 -0
  76. package/lib/modules/Discount/index.js +9 -0
  77. package/lib/modules/Discount/types.d.ts +1 -0
  78. package/lib/modules/Holder/index.d.ts +48 -0
  79. package/lib/modules/Holder/index.js +402 -0
  80. package/lib/modules/Holder/types.d.ts +123 -0
  81. package/lib/modules/Holder/types.js +17 -0
  82. package/lib/modules/Holder/utils.d.ts +13 -0
  83. package/lib/modules/Holder/utils.js +71 -0
  84. package/lib/modules/OpenData/index.js +1 -1
  85. package/lib/modules/Order/index.d.ts +3 -1
  86. package/lib/modules/Order/index.js +26 -10
  87. package/lib/modules/Order/types.d.ts +9 -0
  88. package/lib/modules/Order/utils.d.ts +10 -0
  89. package/lib/modules/Order/utils.js +36 -5
  90. package/lib/modules/Product/types.d.ts +1 -0
  91. package/lib/modules/ProductList/index.js +40 -31
  92. package/lib/modules/Quotation/index.d.ts +1 -1
  93. package/lib/modules/Quotation/index.js +2 -2
  94. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  95. package/lib/modules/ResourcePlanner/index.js +148 -0
  96. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  97. package/lib/modules/ResourcePlanner/planner.js +933 -0
  98. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  99. package/lib/modules/ResourcePlanner/types.js +17 -0
  100. package/lib/modules/Rules/index.js +33 -16
  101. package/lib/modules/SalesSummary/index.js +6 -7
  102. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  103. package/lib/modules/ScanOrderLogger/index.js +13 -1
  104. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  105. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  106. package/lib/modules/Schedule/index.d.ts +3 -1
  107. package/lib/modules/Schedule/index.js +10 -8
  108. package/lib/modules/Summary/utils.js +21 -1
  109. package/lib/modules/index.d.ts +2 -0
  110. package/lib/modules/index.js +5 -1
  111. package/lib/plugins/window.d.ts +1 -0
  112. package/lib/server/index.d.ts +14 -0
  113. package/lib/server/index.js +65 -5
  114. package/lib/solution/BaseSales/index.d.ts +7 -0
  115. package/lib/solution/BaseSales/index.js +24 -8
  116. package/lib/solution/BookingByStep/index.d.ts +17 -2
  117. package/lib/solution/BookingByStep/index.js +60 -18
  118. package/lib/solution/BookingByStep/types.d.ts +2 -1
  119. package/lib/solution/BookingByStep/types.js +5 -0
  120. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  121. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  122. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  123. package/lib/solution/BookingTicket/index.d.ts +1 -1
  124. package/lib/solution/BookingTicket/index.js +10 -2
  125. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  126. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  127. package/lib/solution/ScanOrder/index.d.ts +26 -14
  128. package/lib/solution/ScanOrder/index.js +449 -182
  129. package/lib/solution/ScanOrder/types.d.ts +21 -1
  130. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  131. package/lib/solution/ScanOrder/utils.js +31 -0
  132. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  133. package/lib/solution/ShopDiscount/index.js +14 -0
  134. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  135. package/lib/solution/UnifiedBookingSales/index.js +1084 -0
  136. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  137. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  138. package/lib/solution/VenueBooking/index.d.ts +39 -11
  139. package/lib/solution/VenueBooking/index.js +322 -110
  140. package/lib/solution/VenueBooking/types.d.ts +3 -0
  141. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  142. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  143. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  144. package/lib/solution/index.d.ts +1 -0
  145. package/lib/solution/index.js +3 -1
  146. package/lib/types/index.d.ts +1 -0
  147. package/package.json +1 -1
@@ -0,0 +1,640 @@
1
+ var _excluded = ["form_id", "shop_id", "num", "skip", "customer_id"];
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
+ 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."); }
8
+ 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); }
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ 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; }
12
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
13
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
14
+ 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; }
15
+ 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; }
16
+ 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; }
17
+ 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); }
18
+ 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); } }
19
+ 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); }); }; }
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
24
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
26
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
27
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+ 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; }
31
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
32
+ 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); }
33
+ import { cloneDeep } from 'lodash-es';
34
+ import { BaseModule } from "../BaseModule";
35
+ import { createEmptyFormItemData, getFormIdFromHolderConfig, getProductHolderConfig, normalizeFormId, resolveFormMetaFromHolderItem } from "./utils";
36
+ export * from "./types";
37
+ export * from "./utils";
38
+ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
39
+ _inherits(HolderModule, _BaseModule);
40
+ var _super = _createSuper(HolderModule);
41
+ function HolderModule(name, version) {
42
+ var _this;
43
+ _classCallCheck(this, HolderModule);
44
+ _this = _super.call(this, name, version);
45
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'holder');
46
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
47
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
48
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
49
+ _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
50
+ _defineProperty(_assertThisInitialized(_this), "openCache", false);
51
+ _defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
52
+ _defineProperty(_assertThisInitialized(_this), "isLoading", false);
53
+ _defineProperty(_assertThisInitialized(_this), "error", null);
54
+ /** 已加载过表单数据的 form_id 缓存标记 */
55
+ _defineProperty(_assertThisInitialized(_this), "loadedFormIds", new Set());
56
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
57
+ return _this;
58
+ }
59
+ _createClass(HolderModule, [{
60
+ key: "initialize",
61
+ value: function () {
62
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
63
+ var _options$initialState,
64
+ _this2 = this,
65
+ _options$otherParams,
66
+ _options$otherParams2;
67
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ this.core = core;
71
+ this.store = options.store;
72
+ this.request = this.core.getPlugin('request');
73
+ this.window = this.core.getPlugin('window');
74
+ if ((_options$initialState = options.initialState) !== null && _options$initialState !== void 0 && _options$initialState.holderMap) {
75
+ this.commitFormMap(cloneDeep(options.initialState.holderMap));
76
+ Object.keys(this.store.holderMap).forEach(function (formId) {
77
+ if (_this2.hasFormData(formId)) {
78
+ _this2.loadedFormIds.add(formId);
79
+ }
80
+ });
81
+ }
82
+ if (!this.store.holderMap || _typeof(this.store.holderMap) !== 'object') {
83
+ this.store.holderMap = {};
84
+ }
85
+ if ((_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
86
+ this.openCache = options.otherParams.openCache;
87
+ this.cacheId = options.otherParams.cacheId;
88
+ }
89
+ if ((_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
90
+ this.fatherModule = options.otherParams.fatherModule;
91
+ }
92
+ case 8:
93
+ case "end":
94
+ return _context.stop();
95
+ }
96
+ }, _callee, this);
97
+ }));
98
+ function initialize(_x, _x2) {
99
+ return _initialize.apply(this, arguments);
100
+ }
101
+ return initialize;
102
+ }() /** 统一提交 formMap,仅此处触发 store changed */
103
+ }, {
104
+ key: "commitFormMap",
105
+ value: function commitFormMap(holderMap) {
106
+ this.store.holderMap = holderMap;
107
+ }
108
+
109
+ /** 通知 UI 刷新(数据未变但需要 re-read 的场景) */
110
+ }, {
111
+ key: "notifyFormMapChanged",
112
+ value: function notifyFormMapChanged() {
113
+ this.commitFormMap(_objectSpread({}, this.store.holderMap));
114
+ }
115
+ }, {
116
+ key: "getHolderFormMap",
117
+ value: function getHolderFormMap() {
118
+ return cloneDeep(this.store.holderMap);
119
+ }
120
+ }, {
121
+ key: "getHolderFormData",
122
+ value: function getHolderFormData(formId) {
123
+ var formData = this.store.holderMap[normalizeFormId(formId)];
124
+ return formData ? cloneDeep(formData) : undefined;
125
+ }
126
+ }, {
127
+ key: "setFormData",
128
+ value: function setFormData(formId, data) {
129
+ var _data$records, _data$form;
130
+ var key = normalizeFormId(formId);
131
+ var current = this.store.holderMap[key] || createEmptyFormItemData();
132
+ this.commitFormMap(_objectSpread(_objectSpread({}, this.store.holderMap), {}, _defineProperty({}, key, {
133
+ records: (_data$records = data.records) !== null && _data$records !== void 0 ? _data$records : current.records,
134
+ form: (_data$form = data.form) !== null && _data$form !== void 0 ? _data$form : current.form
135
+ })));
136
+ }
137
+ }, {
138
+ key: "ensureFormItem",
139
+ value: function ensureFormItem(formId) {
140
+ var holderMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.holderMap;
141
+ var key = normalizeFormId(formId);
142
+ if (!holderMap[key]) {
143
+ holderMap[key] = createEmptyFormItemData();
144
+ }
145
+ return holderMap[key];
146
+ }
147
+ }, {
148
+ key: "hasFormData",
149
+ value: function hasFormData(formId) {
150
+ var item = this.store.holderMap[formId];
151
+ return !!item && (Object.keys(item.form || {}).length > 0 || item.records.length > 0);
152
+ }
153
+ }, {
154
+ key: "patchFormMap",
155
+ value: function patchFormMap(holderMap, formId, patch) {
156
+ var _patch$records, _patch$form;
157
+ var current = this.ensureFormItem(formId, holderMap);
158
+ holderMap[formId] = {
159
+ records: (_patch$records = patch.records) !== null && _patch$records !== void 0 ? _patch$records : current.records,
160
+ form: (_patch$form = patch.form) !== null && _patch$form !== void 0 ? _patch$form : current.form
161
+ };
162
+ }
163
+ }, {
164
+ key: "fetchFormInfo",
165
+ value: function () {
166
+ var _fetchFormInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
167
+ var _this3 = this;
168
+ var _ref, form_id, url, useCache, res, formData, formList, nextFormMap, key;
169
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
170
+ while (1) switch (_context2.prev = _context2.next) {
171
+ case 0:
172
+ _ref = params.query || {}, form_id = _ref.form_id;
173
+ url = params.url || "/form/".concat(form_id);
174
+ useCache = params.useCache !== false;
175
+ this.isLoading = true;
176
+ this.error = null;
177
+ _context2.prev = 5;
178
+ _context2.next = 8;
179
+ return this.request.get(url, {}, {
180
+ useCache: useCache
181
+ });
182
+ case 8:
183
+ res = _context2.sent;
184
+ formData = res === null || res === void 0 ? void 0 : res.data;
185
+ formList = Array.isArray(formData === null || formData === void 0 ? void 0 : formData.list) ? formData.list : formData ? [formData] : [];
186
+ nextFormMap = _objectSpread({}, this.store.holderMap);
187
+ formList.forEach(function (form) {
188
+ var _ref2, _form$form_id;
189
+ var key = normalizeFormId((_ref2 = (_form$form_id = form.form_id) !== null && _form$form_id !== void 0 ? _form$form_id : form_id) !== null && _ref2 !== void 0 ? _ref2 : form.id);
190
+ _this3.patchFormMap(nextFormMap, key, {
191
+ form: form
192
+ });
193
+ });
194
+ if (!formList.length && form_id !== undefined) {
195
+ key = normalizeFormId(form_id);
196
+ this.patchFormMap(nextFormMap, key, {
197
+ form: formData || {}
198
+ });
199
+ }
200
+ this.commitFormMap(nextFormMap);
201
+ return _context2.abrupt("return", formList.length === 1 ? formList[0] : formList);
202
+ case 18:
203
+ _context2.prev = 18;
204
+ _context2.t0 = _context2["catch"](5);
205
+ this.error = _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0);
206
+ throw _context2.t0;
207
+ case 22:
208
+ _context2.prev = 22;
209
+ this.isLoading = false;
210
+ return _context2.finish(22);
211
+ case 25:
212
+ case "end":
213
+ return _context2.stop();
214
+ }
215
+ }, _callee2, this, [[5, 18, 22, 25]]);
216
+ }));
217
+ function fetchFormInfo(_x3) {
218
+ return _fetchFormInfo.apply(this, arguments);
219
+ }
220
+ return fetchFormInfo;
221
+ }()
222
+ }, {
223
+ key: "fetchRecords",
224
+ value: function () {
225
+ var _fetchRecords = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
226
+ var _this$window, _this$window$getLocal;
227
+ var url, _ref3, form_id, shop_id, num, skip, customer_id, rest, formId, useCache, customer, customerId, _res$data, res, records, nextFormMap;
228
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
229
+ while (1) switch (_context3.prev = _context3.next) {
230
+ case 0:
231
+ url = params.url || '/form/data/v1';
232
+ _ref3 = params.query || {}, form_id = _ref3.form_id, shop_id = _ref3.shop_id, num = _ref3.num, skip = _ref3.skip, customer_id = _ref3.customer_id, rest = _objectWithoutProperties(_ref3, _excluded);
233
+ formId = normalizeFormId(form_id);
234
+ useCache = params.useCache !== false;
235
+ customer = JSON.parse(((_this$window = this.window) === null || _this$window === void 0 || (_this$window$getLocal = _this$window.getLocalStorage) === null || _this$window$getLocal === void 0 ? void 0 : _this$window$getLocal.call(_this$window, 'customer')) || '{}');
236
+ customerId = customer_id !== null && customer_id !== void 0 ? customer_id : customer.id;
237
+ if (customerId) {
238
+ _context3.next = 8;
239
+ break;
240
+ }
241
+ return _context3.abrupt("return", []);
242
+ case 8:
243
+ this.isLoading = true;
244
+ this.error = null;
245
+ _context3.prev = 10;
246
+ _context3.next = 13;
247
+ return this.request.get(url, _objectSpread({
248
+ customer_id: customerId,
249
+ form_id: form_id,
250
+ shop_id: shop_id,
251
+ num: num || 100,
252
+ skip: skip || 1,
253
+ front_end_cache_id: useCache && this.cacheId
254
+ }, rest), {
255
+ useCache: useCache
256
+ });
257
+ case 13:
258
+ res = _context3.sent;
259
+ records = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
260
+ nextFormMap = _objectSpread({}, this.store.holderMap);
261
+ this.patchFormMap(nextFormMap, formId, {
262
+ records: records
263
+ });
264
+ this.commitFormMap(nextFormMap);
265
+ return _context3.abrupt("return", records);
266
+ case 21:
267
+ _context3.prev = 21;
268
+ _context3.t0 = _context3["catch"](10);
269
+ this.error = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
270
+ throw _context3.t0;
271
+ case 25:
272
+ _context3.prev = 25;
273
+ this.isLoading = false;
274
+ return _context3.finish(25);
275
+ case 28:
276
+ case "end":
277
+ return _context3.stop();
278
+ }
279
+ }, _callee3, this, [[10, 21, 25, 28]]);
280
+ }));
281
+ function fetchRecords(_x4) {
282
+ return _fetchRecords.apply(this, arguments);
283
+ }
284
+ return fetchRecords;
285
+ }()
286
+ }, {
287
+ key: "ensureFormData",
288
+ value: function () {
289
+ var _ensureFormData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
290
+ var formId, useCache, current, tasks;
291
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
292
+ while (1) switch (_context4.prev = _context4.next) {
293
+ case 0:
294
+ formId = normalizeFormId(params.form_id);
295
+ useCache = params.useCache !== false;
296
+ if (!(useCache && !params.forceRefresh && this.loadedFormIds.has(formId))) {
297
+ _context4.next = 5;
298
+ break;
299
+ }
300
+ this.notifyFormMapChanged();
301
+ return _context4.abrupt("return", this.ensureFormItem(formId));
302
+ case 5:
303
+ current = this.ensureFormItem(formId);
304
+ tasks = [];
305
+ if (params.forceRefresh || !Object.keys(current.form || {}).length) {
306
+ tasks.push(this.fetchFormInfo({
307
+ url: params.formInfoUrl,
308
+ query: {
309
+ form_id: params.form_id
310
+ },
311
+ useCache: useCache
312
+ }));
313
+ }
314
+ if (params.forceRefresh || !current.records.length) {
315
+ tasks.push(this.fetchRecords({
316
+ url: params.recordsUrl,
317
+ query: {
318
+ form_id: params.form_id,
319
+ shop_id: params.shop_id,
320
+ customer_id: params.customer_id
321
+ },
322
+ useCache: useCache
323
+ }));
324
+ }
325
+ if (tasks.length) {
326
+ _context4.next = 13;
327
+ break;
328
+ }
329
+ this.notifyFormMapChanged();
330
+ _context4.next = 15;
331
+ break;
332
+ case 13:
333
+ _context4.next = 15;
334
+ return Promise.all(tasks);
335
+ case 15:
336
+ this.loadedFormIds.add(formId);
337
+ return _context4.abrupt("return", this.ensureFormItem(formId));
338
+ case 17:
339
+ case "end":
340
+ return _context4.stop();
341
+ }
342
+ }, _callee4, this);
343
+ }));
344
+ function ensureFormData(_x5) {
345
+ return _ensureFormData.apply(this, arguments);
346
+ }
347
+ return ensureFormData;
348
+ }()
349
+ }, {
350
+ key: "ensureFormByProduct",
351
+ value: function () {
352
+ var _ensureFormByProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
353
+ var _params$shop_id;
354
+ var holderConfig, formId, shopId;
355
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
356
+ while (1) switch (_context5.prev = _context5.next) {
357
+ case 0:
358
+ holderConfig = getProductHolderConfig(params.product);
359
+ if (holderConfig) {
360
+ _context5.next = 3;
361
+ break;
362
+ }
363
+ return _context5.abrupt("return", null);
364
+ case 3:
365
+ formId = getFormIdFromHolderConfig(holderConfig);
366
+ shopId = (_params$shop_id = params.shop_id) !== null && _params$shop_id !== void 0 ? _params$shop_id : params.product.shop_id;
367
+ return _context5.abrupt("return", this.ensureFormData({
368
+ form_id: formId,
369
+ shop_id: shopId,
370
+ customer_id: params.customer_id,
371
+ useCache: params.useCache,
372
+ skip: 1,
373
+ num: 100
374
+ }));
375
+ case 6:
376
+ case "end":
377
+ return _context5.stop();
378
+ }
379
+ }, _callee5, this);
380
+ }));
381
+ function ensureFormByProduct(_x6) {
382
+ return _ensureFormByProduct.apply(this, arguments);
383
+ }
384
+ return ensureFormByProduct;
385
+ }()
386
+ }, {
387
+ key: "addFormRecord",
388
+ value: function () {
389
+ var _addFormRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
390
+ var url, formId, records;
391
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
392
+ while (1) switch (_context6.prev = _context6.next) {
393
+ case 0:
394
+ url = params.url || '/form/record';
395
+ formId = normalizeFormId(params.body.form_id);
396
+ this.isLoading = true;
397
+ this.error = null;
398
+ _context6.prev = 4;
399
+ _context6.next = 7;
400
+ return this.request.post(url, params.body);
401
+ case 7:
402
+ _context6.next = 9;
403
+ return this.fetchRecords({
404
+ query: {
405
+ form_id: params.body.form_id,
406
+ shop_id: params.body.shop_id,
407
+ customer_id: params.body.customer_id
408
+ },
409
+ useCache: false
410
+ });
411
+ case 9:
412
+ records = _context6.sent;
413
+ this.loadedFormIds.add(formId);
414
+ return _context6.abrupt("return", records[records.length - 1]);
415
+ case 14:
416
+ _context6.prev = 14;
417
+ _context6.t0 = _context6["catch"](4);
418
+ this.error = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
419
+ throw _context6.t0;
420
+ case 18:
421
+ _context6.prev = 18;
422
+ this.isLoading = false;
423
+ return _context6.finish(18);
424
+ case 21:
425
+ case "end":
426
+ return _context6.stop();
427
+ }
428
+ }, _callee6, this, [[4, 14, 18, 21]]);
429
+ }));
430
+ function addFormRecord(_x7) {
431
+ return _addFormRecord.apply(this, arguments);
432
+ }
433
+ return addFormRecord;
434
+ }()
435
+ /**
436
+ * UI 层自行请求添加接口后,将返回记录合并到 holderMap 对应 form_id 的 records 中
437
+ */
438
+ }, {
439
+ key: "appendFormRecord",
440
+ value: function appendFormRecord(params) {
441
+ var _record, _params$form_id;
442
+ var record = params.record;
443
+ if ((_record = record) !== null && _record !== void 0 && _record.data && record.form_record_id === undefined) {
444
+ record = record.data;
445
+ }
446
+ var normalizedRecord = cloneDeep(record);
447
+ var formId = normalizeFormId((_params$form_id = params.form_id) !== null && _params$form_id !== void 0 ? _params$form_id : normalizedRecord.form_id);
448
+ if (!formId) {
449
+ throw new Error('[HolderModule] appendFormRecord: form_id is required');
450
+ }
451
+ if (!normalizedRecord.form_record_id) {
452
+ throw new Error('[HolderModule] appendFormRecord: form_record_id is required');
453
+ }
454
+ normalizedRecord.form_id = Number(formId) || normalizedRecord.form_id;
455
+ var nextFormMap = _objectSpread({}, this.store.holderMap);
456
+ var current = this.ensureFormItem(formId, nextFormMap);
457
+ var recordIndex = current.records.findIndex(function (item) {
458
+ return item.form_record_id === normalizedRecord.form_record_id;
459
+ });
460
+ var records = recordIndex >= 0 ? current.records.map(function (item, index) {
461
+ return index === recordIndex ? _objectSpread(_objectSpread({}, item), normalizedRecord) : item;
462
+ }) : [].concat(_toConsumableArray(current.records), [normalizedRecord]);
463
+ this.patchFormMap(nextFormMap, formId, {
464
+ records: records
465
+ });
466
+ this.commitFormMap(nextFormMap);
467
+ this.loadedFormIds.add(formId);
468
+ return normalizedRecord;
469
+ }
470
+ }, {
471
+ key: "removeFormRecord",
472
+ value: function removeFormRecord(formId, formRecordId) {
473
+ var key = normalizeFormId(formId);
474
+ var current = this.store.holderMap[key] || createEmptyFormItemData();
475
+ var nextFormMap = _objectSpread({}, this.store.holderMap);
476
+ this.patchFormMap(nextFormMap, key, {
477
+ records: current.records.filter(function (record) {
478
+ return record.form_record_id !== formRecordId;
479
+ })
480
+ });
481
+ this.commitFormMap(nextFormMap);
482
+ }
483
+ }, {
484
+ key: "clearFormData",
485
+ value: function clearFormData(formId) {
486
+ if (formId !== undefined) {
487
+ var key = normalizeFormId(formId);
488
+ var nextFormMap = _objectSpread({}, this.store.holderMap);
489
+ delete nextFormMap[key];
490
+ this.loadedFormIds.delete(key);
491
+ this.commitFormMap(nextFormMap);
492
+ } else {
493
+ this.loadedFormIds.clear();
494
+ this.commitFormMap({});
495
+ }
496
+ }
497
+
498
+ /**
499
+ * 登录后按当前 holderMap 批量刷新所有表单的 records。
500
+ * 遍历 holderMap,从 form.form 中读取 form_id、shop_id,结合 customer_id 重新拉取记录。
501
+ */
502
+ }, {
503
+ key: "refreshAllFormRecords",
504
+ value: (function () {
505
+ var _refreshAllFormRecords = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
506
+ var _params$useCache,
507
+ _this4 = this;
508
+ var params,
509
+ customer_id,
510
+ recordsUrl,
511
+ num,
512
+ skip,
513
+ useCache,
514
+ entries,
515
+ url,
516
+ results,
517
+ nextFormMap,
518
+ _args8 = arguments;
519
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
520
+ while (1) switch (_context8.prev = _context8.next) {
521
+ case 0:
522
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
523
+ customer_id = params.customer_id, recordsUrl = params.recordsUrl, num = params.num, skip = params.skip;
524
+ useCache = (_params$useCache = params.useCache) !== null && _params$useCache !== void 0 ? _params$useCache : false;
525
+ if (customer_id) {
526
+ _context8.next = 5;
527
+ break;
528
+ }
529
+ return _context8.abrupt("return", this.getHolderFormMap());
530
+ case 5:
531
+ entries = Object.entries(this.store.holderMap);
532
+ if (entries.length) {
533
+ _context8.next = 8;
534
+ break;
535
+ }
536
+ return _context8.abrupt("return", this.getHolderFormMap());
537
+ case 8:
538
+ url = recordsUrl || '/form/data/v1';
539
+ this.isLoading = true;
540
+ this.error = null;
541
+ _context8.prev = 11;
542
+ _context8.next = 14;
543
+ return Promise.all(entries.map( /*#__PURE__*/function () {
544
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref4) {
545
+ var _ref6, mapKey, item, meta, _res$data2, res;
546
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
547
+ while (1) switch (_context7.prev = _context7.next) {
548
+ case 0:
549
+ _ref6 = _slicedToArray(_ref4, 2), mapKey = _ref6[0], item = _ref6[1];
550
+ meta = resolveFormMetaFromHolderItem(mapKey, item);
551
+ if (meta) {
552
+ _context7.next = 4;
553
+ break;
554
+ }
555
+ return _context7.abrupt("return", null);
556
+ case 4:
557
+ _context7.prev = 4;
558
+ _context7.next = 7;
559
+ return _this4.request.get(url, {
560
+ customer_id: customer_id,
561
+ form_id: meta.form_id,
562
+ shop_id: meta.shop_id,
563
+ num: num || 100,
564
+ skip: skip || 1,
565
+ front_end_cache_id: useCache && _this4.cacheId
566
+ }, {
567
+ useCache: useCache
568
+ });
569
+ case 7:
570
+ res = _context7.sent;
571
+ return _context7.abrupt("return", {
572
+ formId: meta.form_id,
573
+ records: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list) || []
574
+ });
575
+ case 11:
576
+ _context7.prev = 11;
577
+ _context7.t0 = _context7["catch"](4);
578
+ console.error("[HolderModule] refreshAllFormRecords failed for form ".concat(meta.form_id), _context7.t0);
579
+ return _context7.abrupt("return", null);
580
+ case 15:
581
+ case "end":
582
+ return _context7.stop();
583
+ }
584
+ }, _callee7, null, [[4, 11]]);
585
+ }));
586
+ return function (_x8) {
587
+ return _ref5.apply(this, arguments);
588
+ };
589
+ }()));
590
+ case 14:
591
+ results = _context8.sent;
592
+ nextFormMap = _objectSpread({}, this.store.holderMap);
593
+ results.forEach(function (result) {
594
+ if (!result) return;
595
+ _this4.patchFormMap(nextFormMap, result.formId, {
596
+ records: result.records
597
+ });
598
+ _this4.loadedFormIds.add(result.formId);
599
+ });
600
+ this.commitFormMap(nextFormMap);
601
+ return _context8.abrupt("return", cloneDeep(nextFormMap));
602
+ case 21:
603
+ _context8.prev = 21;
604
+ _context8.t0 = _context8["catch"](11);
605
+ this.error = _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0);
606
+ throw _context8.t0;
607
+ case 25:
608
+ _context8.prev = 25;
609
+ this.isLoading = false;
610
+ return _context8.finish(25);
611
+ case 28:
612
+ case "end":
613
+ return _context8.stop();
614
+ }
615
+ }, _callee8, this, [[11, 21, 25, 28]]);
616
+ }));
617
+ function refreshAllFormRecords() {
618
+ return _refreshAllFormRecords.apply(this, arguments);
619
+ }
620
+ return refreshAllFormRecords;
621
+ }())
622
+ }, {
623
+ key: "storeChange",
624
+ value: function storeChange(path) {
625
+ if (path !== 'holderMap' && path !== undefined) {
626
+ return;
627
+ }
628
+ if (this.openCache) {
629
+ var store = cloneDeep(this.store);
630
+ this.checkSaveCache({
631
+ cacheId: this.cacheId,
632
+ fatherModule: this.fatherModule,
633
+ store: store,
634
+ cacheKey: ['holderMap']
635
+ });
636
+ }
637
+ }
638
+ }]);
639
+ return HolderModule;
640
+ }(BaseModule);