@cecee/document-flip-book 1.0.18 → 1.0.20

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 (91) hide show
  1. package/dist/cjs/AccountingBook/assets/active-line.png +0 -0
  2. package/dist/cjs/AccountingBook/assets/default-line.png +0 -0
  3. package/dist/cjs/AccountingBook/assets/filp-bg.png +0 -0
  4. package/dist/cjs/AccountingBook/components/AccountingVoucher/index.d.ts +26 -0
  5. package/dist/cjs/AccountingBook/components/AccountingVoucher/index.js +398 -0
  6. package/dist/cjs/AccountingBook/components/AccountingVoucher/index.less +231 -0
  7. package/dist/cjs/AccountingBook/components/ExportModal.d.ts +10 -0
  8. package/dist/cjs/AccountingBook/components/ExportModal.js +96 -0
  9. package/dist/cjs/AccountingBook/components/FilpPage.d.ts +7 -0
  10. package/dist/cjs/AccountingBook/components/FilpPage.js +39 -0
  11. package/dist/cjs/AccountingBook/components/HeaderBar.d.ts +28 -0
  12. package/dist/cjs/AccountingBook/components/HeaderBar.js +245 -0
  13. package/dist/cjs/AccountingBook/components/ImagePageRenderer.d.ts +11 -0
  14. package/dist/cjs/AccountingBook/components/ImagePageRenderer.js +91 -0
  15. package/dist/cjs/AccountingBook/components/LoadingComponent.d.ts +7 -0
  16. package/dist/cjs/AccountingBook/components/LoadingComponent.js +54 -0
  17. package/dist/cjs/AccountingBook/components/PDFPageRenderer.d.ts +13 -0
  18. package/dist/cjs/AccountingBook/components/PDFPageRenderer.js +259 -0
  19. package/dist/cjs/AccountingBook/components/index.less +6 -0
  20. package/dist/cjs/AccountingBook/constants.d.ts +11 -0
  21. package/dist/cjs/AccountingBook/constants.js +25 -0
  22. package/dist/cjs/AccountingBook/hooks/useAmountSearch.d.ts +24 -0
  23. package/dist/cjs/AccountingBook/hooks/useAmountSearch.js +165 -0
  24. package/dist/cjs/AccountingBook/hooks/usePageFlip.d.ts +15 -0
  25. package/dist/cjs/AccountingBook/hooks/usePageFlip.js +67 -0
  26. package/dist/cjs/AccountingBook/index.d.ts +29 -1
  27. package/dist/cjs/AccountingBook/index.js +1163 -7
  28. package/dist/cjs/AccountingBook/index.less +188 -0
  29. package/dist/cjs/AccountingBook/types.d.ts +84 -0
  30. package/dist/cjs/AccountingBook/types.js +5 -0
  31. package/dist/cjs/AccountingBook/utils/canvasUtils.d.ts +51 -0
  32. package/dist/cjs/AccountingBook/utils/canvasUtils.js +499 -0
  33. package/dist/cjs/AccountingBook/utils/html.d.ts +9 -0
  34. package/dist/cjs/AccountingBook/utils/html.js +97 -0
  35. package/dist/cjs/AccountingBook/utils/utils.d.ts +38 -0
  36. package/dist/cjs/AccountingBook/utils/utils.js +204 -0
  37. package/dist/cjs/DocumentFlipBook/ExportModal.d.ts +1 -1
  38. package/dist/cjs/DocumentFlipBook/ExportModal.js +1 -1
  39. package/dist/cjs/DocumentFlipBook/HeaderBar.d.ts +2 -1
  40. package/dist/cjs/DocumentFlipBook/HeaderBar.js +13 -11
  41. package/dist/cjs/DocumentFlipBook/SideTabs.js +111 -6
  42. package/dist/cjs/DocumentFlipBook/index.d.ts +1 -0
  43. package/dist/cjs/DocumentFlipBook/index.js +9 -6
  44. package/dist/cjs/DocumentFlipBook/index.less +239 -12
  45. package/dist/cjs/declarations.d.ts +21 -0
  46. package/dist/esm/AccountingBook/assets/active-line.png +0 -0
  47. package/dist/esm/AccountingBook/assets/default-line.png +0 -0
  48. package/dist/esm/AccountingBook/assets/filp-bg.png +0 -0
  49. package/dist/esm/AccountingBook/components/AccountingVoucher/index.d.ts +26 -0
  50. package/dist/esm/AccountingBook/components/AccountingVoucher/index.js +391 -0
  51. package/dist/esm/AccountingBook/components/AccountingVoucher/index.less +231 -0
  52. package/dist/esm/AccountingBook/components/ExportModal.d.ts +10 -0
  53. package/dist/esm/AccountingBook/components/ExportModal.js +88 -0
  54. package/dist/esm/AccountingBook/components/FilpPage.d.ts +7 -0
  55. package/dist/esm/AccountingBook/components/FilpPage.js +33 -0
  56. package/dist/esm/AccountingBook/components/HeaderBar.d.ts +28 -0
  57. package/dist/esm/AccountingBook/components/HeaderBar.js +236 -0
  58. package/dist/esm/AccountingBook/components/ImagePageRenderer.d.ts +11 -0
  59. package/dist/esm/AccountingBook/components/ImagePageRenderer.js +85 -0
  60. package/dist/esm/AccountingBook/components/LoadingComponent.d.ts +7 -0
  61. package/dist/esm/AccountingBook/components/LoadingComponent.js +48 -0
  62. package/dist/esm/AccountingBook/components/PDFPageRenderer.d.ts +13 -0
  63. package/dist/esm/AccountingBook/components/PDFPageRenderer.js +252 -0
  64. package/dist/esm/AccountingBook/components/index.less +6 -0
  65. package/dist/esm/AccountingBook/constants.d.ts +11 -0
  66. package/dist/esm/AccountingBook/constants.js +17 -0
  67. package/dist/esm/AccountingBook/hooks/useAmountSearch.d.ts +24 -0
  68. package/dist/esm/AccountingBook/hooks/useAmountSearch.js +158 -0
  69. package/dist/esm/AccountingBook/hooks/usePageFlip.d.ts +15 -0
  70. package/dist/esm/AccountingBook/hooks/usePageFlip.js +61 -0
  71. package/dist/esm/AccountingBook/index.d.ts +29 -1
  72. package/dist/esm/AccountingBook/index.js +1162 -6
  73. package/dist/esm/AccountingBook/index.less +188 -0
  74. package/dist/esm/AccountingBook/types.d.ts +84 -0
  75. package/dist/esm/AccountingBook/types.js +1 -0
  76. package/dist/esm/AccountingBook/utils/canvasUtils.d.ts +51 -0
  77. package/dist/esm/AccountingBook/utils/canvasUtils.js +493 -0
  78. package/dist/esm/AccountingBook/utils/html.d.ts +9 -0
  79. package/dist/esm/AccountingBook/utils/html.js +89 -0
  80. package/dist/esm/AccountingBook/utils/utils.d.ts +38 -0
  81. package/dist/esm/AccountingBook/utils/utils.js +195 -0
  82. package/dist/esm/DocumentFlipBook/ExportModal.d.ts +1 -1
  83. package/dist/esm/DocumentFlipBook/ExportModal.js +1 -1
  84. package/dist/esm/DocumentFlipBook/HeaderBar.d.ts +2 -1
  85. package/dist/esm/DocumentFlipBook/HeaderBar.js +13 -11
  86. package/dist/esm/DocumentFlipBook/SideTabs.js +110 -5
  87. package/dist/esm/DocumentFlipBook/index.d.ts +1 -0
  88. package/dist/esm/DocumentFlipBook/index.js +9 -6
  89. package/dist/esm/DocumentFlipBook/index.less +239 -12
  90. package/dist/esm/declarations.d.ts +21 -0
  91. package/package.json +8 -2
@@ -1,18 +1,1174 @@
1
1
  "use strict";
