@pisell/pisellos 3.0.57 → 3.0.58

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 (256) hide show
  1. package/dist/core/index.js +1 -2
  2. package/dist/effects/index.d.ts +3 -4
  3. package/dist/effects/index.js +6 -15
  4. package/dist/modules/AccountList/index.d.ts +1 -7
  5. package/dist/modules/AccountList/index.js +14 -81
  6. package/dist/modules/AccountList/types.d.ts +0 -28
  7. package/dist/modules/AccountList/types.js +0 -8
  8. package/dist/modules/Cart/index.js +1 -1
  9. package/dist/modules/Payment/index.d.ts +9 -273
  10. package/dist/modules/Payment/index.js +109 -2525
  11. package/dist/modules/Payment/types.d.ts +30 -382
  12. package/dist/modules/Payment/types.js +14 -116
  13. package/dist/modules/ProductList/index.d.ts +1 -12
  14. package/dist/modules/ProductList/index.js +3 -27
  15. package/dist/modules/Rules/index.js +14 -27
  16. package/dist/modules/Rules/types.d.ts +0 -1
  17. package/dist/modules/index.d.ts +0 -1
  18. package/dist/modules/index.js +0 -1
  19. package/dist/plugins/window.d.ts +0 -1
  20. package/dist/solution/BookingByStep/index.js +1 -9
  21. package/dist/solution/ShopDiscount/index.js +2 -4
  22. package/dist/solution/index.d.ts +0 -2
  23. package/dist/solution/index.js +1 -3
  24. package/dist/types/index.d.ts +1 -3
  25. package/lib/core/index.js +1 -1
  26. package/lib/effects/index.d.ts +3 -4
  27. package/lib/effects/index.js +1 -4
  28. package/lib/modules/AccountList/index.d.ts +1 -7
  29. package/lib/modules/AccountList/index.js +0 -27
  30. package/lib/modules/AccountList/types.d.ts +0 -28
  31. package/lib/modules/Cart/index.js +1 -1
  32. package/lib/modules/Payment/index.d.ts +9 -273
  33. package/lib/modules/Payment/index.js +50 -1285
  34. package/lib/modules/Payment/types.d.ts +30 -382
  35. package/lib/modules/Payment/types.js +6 -41
  36. package/lib/modules/ProductList/index.d.ts +1 -12
  37. package/lib/modules/ProductList/index.js +2 -29
  38. package/lib/modules/Rules/index.js +12 -20
  39. package/lib/modules/Rules/types.d.ts +0 -1
  40. package/lib/modules/index.d.ts +0 -1
  41. package/lib/modules/index.js +0 -2
  42. package/lib/plugins/window.d.ts +0 -1
  43. package/lib/solution/BookingByStep/index.js +2 -1
  44. package/lib/solution/ShopDiscount/index.js +1 -2
  45. package/lib/solution/index.d.ts +0 -2
  46. package/lib/solution/index.js +1 -5
  47. package/lib/types/index.d.ts +1 -3
  48. package/package.json +2 -4
  49. package/dist/modules/Customer/constants.d.ts +0 -7
  50. package/dist/modules/Customer/constants.js +0 -12
  51. package/dist/modules/Customer/index.d.ts +0 -122
  52. package/dist/modules/Customer/index.js +0 -697
  53. package/dist/modules/Customer/types.d.ts +0 -146
  54. package/dist/modules/Customer/types.js +0 -41
  55. package/dist/modules/Payment/cash.d.ts +0 -11
  56. package/dist/modules/Payment/cash.js +0 -78
  57. package/dist/modules/Payment/eftpos.d.ts +0 -11
  58. package/dist/modules/Payment/eftpos.js +0 -80
  59. package/dist/modules/Payment/wallet.d.ts +0 -11
  60. package/dist/modules/Payment/wallet.js +0 -78
  61. package/dist/modules/Payment/walletpass.d.ts +0 -0
  62. package/dist/modules/Payment/walletpass.js +0 -0
  63. package/dist/plugins/app-types/app/app.d.ts +0 -83
  64. package/dist/plugins/app-types/app/const.d.ts +0 -4
  65. package/dist/plugins/app-types/app/index.d.ts +0 -14
  66. package/dist/plugins/app-types/applicationManager/application.d.ts +0 -50
  67. package/dist/plugins/app-types/applicationManager/index.d.ts +0 -13
  68. package/dist/plugins/app-types/config.d.ts +0 -3
  69. package/dist/plugins/app-types/cookie/index.d.ts +0 -13
  70. package/dist/plugins/app-types/data/index.d.ts +0 -8
  71. package/dist/plugins/app-types/history/config.d.ts +0 -24
  72. package/dist/plugins/app-types/history/index.d.ts +0 -20
  73. package/dist/plugins/app-types/history/type.d.ts +0 -2
  74. package/dist/plugins/app-types/hooks/index.d.ts +0 -12
  75. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
  76. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
  77. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
  78. package/dist/plugins/app-types/hooks/useStore/index.d.ts +0 -6
  79. package/dist/plugins/app-types/index.d.ts +0 -6
  80. package/dist/plugins/app-types/indexDB/index.d.ts +0 -178
  81. package/dist/plugins/app-types/locales/en.d.ts +0 -3
  82. package/dist/plugins/app-types/locales/index.d.ts +0 -37
  83. package/dist/plugins/app-types/locales/original.d.ts +0 -3
  84. package/dist/plugins/app-types/locales/type.d.ts +0 -19
  85. package/dist/plugins/app-types/locales/zh-CN.d.ts +0 -3
  86. package/dist/plugins/app-types/locales/zh-HK.d.ts +0 -3
  87. package/dist/plugins/app-types/logger/feishu.d.ts +0 -11
  88. package/dist/plugins/app-types/logger/index.d.ts +0 -122
  89. package/dist/plugins/app-types/menuManager/hooks.d.ts +0 -17
  90. package/dist/plugins/app-types/menuManager/index.d.ts +0 -28
  91. package/dist/plugins/app-types/models/global.d.ts +0 -32
  92. package/dist/plugins/app-types/models/index.d.ts +0 -45
  93. package/dist/plugins/app-types/models/type.d.ts +0 -2
  94. package/dist/plugins/app-types/package.json +0 -15
  95. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  96. package/dist/plugins/app-types/pubsub/example.d.ts +0 -5
  97. package/dist/plugins/app-types/pubsub/index.d.ts +0 -63
  98. package/dist/plugins/app-types/request/cache.d.ts +0 -46
  99. package/dist/plugins/app-types/request/cancelToken.d.ts +0 -38
  100. package/dist/plugins/app-types/request/config.d.ts +0 -3
  101. package/dist/plugins/app-types/request/constants.d.ts +0 -2
  102. package/dist/plugins/app-types/request/index.d.ts +0 -24
  103. package/dist/plugins/app-types/request/pisell2Request.d.ts +0 -6
  104. package/dist/plugins/app-types/request/type.d.ts +0 -41
  105. package/dist/plugins/app-types/request/utils.d.ts +0 -46
  106. package/dist/plugins/app-types/routes/config.d.ts +0 -7
  107. package/dist/plugins/app-types/routes/index.d.ts +0 -28
  108. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
  109. package/dist/plugins/app-types/socket/components/index.d.ts +0 -2
  110. package/dist/plugins/app-types/socket/constants.d.ts +0 -33
  111. package/dist/plugins/app-types/socket/events.d.ts +0 -31
  112. package/dist/plugins/app-types/socket/heartbeat.d.ts +0 -66
  113. package/dist/plugins/app-types/socket/index.d.ts +0 -61
  114. package/dist/plugins/app-types/socket/monitor.d.ts +0 -169
  115. package/dist/plugins/app-types/socket/reconnect.d.ts +0 -61
  116. package/dist/plugins/app-types/socket/socket.d.ts +0 -129
  117. package/dist/plugins/app-types/socket/types.d.ts +0 -85
  118. package/dist/plugins/app-types/storage/index.d.ts +0 -17
  119. package/dist/plugins/app-types/tasks/index.d.ts +0 -77
  120. package/dist/plugins/app-types/tasks/type.d.ts +0 -62
  121. package/dist/plugins/app-types/tasks/useTasks.d.ts +0 -5
  122. package/dist/plugins/app-types/type.d.ts +0 -2
  123. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
  124. package/dist/plugins/app-types/variables/config.d.ts +0 -3
  125. package/dist/plugins/app-types/variables/index.d.ts +0 -6
  126. package/dist/plugins/app-types/variables/type.d.ts +0 -2
  127. package/dist/plugins/app-types/website/index.d.ts +0 -6
  128. package/dist/plugins/app.d.ts +0 -8
  129. package/dist/plugins/app.js +0 -1
  130. package/dist/solution/BookingTicket/index.d.ts +0 -172
  131. package/dist/solution/BookingTicket/index.js +0 -665
  132. package/dist/solution/BookingTicket/types.d.ts +0 -68
  133. package/dist/solution/BookingTicket/types.js +0 -43
  134. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  135. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
  136. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
  137. package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -174
  138. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -81
  139. package/dist/solution/BookingTicket/utils/scan/index.js +0 -285
  140. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  141. package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
  142. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  143. package/dist/solution/Checkout/index.d.ts +0 -181
  144. package/dist/solution/Checkout/index.js +0 -1596
  145. package/dist/solution/Checkout/types.d.ts +0 -550
  146. package/dist/solution/Checkout/types.js +0 -132
  147. package/dist/solution/Checkout/utils/index.d.ts +0 -73
  148. package/dist/solution/Checkout/utils/index.js +0 -371
  149. package/dist/utils/task.d.ts +0 -40
  150. package/dist/utils/task.js +0 -171
  151. package/dist/utils/watch.d.ts +0 -102
  152. package/dist/utils/watch.js +0 -294
  153. package/lib/modules/Customer/constants.d.ts +0 -7
  154. package/lib/modules/Customer/constants.js +0 -39
  155. package/lib/modules/Customer/index.d.ts +0 -122
  156. package/lib/modules/Customer/index.js +0 -440
  157. package/lib/modules/Customer/types.d.ts +0 -146
  158. package/lib/modules/Customer/types.js +0 -37
  159. package/lib/modules/Payment/cash.d.ts +0 -11
  160. package/lib/modules/Payment/cash.js +0 -51
  161. package/lib/modules/Payment/eftpos.d.ts +0 -11
  162. package/lib/modules/Payment/eftpos.js +0 -51
  163. package/lib/modules/Payment/wallet.d.ts +0 -11
  164. package/lib/modules/Payment/wallet.js +0 -51
  165. package/lib/modules/Payment/walletpass.d.ts +0 -0
  166. package/lib/modules/Payment/walletpass.js +0 -0
  167. package/lib/plugins/app-types/app/app.d.ts +0 -83
  168. package/lib/plugins/app-types/app/const.d.ts +0 -4
  169. package/lib/plugins/app-types/app/index.d.ts +0 -14
  170. package/lib/plugins/app-types/applicationManager/application.d.ts +0 -50
  171. package/lib/plugins/app-types/applicationManager/index.d.ts +0 -13
  172. package/lib/plugins/app-types/config.d.ts +0 -3
  173. package/lib/plugins/app-types/cookie/index.d.ts +0 -13
  174. package/lib/plugins/app-types/data/index.d.ts +0 -8
  175. package/lib/plugins/app-types/history/config.d.ts +0 -24
  176. package/lib/plugins/app-types/history/index.d.ts +0 -20
  177. package/lib/plugins/app-types/history/type.d.ts +0 -2
  178. package/lib/plugins/app-types/hooks/index.d.ts +0 -12
  179. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
  180. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
  181. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
  182. package/lib/plugins/app-types/hooks/useStore/index.d.ts +0 -6
  183. package/lib/plugins/app-types/index.d.ts +0 -6
  184. package/lib/plugins/app-types/indexDB/index.d.ts +0 -178
  185. package/lib/plugins/app-types/locales/en.d.ts +0 -3
  186. package/lib/plugins/app-types/locales/index.d.ts +0 -37
  187. package/lib/plugins/app-types/locales/original.d.ts +0 -3
  188. package/lib/plugins/app-types/locales/type.d.ts +0 -19
  189. package/lib/plugins/app-types/locales/zh-CN.d.ts +0 -3
  190. package/lib/plugins/app-types/locales/zh-HK.d.ts +0 -3
  191. package/lib/plugins/app-types/logger/feishu.d.ts +0 -11
  192. package/lib/plugins/app-types/logger/index.d.ts +0 -122
  193. package/lib/plugins/app-types/menuManager/hooks.d.ts +0 -17
  194. package/lib/plugins/app-types/menuManager/index.d.ts +0 -28
  195. package/lib/plugins/app-types/models/global.d.ts +0 -32
  196. package/lib/plugins/app-types/models/index.d.ts +0 -45
  197. package/lib/plugins/app-types/models/type.d.ts +0 -2
  198. package/lib/plugins/app-types/package.json +0 -15
  199. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  200. package/lib/plugins/app-types/pubsub/example.d.ts +0 -5
  201. package/lib/plugins/app-types/pubsub/index.d.ts +0 -63
  202. package/lib/plugins/app-types/request/cache.d.ts +0 -46
  203. package/lib/plugins/app-types/request/cancelToken.d.ts +0 -38
  204. package/lib/plugins/app-types/request/config.d.ts +0 -3
  205. package/lib/plugins/app-types/request/constants.d.ts +0 -2
  206. package/lib/plugins/app-types/request/index.d.ts +0 -24
  207. package/lib/plugins/app-types/request/pisell2Request.d.ts +0 -6
  208. package/lib/plugins/app-types/request/type.d.ts +0 -41
  209. package/lib/plugins/app-types/request/utils.d.ts +0 -46
  210. package/lib/plugins/app-types/routes/config.d.ts +0 -7
  211. package/lib/plugins/app-types/routes/index.d.ts +0 -28
  212. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
  213. package/lib/plugins/app-types/socket/components/index.d.ts +0 -2
  214. package/lib/plugins/app-types/socket/constants.d.ts +0 -33
  215. package/lib/plugins/app-types/socket/events.d.ts +0 -31
  216. package/lib/plugins/app-types/socket/heartbeat.d.ts +0 -66
  217. package/lib/plugins/app-types/socket/index.d.ts +0 -61
  218. package/lib/plugins/app-types/socket/monitor.d.ts +0 -169
  219. package/lib/plugins/app-types/socket/reconnect.d.ts +0 -61
  220. package/lib/plugins/app-types/socket/socket.d.ts +0 -129
  221. package/lib/plugins/app-types/socket/types.d.ts +0 -85
  222. package/lib/plugins/app-types/storage/index.d.ts +0 -17
  223. package/lib/plugins/app-types/tasks/index.d.ts +0 -77
  224. package/lib/plugins/app-types/tasks/type.d.ts +0 -62
  225. package/lib/plugins/app-types/tasks/useTasks.d.ts +0 -5
  226. package/lib/plugins/app-types/type.d.ts +0 -2
  227. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
  228. package/lib/plugins/app-types/variables/config.d.ts +0 -3
  229. package/lib/plugins/app-types/variables/index.d.ts +0 -6
  230. package/lib/plugins/app-types/variables/type.d.ts +0 -2
  231. package/lib/plugins/app-types/website/index.d.ts +0 -6
  232. package/lib/plugins/app.d.ts +0 -8
  233. package/lib/plugins/app.js +0 -17
  234. package/lib/solution/BookingTicket/index.d.ts +0 -172
  235. package/lib/solution/BookingTicket/index.js +0 -399
  236. package/lib/solution/BookingTicket/types.d.ts +0 -68
  237. package/lib/solution/BookingTicket/types.js +0 -72
  238. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  239. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
  240. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
  241. package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -125
  242. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -81
  243. package/lib/solution/BookingTicket/utils/scan/index.js +0 -210
  244. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  245. package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
  246. package/lib/solution/Checkout/appointmentDemo.json +0 -1
  247. package/lib/solution/Checkout/index.d.ts +0 -181
  248. package/lib/solution/Checkout/index.js +0 -864
  249. package/lib/solution/Checkout/types.d.ts +0 -550
  250. package/lib/solution/Checkout/types.js +0 -75
  251. package/lib/solution/Checkout/utils/index.d.ts +0 -73
  252. package/lib/solution/Checkout/utils/index.js +0 -266
  253. package/lib/utils/task.d.ts +0 -40
  254. package/lib/utils/task.js +0 -109
  255. package/lib/utils/watch.d.ts +0 -102
  256. package/lib/utils/watch.js +0 -217
