@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
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAttachmentCanvasHtml = getAttachmentCanvasHtml;
7
+ exports.getAttachmentPasteHtml = getAttachmentPasteHtml;
8
+ exports.getCoverCanvasHtml = getCoverCanvasHtml;
9
+ exports.getFullFlipbookHtml = getFullFlipbookHtml;
10
+ exports.getVoucherCanvasHtml = getVoucherCanvasHtml;
11
+ var _moment = _interopRequireDefault(require("moment"));
12
+ var _utils = require("./utils");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15
+ 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."); }
16
+ 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); }
17
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
+ 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; } /**
20
+ * HTML 模板工具类
21
+ * 所有动态拼接的 HTML 统一抽离在这里
22
+ */
23
+ // ------------------------------
24
+ // 1. 原始凭证粘贴单 HTML
25
+ // ------------------------------
26
+ function getAttachmentPasteHtml(attachment, amount, count) {
27
+ var isPDF = attachment.path.toLowerCase().endsWith('.pdf');
28
+ var formattedAmount = amount ? Number(amount).toLocaleString('zh-CN', {
29
+ minimumFractionDigits: 2
30
+ }) : '0.00';
31
+ return "\n <div style=\"width:100%;height:100%;padding:20px;box-sizing:border-box;background-color:#ffffff;\">\n <div style=\"text-align:center;font-size:24px;font-weight:bold;margin-bottom:15px;color:#8b4513;\">\n \u539F\u59CB\u51ED\u8BC1\u7C98\u8D34\u5355\n </div>\n <div style=\"position:absolute;top:20px;right:20px;text-align:right;font-size:14px;color:#8b4513;\">\n <div>\u539F\u59CB\u51ED\u8BC1: <span style=\"border-bottom:1px solid #8b4513;\">".concat(count, "</span> \u5F20</div>\n <div>\u91D1\u989D: <span style=\"border-bottom:1px solid #8b4513;\">").concat(formattedAmount, "</span></div>\n </div>\n <div style=\"width:100%;height:85%;display:flex;justify-content:center;align-items:center;\n border:1px dashed #8b4513;margin-top:20px;background-color:white;\">\n ").concat(isPDF ? "<div style=\"color:#666;font-size:16px;\">PDF\u9644\u4EF6 (".concat(attachment.path.split('/').pop(), ")</div>") : "<img src=\"".concat(attachment.path, "\" style=\"max-width:100%;max-height:100%;object-fit:contain;\"\n onerror=\"this.style.display='none';this.parentElement.innerHTML='<div style=\\\"color:red;font-size:20px;\\\">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div>'\">"), "\n </div>\n </div>\n ");
32
+ }
33
+
34
+ // ------------------------------
35
+ // 2. 记账凭证画布 HTML(导出PDF用)
36
+ // ------------------------------
37
+ function getVoucherCanvasHtml(voucherProps, baseVoucherInfo) {
38
+ var _voucherProps$date;
39
+ var originalEntries = voucherProps.entries || [];
40
+ var MIN_ROWS = 5;
41
+ var paddedEntries = _toConsumableArray(originalEntries);
42
+ while (paddedEntries.length < MIN_ROWS) {
43
+ paddedEntries.push({
44
+ summary: '',
45
+ account: '',
46
+ debit: '0',
47
+ credit: '0',
48
+ trade_direction: ''
49
+ });
50
+ }
51
+ return "\n <div class=\"voucher-wrapper\" style=\"\n background-color: #ffffff;\n color: #000;\n width: 998px;\n height: 520px;\n display: flex;\n justify-content: center;\n align-items: center;\n \">\n <div class=\"voucher-container\" style=\"\n max-width: 100%;\n max-height: 100%;\n background-color: #ffffff;\n position: relative;\n \">\n <div class=\"voucher-header\" style=\"text-align: center;\">\n <h1 style=\"font-size: 24px; margin: 0; letter-spacing: 4px; color: #000;\">\u8BB0 \u8D26 \u51ED \u8BC1</h1>\n <div class=\"header-line\" style=\"height: 1px; background-color: #000; margin: 8px auto; width: 300px; position: relative;\">\n <div style=\"position: absolute; top: 2px; left: 0; right: 0; height: 1px; background-color: #000;\"></div>\n </div>\n <div class=\"date\" style=\"font-size: 16px; margin-top: 10px;\">".concat(((_voucherProps$date = voucherProps.date) === null || _voucherProps$date === void 0 ? void 0 : _voucherProps$date.replace(/<[^>]+>/g, '')) || '', "</div>\n </div>\n\n <div class=\"company-info\" style=\"display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px;\">\n <div class=\"company-name\" style=\"margin-right: 5px;\">\n <span style=\"color: #000;\">\u516C\u53F8\uFF1A</span>\n ").concat(voucherProps.company || baseVoucherInfo.company, "\n </div>\n <div class=\"voucher-no\" style=\"margin-right: 20px;\">\n <span style=\"color: #000;\">\u5B57\u7B2C</span> ").concat(voucherProps.voucherNo || '', " <span style=\"color: #000;\">\u53F7</span>\n </div>\n </div>\n\n <div class=\"voucher-table-wrapper\" style=\"border: 1px solid #000; padding: 1px; width: 890px;\">\n <table class=\"voucher-table\" style=\"width: 100%; border-collapse: collapse; border: 1px solid #000;\">\n <thead>\n <tr>\n <th class=\"summary\" style=\"width: 40%; text-align: center; border: 1px solid #000; height: 40px;\">\n <span style=\"color: #000;\">\u6458\u8981</span>\n </th>\n <th class=\"subject\" style=\"width: 45%; text-align: center; border: 1px solid #000; height: 40px;\">\n <span style=\"color: #000;\">\u79D1\u76EE</span>\n </th>\n <th class=\"checkmark\" style=\"width: 20px; text-align: center; border: 1px solid #000; color: #000; font-weight: normal; border-right: none; height: 40px;\"></th>\n <th class=\"amount\" colspan=\"11\" style=\"width: 22.5%; padding: 0; border: 1px solid #000; height: 40px;\">\n <div class=\"amount-header\" style=\"border-bottom: 1px solid #000; padding: 5px 0;\">\n <span style=\"color: #000;\">\u501F\u65B9\u91D1\u989D</span>\n </div>\n <div class=\"amount-grid\" style=\"display: grid; grid-template-columns: repeat(11, 1fr);\">\n ").concat(['亿', '千', '百', '十', '万', '千', '百', '十', '元', '角', '分'].map(function (unit) {
52
+ return "\n <span style=\"border-right: 1px solid #000; font-size: 12px; height: 24px; line-height: 24px; display: flex; align-items: center; justify-content: center; color: #000;\">".concat(unit, "</span>\n ");
53
+ }).join(''), "\n </div>\n </th>\n <th class=\"checkmark\" style=\"text-align: center; border: 1px solid #000; color: #000; font-weight: normal; border-right: none; height: 40px;\"></th>\n <th class=\"amount\" colspan=\"11\" style=\"width: 22.5%; padding: 0; border: 1px solid #000; height: 40px;\">\n <div class=\"amount-header\" style=\"border-bottom: 1px solid #000; padding: 5px 0;\">\n <span style=\"color: #000;\">\u8D37\u65B9\u91D1\u989D</span>\n </div>\n <div class=\"amount-grid\" style=\"display: grid; grid-template-columns: repeat(11, 1fr);\">\n ").concat(['亿', '千', '百', '十', '万', '千', '百', '十', '元', '角', '分'].map(function (unit) {
54
+ return "\n <span style=\"border-right: 1px solid #000; font-size: 12px; height: 24px; line-height: 24px; display: flex; align-items: center; justify-content: center; color: #000;\">".concat(unit, "</span>\n ");
55
+ }).join(''), "\n </div>\n </th>\n </tr>\n </thead>\n <tbody>\n ").concat(paddedEntries.map(function (entry) {
56
+ return "\n <tr style=\"height: 20px;\">\n <td class=\"summary\" style=\"text-align: left; font-family: \u5B8B\u4F53; border: 1px solid #000; height: 40px;\">".concat(entry.summary || '', "</td>\n <td class=\"subject\" style=\"text-align: left; font-family: \u5B8B\u4F53; border: 1px solid #000; height: 40px;\">").concat(entry.account || '', "</td>\n <td class=\"checkmark\" style=\"text-align: center; border: 1px solid #000; color: #000; font-weight: normal; border-right: none; height: 40px;\">").concat(entry.debit && parseFloat(entry.debit) > 0 ? '✓' : '', "</td>\n <td class=\"amount\" colspan=\"11\" style=\"padding: 0; border: 1px solid #000; height: 40px;\">\n <div class=\"money-grid\" style=\"display: grid; grid-template-columns: repeat(11, 1fr); height: 100%;\">\n ").concat((0, _utils.formatAmount)(entry.debit).map(function (digit) {
57
+ return "\n <span class=\"money-cell\" style=\"width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-right: 1px solid #000; color: #000;\">".concat(digit, "</span>\n ");
58
+ }).join(''), "\n </div>\n </td>\n <td class=\"checkmark\" style=\"text-align: center; border: 1px solid #000; color: #000; font-weight: normal; border-right: none; height: 40px;\">").concat(entry.credit && parseFloat(entry.credit) > 0 ? '✓' : '', "</td>\n <td class=\"amount\" colspan=\"11\" style=\"padding: 0; border: 1px solid #000; height: 40px;\">\n <div class=\"money-grid\" style=\"display: grid; grid-template-columns: repeat(11, 1fr); height: 100%;\">\n ").concat((0, _utils.formatAmount)(entry.credit).map(function (digit) {
59
+ return "\n <span class=\"money-cell\" style=\"width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-right: 1px solid #000; color: #000;\">".concat(digit, "</span>\n ");
60
+ }).join(''), "\n </div>\n </td>\n </tr>\n ");
61
+ }).join(''), "\n ").concat(voucherProps.showTotal ? "\n <tr class=\"total-row\" style=\"height: 20px;\">\n <td class=\"summary\" style=\"text-align: center; color: #000; border: 1px solid #000; height: 40px;\">\u5408\u8BA1</td>\n <td class=\"subject\" style=\"border: 1px solid #000; height: 40px;\"></td>\n <td class=\"checkmark\" style=\"text-align: center; border: 1px solid #000; color: #000; font-weight: normal; border-right: none; height: 40px;\">".concat(parseFloat(voucherProps.totalDebit) > 0 ? '✓' : '', "</td>\n <td class=\"amount\" colspan=\"11\" style=\"padding: 0; border: 1px solid #000; height: 40px;\">\n <div class=\"money-grid\" style=\"display: grid; grid-template-columns: repeat(11, 1fr); height: 100%;\">\n ").concat((0, _utils.formatAmount)(voucherProps.totalDebit).map(function (digit) {
62
+ return "\n <span class=\"money-cell\" style=\"width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-right: 1px solid #000; color: #000;\">".concat(digit, "</span>\n ");
63
+ }).join(''), "\n </div>\n </td>\n <td class=\"checkmark\" style=\"text-align: center; border: 1px solid #000; color: #000; font-weight: normal; border-right: none; height: 40px;\">").concat(parseFloat(voucherProps.totalCredit) > 0 ? '✓' : '', "</td>\n <td class=\"amount\" colspan=\"11\" style=\"padding: 0; border: 1px solid #000; height: 40px;\">\n <div class=\"money-grid\" style=\"display: grid; grid-template-columns: repeat(11, 1fr); height: 100%;\">\n ").concat((0, _utils.formatAmount)(voucherProps.totalCredit).map(function (digit) {
64
+ return "\n <span class=\"money-cell\" style=\"width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-right: 1px solid #000; color: #000;\">".concat(digit, "</span>\n ");
65
+ }).join(''), "\n </div>\n </td>\n </tr>\n ") : '', "\n </tbody>\n </table>\n </div>\n\n <div class=\"voucher-footer\" style=\"display: flex; justify-content: space-between; margin-top: 20px; font-size: 14px;\">\n <div class=\"footer-item\" style=\"margin-right: 5px;\">\n <span style=\"color: #000;\">\u4F1A\u8BA1\u4E3B\u7BA1\uFF1A</span>\n <span style=\"margin-left: 10px;\">").concat(voucherProps.accountant || baseVoucherInfo.accountant, "</span>\n </div>\n <div class=\"footer-item\" style=\"margin-right: 5px;\">\n <span style=\"color: #000;\">\u8BB0\u8D26\uFF1A</span>\n <span style=\"margin-left: 10px;\">").concat(voucherProps.recorder || baseVoucherInfo.recorder, "</span>\n </div>\n <div class=\"footer-item\">\n <span style=\"color: #000;\">\u5236\u5355\uFF1A</span>\n <span style=\"margin-left: 10px;\">").concat(voucherProps.maker || baseVoucherInfo.maker, "</span>\n </div>\n </div>\n </div>\n </div>\n ");
66
+ }
67
+
68
+ // ------------------------------
69
+ // 3. 附件画布 HTML(导出PDF用)
70
+ // ------------------------------
71
+ function getAttachmentCanvasHtml(attachmentInfo) {
72
+ var formattedAmount = attachmentInfo.amount ? Number(attachmentInfo.amount).toLocaleString('zh-CN', {
73
+ minimumFractionDigits: 2
74
+ }) : '0.00';
75
+ return "\n <div style=\"width: 998px; height: 520px; background: #ffffff; padding: 20px; box-sizing: border-box; font-family: 'Microsoft YaHei', sans-serif; position: relative;\">\n <div style=\"text-align: center; font-size: 28px; font-weight: bold; margin-bottom: 25px; color: #597461;\">\n \u539F\u59CB\u51ED\u8BC1\u7C98\u8D34\u5355\n </div>\n <div style=\"position: absolute; top: 20px; right: 30px; text-align: right; font-size: 16px; color: #597461; line-height: 2;\">\n <div>\u539F\u59CB\u51ED\u8BC1: <span style=\"border-bottom: 1px solid #597461; padding-bottom: 2px;\">".concat(attachmentInfo.attachmentCount, "</span> \u5F20</div>\n <div>\u91D1\u989D: <span style=\"border-bottom: 1px solid #597461; padding-bottom: 2px;\">").concat(formattedAmount, "</span></div>\n </div>\n <div id=\"attachment-content\" style=\"\n width: calc(100% - 40px);\n height: 450px;\n border: 2px solid #597461;\n background: white;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 30px 20px 0;\n overflow: hidden;\n position: relative;\n \">\n <div id=\"loading-placeholder\" style=\"\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n color: #666;\n font-size: 18px;\n text-align: center;\n \">\n <div style=\"font-size: 24px; margin-bottom: 10px;\">\u23F3</div>\n <div>\u6B63\u5728\u5904\u7406\u9644\u4EF6...</div>\n </div>\n </div>\n </div>\n ");
76
+ }
77
+
78
+ // ------------------------------
79
+ // 4. 封面画布 HTML
80
+ // ------------------------------
81
+ function getCoverCanvasHtml(coverData, companyName) {
82
+ var formattedDate = coverData.expiryDate || (0, _moment.default)().format('YYYY-MM-DD');
83
+ return "\n <div style=\"\n width: 998px;\n height: 520px;\n background-image: url('/assets/material.jpg');\n background-size: cover;\n background-blend-mode: multiply;\n position: relative;\n box-shadow: -4px 0px 0px 0px #b08e67;\n font-family: 'Songti SC', 'SimSun', serif;\n color: #AD352F;\n padding: 40px 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n \">\n <div style=\"\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n width: 160px;\n height: 39%;\n border-right: 2px solid #B48F65;\n transform: skewX(-45deg);\n transform-origin: top left;\n \"></div>\n <div style=\"\n position: absolute;\n top: 10px;\n left: 80px;\n transform: translateX(-50%) rotate(45deg);\n \">\n <div style=\"\n width: 24px;\n height: 24px;\n background: #8B6842;\n border: 6px solid #D9D9D9;\n border-radius: 50%;\n \"></div>\n <div style=\"\n width: 24px;\n height: 24px;\n background: #8B6842;\n border: 6px solid #D9D9D9;\n border-radius: 50%;\n margin-top: 80px;\n \"></div>\n </div>\n <div style=\"\n text-align: center;\n font-size: 36px;\n font-weight: bold;\n margin-bottom: 20px;\n color: #AD352F;\n \">\u4F1A\u8BA1\u51ED\u8BC1\u5C01\u9762</div>\n <div style=\"\n width: 300px;\n height: 2px;\n background-color: #AD352F;\n margin: 4px auto;\n \"></div>\n <div style=\"\n width: 300px;\n height: 2px;\n background-color: #AD352F;\n margin: 4px auto 40px;\n \"></div>\n <table style=\"\n width: 80%;\n margin: 0 auto;\n border-collapse: collapse;\n font-size: 20px;\n color: #AD352F;\n \">\n <tbody>\n <tr>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center; width: 25%;\">\u5355\u4F4D\u540D\u79F0</td>\n <td colspan=\"3\" style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\n <span style=\"color: #3A4662; font-weight: 600;\">".concat(companyName || '', "</span>\n </td>\n </tr>\n <tr>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center; width: 25%;\">\u51ED\u8BC1\u518C\u53F7</td>\n <td colspan=\"3\" style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\n <span style=\"color: #3A4662; font-weight: 600;\">").concat(coverData.credentialCode || '', "</span>\n </td>\n </tr>\n <tr>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\u51ED\u8BC1\u65E5\u671F</td>\n <td colspan=\"3\" style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\n <span style=\"color: #3A4662; font-weight: 600;\">").concat(formattedDate, "</span>\n </td>\n </tr>\n <tr>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\u51ED\u8BC1\u518C\u6570</td>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center; width: 30%;\">\n \u5171<span style=\"color: #3A4662; font-weight: 600;\">").concat(coverData.total_page || 1, "</span>\u518C\u7B2C<span style=\"color: #3A4662; font-weight: 600;\">").concat(coverData.page_num || 1, "</span>\u518C\n </td>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center; width: 25%;\">\u51ED\u8BC1\u53F7\u6570</td>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\n <span style=\"color: #3A4662; font-weight: 600;\">").concat(coverData.credentialNumber || '', "</span>\n </td>\n </tr>\n <tr>\n <td style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\u88C5\u8BA2\u65F6\u95F4</td>\n <td colspan=\"3\" style=\"border: 1px solid #AD352F; padding: 12px; text-align: center;\">\n <span style=\"color: #3A4662; font-weight: 600;\">").concat(coverData.modificationTime || (0, _moment.default)().format('YYYY-MM-DD HH:mm:ss'), "</span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n ");
84
+ }
85
+
86
+ // ------------------------------
87
+ // 5. 最终导出翻书 HTML(完整页面)
88
+ // ------------------------------
89
+ function getFullFlipbookHtml(pageDataArray, coverData, filpBgBase64, defaultLineBase64, activeLineBase64) {
90
+ var now = (0, _moment.default)();
91
+ var title = coverData !== null && coverData !== void 0 && coverData.credentialCode ? "".concat(coverData.credentialCode, " - \u8BB0\u8D26\u51ED\u8BC1") : "\u8BB0\u8D26\u51ED\u8BC1 - ".concat(now.format('YYYY年MM月DD日'));
92
+ var pagesHTML = pageDataArray.map(function (pageData, index) {
93
+ var isCover = index === 0;
94
+ return "<div class=\"page ".concat(isCover ? 'cover-page' : '', "\" data-page=\"").concat(index + 1, "\">").concat(pageData.html, "</div>");
95
+ }).join('\n');
96
+ return "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>".concat(title, "</title>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/turn.js/3/turn.min.js\"></script>\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body { font-family: \"Microsoft YaHei\", sans-serif; background: linear-gradient(135deg, #8c7739 0%, #6b5528 50%, #4a381c 100%); min-height: 100vh; display: flex; flex-direction: column; align-items: center; }\n .flipbook-container { position: relative; perspective: 2000px; width: 1100px; height: 660px; margin: 0 auto 20px; }\n .flipbook-bg { position: absolute; top: 10px; left: -76px; height: 487px; z-index: 1; opacity: 0; transition: opacity 0.3s; box-shadow: 4px 4px 4px 0 #b08e67; pointer-events: none; }\n .flipbook-bg.show { opacity: 1; }\n .flipbook-line-default, .flipbook-line-active { position: absolute; top: 50px; left: -88px; width: 416px; height: 266px; z-index: 3; transform: rotate(-10.9deg); opacity: 0; transition: opacity 0.3s; pointer-events: none; }\n .flipbook-line-default.show, .flipbook-line-active.show { opacity: 1; }\n #flipbook { width: 998px; height: 520px; margin: 0 auto; position: absolute; left: 110px; top: 140px; z-index: 2; box-shadow: 4px 4px 4px 0 #b08e67; }\n #flipbook .page { width: 998px; height: 520px; background: white; box-shadow: 0 10px 40px rgba(0,0,0,0.3); border: 1px solid #ddd; overflow: hidden; }\n #flipbook .page-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: white; }\n .controls { display: flex; justify-content: center; gap: 20px; margin: 40px auto; }\n .btn { padding: 12px 24px; background: white; color: #667eea; border: none; border-radius: 25px; cursor: pointer; transition: all 0.3s; }\n .btn:hover { background: #667eea; color: white; }\n .page-info { color: white; padding: 10px 20px; border-radius: 20px; background: rgba(255,255,255,0.2); }\n </style>\n</head>\n<body>\n <div id=\"loading\" style=\"position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.8);display:flex;justify-content:center;align-items:center;color:white;z-index:9999;\">\n <div style=\"width:60px;height:60px;border:4px solid rgba(255,255,255,0.3);border-top:4px solid white;border-radius:50%;animation:spin 1s linear infinite;\"></div>\n </div>\n <div class=\"flipbook-container\">\n ").concat(filpBgBase64 ? "<img src=\"".concat(filpBgBase64, "\" class=\"flipbook-bg\" />") : '', "\n ").concat(defaultLineBase64 ? "<img src=\"".concat(defaultLineBase64, "\" class=\"flipbook-line-default\" />") : '', "\n ").concat(activeLineBase64 ? "<img src=\"".concat(activeLineBase64, "\" class=\"flipbook-line-active\" />") : '', "\n <div id=\"flipbook\">").concat(pagesHTML, "</div>\n </div>\n <div class=\"controls\">\n <button class=\"btn\" id=\"btn-first\">\u9996\u9875</button>\n <button class=\"btn\" id=\"btn-prev\">\u4E0A\u4E00\u9875</button>\n <div class=\"page-info\">\u7B2C <span id=\"current-page\">1</span> \u9875 / \u5171 <span id=\"total-pages\">").concat(pageDataArray.length, "</span> \u9875</div>\n <button class=\"btn\" id=\"btn-next\">\u4E0B\u4E00\u9875</button>\n <button class=\"btn\" id=\"btn-last\">\u672B\u9875</button>\n </div>\n <script>\n $(function(){\n const total = ").concat(pageDataArray.length, ";\n $('#flipbook').turn({width:998,height:520,autoCenter:true,duration:1000,display:'single'});\n $('#btn-first').click(()=>$('#flipbook').turn('page',1));\n $('#btn-prev').click(()=>$('#flipbook').turn('previous'));\n $('#btn-next').click(()=>$('#flipbook').turn('next'));\n $('#btn-last').click(()=>$('#flipbook').turn('page',total));\n setTimeout(()=>$('#loading').fadeOut(),500);\n });\n @keyframes spin{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}\n </script>\n</body>\n</html>");
97
+ }
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ export declare function formatAmount(amount: string): string[];
3
+ export declare const getSupportedImageExtensions: () => string[];
4
+ export declare const isImageFile: (url: any) => boolean;
5
+ export declare const classifyPages: (pages: React.ReactNode[], filterType?: string) => any[];
6
+ /**
7
+ * 路径格式化:清理首尾空格、反引号和引号
8
+ */
9
+ export declare const formatPath: (path: string) => string;
10
+ /**
11
+ * 全局统一获取附件地址
12
+ * 自动区分环境:dev / test / production
13
+ * 自动处理代理 / 正式域名
14
+ */
15
+ export declare const getAttachmentUrl: (url: string) => string;
16
+ export interface PdfDocumentLike {
17
+ numPages: number;
18
+ getPage: (pageNum: number) => Promise<any>;
19
+ cleanup?: () => void;
20
+ }
21
+ /**
22
+ * PDF 缓存工厂
23
+ */
24
+ export declare const createPdfDocumentCache: (loadDocument: (path: string) => Promise<PdfDocumentLike>) => {
25
+ getDocument(path: string): Promise<PdfDocumentLike>;
26
+ getPageCount(path: string): Promise<number>;
27
+ clear(path: string): void;
28
+ clearAll(): void;
29
+ };
30
+ /**
31
+ * 全局 PDF 缓存实例
32
+ */
33
+ export declare const globalPdfCache: {
34
+ getDocument(path: string): Promise<PdfDocumentLike>;
35
+ getPageCount(path: string): Promise<number>;
36
+ clear(path: string): void;
37
+ clearAll(): void;
38
+ };
@@ -0,0 +1,204 @@
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.createPdfDocumentCache = exports.classifyPages = void 0;
8
+ exports.formatAmount = formatAmount;
9
+ exports.isImageFile = exports.globalPdfCache = exports.getSupportedImageExtensions = exports.getAttachmentUrl = exports.formatPath = void 0;
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _reactPdf = require("react-pdf");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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; }
14
+ 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; }
15
+ 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; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ 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); }
18
+ 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; }
19
+ 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); } }
20
+ 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); }); }; }
21
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
+ 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."); }
23
+ 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); }
24
+ 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; }
25
+ 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; } }
26
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
+ function formatAmount(amount) {
28
+ var result = new Array(11).fill(' ');
29
+ if (!amount || amount === '0' || amount === '0.00') return result;
30
+ var numAmount = parseFloat(amount);
31
+ if (isNaN(numAmount) || numAmount === 0) return result;
32
+ var formattedAmount = numAmount.toFixed(2);
33
+ var _formattedAmount$spli = formattedAmount.split('.'),
34
+ _formattedAmount$spli2 = _slicedToArray(_formattedAmount$spli, 2),
35
+ intPart = _formattedAmount$spli2[0],
36
+ _formattedAmount$spli3 = _formattedAmount$spli2[1],
37
+ decPart = _formattedAmount$spli3 === void 0 ? '00' : _formattedAmount$spli3;
38
+ var paddedInt = intPart.padStart(9, ' ');
39
+ return (paddedInt + decPart).split('').slice(0, 11);
40
+ }
41
+
42
+ // 获取支持的图片格式
43
+ var getSupportedImageExtensions = exports.getSupportedImageExtensions = function getSupportedImageExtensions() {
44
+ return ['png', 'jpg', 'jpeg', 'webp', 'bmp', 'gif'];
45
+ };
46
+
47
+ // 判断是否为图片文件
48
+ var isImageFile = exports.isImageFile = function isImageFile(url) {
49
+ if (!url) return false;
50
+ var extensions = getSupportedImageExtensions();
51
+ // 移除查询参数后再判断后缀
52
+ var cleanUrl = url.split('?')[0].toLowerCase();
53
+ return extensions.some(function (ext) {
54
+ return cleanUrl.endsWith(".".concat(ext));
55
+ });
56
+ };
57
+ var classifyPages = exports.classifyPages = function classifyPages(pages, filterType) {
58
+ var result = [];
59
+ // 如果传了筛选类型,直接筛选
60
+ if (filterType) {
61
+ return pages.filter(function (page) {
62
+ var _page$key;
63
+ if (! /*#__PURE__*/_react.default.isValidElement(page)) return false;
64
+ var key = ((_page$key = page.key) === null || _page$key === void 0 ? void 0 : _page$key.toString()) || '';
65
+ if (filterType === 'voucher') return key.includes('voucher-');
66
+ if (filterType === 'attachment') return key.includes('attachment-');
67
+ if (filterType === 'all') return true;
68
+ return false;
69
+ });
70
+ }
71
+ // 原来的逻辑(生成筛选菜单)
72
+ pages.forEach(function (page) {
73
+ var _page$key2;
74
+ if (! /*#__PURE__*/_react.default.isValidElement(page)) return;
75
+ var key = ((_page$key2 = page.key) === null || _page$key2 === void 0 ? void 0 : _page$key2.toString()) || '';
76
+ if (key.includes('voucher-') && !result.some(function (i) {
77
+ return i.type === 'voucher';
78
+ })) {
79
+ result.push({
80
+ name: '记账凭证',
81
+ type: 'voucher'
82
+ });
83
+ }
84
+ if (key.includes('attachment-') && !result.some(function (i) {
85
+ return i.type === 'attachment';
86
+ })) {
87
+ result.push({
88
+ name: '原始附件',
89
+ type: 'attachment'
90
+ });
91
+ }
92
+ });
93
+
94
+ // 最前面插入【全部数据】
95
+ result.unshift({
96
+ name: '全部数据',
97
+ type: 'all'
98
+ });
99
+ return result;
100
+ };
101
+
102
+ /**
103
+ * 路径格式化:清理首尾空格、反引号和引号
104
+ */
105
+ var formatPath = exports.formatPath = function formatPath(path) {
106
+ if (!path) return '';
107
+ return String(path).trim().replace(/^[`'"]|[`'"]$/g, '').trim();
108
+ };
109
+
110
+ /**
111
+ * 全局统一获取附件地址
112
+ * 自动区分环境:dev / test / production
113
+ * 自动处理代理 / 正式域名
114
+ */
115
+ var getAttachmentUrl = exports.getAttachmentUrl = function getAttachmentUrl(url) {
116
+ if (!url) return '';
117
+
118
+ // 先清理路径
119
+ var formattedUrl = formatPath(url);
120
+
121
+ // 开发环境 = 本地代理(解决跨域)
122
+ if (process.env.NODE_ENV === 'development') {
123
+ return formattedUrl.replace('https://assets.gks.cc/', '/api-pub/').replace('https://pub.gks.cc/', '/api-pub/');
124
+ }
125
+
126
+ // 测试 + 生产环境 = 真实域名
127
+ return formattedUrl;
128
+ };
129
+
130
+ // ================= PDF 缓存逻辑 =================
131
+
132
+ var PDF_OPTIONS = {
133
+ cMapUrl: "https://unpkg.com/pdfjs-dist@".concat(_reactPdf.pdfjs.version, "/cmaps/"),
134
+ cMapPacked: true,
135
+ standardFontDataUrl: "https://unpkg.com/pdfjs-dist@".concat(_reactPdf.pdfjs.version, "/standard_fonts/")
136
+ };
137
+
138
+ /**
139
+ * PDF 缓存工厂
140
+ */
141
+ var createPdfDocumentCache = exports.createPdfDocumentCache = function createPdfDocumentCache(loadDocument) {
142
+ var cache = new Map();
143
+ return {
144
+ getDocument: function getDocument(path) {
145
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
146
+ var doc;
147
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
148
+ while (1) switch (_context.prev = _context.next) {
149
+ case 0:
150
+ if (!cache.has(path)) {
151
+ _context.next = 2;
152
+ break;
153
+ }
154
+ return _context.abrupt("return", cache.get(path));
155
+ case 2:
156
+ _context.next = 4;
157
+ return loadDocument(path);
158
+ case 4:
159
+ doc = _context.sent;
160
+ cache.set(path, doc);
161
+ return _context.abrupt("return", doc);
162
+ case 7:
163
+ case "end":
164
+ return _context.stop();
165
+ }
166
+ }, _callee);
167
+ }))();
168
+ },
169
+ getPageCount: function getPageCount(path) {
170
+ var _this = this;
171
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
172
+ var doc;
173
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
174
+ while (1) switch (_context2.prev = _context2.next) {
175
+ case 0:
176
+ _context2.next = 2;
177
+ return _this.getDocument(path);
178
+ case 2:
179
+ doc = _context2.sent;
180
+ return _context2.abrupt("return", doc.numPages);
181
+ case 4:
182
+ case "end":
183
+ return _context2.stop();
184
+ }
185
+ }, _callee2);
186
+ }))();
187
+ },
188
+ clear: function clear(path) {
189
+ cache.delete(path);
190
+ },
191
+ clearAll: function clearAll() {
192
+ cache.clear();
193
+ }
194
+ };
195
+ };
196
+
197
+ /**
198
+ * 全局 PDF 缓存实例
199
+ */
200
+ var globalPdfCache = exports.globalPdfCache = createPdfDocumentCache(function (path) {
201
+ return _reactPdf.pdfjs.getDocument(_objectSpread({
202
+ url: path
203
+ }, PDF_OPTIONS)).promise;
204
+ });
@@ -3,7 +3,7 @@ import './index.less';
3
3
  interface ExportModalProps {
4
4
  visible: boolean;
5
5
  onCancel: () => void;
6
- onConfirm: (type: 'pdf' | 'html') => void;
6
+ onConfirm: (type: 'pdf' | 'epub') => void;
7
7
  themeColor?: string;
8
8
  }
