@cecee/document-flip-book 1.0.19 → 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 +6 -3
  44. package/dist/cjs/DocumentFlipBook/index.less +235 -9
  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 +6 -3
  89. package/dist/esm/DocumentFlipBook/index.less +235 -9
  90. package/dist/esm/declarations.d.ts +21 -0
  91. package/package.json +8 -2
@@ -0,0 +1,259 @@
1
+ "use strict";
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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PDFPageRenderer = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactImageMagnifiers = require("react-image-magnifiers");
10
+ var _utils = require("../utils/utils");
11
+ require("react-pdf/dist/Page/AnnotationLayer.css");
12
+ require("react-pdf/dist/Page/TextLayer.css");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ 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); }
15
+ 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; }
16
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
17
+ function 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); } }
18
+ 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); }); }; }
19
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
20
+ 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."); }
21
+ 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); }
22
+ 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; }
23
+ 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; } }
24
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
+ var PDFPageRenderer = exports.PDFPageRenderer = function PDFPageRenderer(_ref) {
26
+ var pdfPath = _ref.pdfPath,
27
+ attachmentId = _ref.attachmentId,
28
+ pageNumber = _ref.pageNumber,
29
+ currentIndex = _ref.currentIndex,
30
+ totalCount = _ref.totalCount,
31
+ amount = _ref.amount;
32
+ var _useState = (0, _react.useState)(''),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ pdfImageUrl = _useState2[0],
35
+ setPdfImageUrl = _useState2[1];
36
+ var _useState3 = (0, _react.useState)(''),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ highResImageUrl = _useState4[0],
39
+ setHighResImageUrl = _useState4[1];
40
+ var _useState5 = (0, _react.useState)(true),
41
+ _useState6 = _slicedToArray(_useState5, 2),
42
+ isLoading = _useState6[0],
43
+ setIsLoading = _useState6[1];
44
+ var _useState7 = (0, _react.useState)(''),
45
+ _useState8 = _slicedToArray(_useState7, 2),
46
+ error = _useState8[0],
47
+ setError = _useState8[1];
48
+ var canvasRef = (0, _react.useRef)(null);
49
+ var highResCanvasRef = (0, _react.useRef)(null);
50
+ var formattedAmount = amount ? Number(amount).toLocaleString('zh-CN', {
51
+ minimumFractionDigits: 2,
52
+ maximumFractionDigits: 2
53
+ }) : '0.00';
54
+ (0, _react.useEffect)(function () {
55
+ var isCancelled = false;
56
+ var convertPDFToImage = /*#__PURE__*/function () {
57
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
58
+ var pdf, page, normalCanvas, normalContext, normalViewport, highResCanvas, highResContext, highResViewport;
59
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
60
+ while (1) switch (_context.prev = _context.next) {
61
+ case 0:
62
+ setIsLoading(true);
63
+ setError('');
64
+ _context.prev = 2;
65
+ _context.next = 5;
66
+ return _utils.globalPdfCache.getDocument(pdfPath);
67
+ case 5:
68
+ pdf = _context.sent;
69
+ if (!isCancelled) {
70
+ _context.next = 8;
71
+ break;
72
+ }
73
+ return _context.abrupt("return");
74
+ case 8:
75
+ _context.next = 10;
76
+ return pdf.getPage(pageNumber);
77
+ case 10:
78
+ page = _context.sent;
79
+ if (!isCancelled) {
80
+ _context.next = 13;
81
+ break;
82
+ }
83
+ return _context.abrupt("return");
84
+ case 13:
85
+ normalCanvas = canvasRef.current;
86
+ if (!normalCanvas) {
87
+ _context.next = 23;
88
+ break;
89
+ }
90
+ normalContext = normalCanvas.getContext('2d');
91
+ if (!normalContext) {
92
+ _context.next = 23;
93
+ break;
94
+ }
95
+ normalViewport = page.getViewport({
96
+ scale: 1.2
97
+ });
98
+ normalCanvas.height = normalViewport.height;
99
+ normalCanvas.width = normalViewport.width;
100
+ _context.next = 22;
101
+ return page.render({
102
+ canvasContext: normalContext,
103
+ viewport: normalViewport
104
+ }).promise;
105
+ case 22:
106
+ if (!isCancelled) setPdfImageUrl(normalCanvas.toDataURL('image/png', 0.95));
107
+ case 23:
108
+ highResCanvas = highResCanvasRef.current;
109
+ if (!highResCanvas) {
110
+ _context.next = 33;
111
+ break;
112
+ }
113
+ highResContext = highResCanvas.getContext('2d');
114
+ if (!highResContext) {
115
+ _context.next = 33;
116
+ break;
117
+ }
118
+ highResViewport = page.getViewport({
119
+ scale: 2.0
120
+ });
121
+ highResCanvas.height = highResViewport.height;
122
+ highResCanvas.width = highResViewport.width;
123
+ _context.next = 32;
124
+ return page.render({
125
+ canvasContext: highResContext,
126
+ viewport: highResViewport
127
+ }).promise;
128
+ case 32:
129
+ if (!isCancelled) setHighResImageUrl(highResCanvas.toDataURL('image/png', 0.95));
130
+ case 33:
131
+ if (!isCancelled) setIsLoading(false);
132
+ _context.next = 40;
133
+ break;
134
+ case 36:
135
+ _context.prev = 36;
136
+ _context.t0 = _context["catch"](2);
137
+ console.error('PDF转图片失败:', _context.t0);
138
+ if (!isCancelled) {
139
+ setError(_context.t0 instanceof Error ? _context.t0.message : 'PDF加载失败');
140
+ setIsLoading(false);
141
+ }
142
+ case 40:
143
+ case "end":
144
+ return _context.stop();
145
+ }
146
+ }, _callee, null, [[2, 36]]);
147
+ }));
148
+ return function convertPDFToImage() {
149
+ return _ref2.apply(this, arguments);
150
+ };
151
+ }();
152
+ convertPDFToImage();
153
+ return function () {
154
+ isCancelled = true;
155
+ };
156
+ }, [pdfPath, pageNumber]);
157
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
158
+ style: {
159
+ width: '100%',
160
+ height: '100%',
161
+ backgroundColor: '#fff',
162
+ position: 'relative'
163
+ },
164
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
165
+ style: {
166
+ margin: '0 auto',
167
+ padding: '10px',
168
+ textAlign: 'center',
169
+ fontSize: '26px',
170
+ width: '220px',
171
+ fontWeight: 'bold',
172
+ color: '#597461'
173
+ },
174
+ children: "\u539F\u59CB\u51ED\u8BC1\u7C98\u8D34\u5355"
175
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
176
+ style: {
177
+ position: 'absolute',
178
+ top: '10px',
179
+ right: '20px',
180
+ textAlign: 'right',
181
+ fontSize: '14px',
182
+ color: '#597461',
183
+ lineHeight: '1.5'
184
+ },
185
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
186
+ children: ["\u539F\u59CB\u51ED\u8BC1 ", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
187
+ style: {
188
+ borderBottom: '1px solid #597461'
189
+ },
190
+ children: [currentIndex, "/", totalCount]
191
+ }), " \u5F20"]
192
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
193
+ children: ["\u91D1\u989D ", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
194
+ style: {
195
+ borderBottom: '1px solid #597461'
196
+ },
197
+ children: formattedAmount
198
+ })]
199
+ })]
200
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
201
+ style: {
202
+ width: '100%',
203
+ height: '85%',
204
+ display: 'flex',
205
+ justifyContent: 'center',
206
+ alignItems: 'center',
207
+ border: '1px solid #597461',
208
+ overflow: 'hidden'
209
+ },
210
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("canvas", {
211
+ ref: canvasRef,
212
+ style: {
213
+ display: 'none'
214
+ }
215
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("canvas", {
216
+ ref: highResCanvasRef,
217
+ style: {
218
+ display: 'none'
219
+ }
220
+ }), isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
221
+ style: {
222
+ color: '#999',
223
+ fontSize: '20px'
224
+ },
225
+ children: "PDF \u8F6C\u6362\u4E2D..."
226
+ }) : error ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
227
+ style: {
228
+ textAlign: 'center',
229
+ color: '#f00',
230
+ fontSize: '16px'
231
+ },
232
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
233
+ children: "PDF \u52A0\u8F7D\u5931\u8D25"
234
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
235
+ style: {
236
+ fontSize: '12px',
237
+ marginTop: '5px'
238
+ },
239
+ children: error
240
+ })]
241
+ }) : pdfImageUrl && highResImageUrl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactImageMagnifiers.GlassMagnifier, {
242
+ imageSrc: pdfImageUrl,
243
+ imageAlt: "PDF\u9884\u89C8",
244
+ largeImageSrc: highResImageUrl,
245
+ magnifierBorderSize: 3,
246
+ magnifierBorderColor: "rgba(255, 255, 255, 0.5)",
247
+ magnifierBackgroundColor: "rgba(0, 0, 0, 0.1)",
248
+ square: false,
249
+ magnifierSize: "25%",
250
+ style: {
251
+ maxWidth: '100%',
252
+ maxHeight: '100%',
253
+ objectFit: 'contain',
254
+ cursor: 'zoom-in'
255
+ }
256
+ }) : null]
257
+ })]
258
+ });
259
+ };
@@ -0,0 +1,6 @@
1
+ .dfb-divider {
2
+ width: 1px !important;
3
+ height: 18px !important;
4
+ background: #e8e8e8;
5
+ margin: 0 8px;
6
+ }
@@ -0,0 +1,11 @@
1
+ export declare const filpBg: string;
2
+ export declare const defaultLine: string;
3
+ export declare const activeLine: string;
4
+ export declare const VOUCHER_MIN_ROWS = 5;
5
+ export declare const PAGE_SIZE: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ export declare const MIN_ROWS = 5;
10
+ export declare const PAGE_WIDTH = 998;
11
+ export declare const PAGE_HEIGHT = 520;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filpBg = exports.defaultLine = exports.activeLine = exports.VOUCHER_MIN_ROWS = exports.PAGE_WIDTH = exports.PAGE_SIZE = exports.PAGE_HEIGHT = exports.MIN_ROWS = void 0;
7
+ var _filpBg = _interopRequireDefault(require("./assets/filp-bg.png"));
8
+ var _defaultLine = _interopRequireDefault(require("./assets/default-line.png"));
9
+ var _activeLine = _interopRequireDefault(require("./assets/active-line.png"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ // 图片资源
12
+
13
+ var filpBg = exports.filpBg = _filpBg.default;
14
+ var defaultLine = exports.defaultLine = _defaultLine.default;
15
+ var activeLine = exports.activeLine = _activeLine.default;
16
+
17
+ // 渲染配置
18
+ var VOUCHER_MIN_ROWS = exports.VOUCHER_MIN_ROWS = 5;
19
+ var PAGE_SIZE = exports.PAGE_SIZE = {
20
+ width: 998,
21
+ height: 520
22
+ };
23
+ var MIN_ROWS = exports.MIN_ROWS = 5;
24
+ var PAGE_WIDTH = exports.PAGE_WIDTH = 998;
25
+ var PAGE_HEIGHT = exports.PAGE_HEIGHT = 520;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ export interface AmountSearchItem {
3
+ label: string;
4
+ value: string;
5
+ amount: string;
6
+ pageKey: string;
7
+ }
8
+ export interface UseAmountSearchProps {
9
+ originalPagesFull: React.ReactNode[];
10
+ bookRef: React.RefObject<any>;
11
+ setCurrentFilterTitle: (title: string) => void;
12
+ setPages: (pages: React.ReactNode[]) => void;
13
+ setCurrentPageIndex: (index: number) => void;
14
+ goToFirstPage: () => void;
15
+ }
16
+ export declare const useAmountSearch: ({ originalPagesFull, bookRef, setCurrentFilterTitle, setPages, setCurrentPageIndex, goToFirstPage, }: UseAmountSearchProps) => {
17
+ searchValue: string;
18
+ setSearchValue: React.Dispatch<React.SetStateAction<string>>;
19
+ searchOptions: AmountSearchItem[];
20
+ handleAmountSearch: (value: string) => void;
21
+ handleGotoPageByAmount: (value: string) => void;
22
+ handleSearchClear: () => void;
23
+ buildAllAmountOptions: (data: any) => void;
24
+ };
@@ -0,0 +1,165 @@
1
+ "use strict";
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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useAmountSearch = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ 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); }
10
+ 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; }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ 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."); }
13
+ 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); }
14
+ 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; }
15
+ 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; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ // ====================== TS 类型 ======================
18
+
19
+ // ====================== 独立 Hook ======================
20
+ var useAmountSearch = exports.useAmountSearch = function useAmountSearch(_ref) {
21
+ var originalPagesFull = _ref.originalPagesFull,
22
+ bookRef = _ref.bookRef,
23
+ setCurrentFilterTitle = _ref.setCurrentFilterTitle,
24
+ setPages = _ref.setPages,
25
+ setCurrentPageIndex = _ref.setCurrentPageIndex,
26
+ goToFirstPage = _ref.goToFirstPage;
27
+ var _useState = (0, _react.useState)(''),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ searchValue = _useState2[0],
30
+ setSearchValue = _useState2[1];
31
+ var _useState3 = (0, _react.useState)([]),
32
+ _useState4 = _slicedToArray(_useState3, 2),
33
+ searchOptions = _useState4[0],
34
+ setSearchOptions = _useState4[1];
35
+ var allSearchItems = (0, _react.useRef)([]);
36
+ var amountToPageMap = (0, _react.useRef)(new Map());
37
+
38
+ // 输入搜索
39
+ var handleAmountSearch = function handleAmountSearch(value) {
40
+ setSearchValue(value);
41
+ if (allSearchItems.current.length === 0) return;
42
+ var keywords = (value === null || value === void 0 ? void 0 : value.trim().toLowerCase()) || '';
43
+ var filtered = keywords ? allSearchItems.current.filter(function (item) {
44
+ return item.amount.toLowerCase().includes(keywords) || item.label.toLowerCase().includes(keywords);
45
+ }) : allSearchItems.current;
46
+ setSearchOptions(filtered);
47
+ };
48
+
49
+ // 点击搜索项 → 跳转到对应凭证
50
+ var handleGotoPageByAmount = function handleGotoPageByAmount(value) {
51
+ var targetItem = allSearchItems.current.find(function (item) {
52
+ return item.value === value;
53
+ });
54
+ if (!targetItem) return;
55
+ goToFirstPage();
56
+ setSearchValue(targetItem.label);
57
+ var targetPageKey = targetItem.pageKey;
58
+ // 匹配 key 筛选页面
59
+ var filteredPages = originalPagesFull.filter(function (p) {
60
+ if (! /*#__PURE__*/_react.default.isValidElement(p)) return false;
61
+ var pageKey = p.key || '';
62
+ return pageKey.includes(targetPageKey);
63
+ });
64
+ if (!filteredPages.length) return;
65
+ setCurrentFilterTitle('');
66
+ setPages(filteredPages);
67
+ setCurrentPageIndex(0);
68
+ setTimeout(function () {
69
+ var _bookRef$current;
70
+ (_bookRef$current = bookRef.current) === null || _bookRef$current === void 0 || _bookRef$current.pageFlip().turnToPage(0);
71
+ }, 50);
72
+ };
73
+
74
+ // 清空搜索
75
+ var handleSearchClear = function handleSearchClear() {
76
+ setSearchValue('');
77
+ setSearchOptions(allSearchItems.current);
78
+ setPages(originalPagesFull);
79
+ setCurrentFilterTitle('all');
80
+ setCurrentPageIndex(0);
81
+ setTimeout(function () {
82
+ var _bookRef$current2;
83
+ (_bookRef$current2 = bookRef.current) === null || _bookRef$current2 === void 0 || _bookRef$current2.pageFlip().turnToPage(0);
84
+ }, 50);
85
+ };
86
+
87
+ // 构建搜索选项
88
+ var buildAllAmountOptions = function buildAllAmountOptions(data) {
89
+ var _data$items;
90
+ var stubPages = (data === null || data === void 0 || (_data$items = data.items) === null || _data$items === void 0 ? void 0 : _data$items.stub_pages) || [];
91
+ if (!stubPages.length) return;
92
+ var items = [];
93
+ var pageMap = new Map();
94
+ var addSearchItem = function addSearchItem(key, label, amount, pageKey) {
95
+ items.push({
96
+ label: label,
97
+ value: key,
98
+ amount: amount,
99
+ pageKey: pageKey
100
+ });
101
+ pageMap.set(key, pageKey);
102
+ };
103
+
104
+ // 金额格式化:保留2位小数,避免科学计数/截断
105
+ var formatAmount = function formatAmount(amt) {
106
+ var num = Number(amt) || 0;
107
+ return num.toFixed(2);
108
+ };
109
+ stubPages.forEach(function (stubPage) {
110
+ var _stubPage$stub_page_d2;
111
+ var stubId = stubPage.id,
112
+ _stubPage$code = stubPage.code,
113
+ code = _stubPage$code === void 0 ? '' : _stubPage$code,
114
+ _stubPage$remark = stubPage.remark,
115
+ remark = _stubPage$remark === void 0 ? '无备注' : _stubPage$remark,
116
+ _stubPage$amount = stubPage.amount,
117
+ amount = _stubPage$amount === void 0 ? '0' : _stubPage$amount,
118
+ _stubPage$stub_page_d = stubPage.stub_page_details,
119
+ stub_page_details = _stubPage$stub_page_d === void 0 ? [] : _stubPage$stub_page_d,
120
+ _stubPage$stub_page_r = stubPage.stub_page_raws,
121
+ stub_page_raws = _stubPage$stub_page_r === void 0 ? [] : _stubPage$stub_page_r;
122
+ var voucherText = "\u8BB0".concat(code);
123
+ var voucherKey = "voucher-".concat(((_stubPage$stub_page_d2 = stubPage.stub_page_details) === null || _stubPage$stub_page_d2 === void 0 || (_stubPage$stub_page_d2 = _stubPage$stub_page_d2[0]) === null || _stubPage$stub_page_d2 === void 0 ? void 0 : _stubPage$stub_page_d2.id) || '', "-1");
124
+ var formattedTotalAmt = formatAmount(amount);
125
+ // 1. 总金额项(完全匹配截图样式:记XX|备注|总金额 → 金额)
126
+ addSearchItem("stub_".concat(stubId), "".concat(voucherText, "\uFF5C").concat(remark, "\uFF5C").concat(formattedTotalAmt), formattedTotalAmt, voucherKey);
127
+
128
+ // 2. 凭证明细项(完全匹配截图样式:记XX|备注|凭证明细 → 金额)
129
+ stub_page_details.forEach(function (detail) {
130
+ var detailAmt = detail.amount || '0';
131
+ var formattedDetailAmt = formatAmount(detailAmt);
132
+ var tradeDirection = detail.trade_direction || '';
133
+
134
+ // addSearchItem(
135
+ // `detail_${detail.id}`,
136
+ // `${voucherText}|${remark}(${tradeDirection})|${formattedDetailAmt}`,
137
+ // formattedDetailAmt,
138
+ // voucherKey
139
+ // );
140
+ });
141
+
142
+ // 3. 原始单据/附件项(完全匹配截图样式:记XX|附件标题|附件N → 金额)
143
+ stub_page_raws.forEach(function (raw, idx) {
144
+ var _raw$attachments;
145
+ var rawAmt = raw.amount || '0';
146
+ var title = raw.title || '无标题';
147
+ var formattedRawAmt = formatAmount(rawAmt);
148
+ var attachKey = (_raw$attachments = raw.attachments) !== null && _raw$attachments !== void 0 && (_raw$attachments = _raw$attachments[0]) !== null && _raw$attachments !== void 0 && _raw$attachments.id ? "attachment-".concat(raw.attachments[0].id) : voucherKey;
149
+ addSearchItem("raw_".concat(raw.id), "".concat(voucherText, "\uFF5C").concat(title, "\uFF5C\u9644\u4EF6").concat(idx + 1, " | ").concat(formattedRawAmt), formattedRawAmt, attachKey);
150
+ });
151
+ });
152
+ allSearchItems.current = items;
153
+ amountToPageMap.current = pageMap;
154
+ setSearchOptions(items);
155
+ };
156
+ return {
157
+ searchValue: searchValue,
158
+ setSearchValue: setSearchValue,
159
+ searchOptions: searchOptions,
160
+ handleAmountSearch: handleAmountSearch,
161
+ handleGotoPageByAmount: handleGotoPageByAmount,
162
+ handleSearchClear: handleSearchClear,
163
+ buildAllAmountOptions: buildAllAmountOptions
164
+ };
165
+ };
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ bookRef: React.RefObject<any>;
4
+ currentPageIndex: number;
5
+ totalPages: number;
6
+ setCurrentPageIndex: (index: number) => void;
7
+ }
8
+ export declare function usePageFlip({ bookRef, currentPageIndex, totalPages, setCurrentPageIndex, }: Props): {
9
+ handleFlip: (e: any) => void;
10
+ loadPrevVoucher: () => void;
11
+ loadNextVoucher: () => void;
12
+ goToFirstPage: () => void;
13
+ goToLastPage: () => void;
14
+ };
15
+ export {};
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.usePageFlip = usePageFlip;
7
+ var _react = require("react");
8
+ var _antd = require("antd");
9
+ function usePageFlip(_ref) {
10
+ var bookRef = _ref.bookRef,
11
+ currentPageIndex = _ref.currentPageIndex,
12
+ totalPages = _ref.totalPages,
13
+ setCurrentPageIndex = _ref.setCurrentPageIndex;
14
+ var isNavigating = (0, _react.useCallback)(function () {
15
+ return false;
16
+ }, []);
17
+
18
+ // 上一页
19
+ var loadPrevVoucher = (0, _react.useCallback)(function () {
20
+ if (!bookRef.current || currentPageIndex <= 0) {
21
+ _antd.message.info('已经是第一页', 1);
22
+ return;
23
+ }
24
+ bookRef.current.pageFlip().flipPrev();
25
+ }, [bookRef, currentPageIndex]);
26
+
27
+ // 下一页 ✅
28
+ var loadNextVoucher = (0, _react.useCallback)(function () {
29
+ if (!bookRef.current || currentPageIndex >= totalPages - 1) {
30
+ _antd.message.info('已经是最后一页', 1);
31
+ return;
32
+ }
33
+ bookRef.current.pageFlip().flipNext();
34
+ }, [bookRef, currentPageIndex, totalPages]);
35
+
36
+ // 首页
37
+ var goToFirstPage = (0, _react.useCallback)(function () {
38
+ if (!bookRef.current) return;
39
+ bookRef.current.pageFlip().turnToPage(0);
40
+ }, [bookRef]);
41
+
42
+ // 尾页
43
+ var goToLastPage = (0, _react.useCallback)(function () {
44
+ if (!bookRef.current || totalPages === 0) return;
45
+ var last = totalPages - 1;
46
+ bookRef.current.pageFlip().flip(last, {
47
+ duration: 0
48
+ });
49
+ }, [bookRef, totalPages]);
50
+
51
+ // 翻页事件(这里会自动同步 index)
52
+ var handleFlip = (0, _react.useCallback)(function (e) {
53
+ var newPage = e.data;
54
+ if (newPage < 0 || newPage >= totalPages) {
55
+ _antd.message.info(newPage < 0 ? '已经是第一页' : '已经是最后一页', 2);
56
+ return;
57
+ }
58
+ setCurrentPageIndex(newPage);
59
+ }, [totalPages, setCurrentPageIndex]);
60
+ return {
61
+ handleFlip: handleFlip,
62
+ loadPrevVoucher: loadPrevVoucher,
63
+ loadNextVoucher: loadNextVoucher,
64
+ goToFirstPage: goToFirstPage,
65
+ goToLastPage: goToLastPage
66
+ };
67
+ }
@@ -1,3 +1,31 @@
1
1
  import React from 'react';
2
- declare const AccountingBook: React.FC;
2
+ import './index.less';
3
+ import 'react-pdf/dist/Page/AnnotationLayer.css';
4
+ import 'react-pdf/dist/Page/TextLayer.css';
5
+ import { StubPage } from './types';
6
+ interface AccountingBookProps {
7
+ data: {
8
+ stub_pages: StubPage[];
9
+ total_page: number;
10
+ };
11
+ loading?: boolean;
12
+ loadingMessage?: string;
13
+ pdfLoading?: boolean;
14
+ companyInfo?: {
15
+ name: string;
16
+ };
17
+ baseVoucherInfo: {
18
+ company: string;
19
+ accountant: string;
20
+ recorder: string;
21
+ maker: string;
22
+ };
23
+ onUnbinding?: () => void;
24
+ onLoadMore?: (nextPage: number) => Promise<void>;
25
+ ledgerBookListApi?: (params: any) => Promise<any>;
26
+ onRefresh?: () => void;
27
+ iconColor?: string;
28
+ themeColor?: string;
29
+ }
30
+ export declare const AccountingBook: React.FC<AccountingBookProps>;
3
31
  export default AccountingBook;