@@ -1,697 +0,0 @@
1
- var _excluded = ["skip", "num", "search"],
2
- _excluded2 = ["skip", "num"];
3
- 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); }
4
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
- 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."); }
6
- 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); }
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
- 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; }
10
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
- 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; }
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 _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; }
15
- 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); } }
16
- 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); }); }; }
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
- 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); } }
19
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
- 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); }
21
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
- 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); }; }
23
- 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); }
24
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
- 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; } }
26
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
- 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; }
28
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
29
- 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); }
30
- import { cloneDeep } from 'lodash-es';
31
- import { BaseModule } from "../BaseModule";
32
- import { CustomerHooks } from "./types";
33
- import { DEFAULT_CUSTOMER, DEFAULT_PAGE_SIZE, SORT_BY } from "./constants";
34
- export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
35
- _inherits(CustomerModule, _BaseModule);
36
- var _super = _createSuper(CustomerModule);
37
- function CustomerModule(name, version) {
38
- var _this;
39
- _classCallCheck(this, CustomerModule);
40
- _this = _super.call(this, name, version);
41
- _defineProperty(_assertThisInitialized(_this), "defaultName", 'customer');
42
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
43
- _defineProperty(_assertThisInitialized(_this), "store", {
44
- customerList: [],
45
- selectedCustomer: null,
46
- total: 0,
47
- currentPage: 1,
48
- pageSize: DEFAULT_PAGE_SIZE,
49
- loading: false,
50
- error: null,
51
- hasMore: true,
52
- loadingMore: false,
53
- searchParams: {}
54
- });
55
- _defineProperty(_assertThisInitialized(_this), "request", void 0);
56
- _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
57
- _defineProperty(_assertThisInitialized(_this), "openCache", false);
58
- _defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
59
- return _this;
60
- }
61
- _createClass(CustomerModule, [{
62
- key: "initialize",
63
- value: function () {
64
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
65
- var _options$initialState, _options$initialState2, _options$initialState3, _options$initialState4, _options$initialState5, _options$initialState6, _options$initialState7, _options$initialState8, _options$initialState9, _options$initialState10, _options$initialState11, _options$otherParams, _options$otherParams2;
66
- var customerList;
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 === null || options === void 0 ? void 0 : options.store;
72
- this.request = this.core.getPlugin('request');
73
-
74
- // 初始化状态
75
- if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.customerList)) {
76
- customerList = cloneDeep(options.initialState.customerList || []);
77
- this.store.customerList = customerList;
78
- } else {
79
- this.store.customerList = [];
80
- }
81
- if (options !== null && options !== void 0 && (_options$initialState2 = options.initialState) !== null && _options$initialState2 !== void 0 && _options$initialState2.selectedCustomer) {
82
- this.store.selectedCustomer = cloneDeep(options.initialState.selectedCustomer);
83
- } else {
84
- this.store.selectedCustomer = null;
85
- }
86
- if (typeof (options === null || options === void 0 || (_options$initialState3 = options.initialState) === null || _options$initialState3 === void 0 ? void 0 : _options$initialState3.total) === 'number') {
87
- this.store.total = options.initialState.total;
88
- } else {
89
- this.store.total = 0;
90
- }
91
- if (typeof (options === null || options === void 0 || (_options$initialState4 = options.initialState) === null || _options$initialState4 === void 0 ? void 0 : _options$initialState4.currentPage) === 'number') {
92
- this.store.currentPage = options.initialState.currentPage;
93
- } else {
94
- this.store.currentPage = 1;
95
- }
96
- if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number') {
97
- this.store.pageSize = options.initialState.pageSize;
98
- } else {
99
- this.store.pageSize = DEFAULT_PAGE_SIZE;
100
- }
101
-
102
- // 初始化滚动加载相关状态
103
- this.store.hasMore = (_options$initialState6 = options === null || options === void 0 || (_options$initialState7 = options.initialState) === null || _options$initialState7 === void 0 ? void 0 : _options$initialState7.hasMore) !== null && _options$initialState6 !== void 0 ? _options$initialState6 : true;
104
- this.store.loadingMore = (_options$initialState8 = options === null || options === void 0 || (_options$initialState9 = options.initialState) === null || _options$initialState9 === void 0 ? void 0 : _options$initialState9.loadingMore) !== null && _options$initialState8 !== void 0 ? _options$initialState8 : false;
105
- this.store.searchParams = (_options$initialState10 = options === null || options === void 0 || (_options$initialState11 = options.initialState) === null || _options$initialState11 === void 0 ? void 0 : _options$initialState11.searchParams) !== null && _options$initialState10 !== void 0 ? _options$initialState10 : {};
106
-
107
- // 缓存配置
108
- if (options !== null && options !== void 0 && (_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
109
- this.openCache = options.otherParams.openCache;
110
- this.cacheId = options.otherParams.cacheId;
111
- }
112
- if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
113
- this.fatherModule = options.otherParams.fatherModule;
114
- }
115
- case 13:
116
- case "end":
117
- return _context.stop();
118
- }
119
- }, _callee, this);
120
- }));
121
- function initialize(_x, _x2) {
122
- return _initialize.apply(this, arguments);
123
- }
124
- return initialize;
125
- }()
126
- /**
127
- * 获取客户列表数据(内部方法)
128
- * @param params 查询参数
129
- * @returns API响应数据
130
- */
131
- }, {
132
- key: "fetchCustomerListData",
133
- value: (function () {
134
- var _fetchCustomerListData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
135
- var _res$data, _res$data2;
136
- var params,
137
- url,
138
- _params$skip,
139
- skip,
140
- _params$num,
141
- num,
142
- search,
143
- otherParams,
144
- queryParams,
145
- res,
146
- _args2 = arguments;
147
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
148
- while (1) switch (_context2.prev = _context2.next) {
149
- case 0:
150
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
151
- url = '/customer/select-list';
152
- _params$skip = params.skip, skip = _params$skip === void 0 ? 1 : _params$skip, _params$num = params.num, num = _params$num === void 0 ? DEFAULT_PAGE_SIZE : _params$num, search = params.search, otherParams = _objectWithoutProperties(params, _excluded);
153
- queryParams = _objectSpread(_objectSpread({
154
- skip: skip,
155
- num: num,
156
- sort_by: SORT_BY,
157
- with: ['latestWalletDetail.wallet'],
158
- search_wallet_flag: 1,
159
- search_wallet_pass_flag: 1
160
- }, search && {
161
- search: search
162
- }), otherParams);
163
- _context2.next = 6;
164
- return this.request.get(url, queryParams);
165
- case 6:
166
- res = _context2.sent;
167
- if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
168
- _context2.next = 9;
169
- break;
170
- }
171
- throw new Error(res === null || res === void 0 ? void 0 : res.message);
172
- case 9:
173
- return _context2.abrupt("return", {
174
- customerList: (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [],
175
- total: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.count) || 0,
176
- page: skip,
177
- pageSize: num
178
- });
179
- case 10:
180
- case "end":
181
- return _context2.stop();
182
- }
183
- }, _callee2, this);
184
- }));
185
- function fetchCustomerListData() {
186
- return _fetchCustomerListData.apply(this, arguments);
187
- }
188
- return fetchCustomerListData;
189
- }()
190
- /**
191
- * 处理客户列表操作的错误(内部方法)
192
- * @param error 错误对象
193
- * @param operation 操作名称
194
- */
195
- )
196
- }, {
197
- key: "handleCustomerListError",
198
- value: (function () {
199
- var _handleCustomerListError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error, operation) {
200
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
201
- while (1) switch (_context3.prev = _context3.next) {
202
- case 0:
203
- console.error("Failed to ".concat(operation, ":"), error);
204
- this.store.error = error instanceof Error ? error.message : "Failed to ".concat(operation);
205
- _context3.next = 4;
206
- return this.core.effects.emit(CustomerHooks.OnCustomerListError, this.store.error);
207
- case 4:
208
- case "end":
209
- return _context3.stop();
210
- }
211
- }, _callee3, this);
212
- }));
213
- function handleCustomerListError(_x3, _x4) {
214
- return _handleCustomerListError.apply(this, arguments);
215
- }
216
- return handleCustomerListError;
217
- }()
218
- /**
219
- * 获取客户列表
220
- * @param params 查询参数
221
- * @returns 客户列表响应
222
- */
223
- )
224
- }, {
225
- key: "getCustomerList",
226
- value: (function () {
227
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
228
- var params,
229
- _yield$this$fetchCust,
230
- customerList,
231
- total,
232
- page,
233
- pageSize,
234
- skip,
235
- num,
236
- searchParams,
237
- response,
238
- _args4 = arguments;
239
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
240
- while (1) switch (_context4.prev = _context4.next) {
241
- case 0:
242
- params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
243
- _context4.prev = 1;
244
- this.store.loading = true;
245
- this.store.error = null;
246
- _context4.next = 6;
247
- return this.fetchCustomerListData(params);
248
- case 6:
249
- _yield$this$fetchCust = _context4.sent;
250
- customerList = _yield$this$fetchCust.customerList;
251
- total = _yield$this$fetchCust.total;
252
- page = _yield$this$fetchCust.page;
253
- pageSize = _yield$this$fetchCust.pageSize;
254
- // 保存搜索条件(排除skip和num)
255
- skip = params.skip, num = params.num, searchParams = _objectWithoutProperties(params, _excluded2);
256
- this.store.searchParams = cloneDeep(searchParams);
257
-
258
- // 更新分页状态
259
- this.store.currentPage = page;
260
- this.store.pageSize = pageSize;
261
- this.store.total = total;
262
-
263
- // 计算是否还有更多数据
264
- this.store.hasMore = page * pageSize < total;
265
-
266
- // 设置客户列表(替换模式)
267
- this.store.customerList = cloneDeep(customerList);
268
- _context4.next = 20;
269
- return this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
270
- case 20:
271
- // 触发分页变化事件
272
- this.triggerPaginationChange({
273
- page: page,
274
- pageSize: pageSize,
275
- total: total,
276
- totalPages: Math.ceil(total / pageSize)
277
- });
278
- response = {
279
- list: customerList,
280
- total: total,
281
- page: page,
282
- pageSize: pageSize
283
- };
284
- return _context4.abrupt("return", response);
285
- case 25:
286
- _context4.prev = 25;
287
- _context4.t0 = _context4["catch"](1);
288
- _context4.next = 29;
289
- return this.handleCustomerListError(_context4.t0, 'fetch customer list');
290
- case 29:
291
- throw _context4.t0;
292
- case 30:
293
- _context4.prev = 30;
294
- this.store.loading = false;
295
- this.storeChange();
296
- return _context4.finish(30);
297
- case 34:
298
- case "end":
299
- return _context4.stop();
300
- }
301
- }, _callee4, this, [[1, 25, 30, 34]]);
302
- }));
303
- function getCustomerList() {
304
- return _getCustomerList.apply(this, arguments);
305
- }
306
- return getCustomerList;
307
- }()
308
- /**
309
- * 设置客户列表
310
- * @param customers 客户列表
311
- * @param total 总数
312
- */
313
- )
314
- }, {
315
- key: "setCustomerList",
316
- value: function setCustomerList(customers, total) {
317
- this.store.customerList = cloneDeep(customers);
318
- if (typeof total === 'number') {
319
- this.store.total = total;
320
- }
321
- this.storeChange();
322
- }
323
-
324
- /**
325
- * 设置当前选择的客户
326
- * @param customer 选择的客户
327
- */
328
- }, {
329
- key: "setSelectedCustomer",
330
- value: function setSelectedCustomer(customer) {
331
- this.store.selectedCustomer = !customer ? DEFAULT_CUSTOMER : cloneDeep(customer);
332
- this.core.effects.emit(CustomerHooks.OnCustomerSelected, this.store.selectedCustomer);
333
- this.storeChange();
334
- }
335
-
336
- /**
337
- * 获取当前选择的客户
338
- * @returns 当前选择的客户
339
- */
340
- }, {
341
- key: "getSelectedCustomer",
342
- value: function getSelectedCustomer() {
343
- return this.store.selectedCustomer;
344
- }
345
-
346
- /**
347
- * 获取客户列表
348
- * @returns 客户列表
349
- */
350
- }, {
351
- key: "getCustomers",
352
- value: function getCustomers() {
353
- return _toConsumableArray(this.store.customerList);
354
- }
355
-
356
- /**
357
- * 根据ID查找客户
358
- * @param id 客户ID
359
- * @returns 客户信息
360
- */
361
- }, {
362
- key: "getCustomerById",
363
- value: function getCustomerById(id) {
364
- return this.store.customerList.find(function (customer) {
365
- return customer.id === id;
366
- }) || null;
367
- }
368
-
369
- /**
370
- * 清空客户列表
371
- */
372
- }, {
373
- key: "clearCustomers",
374
- value: function clearCustomers() {
375
- this.store.customerList = [];
376
- this.store.selectedCustomer = null;
377
- this.store.total = 0;
378
- this.store.currentPage = 1;
379
- this.store.pageSize = DEFAULT_PAGE_SIZE;
380
- this.store.hasMore = true;
381
- this.store.loadingMore = false;
382
- this.store.searchParams = {};
383
- this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
384
- this.storeChange();
385
- }
386
-
387
- /**
388
- * 添加客户到列表第一位
389
- * @param customer 要添加的客户信息
390
- */
391
- }, {
392
- key: "addCustomerToFirst",
393
- value: function addCustomerToFirst(customer) {
394
- // 深拷贝客户对象以避免引用问题
395
- var newCustomer = cloneDeep(customer);
396
-
397
- // 将客户添加到列表第一位
398
- this.store.customerList = [newCustomer].concat(_toConsumableArray(this.store.customerList));
399
-
400
- // 更新总数
401
- this.store.total += 1;
402
-
403
- // 触发客户列表更新事件
404
- this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
405
-
406
- // 保存状态变化
407
- this.storeChange();
408
- }
409
-
410
- /**
411
- * 获取当前状态
412
- * @returns 当前状态
413
- */
414
- }, {
415
- key: "getState",
416
- value: function getState() {
417
- return cloneDeep(this.store);
418
- }
419
-
420
- /**
421
- * 获取分页信息
422
- * @returns 分页信息
423
- */
424
- }, {
425
- key: "getPaginationInfo",
426
- value: function getPaginationInfo() {
427
- return {
428
- page: this.store.currentPage,
429
- pageSize: this.store.pageSize,
430
- total: this.store.total,
431
- totalPages: Math.ceil(this.store.total / this.store.pageSize)
432
- };
433
- }
434
-
435
- /**
436
- * 触发分页变化事件
437
- * @param pagination 分页信息
438
- */
439
- }, {
440
- key: "triggerPaginationChange",
441
- value: function triggerPaginationChange(pagination) {
442
- this.core.effects.emit(CustomerHooks.OnPaginationChange, pagination);
443
- }
444
-
445
- /**
446
- * 设置分页信息
447
- * @param page 页码
448
- * @param pageSize 每页数量
449
- */
450
- }, {
451
- key: "setPaginationInfo",
452
- value: function setPaginationInfo(page, pageSize) {
453
- this.store.currentPage = page;
454
- this.store.pageSize = pageSize;
455
- this.storeChange();
456
-
457
- // 触发分页变化事件
458
- this.triggerPaginationChange({
459
- page: page,
460
- pageSize: pageSize,
461
- total: this.store.total,
462
- totalPages: Math.ceil(this.store.total / pageSize)
463
- });
464
- }
465
-
466
- /**
467
- * 便捷方法:切换分页并自动获取数据
468
- * @param page 页码
469
- * @param pageSize 每页数量(可选,不传则使用当前pageSize)
470
- * @returns 客户列表响应
471
- */
472
- }, {
473
- key: "changeCustomerPage",
474
- value: (function () {
475
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
476
- var targetPageSize, skip, num;
477
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
478
- while (1) switch (_context5.prev = _context5.next) {
479
- case 0:
480
- targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
481
- this.setPaginationInfo(page, targetPageSize);
482
-
483
- // skip直接使用page,num使用pageSize
484
- skip = page;
485
- num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
486
- _context5.next = 6;
487
- return this.getCustomerList(_objectSpread({
488
- skip: skip,
489
- num: num
490
- }, this.store.searchParams));
491
- case 6:
492
- return _context5.abrupt("return", _context5.sent);
493
- case 7:
494
- case "end":
495
- return _context5.stop();
496
- }
497
- }, _callee5, this);
498
- }));
499
- function changeCustomerPage(_x5, _x6) {
500
- return _changeCustomerPage.apply(this, arguments);
501
- }
502
- return changeCustomerPage;
503
- }()
504
- /**
505
- * 滚动加载更多客户数据 - 数据会追加到现有列表中
506
- * @returns 客户列表响应
507
- */
508
- )
509
- }, {
510
- key: "loadMoreCustomers",
511
- value: (function () {
512
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
513
- var nextPage, _yield$this$fetchCust2, newCustomers, total, page, pageSize, updatedCustomerList, response;
514
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
515
- while (1) switch (_context6.prev = _context6.next) {
516
- case 0:
517
- if (!(!this.store.hasMore || this.store.loadingMore)) {
518
- _context6.next = 2;
519
- break;
520
- }
521
- return _context6.abrupt("return", {
522
- list: [],
523
- total: this.store.total,
524
- page: this.store.currentPage,
525
- pageSize: this.store.pageSize
526
- });
527
- case 2:
528
- // 计算下一页
529
- nextPage = this.store.currentPage + 1;
530
- _context6.prev = 3;
531
- this.store.loadingMore = true;
532
- this.store.error = null;
533
-
534
- // 使用公共方法获取数据,传入存储的搜索条件
535
- _context6.next = 8;
536
- return this.fetchCustomerListData(_objectSpread({
537
- skip: nextPage,
538
- num: this.store.pageSize
539
- }, this.store.searchParams));
540
- case 8:
541
- _yield$this$fetchCust2 = _context6.sent;
542
- newCustomers = _yield$this$fetchCust2.customerList;
543
- total = _yield$this$fetchCust2.total;
544
- page = _yield$this$fetchCust2.page;
545
- pageSize = _yield$this$fetchCust2.pageSize;
546
- // 将新数据追加到现有列表(追加模式)
547
- updatedCustomerList = [].concat(_toConsumableArray(this.store.customerList), _toConsumableArray(cloneDeep(newCustomers))); // 更新状态
548
- this.store.customerList = updatedCustomerList;
549
- this.store.currentPage = page;
550
- this.store.total = total;
551
- this.store.hasMore = page * pageSize < total;
552
-
553
- // 触发滚动加载特定事件
554
- _context6.next = 20;
555
- return this.core.effects.emit(CustomerHooks.OnScrollLoadMore, {
556
- newCustomers: newCustomers,
557
- allCustomers: this.store.customerList,
558
- currentPage: page,
559
- hasMore: this.store.hasMore
560
- });
561
- case 20:
562
- _context6.next = 22;
563
- return this.core.effects.emit(CustomerHooks.OnCustomerListUpdate, this.store);
564
- case 22:
565
- // 触发分页变化事件
566
- this.triggerPaginationChange({
567
- page: page,
568
- pageSize: pageSize,
569
- total: total,
570
- totalPages: Math.ceil(total / pageSize)
571
- });
572
- response = {
573
- list: newCustomers,
574
- // 返回新加载的数据
575
- total: total,
576
- page: page,
577
- pageSize: pageSize
578
- };
579
- return _context6.abrupt("return", response);
580
- case 27:
581
- _context6.prev = 27;
582
- _context6.t0 = _context6["catch"](3);
583
- _context6.next = 31;
584
- return this.handleCustomerListError(_context6.t0, 'load more customers');
585
- case 31:
586
- throw _context6.t0;
587
- case 32:
588
- _context6.prev = 32;
589
- this.store.loadingMore = false;
590
- this.storeChange();
591
- return _context6.finish(32);
592
- case 36:
593
- case "end":
594
- return _context6.stop();
595
- }
596
- }, _callee6, this, [[3, 27, 32, 36]]);
597
- }));
598
- function loadMoreCustomers() {
599
- return _loadMoreCustomers.apply(this, arguments);
600
- }
601
- return loadMoreCustomers;
602
- }()
603
- /**
604
- * 重置并重新开始滚动加载
605
- * @param params 查询参数
606
- * @returns 客户列表响应
607
- */
608
- )
609
- }, {
610
- key: "resetAndLoadCustomers",
611
- value: (function () {
612
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
613
- var params,
614
- resetParams,
615
- response,
616
- _args7 = arguments;
617
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
618
- while (1) switch (_context7.prev = _context7.next) {
619
- case 0:
620
- params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
621
- // 重置状态
622
- this.store.customerList = [];
623
- this.store.currentPage = 1;
624
- this.store.hasMore = true;
625
- this.store.loadingMore = false;
626
-
627
- // 使用第一页参数
628
- resetParams = _objectSpread(_objectSpread({}, params), {}, {
629
- skip: 1,
630
- num: params.num || this.store.pageSize
631
- }); // 调用普通的获取列表方法
632
- _context7.next = 8;
633
- return this.getCustomerList(resetParams);
634
- case 8:
635
- response = _context7.sent;
636
- _context7.next = 11;
637
- return this.core.effects.emit(CustomerHooks.OnScrollLoadComplete, {
638
- customers: this.store.customerList,
639
- total: this.store.total,
640
- hasMore: this.store.hasMore
641
- });
642
- case 11:
643
- return _context7.abrupt("return", response);
644
- case 12:
645
- case "end":
646
- return _context7.stop();
647
- }
648
- }, _callee7, this);
649
- }));
650
- function resetAndLoadCustomers() {
651
- return _resetAndLoadCustomers.apply(this, arguments);
652
- }
653
- return resetAndLoadCustomers;
654
- }()
655
- /**
656
- * 检查是否还有更多数据可以加载
657
- * @returns 是否还有更多数据
658
- */
659
- )
660
- }, {
661
- key: "hasMoreCustomers",
662
- value: function hasMoreCustomers() {
663
- return this.store.hasMore && !this.store.loadingMore;
664
- }
665
-
666
- /**
667
- * 获取当前的搜索条件
668
- * @returns 当前搜索条件
669
- */
670
- }, {
671
- key: "getCurrentSearchParams",
672
- value: function getCurrentSearchParams() {
673
- return cloneDeep(this.store.searchParams);
674
- }
675
-
676
- /**
677
- * 缓存状态变化
678
- */
679
- }, {
680
- key: "storeChange",
681
- value: function storeChange() {
682
- if (this.openCache) {
683
- var store = cloneDeep(this.store);
684
- this.checkSaveCache({
685
- cacheId: this.cacheId,
686
- fatherModule: this.fatherModule,
687
- store: store,
688
- cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize', 'hasMore', 'loadingMore', 'searchParams']
689
- });
690
- }
691
- }
692
- }]);
693
- return CustomerModule;
694
- }(BaseModule);
695
-
696
- // 导出类型和模块
697
- export * from "./types";