2
2
 
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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ exports.default = exports.AccountingBook = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactPageflip = _interopRequireDefault(require("react-pageflip"));
10
+ var _antd = require("antd");
11
+ var _reactPdf = require("react-pdf");
12
+ var _moment = _interopRequireDefault(require("moment"));
13
+ var _jspdf = _interopRequireDefault(require("jspdf"));
14
+ var _jszip = _interopRequireDefault(require("jszip"));
15
+ var _utils = require("./utils/utils");
16
+ require("./index.less");
17
+ require("react-pdf/dist/Page/AnnotationLayer.css");
18
+ require("react-pdf/dist/Page/TextLayer.css");
19
+ var _FilpPage = require("./components/FilpPage");
20
+ var _PDFPageRenderer = require("./components/PDFPageRenderer");
21
+ var _ImagePageRenderer = require("./components/ImagePageRenderer");
22
+ var _AccountingVoucher = _interopRequireDefault(require("./components/AccountingVoucher"));
23
+ var _HeaderBar = _interopRequireDefault(require("./components/HeaderBar"));
24
+ var _constants = require("./constants");
25
+ var _LoadingComponent = require("./components/LoadingComponent");
26
+ var _canvasUtils = require("./utils/canvasUtils");
27
+ var _usePageFlip2 = require("./hooks/usePageFlip");
28
+ var _useAmountSearch2 = require("./hooks/useAmountSearch");
8
29
  var _jsxRuntime = require("react/jsx-runtime");