9
9
  declare const ExportModal: React.FC<ExportModalProps>;
@@ -79,7 +79,7 @@ var ExportModal = function ExportModal(_ref) {
79
79
  children: "PDF \u6587\u6863"
80
80
  })
81
81
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Radio, {
82
- value: "html",
82
+ value: "epub",
83
83
  className: "export-radio",
84
84
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
85
85
  style: {
@@ -7,6 +7,7 @@ interface HeaderBarProps {
7
7
  currentPage: number;
8
8
  totalPages: number;
9
9
  themeColor?: string;
10
+ iconColor?: string;
10
11
  onBack?: () => void;
11
12
  onRequestFullscreen?: () => void;
12
13
  onClose?: () => void;
@@ -15,7 +16,7 @@ interface HeaderBarProps {
15
16
  onNextPage: () => void;
16
17
  onGoLast: () => void;
17
18
  onPrint: () => void;
18
- onDownload: (type?: 'pdf' | 'html') => void;
19
+ onDownload: (type?: 'pdf' | 'epub') => void;
19
20
  onRefresh?: () => void;
20
21
  onSearch?: (val: string) => void;
21
22
  }
@@ -37,7 +37,9 @@ var HeaderBar = function HeaderBar(_ref) {
37
37
  onRefresh = _ref.onRefresh,
38
38
  onSearch = _ref.onSearch,
39
39
  _ref$themeColor = _ref.themeColor,
40
- themeColor = _ref$themeColor === void 0 ? '#9F7D4E' : _ref$themeColor;
40
+ themeColor = _ref$themeColor === void 0 ? '#9F7D4E' : _ref$themeColor,
41
+ _ref$iconColor = _ref.iconColor,
42
+ iconColor = _ref$iconColor === void 0 ? '#0064ff' : _ref$iconColor;
41
43
  var _useState = (0, _react.useState)(''),
42
44
  _useState2 = _slicedToArray(_useState, 2),
43
45
  keyword = _useState2[0],
@@ -68,7 +70,7 @@ var HeaderBar = function HeaderBar(_ref) {
68
70
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LeftOutlined, {
69
71
  style: {
70
72
  fontSize: 16,
71
- color: '#0064ff'
73
+ color: iconColor
72
74
  }
73
75
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
74
76
  children: "\u8FD4\u56DE"
@@ -85,7 +87,7 @@ var HeaderBar = function HeaderBar(_ref) {
85
87
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ReloadOutlined, {
86
88
  style: {
87
89
  fontSize: 16,
88
- color: '#0064ff'
90
+ color: iconColor
89
91
  }
90
92
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
91
93
  children: "\u5237\u65B0"
@@ -100,7 +102,7 @@ var HeaderBar = function HeaderBar(_ref) {
100
102
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.FullscreenOutlined, {
101
103
  style: {
102
104
  fontSize: 16,
103
- color: '#0064ff'
105
+ color: iconColor
104
106
  }
105
107
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
106
108
  children: "\u5168\u5C4F"
@@ -112,7 +114,7 @@ var HeaderBar = function HeaderBar(_ref) {
112
114
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.FullscreenExitOutlined, {
113
115
  style: {
114
116
  fontSize: 16,
115
- color: '#0064ff'
117
+ color: iconColor
116
118
  }
117
119
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
118
120
  children: "\u9000\u51FA\u5168\u5C4F"
@@ -127,7 +129,7 @@ var HeaderBar = function HeaderBar(_ref) {
127
129
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.StepBackwardOutlined, {
128
130
  style: {
129
131
  fontSize: 16,
130
- color: '#0064ff'
132
+ color: iconColor
131
133
  }
132
134
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
133
135
  children: "\u5230\u5934"
@@ -140,7 +142,7 @@ var HeaderBar = function HeaderBar(_ref) {
140
142
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CaretLeftOutlined, {
141
143
  style: {
142
144
  fontSize: 16,
143
- color: '#0064ff'
145
+ color: iconColor
144
146
  }
145
147
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
146
148
  children: "\u4E0A\u9875"
@@ -156,7 +158,7 @@ var HeaderBar = function HeaderBar(_ref) {
156
158
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CaretRightOutlined, {
157
159
  style: {
158
160
  fontSize: 16,
159
- color: '#0064ff'
161
+ color: iconColor
160
162
  }
161
163
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
162
164
  children: "\u4E0B\u9875"
@@ -169,7 +171,7 @@ var HeaderBar = function HeaderBar(_ref) {
169
171
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.StepForwardOutlined, {
170
172
  style: {
171
173
  fontSize: 16,
172
- color: '#0064ff'
174
+ color: iconColor
173
175
  }
174
176
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
175
177
  children: "\u5230\u5C3E"
@@ -187,7 +189,7 @@ var HeaderBar = function HeaderBar(_ref) {
187
189
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.PrinterOutlined, {
188
190
  style: {
189
191
  fontSize: 16,
190
- color: '#0064ff'
192
+ color: iconColor
191
193
  }
192
194
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
193
195
  children: "\u6253\u5370"
@@ -201,7 +203,7 @@ var HeaderBar = function HeaderBar(_ref) {
201
203
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DownloadOutlined, {
202
204
  style: {
203
205
  fontSize: 16,
204
- color: '#0064ff'
206
+ color: iconColor
205
207
  }
206
208
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
207
209
  children: "\u4E0B\u8F7D"