9
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- var AccountingBook = function AccountingBook() {
31
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
32
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
33
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
34
+ 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; }
35
+ 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; }
36
+ 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; }
37
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
38
+ 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); }
39
+ 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; }
40
+ 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); } }
41
+ 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); }); }; }
42
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
43
+ 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."); }
44
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
45
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
46
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
47
+ 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."); }
48
+ 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); }
49
+ 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; }
50
+ 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; } }
51
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /*
52
+ * @Author: Geralt Rivia
53
+ * @Date: 2025-02-20 13:39:30
54
+ * @LastEditors: Geralt Rivia
55
+ * @LastEditTime: 2025-12-31 10:40:27
56
+ * @Description: 记帐凭证详情组件
57
+ */
58
+ _reactPdf.pdfjs.GlobalWorkerOptions.workerSrc = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(_reactPdf.pdfjs.version, "/pdf.worker.min.js");
59
+ var AccountingBook = exports.AccountingBook = function AccountingBook(_ref) {
60
+ var data = _ref.data,
61
+ externalLoading = _ref.loading,
62
+ externalLoadingMessage = _ref.loadingMessage,
63
+ externalPdfLoading = _ref.pdfLoading,
64
+ companyInfo = _ref.companyInfo,
65
+ baseVoucherInfo = _ref.baseVoucherInfo,
66
+ onUnbinding = _ref.onUnbinding,
67
+ onLoadMore = _ref.onLoadMore,
68
+ ledgerBookListApi = _ref.ledgerBookListApi,
69
+ externalOnRefresh = _ref.onRefresh,
70
+ _ref$iconColor = _ref.iconColor,
71
+ iconColor = _ref$iconColor === void 0 ? '#0064ff' : _ref$iconColor,
72
+ _ref$themeColor = _ref.themeColor,
73
+ themeColor = _ref$themeColor === void 0 ? '#4Baae3' : _ref$themeColor;
74
+ var _useState = (0, _react.useState)([]),
75
+ _useState2 = _slicedToArray(_useState, 2),
76
+ pages = _useState2[0],
77
+ setPages = _useState2[1];
78
+ var _useState3 = (0, _react.useState)(0),
79
+ _useState4 = _slicedToArray(_useState3, 2),
80
+ currentPageIndex = _useState4[0],
81
+ setCurrentPageIndex = _useState4[1];
82
+ var _useState5 = (0, _react.useState)(false),
83
+ _useState6 = _slicedToArray(_useState5, 2),
84
+ loading = _useState6[0],
85
+ setLoading = _useState6[1];
86
+ var _useState7 = (0, _react.useState)(false),
87
+ _useState8 = _slicedToArray(_useState7, 2),
88
+ pdfLoading = _useState8[0],
89
+ setPdfLoading = _useState8[1];
90
+ var _useState9 = (0, _react.useState)(''),
91
+ _useState10 = _slicedToArray(_useState9, 2),
92
+ loadingMessage = _useState10[0],
93
+ setLoadingMessage = _useState10[1];
94
+ var bookRef = (0, _react.useRef)(null);
95
+ var _useState11 = (0, _react.useState)(0),
96
+ _useState12 = _slicedToArray(_useState11, 2),
97
+ refreshKey = _useState12[0],
98
+ setRefreshKey = _useState12[1];
99
+
100
+ // ====================== 筛选状态 ======================
101
+ var _useState13 = (0, _react.useState)([]),
102
+ _useState14 = _slicedToArray(_useState13, 2),
103
+ filterList = _useState14[0],
104
+ setFilterList = _useState14[1];
105
+ var _useState15 = (0, _react.useState)('all'),
106
+ _useState16 = _slicedToArray(_useState15, 2),
107
+ currentFilterTitle = _useState16[0],
108
+ setCurrentFilterTitle = _useState16[1];
109
+ var _useState17 = (0, _react.useState)([]),
110
+ _useState18 = _slicedToArray(_useState17, 2),
111
+ originalPagesFull = _useState18[0],
112
+ setOriginalPagesFull = _useState18[1];
113
+ var _usePageFlip = (0, _usePageFlip2.usePageFlip)({
114
+ bookRef: bookRef,
115
+ currentPageIndex: currentPageIndex,
116
+ totalPages: pages.length,
117
+ setCurrentPageIndex: setCurrentPageIndex
118
+ }),
119
+ handleFlip = _usePageFlip.handleFlip,
120
+ loadPrevVoucher = _usePageFlip.loadPrevVoucher,
121
+ loadNextVoucher = _usePageFlip.loadNextVoucher,
122
+ goToFirstPage = _usePageFlip.goToFirstPage,
123
+ goToLastPage = _usePageFlip.goToLastPage;
124
+ var _useAmountSearch = (0, _useAmountSearch2.useAmountSearch)({
125
+ originalPagesFull: originalPagesFull,
126
+ bookRef: bookRef,
127
+ setCurrentFilterTitle: setCurrentFilterTitle,
128
+ setPages: setPages,
129
+ setCurrentPageIndex: setCurrentPageIndex,
130
+ goToFirstPage: goToFirstPage
131
+ }),
132
+ searchValue = _useAmountSearch.searchValue,
133
+ setSearchValue = _useAmountSearch.setSearchValue,
134
+ searchOptions = _useAmountSearch.searchOptions,
135
+ handleAmountSearch = _useAmountSearch.handleAmountSearch,
136
+ handleGotoPageByAmount = _useAmountSearch.handleGotoPageByAmount,
137
+ handleSearchClear = _useAmountSearch.handleSearchClear,
138
+ buildAllAmountOptions = _useAmountSearch.buildAllAmountOptions;
139
+
140
+ // ====================== 生成筛选菜单 ======================
141
+ var generateFilterList = function generateFilterList(stubPages) {
142
+ var titleMap = new Map();
143
+ console.log(stubPages);
144
+ stubPages.forEach(function (page) {
145
+ var _page$stub_page_raws;
146
+ // 只遍历存在、且 attachments 不为空的 raw
147
+ (_page$stub_page_raws = page.stub_page_raws) === null || _page$stub_page_raws === void 0 || _page$stub_page_raws.forEach(function (raw) {
148
+ var _raw$title;
149
+ // 过滤:attachments 是空数组则跳过
150
+ if (!raw.attachments || raw.attachments.length === 0) return;
151
+ var title = ((_raw$title = raw.title) === null || _raw$title === void 0 ? void 0 : _raw$title.trim()) || '无标题单据';
152
+ titleMap.set(title, title);
153
+ });
154
+ });
155
+ var list = Array.from(titleMap.keys()).map(function (title) {
156
+ return {
157
+ type: title,
158
+ name: title
159
+ };
160
+ });
161
+ return [{
162
+ type: 'all',
163
+ name: '全部凭证'
164
+ }].concat(_toConsumableArray(list));
165
+ };
166
+ var filterPagesByDocTitle = function filterPagesByDocTitle(allPages, targetTitle) {
167
+ if (targetTitle === 'all') return _toConsumableArray(allPages);
168
+ return allPages.filter(function (p) {
169
+ var _p$props;
170
+ if (! /*#__PURE__*/_react.default.isValidElement(p)) return false;
171
+ var pageTitle = (_p$props = p.props) === null || _p$props === void 0 ? void 0 : _p$props['data-doc-title'];
172
+ // 处理数组情况(针对记账凭证可能对应多个原始单据的情况)
173
+ if (Array.isArray(pageTitle)) {
174
+ return pageTitle.some(function (t) {
175
+ return t === targetTitle;
176
+ });
177
+ }
178
+ return pageTitle === targetTitle;
179
+ });
180
+ };
181
+ (0, _react.useEffect)(function () {
182
+ var preloadImages = function preloadImages() {
183
+ [_constants.filpBg, _constants.defaultLine, _constants.activeLine].forEach(function (src) {
184
+ var img = new Image();
185
+ img.src = src;
186
+ });
187
+ };
188
+ preloadImages();
189
+ }, []);
190
+ (0, _react.useEffect)(function () {
191
+ if (!bookRef.current || pages.length === 0) return;
192
+ var pageFlipInstance = bookRef.current.pageFlip();
193
+ if (pageFlipInstance && currentPageIndex < pages.length) {
194
+ pageFlipInstance.flip(currentPageIndex, {
195
+ duration: 0
196
+ });
197
+ }
198
+ }, [currentPageIndex, pages.length]);
199
+
200
+ // 处理传入的数据
201
+ (0, _react.useEffect)(function () {
202
+ if (data !== null && data !== void 0 && data.stub_pages) {
203
+ processData(data.stub_pages);
204
+ }
205
+ }, [data, refreshKey]); // 添加 refreshKey 作为依赖
206
+
207
+ var processData = /*#__PURE__*/function () {
208
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(stubPages) {
209
+ var filters, newVoucherItems, detailToStubPage, allDetails, allProcessedPages, BATCH_SIZE, i, batch, batchPagesTasks, batchResults, batchPages;
210
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
211
+ while (1) switch (_context2.prev = _context2.next) {
212
+ case 0:
213
+ setLoading(true);
214
+ setLoadingMessage('正在生成页面...');
215
+ _context2.prev = 2;
216
+ filters = generateFilterList(stubPages);
217
+ setFilterList(filters);
218
+ buildAllAmountOptions({
219
+ items: {
220
+ stub_pages: stubPages
221
+ }
222
+ });
223
+ newVoucherItems = [];
224
+ detailToStubPage = new Map();
225
+ stubPages.forEach(function (sp) {
226
+ var detailsByCode = new Map();
227
+ (sp.stub_page_details || []).forEach(function (d) {
228
+ var code = d.code || 0;
229
+ if (!detailsByCode.has(code)) detailsByCode.set(code, []);
230
+ detailsByCode.get(code).push(d);
231
+ detailToStubPage.set(d.id, sp);
232
+ });
233
+ detailsByCode.forEach(function (ds, code) {
234
+ var fd = ds[0];
235
+ newVoucherItems.push({
236
+ id: fd.id || 0,
237
+ code: code,
238
+ dt: fd.dt || '',
239
+ remark: fd.remark || '',
240
+ amount: fd.amount || '0'
241
+ });
242
+ });
243
+ });
244
+ allDetails = stubPages.flatMap(function (p) {
245
+ return p.stub_page_details || [];
246
+ });
247
+ allProcessedPages = []; // 分批处理凭证,实现渐进式加载
248
+ BATCH_SIZE = 2;
249
+ i = 0;
250
+ case 13:
251
+ if (!(i < newVoucherItems.length)) {
252
+ _context2.next = 27;
253
+ break;
254
+ }
255
+ batch = newVoucherItems.slice(i, i + BATCH_SIZE);
256
+ batchPagesTasks = batch.map( /*#__PURE__*/function () {
257
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(vi) {
258
+ var sp;
259
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
260
+ while (1) switch (_context.prev = _context.next) {
261
+ case 0:
262
+ sp = detailToStubPage.get(vi.id);
263
+ if (!sp) {
264
+ _context.next = 5;
265
+ break;
266
+ }
267
+ _context.next = 4;
268
+ return loadVoucherDetails(vi, sp, allDetails);
269
+ case 4:
270
+ return _context.abrupt("return", _context.sent);
271
+ case 5:
272
+ return _context.abrupt("return", []);
273
+ case 6:
274
+ case "end":
275
+ return _context.stop();
276
+ }
277
+ }, _callee);
278
+ }));
279
+ return function (_x2) {
280
+ return _ref3.apply(this, arguments);
281
+ };
282
+ }());
283
+ _context2.next = 18;
284
+ return Promise.all(batchPagesTasks);
285
+ case 18:
286
+ batchResults = _context2.sent;
287
+ batchPages = batchResults.flat();
288
+ allProcessedPages = [].concat(_toConsumableArray(allProcessedPages), _toConsumableArray(batchPages));
289
+
290
+ // 实时更新原始页面池和当前展示页面
291
+ setOriginalPagesFull(_toConsumableArray(allProcessedPages));
292
+
293
+ // 只有在非搜索/非筛选模式下才更新当前展示的 pages
294
+ setPages(function (prevPages) {
295
+ // 如果当前有筛选,我们需要根据筛选条件更新展示的内容
296
+ if (currentFilterTitle !== 'all') {
297
+ return filterPagesByDocTitle(allProcessedPages, currentFilterTitle);
298
+ }
299
+ return _toConsumableArray(allProcessedPages);
300
+ });
301
+
302
+ // 第一批加载完后关闭主 loading
303
+ if (i === 0) {
304
+ setLoading(false);
305
+ setCurrentPageIndex(0);
306
+ }
307
+ case 24:
308
+ i += BATCH_SIZE;
309
+ _context2.next = 13;
310
+ break;
311
+ case 27:
312
+ // 所有数据处理完后,确保 loading 关闭
313
+ setLoading(false);
314
+ _context2.next = 34;
315
+ break;
316
+ case 30:
317
+ _context2.prev = 30;
318
+ _context2.t0 = _context2["catch"](2);
319
+ console.error('处理数据失败', _context2.t0);
320
+ setLoading(false);
321
+ case 34:
322
+ case "end":
323
+ return _context2.stop();
324
+ }
325
+ }, _callee2, null, [[2, 30]]);
326
+ }));
327
+ return function processData(_x) {
328
+ return _ref2.apply(this, arguments);
329
+ };
330
+ }();
331
+ var loadVoucherDetails = function loadVoucherDetails(voucherItem, stubPage, allDetails) {
332
+ var entries = allDetails.filter(function (detail) {
333
+ return detail.code === voucherItem.code;
334
+ }).map(function (detail) {
335
+ return {
336
+ id: detail.id || 0,
337
+ remark: detail.remark || '',
338
+ subject: detail.subject || '',
339
+ trade_direction: detail.trade_direction || '',
340
+ amount: detail.amount || '0'
341
+ };
342
+ });
343
+ var documents = (stubPage.stub_page_raws || []).map(function (raw) {
344
+ return {
345
+ id: raw.id || 0,
346
+ title: raw.title || '未命名单据',
347
+ amount: raw.amount || '0',
348
+ attachments: (raw.attachments || []).map(function (a) {
349
+ return {
350
+ id: a.id || 0,
351
+ path: a.path || ''
352
+ };
353
+ })
354
+ };
355
+ });
356
+ return createVoucherPages(voucherItem, entries, documents);
357
+ };
358
+ var createVoucherPages = /*#__PURE__*/function () {
359
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(voucherItem, entries, documents) {
360
+ var pages, MIN_ROWS, totalDebit, totalCredit, formattedEntries, totalPages, formattedDate, docTitles, pageNum, startIndex, endIndex, pageEntries, attachmentCount, attachmentTasks, totalAttachments, _iterator, _step, _doc$title2, _doc$attachments2, doc, currentDocTitle, _iterator2, _step2, attachment, fileUrl, isPdf, isPng, attachmentPagesResults;
361
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
362
+ while (1) switch (_context4.prev = _context4.next) {
363
+ case 0:
364
+ pages = [];
365
+ MIN_ROWS = 5;
366
+ totalDebit = 0;
367
+ totalCredit = 0;
368
+ formattedEntries = entries.map(function (entry) {
369
+ var debit = entry.trade_direction === '借' ? parseFloat(entry.amount) || 0 : 0;
370
+ var credit = entry.trade_direction === '贷' ? parseFloat(entry.amount) || 0 : 0;
371
+ totalDebit += debit;
372
+ totalCredit += credit;
373
+ return {
374
+ summary: entry.remark || '无摘要',
375
+ account: entry.subject || '无科目',
376
+ debit: debit.toFixed(2),
377
+ credit: credit.toFixed(2),
378
+ trade_direction: entry.trade_direction
379
+ };
380
+ });
381
+ totalPages = Math.max(Math.ceil(formattedEntries.length / MIN_ROWS), 1);
382
+ formattedDate = function formattedDate(voucherItem) {
383
+ if (!voucherItem.dt || !(0, _moment.default)(voucherItem.dt).isValid()) return '<span style="color: #999;">无有效日期</span>';
384
+ var date = (0, _moment.default)(voucherItem.dt);
385
+ return "".concat(date.format('YYYY'), "<span style=\"color: #8b4513;\">\u5E74</span>").concat(date.format('MM'), "<span style=\"color: #8b4513;\">\u6708</span>").concat(date.format('DD'), "<span style=\"color: #8b4513;\">\u65E5</span>");
386
+ };
387
+ docTitles = documents.map(function (doc) {
388
+ var _doc$title;
389
+ return ((_doc$title = doc.title) === null || _doc$title === void 0 ? void 0 : _doc$title.trim()) || '无标题单据';
390
+ });
391
+ for (pageNum = 1; pageNum <= totalPages; pageNum++) {
392
+ startIndex = (pageNum - 1) * MIN_ROWS;
393
+ endIndex = Math.min(pageNum * MIN_ROWS, formattedEntries.length);
394
+ pageEntries = formattedEntries.slice(startIndex, endIndex);
395
+ pages.push( /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
396
+ className: "voucher-page",
397
+ 'data-doc-title': docTitles,
398
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AccountingVoucher.default, _objectSpread(_objectSpread({}, baseVoucherInfo), {}, {
399
+ date: formattedDate(voucherItem),
400
+ voucherNo: "".concat(voucherItem.code, "-").concat(pageNum),
401
+ entries: pageEntries,
402
+ showTotal: pageNum === totalPages,
403
+ totalDebit: totalDebit.toFixed(2),
404
+ totalCredit: totalCredit.toFixed(2)
405
+ }))
406
+ }, "voucher-".concat(voucherItem.id, "-").concat(pageNum)));
407
+ }
408
+ attachmentCount = 0;
409
+ attachmentTasks = [];
410
+ totalAttachments = 0;
411
+ documents.forEach(function (doc) {
412
+ var _doc$attachments;
413
+ if ((_doc$attachments = doc.attachments) !== null && _doc$attachments !== void 0 && _doc$attachments.length) totalAttachments += doc.attachments.length;
414
+ });
415
+ if (totalAttachments === 0) totalAttachments = 1;
416
+ _iterator = _createForOfIteratorHelper(documents);
417
+ try {
418
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
419
+ doc = _step.value;
420
+ currentDocTitle = ((_doc$title2 = doc.title) === null || _doc$title2 === void 0 ? void 0 : _doc$title2.trim()) || '无标题单据';
421
+ if ((_doc$attachments2 = doc.attachments) !== null && _doc$attachments2 !== void 0 && _doc$attachments2.length) {
422
+ _iterator2 = _createForOfIteratorHelper(doc.attachments);
423
+ try {
424
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
425
+ attachment = _step2.value;
426
+ attachmentCount++;
427
+ fileUrl = (0, _utils.getAttachmentUrl)(attachment.path);
428
+ isPdf = fileUrl.toLowerCase().endsWith('.pdf');
429
+ isPng = (0, _utils.isImageFile)(fileUrl);
430
+ if (isPng) {
431
+ attachmentTasks.push({
432
+ type: 'image',
433
+ element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagePageRenderer.ImagePageRenderer, {
434
+ src: fileUrl,
435
+ alt: "\u539F\u59CB\u5355\u636E - ".concat(doc.title),
436
+ attachmentId: attachment.id,
437
+ currentIndex: attachmentCount,
438
+ totalCount: totalAttachments,
439
+ amount: doc.amount,
440
+ 'data-doc-title': currentDocTitle
441
+ }, "attachment-".concat(attachment.id))
442
+ });
443
+ } else if (isPdf) {
444
+ attachmentTasks.push({
445
+ type: 'pdf',
446
+ promise: loadPDFPages(fileUrl, attachment.id, attachmentCount, totalAttachments, doc.amount, currentDocTitle)
447
+ });
448
+ }
449
+ }
450
+ } catch (err) {
451
+ _iterator2.e(err);
452
+ } finally {
453
+ _iterator2.f();
454
+ }
455
+ }
456
+ }
457
+
458
+ // 并行处理所有 PDF 的页数获取
459
+ } catch (err) {
460
+ _iterator.e(err);
461
+ } finally {
462
+ _iterator.f();
463
+ }
464
+ _context4.next = 18;
465
+ return Promise.all(attachmentTasks.map( /*#__PURE__*/function () {
466
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(task) {
467
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
468
+ while (1) switch (_context3.prev = _context3.next) {
469
+ case 0:
470
+ if (!(task.type === 'image')) {
471
+ _context3.next = 2;
472
+ break;
473
+ }
474
+ return _context3.abrupt("return", [task.element]);
475
+ case 2:
476
+ if (!(task.type === 'pdf')) {
477
+ _context3.next = 13;
478
+ break;
479
+ }
480
+ _context3.prev = 3;
481
+ _context3.next = 6;
482
+ return task.promise;
483
+ case 6:
484
+ return _context3.abrupt("return", _context3.sent);
485
+ case 9:
486
+ _context3.prev = 9;
487
+ _context3.t0 = _context3["catch"](3);
488
+ console.error('加载 PDF 失败', _context3.t0);
489
+ return _context3.abrupt("return", []);
490
+ case 13:
491
+ return _context3.abrupt("return", []);
492
+ case 14:
493
+ case "end":
494
+ return _context3.stop();
495
+ }
496
+ }, _callee3, null, [[3, 9]]);
497
+ }));
498
+ return function (_x6) {
499
+ return _ref5.apply(this, arguments);
500
+ };
501
+ }()));
502
+ case 18:
503
+ attachmentPagesResults = _context4.sent;
504
+ pages.push.apply(pages, _toConsumableArray(attachmentPagesResults.flat()));
505
+ return _context4.abrupt("return", pages);
506
+ case 21:
507
+ case "end":
508
+ return _context4.stop();
509
+ }
510
+ }, _callee4);
511
+ }));
512
+ return function createVoucherPages(_x3, _x4, _x5) {
513
+ return _ref4.apply(this, arguments);
514
+ };
515
+ }();
516
+ var loadPDFPages = /*#__PURE__*/function () {
517
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pdfPath, attachmentId, currentIndex, totalCount, amount, docTitle) {
518
+ var pdf, pdfPages, i;
519
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
520
+ while (1) switch (_context5.prev = _context5.next) {
521
+ case 0:
522
+ _context5.prev = 0;
523
+ _context5.next = 3;
524
+ return _utils.globalPdfCache.getDocument(pdfPath);
525
+ case 3:
526
+ pdf = _context5.sent;
527
+ pdfPages = [];
528
+ for (i = 1; i <= pdf.numPages; i++) {
529
+ pdfPages.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_PDFPageRenderer.PDFPageRenderer, {
530
+ pdfPath: pdfPath,
531
+ attachmentId: attachmentId,
532
+ pageNumber: i,
533
+ currentIndex: currentIndex,
534
+ totalCount: totalCount,
535
+ amount: amount,
536
+ 'data-doc-title': docTitle
537
+ }, "attachment-".concat(attachmentId, "-page-").concat(i)));
538
+ }
539
+ return _context5.abrupt("return", pdfPages);
540
+ case 9:
541
+ _context5.prev = 9;
542
+ _context5.t0 = _context5["catch"](0);
543
+ return _context5.abrupt("return", [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
544
+ 'data-doc-title': docTitle,
545
+ children: "PDF \u52A0\u8F7D\u5931\u8D25"
546
+ }, "err-".concat(attachmentId))]);
547
+ case 12:
548
+ case "end":
549
+ return _context5.stop();
550
+ }
551
+ }, _callee5, null, [[0, 9]]);
552
+ }));
553
+ return function loadPDFPages(_x7, _x8, _x9, _x10, _x11, _x12) {
554
+ return _ref6.apply(this, arguments);
555
+ };
556
+ }();
557
+ var handleDownload = function handleDownload(type) {
558
+ if (type === 'pdf') exportPDF();else exportEPUB();
559
+ };
560
+ var handleRefresh = /*#__PURE__*/function () {
561
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
562
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
563
+ while (1) switch (_context6.prev = _context6.next) {
564
+ case 0:
565
+ // 清除 PDF 缓存
566
+ _utils.globalPdfCache.clearAll();
567
+ // 重置状态
568
+ setCurrentPageIndex(0);
569
+ setCurrentFilterTitle('all');
570
+ setSearchValue('');
571
+
572
+ // 如果有外部刷新回调,优先调用外部的
573
+ if (externalOnRefresh) {
574
+ externalOnRefresh();
575
+ } else {
576
+ // 否则使用内部刷新逻辑
577
+ try {
578
+ // 增加 refreshKey 重新触发数据处理
579
+ setRefreshKey(function (prev) {
580
+ return prev + 1;
581
+ });
582
+ } catch (error) {
583
+ console.error('刷新失败:', error);
584
+ }
585
+ }
586
+ case 5:
587
+ case "end":
588
+ return _context6.stop();
589
+ }
590
+ }, _callee6);
591
+ }));
592
+ return function handleRefresh() {
593
+ return _ref7.apply(this, arguments);
594
+ };
595
+ }();
596
+ var exportEPUB = /*#__PURE__*/function () {
597
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
598
+ var hide, _zip$folder, _zip$folder2, _zip$folder7, _zip$folder8, imgUrls, preloadMap, coverData, _r$data, r, it, zip, manifestItems, spineItems, navPoints, pageCount, cvs, _zip$folder3, _zip$folder4, imgDataUrl, base64, binary, bytes, i, _i, _p$key, p, k, _cvs, _children, props, info, _zip$folder5, _zip$folder6, _imgDataUrl, _base, _binary, _bytes, j, imgFileName, xhtmlFileName, pageId, title, content, url, a;
599
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
600
+ while (1) switch (_context7.prev = _context7.next) {
601
+ case 0:
602
+ hide = _antd.message.loading('正在导出 EPUB 电子书,请稍候…', 0);
603
+ _context7.prev = 1;
604
+ imgUrls = [];
605
+ pages.forEach(function (p) {
606
+ var _String;
607
+ if ( /*#__PURE__*/_react.default.isValidElement(p) && (_String = String(p.key)) !== null && _String !== void 0 && _String.includes('attachment-')) {
608
+ var info = (0, _canvasUtils.extractAttachmentInfo)(p);
609
+ if ((info === null || info === void 0 ? void 0 : info.type) === 'image') imgUrls.push(info.src);
610
+ }
611
+ });
612
+ _context7.next = 6;
613
+ return (0, _canvasUtils.batchPreloadImages)(_toConsumableArray(new Set(imgUrls)));
614
+ case 6:
615
+ preloadMap = _context7.sent;
616
+ coverData = null;
617
+ if (!ledgerBookListApi) {
618
+ _context7.next = 18;
619
+ break;
620
+ }
621
+ _context7.prev = 9;
622
+ _context7.next = 12;
623
+ return ledgerBookListApi({
624
+ tail_mark: 1,
625
+ page_size: 1,
626
+ kind: 'done'
627
+ });
628
+ case 12:
629
+ r = _context7.sent;
630
+ if (r.code === 0 && (_r$data = r.data) !== null && _r$data !== void 0 && (_r$data = _r$data.items) !== null && _r$data !== void 0 && _r$data.length) {
631
+ it = r.data.items[0];
632
+ coverData = {
633
+ issuingUnit: (companyInfo === null || companyInfo === void 0 ? void 0 : companyInfo.name) || '迈金西',
634
+ expiryDate: it.dt,
635
+ credentialCode: it.uuid,
636
+ total_page: it.total_page,
637
+ page_num: it.page_num,
638
+ credentialNumber: it.code,
639
+ modificationTime: (0, _moment.default)(it.updated_at).format('YYYY-MM-DD HH:mm'),
640
+ id: it.id
641
+ };
642
+ }
643
+ _context7.next = 18;
644
+ break;
645
+ case 16:
646
+ _context7.prev = 16;
647
+ _context7.t0 = _context7["catch"](9);
648
+ case 18:
649
+ zip = new _jszip.default();
650
+ zip.file('mimetype', 'application/epub+zip', {
651
+ compression: 'STORE'
652
+ });
653
+ (_zip$folder = zip.folder('META-INF')) === null || _zip$folder === void 0 || _zip$folder.file('container.xml', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<container version=\"1.0\" xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n <rootfiles>\n <rootfile full-path=\"OEBPS/content.opf\" media-type=\"application/oebps-package+xml\"/>\n </rootfiles>\n</container>");
654
+ manifestItems = ['<item id="style" href="Styles/style.css" media-type="text/css"/>', '<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>'];
655
+ spineItems = [];
656
+ navPoints = []; // 样式表
657
+ (_zip$folder2 = zip.folder('OEBPS')) === null || _zip$folder2 === void 0 || (_zip$folder2 = _zip$folder2.folder('Styles')) === null || _zip$folder2 === void 0 || _zip$folder2.file('style.css', "\nbody { margin: 0; padding: 0; background: #fff; }\nimg { max-width: 100%; height: auto; }\n.page-container { text-align: center; page-break-after: always; }\n");
658
+ pageCount = 0; // 封面
659
+ if (!coverData) {
660
+ _context7.next = 31;
661
+ break;
662
+ }
663
+ _context7.next = 29;
664
+ return (0, _canvasUtils.createCoverCanvas)(coverData, (companyInfo === null || companyInfo === void 0 ? void 0 : companyInfo.name) || '');
665
+ case 29:
666
+ cvs = _context7.sent;
667
+ if (cvs) {
668
+ pageCount++;
669
+ imgDataUrl = cvs.toDataURL('image/jpeg', 0.9);
670
+ base64 = imgDataUrl.split(',')[1];
671
+ binary = window.atob(base64);
672
+ bytes = new Uint8Array(binary.length);
673
+ for (i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
674
+ (_zip$folder3 = zip.folder('OEBPS')) === null || _zip$folder3 === void 0 || (_zip$folder3 = _zip$folder3.folder('Images')) === null || _zip$folder3 === void 0 || _zip$folder3.file('cover.jpg', bytes.buffer);
675
+ (_zip$folder4 = zip.folder('OEBPS')) === null || _zip$folder4 === void 0 || (_zip$folder4 = _zip$folder4.folder('Text')) === null || _zip$folder4 === void 0 || _zip$folder4.file('cover.xhtml', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Cover</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"../Styles/style.css\"/>\n</head>\n<body style=\"margin:0;padding:0;text-align:center;\">\n <div style=\"width:100%;height:100%;\"><img src=\"../Images/cover.jpg\" style=\"max-width:100%;max-height:100%;\"/></div>\n</body>\n</html>");
676
+ manifestItems.push('<item id="cover" href="Text/cover.xhtml" media-type="application/xhtml+xml"/>');
677
+ manifestItems.push('<item id="cover-image" href="Images/cover.jpg" media-type="image/jpeg" properties="cover-image"/>');
678
+ spineItems.push('<itemref idref="cover"/>');
679
+ navPoints.push("<navPoint id=\"navPoint-".concat(pageCount, "\" playOrder=\"").concat(pageCount, "\"><navLabel><text>\u5C01\u9762</text></navLabel><content src=\"Text/cover.xhtml\"/></navPoint>"));
680
+ }
681
+ case 31:
682
+ _i = 0;
683
+ case 32:
684
+ if (!(_i < pages.length)) {
685
+ _context7.next = 56;
686
+ break;
687
+ }
688
+ p = pages[_i];
689
+ if ( /*#__PURE__*/_react.default.isValidElement(p)) {
690
+ _context7.next = 36;
691
+ break;
692
+ }
693
+ return _context7.abrupt("continue", 53);
694
+ case 36:
695
+ k = ((_p$key = p.key) === null || _p$key === void 0 ? void 0 : _p$key.toString()) || '';
696
+ _cvs = null;
697
+ if (!k.includes('voucher-')) {
698
+ _context7.next = 46;
699
+ break;
700
+ }
701
+ props = (_children = p.props.children) === null || _children === void 0 ? void 0 : _children.props;
702
+ if (!props) {
703
+ _context7.next = 44;
704
+ break;
705
+ }
706
+ _context7.next = 43;
707
+ return (0, _canvasUtils.createVoucherCanvas)(props, baseVoucherInfo);
708
+ case 43:
709
+ _cvs = _context7.sent;
710
+ case 44:
711
+ _context7.next = 52;
712
+ break;
713
+ case 46:
714
+ if (!k.includes('attachment-')) {
715
+ _context7.next = 52;
716
+ break;
717
+ }
718
+ info = (0, _canvasUtils.extractAttachmentInfo)(p);
719
+ if (!info) {
720
+ _context7.next = 52;
721
+ break;
722
+ }
723
+ _context7.next = 51;
724
+ return (0, _canvasUtils.createAttachmentCanvasFixed)(info, preloadMap);
725
+ case 51:
726
+ _cvs = _context7.sent;
727
+ case 52:
728
+ if (_cvs) {
729
+ pageCount++;
730
+ _imgDataUrl = _cvs.toDataURL('image/jpeg', 0.9);
731
+ _base = _imgDataUrl.split(',')[1];
732
+ _binary = window.atob(_base);
733
+ _bytes = new Uint8Array(_binary.length);
734
+ for (j = 0; j < _binary.length; j++) _bytes[j] = _binary.charCodeAt(j);
735
+ imgFileName = "page".concat(pageCount, ".jpg");
736
+ xhtmlFileName = "page".concat(pageCount, ".xhtml");
737
+ pageId = "page".concat(pageCount);
738
+ (_zip$folder5 = zip.folder('OEBPS')) === null || _zip$folder5 === void 0 || (_zip$folder5 = _zip$folder5.folder('Images')) === null || _zip$folder5 === void 0 || _zip$folder5.file(imgFileName, _bytes.buffer);
739
+ (_zip$folder6 = zip.folder('OEBPS')) === null || _zip$folder6 === void 0 || (_zip$folder6 = _zip$folder6.folder('Text')) === null || _zip$folder6 === void 0 || _zip$folder6.file(xhtmlFileName, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Page ".concat(pageCount, "</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"../Styles/style.css\"/>\n</head>\n<body style=\"margin:0;padding:0;text-align:center;\">\n <div class=\"page-container\"><img src=\"../Images/").concat(imgFileName, "\"/></div>\n</body>\n</html>"));
740
+ manifestItems.push("<item id=\"".concat(pageId, "\" href=\"Text/").concat(xhtmlFileName, "\" media-type=\"application/xhtml+xml\"/>"));
741
+ manifestItems.push("<item id=\"".concat(pageId, "-img\" href=\"Images/").concat(imgFileName, "\" media-type=\"image/jpeg\"/>"));
742
+ spineItems.push("<itemref idref=\"".concat(pageId, "\"/>"));
743
+ navPoints.push("<navPoint id=\"navPoint-".concat(pageCount, "\" playOrder=\"").concat(pageCount, "\"><navLabel><text>\u7B2C ").concat(pageCount, " \u9875</text></navLabel><content src=\"Text/").concat(xhtmlFileName, "\"/></navPoint>"));
744
+ }
745
+ case 53:
746
+ _i++;
747
+ _context7.next = 32;
748
+ break;
749
+ case 56:
750
+ // content.opf
751
+ title = "\u51ED\u8BC1_".concat((0, _moment.default)().format('YYYYMMDD_HHmmss'));
752
+ (_zip$folder7 = zip.folder('OEBPS')) === null || _zip$folder7 === void 0 || _zip$folder7.file('content.opf', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package xmlns=\"http://www.idpf.org/2007/opf\" unique-identifier=\"pub-id\" version=\"3.0\">\n <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n <dc:identifier id=\"pub-id\">urn:uuid:".concat(crypto.randomUUID(), "</dc:identifier>\n <dc:title>").concat(title, "</dc:title>\n <dc:language>zh-CN</dc:language>\n <dc:creator>Archive System</dc:creator>\n <dc:date>").concat(new Date().toISOString(), "</dc:date>\n <meta property=\"dcterms:modified\">").concat(new Date().toISOString().split('.')[0], "Z</meta>\n </metadata>\n <manifest>\n ").concat(manifestItems.join('\n '), "\n </manifest>\n <spine toc=\"ncx\">\n ").concat(spineItems.join('\n '), "\n </spine>\n</package>"));
753
+
754
+ // toc.ncx
755
+ (_zip$folder8 = zip.folder('OEBPS')) === null || _zip$folder8 === void 0 || _zip$folder8.file('toc.ncx', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ncx xmlns=\"http://www.daisy.org/z3986/2005/ncx/\" version=\"2005-1\">\n <head>\n <meta name=\"dtb:uid\" content=\"urn:uuid:12345\"/>\n <meta name=\"dtb:depth\" content=\"1\"/>\n <meta name=\"dtb:totalPageCount\" content=\"0\"/>\n <meta name=\"dtb:maxPageNumber\" content=\"0\"/>\n </head>\n <docTitle><text>".concat(title, "</text></docTitle>\n <navMap>\n ").concat(navPoints.join('\n '), "\n </navMap>\n</ncx>"));
756
+ _context7.next = 61;
757
+ return zip.generateAsync({
758
+ type: 'blob',
759
+ mimeType: 'application/epub+zip'
760
+ });
761
+ case 61:
762
+ content = _context7.sent;
763
+ url = URL.createObjectURL(content);
764
+ a = document.createElement('a');
765
+ a.download = "".concat(title, ".epub");
766
+ a.href = url;
767
+ a.click();
768
+ URL.revokeObjectURL(url);
769
+ _antd.message.success('EPUB 导出成功');
770
+ _context7.next = 75;
771
+ break;
772
+ case 71:
773
+ _context7.prev = 71;
774
+ _context7.t1 = _context7["catch"](1);
775
+ console.error('EPUB 导出失败:', _context7.t1);
776
+ _antd.message.error('EPUB 导出失败');
777
+ case 75:
778
+ _context7.prev = 75;
779
+ hide();
780
+ return _context7.finish(75);
781
+ case 78:
782
+ case "end":
783
+ return _context7.stop();
784
+ }
785
+ }, _callee7, null, [[1, 71, 75, 78], [9, 16]]);
786
+ }));
787
+ return function exportEPUB() {
788
+ return _ref8.apply(this, arguments);
789
+ };
790
+ }();
791
+ var exportPDF = /*#__PURE__*/function () {
792
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
793
+ var hide, imgUrls, preloadMap, pdf, first, _iterator3, _step3, _p$key2, p, k, cvs, _children2, props, info, d;
794
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
795
+ while (1) switch (_context8.prev = _context8.next) {
796
+ case 0:
797
+ hide = _antd.message.loading('正在导出 PDF 文档,请稍候…', 0);
798
+ _context8.prev = 1;
799
+ imgUrls = [];
800
+ pages.forEach(function (p) {
801
+ var _String2;
802
+ if ( /*#__PURE__*/_react.default.isValidElement(p) && (_String2 = String(p.key)) !== null && _String2 !== void 0 && _String2.includes('attachment-')) {
803
+ var info = (0, _canvasUtils.extractAttachmentInfo)(p);
804
+ if ((info === null || info === void 0 ? void 0 : info.type) === 'image') imgUrls.push(info.src);
805
+ }
806
+ });
807
+ _context8.next = 6;
808
+ return (0, _canvasUtils.batchPreloadImages)(_toConsumableArray(new Set(imgUrls)));
809
+ case 6:
810
+ preloadMap = _context8.sent;
811
+ pdf = new _jspdf.default({
812
+ orientation: 'landscape',
813
+ unit: 'mm',
814
+ format: [210, 148]
815
+ });
816
+ first = true;
817
+ _iterator3 = _createForOfIteratorHelper(pages);
818
+ _context8.prev = 10;
819
+ _iterator3.s();
820
+ case 12:
821
+ if ((_step3 = _iterator3.n()).done) {
822
+ _context8.next = 35;
823
+ break;
824
+ }
825
+ p = _step3.value;
826
+ if ( /*#__PURE__*/_react.default.isValidElement(p)) {
827
+ _context8.next = 16;
828
+ break;
829
+ }
830
+ return _context8.abrupt("continue", 33);
831
+ case 16:
832
+ k = ((_p$key2 = p.key) === null || _p$key2 === void 0 ? void 0 : _p$key2.toString()) || '';
833
+ cvs = null;
834
+ if (!k.includes('voucher-')) {
835
+ _context8.next = 26;
836
+ break;
837
+ }
838
+ props = (_children2 = p.props.children) === null || _children2 === void 0 ? void 0 : _children2.props;
839
+ if (!props) {
840
+ _context8.next = 24;
841
+ break;
842
+ }
843
+ _context8.next = 23;
844
+ return (0, _canvasUtils.createVoucherCanvas)(props, baseVoucherInfo);
845
+ case 23:
846
+ cvs = _context8.sent;
847
+ case 24:
848
+ _context8.next = 32;
849
+ break;
850
+ case 26:
851
+ if (!k.includes('attachment-')) {
852
+ _context8.next = 32;
853
+ break;
854
+ }
855
+ info = (0, _canvasUtils.extractAttachmentInfo)(p);
856
+ if (!info) {
857
+ _context8.next = 32;
858
+ break;
859
+ }
860
+ _context8.next = 31;
861
+ return (0, _canvasUtils.createAttachmentCanvasFixed)(info, preloadMap);
862
+ case 31:
863
+ cvs = _context8.sent;
864
+ case 32:
865
+ if (cvs) {
866
+ if (!first) pdf.addPage([210, 148], 'landscape');
867
+ first = false;
868
+ d = cvs.toDataURL('image/jpeg', 0.9);
869
+ pdf.addImage(d, 'JPEG', 0, 0, 210, 148);
870
+ }
871
+ case 33:
872
+ _context8.next = 12;
873
+ break;
874
+ case 35:
875
+ _context8.next = 40;
876
+ break;
877
+ case 37:
878
+ _context8.prev = 37;
879
+ _context8.t0 = _context8["catch"](10);
880
+ _iterator3.e(_context8.t0);
881
+ case 40:
882
+ _context8.prev = 40;
883
+ _iterator3.f();
884
+ return _context8.finish(40);
885
+ case 43:
886
+ pdf.save("\u51ED\u8BC1_".concat((0, _moment.default)().format('YYYYMMDD_HHmmss'), ".pdf"));
887
+ _antd.message.success('PDF导出成功');
888
+ _context8.next = 50;
889
+ break;
890
+ case 47:
891
+ _context8.prev = 47;
892
+ _context8.t1 = _context8["catch"](1);
893
+ _antd.message.error('PDF导出失败');
894
+ case 50:
895
+ _context8.prev = 50;
896
+ hide();
897
+ return _context8.finish(50);
898
+ case 53:
899
+ case "end":
900
+ return _context8.stop();
901
+ }
902
+ }, _callee8, null, [[1, 47, 50, 53], [10, 37, 40, 43]]);
903
+ }));
904
+ return function exportPDF() {
905
+ return _ref9.apply(this, arguments);
906
+ };
907
+ }();
908
+ var handlePrint = /*#__PURE__*/function () {
909
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
910
+ var hide, imgUrls, preloadMap, imgs, _iterator4, _step4, _p$key3, p, k, cvs, _children3, props, info, w;
911
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
912
+ while (1) switch (_context9.prev = _context9.next) {
913
+ case 0:
914
+ hide = _antd.message.loading('正在生成打印内容,请稍候…', 0);
915
+ _context9.prev = 1;
916
+ imgUrls = [];
917
+ pages.forEach(function (p) {
918
+ var _String3;
919
+ if ( /*#__PURE__*/_react.default.isValidElement(p) && (_String3 = String(p.key)) !== null && _String3 !== void 0 && _String3.includes('attachment-')) {
920
+ var info = (0, _canvasUtils.extractAttachmentInfo)(p);
921
+ if ((info === null || info === void 0 ? void 0 : info.type) === 'image') imgUrls.push(info.src);
922
+ }
923
+ });
924
+ _context9.next = 6;
925
+ return (0, _canvasUtils.batchPreloadImages)(_toConsumableArray(new Set(imgUrls)));
926
+ case 6:
927
+ preloadMap = _context9.sent;
928
+ imgs = [];
929
+ _iterator4 = _createForOfIteratorHelper(pages);
930
+ _context9.prev = 9;
931
+ _iterator4.s();
932
+ case 11:
933
+ if ((_step4 = _iterator4.n()).done) {
934
+ _context9.next = 34;
935
+ break;
936
+ }
937
+ p = _step4.value;
938
+ if ( /*#__PURE__*/_react.default.isValidElement(p)) {
939
+ _context9.next = 15;
940
+ break;
941
+ }
942
+ return _context9.abrupt("continue", 32);
943
+ case 15:
944
+ k = ((_p$key3 = p.key) === null || _p$key3 === void 0 ? void 0 : _p$key3.toString()) || '';
945
+ cvs = null;
946
+ if (!k.includes('voucher-')) {
947
+ _context9.next = 25;
948
+ break;
949
+ }
950
+ props = (_children3 = p.props.children) === null || _children3 === void 0 ? void 0 : _children3.props;
951
+ if (!props) {
952
+ _context9.next = 23;
953
+ break;
954
+ }
955
+ _context9.next = 22;
956
+ return (0, _canvasUtils.createVoucherCanvas)(props, baseVoucherInfo);
957
+ case 22:
958
+ cvs = _context9.sent;
959
+ case 23:
960
+ _context9.next = 31;
961
+ break;
962
+ case 25:
963
+ if (!k.includes('attachment-')) {
964
+ _context9.next = 31;
965
+ break;
966
+ }
967
+ info = (0, _canvasUtils.extractAttachmentInfo)(p);
968
+ if (!info) {
969
+ _context9.next = 31;
970
+ break;
971
+ }
972
+ _context9.next = 30;
973
+ return (0, _canvasUtils.createAttachmentCanvasFixed)(info, preloadMap);
974
+ case 30:
975
+ cvs = _context9.sent;
976
+ case 31:
977
+ if (cvs) imgs.push(cvs.toDataURL('image/jpeg', 0.9));
978
+ case 32:
979
+ _context9.next = 11;
980
+ break;
981
+ case 34:
982
+ _context9.next = 39;
983
+ break;
984
+ case 36:
985
+ _context9.prev = 36;
986
+ _context9.t0 = _context9["catch"](9);
987
+ _iterator4.e(_context9.t0);
988
+ case 39:
989
+ _context9.prev = 39;
990
+ _iterator4.f();
991
+ return _context9.finish(39);
992
+ case 42:
993
+ w = window.open('', '_blank');
994
+ if (w) {
995
+ _context9.next = 47;
996
+ break;
997
+ }
998
+ _antd.message.error('请允许弹窗');
999
+ hide();
1000
+ return _context9.abrupt("return");
1001
+ case 47:
1002
+ w.document.write("<html><head><style>@page{size:landscape;margin:0;}body{margin:0}.p{width:100vw;height:100vh;display:flex;align-items:center;justify-content:center;page-break-after:always}img{max-width:100%;max-height:100%}</style></head><body>".concat(imgs.map(function (i) {
1003
+ return "<div class=\"p\"><img src=\"".concat(i, "\" /></div>");
1004
+ }).join(''), "</body><script>window.onload=()=>setTimeout(()=>window.print(),500)</script></html>"));
1005
+ w.document.close();
1006
+ _context9.next = 54;
1007
+ break;
1008
+ case 51:
1009
+ _context9.prev = 51;
1010
+ _context9.t1 = _context9["catch"](1);
1011
+ _antd.message.error('打印失败');
1012
+ case 54:
1013
+ _context9.prev = 54;
1014
+ hide();
1015
+ return _context9.finish(54);
1016
+ case 57:
1017
+ case "end":
1018
+ return _context9.stop();
1019
+ }
1020
+ }, _callee9, null, [[1, 51, 54, 57], [9, 36, 39, 42]]);
1021
+ }));
1022
+ return function handlePrint() {
1023
+ return _ref10.apply(this, arguments);
1024
+ };
1025
+ }();
1026
+ var goToTypePage = function goToTypePage(title) {
1027
+ goToFirstPage();
1028
+ setCurrentFilterTitle(title);
1029
+ if (title === "all") {
1030
+ var filtered = filterPagesByDocTitle(originalPagesFull, title);
1031
+ setPages(filtered);
1032
+ } else {
1033
+ var _filtered = filterPagesByDocTitle(originalPagesFull, title);
1034
+ var newFiltered = _filtered.filter(function (p) {
1035
+ var _String4;
1036
+ return !((_String4 = String(p.key)) !== null && _String4 !== void 0 && _String4.includes('voucher-'));
1037
+ });
1038
+ setPages(newFiltered);
1039
+ }
1040
+ setCurrentPageIndex(0);
1041
+ setSearchValue('');
1042
+ setTimeout(function () {
1043
+ if (bookRef.current) bookRef.current.pageFlip().turnToPage(0);
1044
+ }, 50);
1045
+ };
1046
+ var isLoading = externalLoading || loading;
1047
+ var finalLoadingMessage = externalLoadingMessage || loadingMessage;
1048
+ var isPdfLoading = externalPdfLoading || pdfLoading;
11
1049
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
12
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
13
- children: "Accounting Book Component"
14
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
15
- children: "This is a placeholder for the Accounting Book component."
1050
+ className: "accounting-book-component",
1051
+ children: [isLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingComponent.LoadingComponent, {
1052
+ message: finalLoadingMessage,
1053
+ pdfLoading: isPdfLoading
1054
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderBar.default, {
1055
+ currentPage: currentPageIndex,
1056
+ totalPages: pages.length,
1057
+ onGoFirst: goToFirstPage,
1058
+ onPrevPage: loadPrevVoucher,
1059
+ onNextPage: loadNextVoucher,
1060
+ onGoLast: goToLastPage,
1061
+ onPrint: handlePrint,
1062
+ onDownload: handleDownload,
1063
+ onUnbinding: onUnbinding,
1064
+ onRefresh: handleRefresh,
1065
+ showSearchSelect: true,
1066
+ searchValue: searchValue,
1067
+ searchOptions: searchOptions,
1068
+ onSearchInputChange: handleAmountSearch,
1069
+ onSearchSelect: handleGotoPageByAmount,
1070
+ onSearchClear: handleSearchClear,
1071
+ iconColor: iconColor,
1072
+ themeColor: themeColor
1073
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1074
+ className: "flipbook",
1075
+ children: pages.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1076
+ className: "flipbook-container",
1077
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1078
+ src: _constants.filpBg,
1079
+ alt: "bg",
1080
+ style: {
1081
+ position: 'absolute',
1082
+ top: 10,
1083
+ left: -76,
1084
+ height: 487,
1085
+ zIndex: 1
1086
+ }
1087
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1088
+ src: _constants.defaultLine,
1089
+ alt: "defaultLine",
1090
+ style: {
1091
+ position: 'absolute',
1092
+ top: 50,
1093
+ left: -88,
1094
+ width: 416,
1095
+ height: 266,
1096
+ zIndex: 3,
1097
+ transform: 'rotate(-10.9deg)',
1098
+ opacity: currentPageIndex === 0 ? 1 : 0
1099
+ }
1100
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1101
+ src: _constants.activeLine,
1102
+ alt: "activeLine",
1103
+ style: {
1104
+ position: 'absolute',
1105
+ top: 50,
1106
+ left: -88,
1107
+ width: 416,
1108
+ height: 266,
1109
+ zIndex: 3,
1110
+ transform: 'rotate(-10.9deg)',
1111
+ opacity: currentPageIndex >= 1 ? 1 : 0
1112
+ }
1113
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPageflip.default, {
1114
+ width: 998,
1115
+ height: 520,
1116
+ size: "fixed",
1117
+ minWidth: 998,
1118
+ maxWidth: 1854,
1119
+ minHeight: 520,
1120
+ maxHeight: 872,
1121
+ maxShadowOpacity: 0.5,
1122
+ showCover: false,
1123
+ mobileScrollSupport: true,
1124
+ ref: bookRef,
1125
+ className: "flip-book",
1126
+ drawShadow: true,
1127
+ flippingTime: 20,
1128
+ usePortrait: true,
1129
+ onFlip: handleFlip,
1130
+ startPage: currentPageIndex,
1131
+ autoSize: true,
1132
+ style: {
1133
+ position: 'relative',
1134
+ zIndex: 2
1135
+ },
1136
+ startZIndex: 2,
1137
+ clickEventForward: false,
1138
+ useMouseEvents: true,
1139
+ swipeDistance: 30,
1140
+ showPageCorners: false,
1141
+ disableFlipByClick: false,
1142
+ renderOnlyPageLengthChange: false,
1143
+ children: pages.map(function (p, i) {
1144
+ var isNear = Math.abs(i - currentPageIndex) <= 4;
1145
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FilpPage.FilpPage, {
1146
+ index: i,
1147
+ children: isNear ? p : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1148
+ style: {
1149
+ width: '100%',
1150
+ height: '100%',
1151
+ background: '#fff'
1152
+ }
1153
+ })
1154
+ }, "p-".concat(i));
1155
+ })
1156
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1157
+ className: "fliterBar",
1158
+ children: filterList.map(function (item, idx) {
1159
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1160
+ className: "filter-item ".concat(currentFilterTitle === item.type ? 'active' : ''),
1161
+ onClick: function onClick() {
1162
+ return goToTypePage(item.type);
1163
+ },
1164
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1165
+ className: "filter-text",
1166
+ children: item.name
1167
+ })
1168
+ }, idx);
1169
+ })
1170
+ })]
1171
+ })
16
1172
  })]
17
1173
  });
18
1174
  };