ztxkui 4.2.23-336 → 4.2.23-336-beta
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.
- package/dist/DemoCom/PrintContainerDemo.js +8 -7
- package/dist/components/PrintBox/demoComponents/index.js +1 -1
- package/dist/components/PrintContainer/kkJSBridge.js +2 -0
- package/dist/components/PrintContainer/print.d.ts +78 -0
- package/dist/components/PrintContainer/print.js +696 -0
- package/package.json +2 -2
|
@@ -110,11 +110,7 @@ var PrintContainerDemo = function () {
|
|
|
110
110
|
};
|
|
111
111
|
}, []);
|
|
112
112
|
console.log(dayjs().format('MMDDHHmmss'));
|
|
113
|
-
return (React.createElement(PrintContainer
|
|
114
|
-
// isAddExportPage={true}
|
|
115
|
-
// loading={loading}
|
|
116
|
-
, {
|
|
117
|
-
// isAddExportPage={true}
|
|
113
|
+
return (React.createElement(PrintContainer, { isAddExportPage: true,
|
|
118
114
|
// loading={loading}
|
|
119
115
|
request: request, deptId: "1514842459376930817", flowId: "scm_print_thd", fileId: "1551733945007517697",
|
|
120
116
|
// // keywordList={keywordList}
|
|
@@ -147,7 +143,12 @@ var PrintContainerDemo = function () {
|
|
|
147
143
|
// deptId="1295909543961944065"
|
|
148
144
|
// flowId="scm_print_tdtd"
|
|
149
145
|
// showAboutExport
|
|
150
|
-
showPrintBtn: true, showPluginPrintBtn: true },
|
|
151
|
-
|
|
146
|
+
showPrintBtn: true, showPluginPrintBtn: true }, Array(2)
|
|
147
|
+
.fill(1)
|
|
148
|
+
.map(function (item, index) {
|
|
149
|
+
return (React.createElement("div", null,
|
|
150
|
+
React.createElement(Tidan, { title: index + '', key: index }),
|
|
151
|
+
React.createElement("div", { className: "print-page-break-after" })));
|
|
152
|
+
})));
|
|
152
153
|
};
|
|
153
154
|
export default PrintContainerDemo;
|
|
@@ -167,7 +167,7 @@ var Demo = function () {
|
|
|
167
167
|
}, onExecuteClick: function (type, data) {
|
|
168
168
|
console.log('操作执行完成后', type, data);
|
|
169
169
|
return Promise.resolve(true);
|
|
170
|
-
}, ref: printRef, isAutoSeal: true, request: request, deptId: "1514842459376930817", flowId: "scm_print_thd",
|
|
170
|
+
}, ref: printRef, isAutoSeal: true, isWater: false, request: request, deptId: "1514842459376930817", flowId: "scm_print_thd",
|
|
171
171
|
// pageDom=".html2canvas-container-page"
|
|
172
172
|
pageDom: ".test111", leftPadding: 50, topPadding: 50, bottomPadding: 50,
|
|
173
173
|
// insertHeader={(pdf, currentPage) => `1111 ${currentPage}`}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getToken } from 'ztxkutils/dist/authority';
|
|
2
|
+
import { encodeFileIdByDownload } from 'ztxkutils/dist/fileOperation';
|
|
2
3
|
function createDownloadUrl(apiUrl, fileId, otherOptions) {
|
|
4
|
+
fileId = encodeFileIdByDownload(fileId);
|
|
3
5
|
var token = getToken();
|
|
4
6
|
var _apiUrl = apiUrl.endsWith('/')
|
|
5
7
|
? apiUrl.slice(0, apiUrl.length - 1)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author 陈亚雄
|
|
3
|
+
* @description 打印相关方法
|
|
4
|
+
*/
|
|
5
|
+
import { jsPDF } from 'jspdf';
|
|
6
|
+
/**
|
|
7
|
+
* 添加水印
|
|
8
|
+
*/
|
|
9
|
+
export declare function addWaterHandle({ waterText, waterClassName, }?: {
|
|
10
|
+
waterText?: string;
|
|
11
|
+
waterClassName?: string[];
|
|
12
|
+
isPrintWater?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
export declare function removeWaterHandle(): void;
|
|
15
|
+
/**
|
|
16
|
+
* 打印页面
|
|
17
|
+
* hiddenClassNames 需要隐藏的样式 默认有hiddenPrint
|
|
18
|
+
*/
|
|
19
|
+
interface IParams {
|
|
20
|
+
/** 需要隐藏的样式类名 ['.test', '.test1] */
|
|
21
|
+
hiddenClassNames?: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function printCurrentDom({ hiddenClassNames }?: IParams): void;
|
|
24
|
+
export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, noWater, pdfOptions, imgPositionX, waterText, }: {
|
|
25
|
+
pageClassName?: string;
|
|
26
|
+
dom: HTMLElement;
|
|
27
|
+
pdfName: string;
|
|
28
|
+
isShowPage?: boolean;
|
|
29
|
+
noWater?: boolean;
|
|
30
|
+
pdfOptions?: any;
|
|
31
|
+
imgPositionX?: number;
|
|
32
|
+
waterText?: string;
|
|
33
|
+
}): Promise<jsPDF>;
|
|
34
|
+
export declare function htmlToPdfUseCanvas({ pageClassName, dom, pdfName, isShowPage, isOnlyOne, noWater, pdfOptions, imgPositionX, isDownload, isAutoPageCount, }: {
|
|
35
|
+
pageClassName?: string;
|
|
36
|
+
dom: HTMLElement;
|
|
37
|
+
pdfName: string;
|
|
38
|
+
isShowPage?: boolean;
|
|
39
|
+
isOnlyOne?: boolean;
|
|
40
|
+
noWater?: boolean;
|
|
41
|
+
pdfOptions?: any;
|
|
42
|
+
imgPositionX?: number;
|
|
43
|
+
isDownload?: boolean;
|
|
44
|
+
isAutoPageCount?: boolean;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
pdfs: any;
|
|
47
|
+
pdfBase64: any;
|
|
48
|
+
}>;
|
|
49
|
+
export interface IPdfOption {
|
|
50
|
+
/** 是否压缩 */
|
|
51
|
+
compress?: boolean;
|
|
52
|
+
/** pdf 横向 还是 纵向 */
|
|
53
|
+
pageOrient?: 'p' | 'portrait' | 'l' | 'landscape';
|
|
54
|
+
/** 格式 */
|
|
55
|
+
pageFormat?: string;
|
|
56
|
+
/** 左右边距 */
|
|
57
|
+
pageMarginX?: number;
|
|
58
|
+
/** 上下边距 */
|
|
59
|
+
pageMarginY?: number;
|
|
60
|
+
}
|
|
61
|
+
export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, fileBinary, pdfName, isDownload, pdfOption, isAddWater, waterBase64, imgWidth, imgHeight, isCompress, waterText, }: {
|
|
62
|
+
pageClassName?: string;
|
|
63
|
+
dom: HTMLElement;
|
|
64
|
+
isShowPage?: boolean;
|
|
65
|
+
fileBinary: any;
|
|
66
|
+
pdfName?: string;
|
|
67
|
+
isDownload?: boolean;
|
|
68
|
+
pdfOption?: IPdfOption;
|
|
69
|
+
/** 是否添加水印 */
|
|
70
|
+
isAddWater?: boolean;
|
|
71
|
+
/** 水印base 64字符串 */
|
|
72
|
+
waterBase64?: string;
|
|
73
|
+
imgWidth?: number;
|
|
74
|
+
imgHeight?: number;
|
|
75
|
+
isCompress?: boolean;
|
|
76
|
+
waterText?: string;
|
|
77
|
+
}): Promise<unknown>;
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
49
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
50
|
+
to[j] = from[i];
|
|
51
|
+
return to;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* @author 陈亚雄
|
|
55
|
+
* @description 打印相关方法
|
|
56
|
+
*/
|
|
57
|
+
import { jsPDF } from 'jspdf';
|
|
58
|
+
import html2canvas from 'html2canvas';
|
|
59
|
+
/**
|
|
60
|
+
* 添加水印
|
|
61
|
+
*/
|
|
62
|
+
export function addWaterHandle(_a) {
|
|
63
|
+
var _b = _a === void 0 ? {
|
|
64
|
+
waterText: '',
|
|
65
|
+
waterClassName: [],
|
|
66
|
+
} : _a, waterText = _b.waterText, waterClassName = _b.waterClassName;
|
|
67
|
+
var waterStyleDom = document.getElementById('water-style-dom-110011');
|
|
68
|
+
if (waterStyleDom) {
|
|
69
|
+
waterStyleDom.remove();
|
|
70
|
+
}
|
|
71
|
+
var canvasImg = createWaterHandle({
|
|
72
|
+
waterText: waterText,
|
|
73
|
+
}).imgBase64;
|
|
74
|
+
var styleDom = document.createElement('style');
|
|
75
|
+
styleDom.setAttribute('type', 'text/css');
|
|
76
|
+
styleDom.setAttribute('id', 'water-style-dom-110011');
|
|
77
|
+
styleDom.innerText =
|
|
78
|
+
'@media print{' +
|
|
79
|
+
'body {background: url(' +
|
|
80
|
+
canvasImg +
|
|
81
|
+
') left top repeat;} ' +
|
|
82
|
+
(Array.isArray(waterClassName) && waterClassName.length > 0
|
|
83
|
+
? waterClassName.join(',') + " { min-height: 90vh }"
|
|
84
|
+
: '') +
|
|
85
|
+
'}' +
|
|
86
|
+
'@page { size: auto; }' +
|
|
87
|
+
'body {background: url(' +
|
|
88
|
+
canvasImg +
|
|
89
|
+
') left top repeat;}}';
|
|
90
|
+
document.head.appendChild(styleDom);
|
|
91
|
+
}
|
|
92
|
+
export function removeWaterHandle() {
|
|
93
|
+
var waterStyleDom = document.getElementById('water-style-dom-110011');
|
|
94
|
+
if (waterStyleDom) {
|
|
95
|
+
waterStyleDom.remove();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export function printCurrentDom(_a) {
|
|
99
|
+
var _b = _a === void 0 ? { hiddenClassNames: [] } : _a, hiddenClassNames = _b.hiddenClassNames;
|
|
100
|
+
var printStyleDom = document.getElementById('print-style-dom-110011');
|
|
101
|
+
if (printStyleDom) {
|
|
102
|
+
printStyleDom.remove();
|
|
103
|
+
}
|
|
104
|
+
var styleDom = document.createElement('style');
|
|
105
|
+
styleDom.setAttribute('type', 'text/css');
|
|
106
|
+
styleDom.setAttribute('id', 'print-style-dom-110011');
|
|
107
|
+
styleDom.innerText = "@media print{ " + __spreadArray(__spreadArray([], (hiddenClassNames || [])), [
|
|
108
|
+
'.hiddenPrint',
|
|
109
|
+
'.hidden-print-footer',
|
|
110
|
+
]).join(',') + " { display: none; } }";
|
|
111
|
+
document.head.appendChild(styleDom);
|
|
112
|
+
window.print();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 创建文本水印图片
|
|
116
|
+
* @param waterText 水印文本
|
|
117
|
+
* @param opacity 水印透明度
|
|
118
|
+
* @returns canvas png
|
|
119
|
+
*/
|
|
120
|
+
function createWaterHandle(obj) {
|
|
121
|
+
// const token = getToken();
|
|
122
|
+
// let defaultWaterText = '内部资料,严禁外泄!';
|
|
123
|
+
// if (token) {
|
|
124
|
+
// try {
|
|
125
|
+
// const tokenObj: any = jwtDecode(token);
|
|
126
|
+
// defaultWaterText = `浙商中拓 ${tokenObj?.real_name || ''}`;
|
|
127
|
+
// } catch (err) {
|
|
128
|
+
// console.log(err);
|
|
129
|
+
// }
|
|
130
|
+
// }
|
|
131
|
+
var defaultWaterText = '浙商中拓';
|
|
132
|
+
var _a = obj || {}, waterText = _a.waterText, opacity = _a.opacity, fontSize = _a.fontSize, cavansWidth = _a.cavansWidth, cavansHeight = _a.cavansHeight;
|
|
133
|
+
var canvas = document.createElement('canvas');
|
|
134
|
+
var defaultCanvasWidth = waterText
|
|
135
|
+
? waterText.length > 10
|
|
136
|
+
? waterText.length * 22
|
|
137
|
+
: 240
|
|
138
|
+
: 240;
|
|
139
|
+
var defaultCanvasHeight = waterText
|
|
140
|
+
? waterText.length > 10
|
|
141
|
+
? waterText.length * 9
|
|
142
|
+
: 100
|
|
143
|
+
: 100;
|
|
144
|
+
canvas.width = cavansWidth || defaultCanvasWidth;
|
|
145
|
+
canvas.height = cavansHeight || defaultCanvasHeight;
|
|
146
|
+
var ctx = canvas.getContext('2d');
|
|
147
|
+
if (ctx) {
|
|
148
|
+
ctx.rotate((-10 * Math.PI) / 180); // 水印旋转角度
|
|
149
|
+
ctx.font = (fontSize || '18px') + " \u5FAE\u8F6F\u96C5\u9ED1";
|
|
150
|
+
ctx.fillStyle = "rgba(0,0,0," + (opacity ? opacity : '0.07') + ")";
|
|
151
|
+
ctx.textAlign = 'center';
|
|
152
|
+
ctx.textBaseline = 'middle';
|
|
153
|
+
ctx.fillText(waterText || defaultWaterText, canvas.width / 2, canvas.height); // 水印在画布的位置x,y轴
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
imgBase64: canvas.toDataURL('image/png'),
|
|
157
|
+
width: canvas.width,
|
|
158
|
+
height: canvas.height,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function addPdfWaterHandle(pdf, waterBase64, imgInfo) {
|
|
162
|
+
var width = 200;
|
|
163
|
+
var height = 80;
|
|
164
|
+
if (imgInfo) {
|
|
165
|
+
width = imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.width;
|
|
166
|
+
height = imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.height;
|
|
167
|
+
}
|
|
168
|
+
for (var i = 0; i < 10; i++) {
|
|
169
|
+
pdf.addImage(waterBase64, 'PNG', 40, 140 * i, width, height, "1" + i);
|
|
170
|
+
pdf.addImage(waterBase64, 'PNG', 80 + width, 140 * i, width, height, "2" + i);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* html转pdf
|
|
175
|
+
*/
|
|
176
|
+
function createPdf(canvas, pdf, noWater, positionX, options) {
|
|
177
|
+
var contentWidth = canvas.width;
|
|
178
|
+
var contentHeight = canvas.height;
|
|
179
|
+
var setWidth = (options === null || options === void 0 ? void 0 : options.width) || 592.28;
|
|
180
|
+
var setHeight = (options === null || options === void 0 ? void 0 : options.height) || 841.89;
|
|
181
|
+
// 一页pdf显示html页面生成的canvas高度
|
|
182
|
+
// const pageHeight = (contentWidth / 592.28) * 841.89;
|
|
183
|
+
var pageHeight = (contentWidth / setWidth) * setHeight;
|
|
184
|
+
// 未生成pdf的html页面高度
|
|
185
|
+
var leftHeight = contentHeight;
|
|
186
|
+
// 页面拍内衣
|
|
187
|
+
var position = 0;
|
|
188
|
+
//a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
|
|
189
|
+
// const imgWidth = 595.28;
|
|
190
|
+
// const imgHeight = (592.28 / contentWidth) * contentHeight;
|
|
191
|
+
var imgWidth = setWidth - (positionX || 20) - 10;
|
|
192
|
+
var imgHeight = (setWidth / contentWidth) * contentHeight;
|
|
193
|
+
var pageData = canvas.toDataURL('image/jpeg', 1.0);
|
|
194
|
+
//有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
|
|
195
|
+
//当内容未超过pdf一页显示的范围,无需分页
|
|
196
|
+
if (leftHeight < pageHeight) {
|
|
197
|
+
pdf.addImage(pageData, 'JPEG', positionX || 20, 10, imgWidth, imgHeight);
|
|
198
|
+
if (!noWater) {
|
|
199
|
+
var _a = createWaterHandle({
|
|
200
|
+
opacity: '0.07',
|
|
201
|
+
fontSize: '14px',
|
|
202
|
+
waterText: (options === null || options === void 0 ? void 0 : options.waterText) || '',
|
|
203
|
+
}), waterBase64 = _a.imgBase64, width = _a.width, height = _a.height;
|
|
204
|
+
addPdfWaterHandle(pdf, waterBase64, { width: width, height: height });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
while (leftHeight > 0) {
|
|
209
|
+
pdf.addImage(pageData, 'JPEG', positionX || 20, position, imgWidth, imgHeight);
|
|
210
|
+
if (!noWater) {
|
|
211
|
+
var _b = createWaterHandle({
|
|
212
|
+
opacity: '0.07',
|
|
213
|
+
fontSize: '14px',
|
|
214
|
+
waterText: (options === null || options === void 0 ? void 0 : options.waterText) || '',
|
|
215
|
+
}), waterBase64 = _b.imgBase64, width = _b.width, height = _b.height;
|
|
216
|
+
addPdfWaterHandle(pdf, waterBase64, { width: width, height: height });
|
|
217
|
+
}
|
|
218
|
+
leftHeight -= pageHeight;
|
|
219
|
+
// position -= 841.89;
|
|
220
|
+
position -= setHeight;
|
|
221
|
+
//避免添加空白页
|
|
222
|
+
if (leftHeight > 0) {
|
|
223
|
+
pdf.addPage();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
export function htmlToPdf(_a) {
|
|
229
|
+
var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage, noWater = _a.noWater, pdfOptions = _a.pdfOptions, imgPositionX = _a.imgPositionX, waterText = _a.waterText;
|
|
230
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
+
var allDom, format, pdf, promiseAllDomArray_1;
|
|
232
|
+
return __generator(this, function (_b) {
|
|
233
|
+
switch (_b.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
allDom = document.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
|
|
236
|
+
format = (pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.format) || [632.28, 841.89];
|
|
237
|
+
pdf = new jsPDF(__assign({ unit: 'pt', format: format }, (pdfOptions || {})));
|
|
238
|
+
if (!(allDom.length > 0 && isShowPage)) return [3 /*break*/, 2];
|
|
239
|
+
return [4 /*yield*/, reduceDom(allDom, dom, function (child) {
|
|
240
|
+
return html2canvas(child, {
|
|
241
|
+
scale: 2,
|
|
242
|
+
});
|
|
243
|
+
})];
|
|
244
|
+
case 1:
|
|
245
|
+
promiseAllDomArray_1 = _b.sent();
|
|
246
|
+
return [2 /*return*/, (function () {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
var i, _i, promiseAllDomArray_2, item, canvas;
|
|
249
|
+
return __generator(this, function (_a) {
|
|
250
|
+
switch (_a.label) {
|
|
251
|
+
case 0:
|
|
252
|
+
i = 0;
|
|
253
|
+
_i = 0, promiseAllDomArray_2 = promiseAllDomArray_1;
|
|
254
|
+
_a.label = 1;
|
|
255
|
+
case 1:
|
|
256
|
+
if (!(_i < promiseAllDomArray_2.length)) return [3 /*break*/, 4];
|
|
257
|
+
item = promiseAllDomArray_2[_i];
|
|
258
|
+
i++;
|
|
259
|
+
return [4 /*yield*/, item];
|
|
260
|
+
case 2:
|
|
261
|
+
canvas = _a.sent();
|
|
262
|
+
createPdf(canvas, pdf, noWater, imgPositionX, {
|
|
263
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
|
264
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
|
265
|
+
waterText: waterText,
|
|
266
|
+
});
|
|
267
|
+
if (i < promiseAllDomArray_1.length) {
|
|
268
|
+
pdf.addPage();
|
|
269
|
+
}
|
|
270
|
+
_a.label = 3;
|
|
271
|
+
case 3:
|
|
272
|
+
_i++;
|
|
273
|
+
return [3 /*break*/, 1];
|
|
274
|
+
case 4:
|
|
275
|
+
pdf.save(pdfName + ".pdf");
|
|
276
|
+
return [2 /*return*/, Promise.resolve(pdf)];
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
})()];
|
|
281
|
+
case 2: return [2 /*return*/, html2canvas(dom, { scale: 2 }).then(function (canvas) {
|
|
282
|
+
createPdf(canvas, pdf, noWater, imgPositionX, {
|
|
283
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
|
284
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
|
285
|
+
waterText: waterText,
|
|
286
|
+
});
|
|
287
|
+
pdf.save(pdfName + ".pdf");
|
|
288
|
+
return pdf;
|
|
289
|
+
})];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
export function htmlToPdfUseCanvas(_a) {
|
|
295
|
+
var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage, isOnlyOne = _a.isOnlyOne, noWater = _a.noWater, pdfOptions = _a.pdfOptions, imgPositionX = _a.imgPositionX, isDownload = _a.isDownload, isAutoPageCount = _a.isAutoPageCount;
|
|
296
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
+
var allDom, format, _pdfOptions, pdfBase64_1, pdfs_1, promiseAllDomArray_3, pdf_1, pdf_2;
|
|
298
|
+
return __generator(this, function (_b) {
|
|
299
|
+
switch (_b.label) {
|
|
300
|
+
case 0:
|
|
301
|
+
allDom = document.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
|
|
302
|
+
format = (pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.format) || [632.28, 841.89];
|
|
303
|
+
_pdfOptions = __assign({ unit: 'pt', format: format }, (pdfOptions || {}));
|
|
304
|
+
if (!(allDom.length > 0 && isShowPage)) return [3 /*break*/, 2];
|
|
305
|
+
pdfBase64_1 = [];
|
|
306
|
+
pdfs_1 = [];
|
|
307
|
+
return [4 /*yield*/, reduceDom(allDom, dom, function (child) {
|
|
308
|
+
return html2canvas(child, {
|
|
309
|
+
scale: 2,
|
|
310
|
+
});
|
|
311
|
+
})];
|
|
312
|
+
case 1:
|
|
313
|
+
promiseAllDomArray_3 = _b.sent();
|
|
314
|
+
if (isOnlyOne) {
|
|
315
|
+
pdf_1 = new jsPDF(_pdfOptions);
|
|
316
|
+
return [2 /*return*/, (function () {
|
|
317
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
318
|
+
var i, _i, promiseAllDomArray_4, item, canvas;
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
switch (_a.label) {
|
|
321
|
+
case 0:
|
|
322
|
+
i = 0;
|
|
323
|
+
_i = 0, promiseAllDomArray_4 = promiseAllDomArray_3;
|
|
324
|
+
_a.label = 1;
|
|
325
|
+
case 1:
|
|
326
|
+
if (!(_i < promiseAllDomArray_4.length)) return [3 /*break*/, 4];
|
|
327
|
+
item = promiseAllDomArray_4[_i];
|
|
328
|
+
i++;
|
|
329
|
+
return [4 /*yield*/, item];
|
|
330
|
+
case 2:
|
|
331
|
+
canvas = _a.sent();
|
|
332
|
+
createPdf(canvas, pdf_1, noWater, imgPositionX, {
|
|
333
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
|
334
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
|
335
|
+
});
|
|
336
|
+
if (i < promiseAllDomArray_3.length) {
|
|
337
|
+
pdf_1.addPage();
|
|
338
|
+
}
|
|
339
|
+
_a.label = 3;
|
|
340
|
+
case 3:
|
|
341
|
+
_i++;
|
|
342
|
+
return [3 /*break*/, 1];
|
|
343
|
+
case 4:
|
|
344
|
+
if (isDownload) {
|
|
345
|
+
pdf_1.save(pdfName + ".pdf");
|
|
346
|
+
}
|
|
347
|
+
return [2 /*return*/, Promise.resolve({
|
|
348
|
+
pdfs: [pdf_1],
|
|
349
|
+
pdfBase64: [pdf_1.output('dataurlstring')],
|
|
350
|
+
})];
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
})()];
|
|
355
|
+
}
|
|
356
|
+
return [2 /*return*/, (function () {
|
|
357
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
358
|
+
var _i, promiseAllDomArray_5, item, pdf, canvas;
|
|
359
|
+
return __generator(this, function (_a) {
|
|
360
|
+
switch (_a.label) {
|
|
361
|
+
case 0:
|
|
362
|
+
_i = 0, promiseAllDomArray_5 = promiseAllDomArray_3;
|
|
363
|
+
_a.label = 1;
|
|
364
|
+
case 1:
|
|
365
|
+
if (!(_i < promiseAllDomArray_5.length)) return [3 /*break*/, 4];
|
|
366
|
+
item = promiseAllDomArray_5[_i];
|
|
367
|
+
pdf = new jsPDF(_pdfOptions);
|
|
368
|
+
pdf.setCompression(true);
|
|
369
|
+
return [4 /*yield*/, item];
|
|
370
|
+
case 2:
|
|
371
|
+
canvas = _a.sent();
|
|
372
|
+
createPdf(canvas, pdf, noWater, imgPositionX, {
|
|
373
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
|
374
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
|
375
|
+
});
|
|
376
|
+
if (isDownload) {
|
|
377
|
+
pdf.save(pdfName + ".pdf");
|
|
378
|
+
}
|
|
379
|
+
pdfBase64_1.push(pdf.output('dataurlstring'));
|
|
380
|
+
pdfs_1.push(pdf);
|
|
381
|
+
_a.label = 3;
|
|
382
|
+
case 3:
|
|
383
|
+
_i++;
|
|
384
|
+
return [3 /*break*/, 1];
|
|
385
|
+
case 4: return [2 /*return*/, Promise.resolve({
|
|
386
|
+
pdfs: pdfs_1,
|
|
387
|
+
pdfBase64: pdfBase64_1,
|
|
388
|
+
})];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
})()];
|
|
393
|
+
case 2:
|
|
394
|
+
pdf_2 = new jsPDF(_pdfOptions);
|
|
395
|
+
return [2 /*return*/, html2canvas(dom, { scale: 2 }).then(function (canvas) {
|
|
396
|
+
createPdf(canvas, pdf_2, noWater, imgPositionX, {
|
|
397
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
|
398
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
|
399
|
+
});
|
|
400
|
+
if (isDownload) {
|
|
401
|
+
pdf_2.save(pdfName + ".pdf");
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
pdfs: [pdf_2],
|
|
405
|
+
pdfBase64: [pdf_2.output('dataurlstring')],
|
|
406
|
+
};
|
|
407
|
+
})];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
export function htmlToPdfNoCanvas(_a) {
|
|
413
|
+
var _b, _c;
|
|
414
|
+
var pageClassName = _a.pageClassName, dom = _a.dom, isShowPage = _a.isShowPage, fileBinary = _a.fileBinary, pdfName = _a.pdfName, isDownload = _a.isDownload, pdfOption = _a.pdfOption, isAddWater = _a.isAddWater, waterBase64 = _a.waterBase64, imgWidth = _a.imgWidth, imgHeight = _a.imgHeight, isCompress = _a.isCompress, waterText = _a.waterText;
|
|
415
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
416
|
+
var allDom, pageFormat, pageOrient, pageMarginX, pageMarginY, pdfOptions, pdfBase64_2, pdf_3, pageWidth_1;
|
|
417
|
+
return __generator(this, function (_d) {
|
|
418
|
+
allDom = dom.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
|
|
419
|
+
pageFormat = (pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageFormat) ? pdfOption.pageFormat : 'a4';
|
|
420
|
+
pageOrient = (pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageOrient) ? pdfOption.pageOrient : 'p';
|
|
421
|
+
pageMarginX = (_b = pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageMarginX) !== null && _b !== void 0 ? _b : 20;
|
|
422
|
+
pageMarginY = (_c = pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageMarginY) !== null && _c !== void 0 ? _c : 10;
|
|
423
|
+
pdfOptions = {
|
|
424
|
+
// 是否压缩生成的PDF
|
|
425
|
+
compress: isCompress ? true : false,
|
|
426
|
+
// 格式
|
|
427
|
+
format: pageFormat,
|
|
428
|
+
hotfixes: ['px_scaling'],
|
|
429
|
+
// 方向 纵向 'p' 横向 'l'
|
|
430
|
+
orientation: pageOrient,
|
|
431
|
+
// 指定坐标时要使用的测量单位
|
|
432
|
+
// unit: 'px',
|
|
433
|
+
unit: 'pt',
|
|
434
|
+
};
|
|
435
|
+
// 如果需要分页
|
|
436
|
+
if (allDom.length > 0 && isShowPage) {
|
|
437
|
+
pdfBase64_2 = [];
|
|
438
|
+
return [2 /*return*/, (function () {
|
|
439
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
+
var pdfs;
|
|
441
|
+
return __generator(this, function (_a) {
|
|
442
|
+
switch (_a.label) {
|
|
443
|
+
case 0: return [4 /*yield*/, reduceDom(allDom, dom, function (item, i) {
|
|
444
|
+
return new Promise(function (resolve) {
|
|
445
|
+
// 每页都创建一个pdf实例
|
|
446
|
+
var pdf = new jsPDF(pdfOptions);
|
|
447
|
+
var pageWidth = pdf.internal.pageSize.width - pageMarginX * 2;
|
|
448
|
+
setPdfVersion(pdf);
|
|
449
|
+
supportJsPdfChinese(pdf, fileBinary);
|
|
450
|
+
// 正确呈现文档
|
|
451
|
+
pdf.html(item, {
|
|
452
|
+
autoPaging: 'text',
|
|
453
|
+
margin: [pageMarginY, pageMarginX, pageMarginY, pageMarginX],
|
|
454
|
+
width: pageWidth,
|
|
455
|
+
windowWidth: pageWidth,
|
|
456
|
+
callback: function (res) {
|
|
457
|
+
// 添加呈现的HTML所需的页面(从第2页开始)
|
|
458
|
+
for (var i_1 = 2, j = res.internal.getNumberOfPages(); i_1 <= j; i_1++) {
|
|
459
|
+
pdf.addPage(pageFormat, pageOrient);
|
|
460
|
+
}
|
|
461
|
+
for (var i_2 = 1, j = res.internal.getNumberOfPages(); i_2 <= j; i_2++) {
|
|
462
|
+
pdf.setPage(i_2);
|
|
463
|
+
// 添加水印
|
|
464
|
+
if (isAddWater) {
|
|
465
|
+
setPdfWater(pdf, waterBase64, imgWidth, imgHeight);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (isDownload) {
|
|
469
|
+
pdf.save(pdfName + "_" + i + ".pdf");
|
|
470
|
+
}
|
|
471
|
+
pdfBase64_2.push(pdf.output('dataurlstring'));
|
|
472
|
+
resolve(pdf);
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
})];
|
|
477
|
+
case 1:
|
|
478
|
+
pdfs = _a.sent();
|
|
479
|
+
return [2 /*return*/, Promise.resolve({
|
|
480
|
+
pdfs: pdfs,
|
|
481
|
+
pdfBase64: pdfBase64_2,
|
|
482
|
+
})];
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
})()];
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
pdf_3 = new jsPDF(pdfOptions);
|
|
490
|
+
pageWidth_1 = pdf_3.internal.pageSize.width - pageMarginX * 2;
|
|
491
|
+
setPdfVersion(pdf_3);
|
|
492
|
+
supportJsPdfChinese(pdf_3, fileBinary);
|
|
493
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
494
|
+
// 正确呈现文档
|
|
495
|
+
pdf_3.html(dom, {
|
|
496
|
+
autoPaging: 'text',
|
|
497
|
+
margin: [pageMarginY, pageMarginX, pageMarginY, pageMarginX],
|
|
498
|
+
width: pageWidth_1,
|
|
499
|
+
windowWidth: pageWidth_1,
|
|
500
|
+
callback: function (res) {
|
|
501
|
+
// 添加呈现的HTML所需的页面(从第2页开始)
|
|
502
|
+
for (var i = 2, j = res.internal.getNumberOfPages(); i <= j; i++) {
|
|
503
|
+
pdf_3.addPage(pageFormat, pageOrient);
|
|
504
|
+
}
|
|
505
|
+
for (var i = 1, j = res.internal.getNumberOfPages(); i <= j; i++) {
|
|
506
|
+
pdf_3.setPage(i);
|
|
507
|
+
// 添加水印
|
|
508
|
+
if (isAddWater) {
|
|
509
|
+
setPdfWater(pdf_3, waterBase64, imgWidth, imgHeight);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (isDownload) {
|
|
513
|
+
pdf_3.save(pdfName + ".pdf");
|
|
514
|
+
}
|
|
515
|
+
resolve({
|
|
516
|
+
pdfs: [pdf_3],
|
|
517
|
+
pdfBase64: [pdf_3.output('dataurlstring')],
|
|
518
|
+
});
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
// new jsPDF(pdfOptions).html(dom, {
|
|
522
|
+
// autoPaging: 'text',
|
|
523
|
+
// margin: [pageMarginY, pageMarginX, pageMarginY, pageMarginX],
|
|
524
|
+
// width: pageWidth,
|
|
525
|
+
// windowWidth: pageWidth,
|
|
526
|
+
// callback: function (res) {
|
|
527
|
+
// // 添加呈现的HTML所需的页面(从第2页开始)
|
|
528
|
+
// for (
|
|
529
|
+
// let i = 2, j = (res as any).internal.getNumberOfPages();
|
|
530
|
+
// i <= j;
|
|
531
|
+
// i++
|
|
532
|
+
// ) {
|
|
533
|
+
// pdf.addPage(pageFormat, pageOrient);
|
|
534
|
+
// }
|
|
535
|
+
// // 正确呈现文档
|
|
536
|
+
// pdf.html(dom, {
|
|
537
|
+
// autoPaging: 'text',
|
|
538
|
+
// margin: [pageMarginY, pageMarginX, pageMarginY, pageMarginX],
|
|
539
|
+
// width: pageWidth,
|
|
540
|
+
// windowWidth: pageWidth,
|
|
541
|
+
// callback: function () {
|
|
542
|
+
// for (
|
|
543
|
+
// let i = 1, j = (res as any).internal.getNumberOfPages();
|
|
544
|
+
// i <= j;
|
|
545
|
+
// i++
|
|
546
|
+
// ) {
|
|
547
|
+
// pdf.setPage(i);
|
|
548
|
+
// // 添加水印
|
|
549
|
+
// if (isAddWater) {
|
|
550
|
+
// setPdfWater(pdf, waterBase64, imgWidth, imgHeight);
|
|
551
|
+
// }
|
|
552
|
+
// }
|
|
553
|
+
// if (isDownload) {
|
|
554
|
+
// pdf.save(`${pdfName}.pdf`);
|
|
555
|
+
// }
|
|
556
|
+
// resolve({
|
|
557
|
+
// pdfs: [pdf],
|
|
558
|
+
// pdfBase64: [pdf.output('dataurlstring')],
|
|
559
|
+
// });
|
|
560
|
+
// },
|
|
561
|
+
// });
|
|
562
|
+
// },
|
|
563
|
+
// });
|
|
564
|
+
})];
|
|
565
|
+
}
|
|
566
|
+
return [2 /*return*/];
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* @author 陈亚雄
|
|
572
|
+
* @description 设置pdf版本号,契约锁需要1.7以上的pdf版本
|
|
573
|
+
* @param pdf pdf实例
|
|
574
|
+
*/
|
|
575
|
+
function setPdfVersion(pdf) {
|
|
576
|
+
try {
|
|
577
|
+
pdf.__private__.setPdfVersion('1.7');
|
|
578
|
+
}
|
|
579
|
+
catch (err) {
|
|
580
|
+
console.log(err);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* @author 陈亚雄
|
|
585
|
+
* @description jspdf支持中文字符
|
|
586
|
+
* @param pdf pdf实例
|
|
587
|
+
* @param fileBinary 中文字符编码base64串
|
|
588
|
+
*/
|
|
589
|
+
function supportJsPdfChinese(pdf, fileBinary) {
|
|
590
|
+
pdf.addFileToVFS('microsoft-yahei.ttf', fileBinary === null || fileBinary === void 0 ? void 0 : fileBinary.data);
|
|
591
|
+
pdf.addFont('microsoft-yahei.ttf', 'microsoft-yahei', 'normal');
|
|
592
|
+
pdf.setFont('microsoft-yahei');
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* @author 陈亚雄
|
|
596
|
+
* @description 为pdf添加水印,每页添加6个水印
|
|
597
|
+
* @param pdf pdf实例
|
|
598
|
+
*/
|
|
599
|
+
function setPdfWater(pdf, waterBase64, imgWidth, imgHeight) {
|
|
600
|
+
if (waterBase64 && imgWidth && imgHeight) {
|
|
601
|
+
pdf.addImage(waterBase64, 'PNG', 20, 20, imgWidth, imgHeight, '1');
|
|
602
|
+
pdf.addImage(waterBase64, 'PNG', 20 + imgWidth, 20, imgWidth, imgHeight, '2');
|
|
603
|
+
pdf.addImage(waterBase64, 'PNG', 20, 20 + imgHeight, imgWidth, imgHeight, '3');
|
|
604
|
+
pdf.addImage(waterBase64, 'PNG', 20 + imgWidth, 20 + imgHeight, imgWidth, imgHeight, '4');
|
|
605
|
+
pdf.addImage(waterBase64, 'PNG', 20, 20 + imgHeight + imgHeight, imgWidth, imgHeight, '5');
|
|
606
|
+
pdf.addImage(waterBase64, 'PNG', 20 + imgWidth, 20 + imgHeight + imgHeight, imgWidth, imgHeight, '6');
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* @author xjy
|
|
611
|
+
* @description 性能优化,减少页面dom数量
|
|
612
|
+
* @param allDom 需要打印的dom节点,parentDom 需要打印的dom的父节点
|
|
613
|
+
* @param handler 处理每个dom节点的函数,返回Promise
|
|
614
|
+
*/
|
|
615
|
+
function reduceDom(allDom, parentDom, handler) {
|
|
616
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
617
|
+
var domList, children, spinning, fragment, _i, children_1, element, promiseAllDomArray, _a, _b, _c, i_3, element, _d, _e, i, timer;
|
|
618
|
+
return __generator(this, function (_f) {
|
|
619
|
+
switch (_f.label) {
|
|
620
|
+
case 0:
|
|
621
|
+
domList = Array.from(allDom);
|
|
622
|
+
children = Array.from(parentDom.children);
|
|
623
|
+
return [4 /*yield*/, getSpinning()];
|
|
624
|
+
case 1:
|
|
625
|
+
spinning = _f.sent();
|
|
626
|
+
if (spinning) {
|
|
627
|
+
console.log('spinning', spinning);
|
|
628
|
+
spinning.style.display = 'flex';
|
|
629
|
+
spinning.style.flexDirection = 'column';
|
|
630
|
+
spinning.style.justifyContent = 'center';
|
|
631
|
+
spinning.style.alignItems = 'center';
|
|
632
|
+
spinning.innerHTML = '正在生成PDF...';
|
|
633
|
+
}
|
|
634
|
+
fragment = document.createDocumentFragment();
|
|
635
|
+
// 卸载dom
|
|
636
|
+
for (_i = 0, children_1 = children; _i < children_1.length; _i++) {
|
|
637
|
+
element = children_1[_i];
|
|
638
|
+
parentDom.removeChild(element);
|
|
639
|
+
fragment.appendChild(element);
|
|
640
|
+
}
|
|
641
|
+
promiseAllDomArray = [];
|
|
642
|
+
_a = [];
|
|
643
|
+
for (_b in domList)
|
|
644
|
+
_a.push(_b);
|
|
645
|
+
_c = 0;
|
|
646
|
+
_f.label = 2;
|
|
647
|
+
case 2:
|
|
648
|
+
if (!(_c < _a.length)) return [3 /*break*/, 5];
|
|
649
|
+
i_3 = _a[_c];
|
|
650
|
+
if (spinning) {
|
|
651
|
+
spinning.innerHTML = "<p>\u6B63\u5728\u751F\u6210PDF...</p><p>\u5F53\u524D\u8FDB\u5EA6" + (1 + Number(i_3)) + "/" + domList.length + "\u9875</p>";
|
|
652
|
+
}
|
|
653
|
+
element = domList[i_3].cloneNode(true);
|
|
654
|
+
parentDom.appendChild(element);
|
|
655
|
+
_e = (_d = promiseAllDomArray).push;
|
|
656
|
+
return [4 /*yield*/, handler(element, i_3)];
|
|
657
|
+
case 3:
|
|
658
|
+
_e.apply(_d, [_f.sent()]);
|
|
659
|
+
parentDom.removeChild(element);
|
|
660
|
+
_f.label = 4;
|
|
661
|
+
case 4:
|
|
662
|
+
_c++;
|
|
663
|
+
return [3 /*break*/, 2];
|
|
664
|
+
case 5:
|
|
665
|
+
// 添加dom
|
|
666
|
+
// for (let element of children) {
|
|
667
|
+
// parentDom.appendChild(element);
|
|
668
|
+
// }
|
|
669
|
+
parentDom.appendChild(fragment);
|
|
670
|
+
i = 0;
|
|
671
|
+
if (spinning) {
|
|
672
|
+
spinning.innerHTML = "<p>\u6B63\u5728\u5BFC\u51FAPDF...</p><p>\u7B49\u5F85" + (1 + i) + "\u79D2";
|
|
673
|
+
}
|
|
674
|
+
timer = setInterval(function () {
|
|
675
|
+
var spinning = document.querySelector('.ant-spin-spinning');
|
|
676
|
+
if (spinning) {
|
|
677
|
+
spinning.innerHTML = "<p>\u6B63\u5728\u5BFC\u51FAPDF...</p><p>\u7B49\u5F85" + (1 + i) + "\u79D2";
|
|
678
|
+
i++;
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
timer && clearInterval(timer);
|
|
682
|
+
}
|
|
683
|
+
}, 1000);
|
|
684
|
+
return [2 /*return*/, promiseAllDomArray];
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
function getSpinning() {
|
|
690
|
+
return new Promise(function (resolve) {
|
|
691
|
+
setTimeout(function () {
|
|
692
|
+
var spinning = document.querySelector('.ant-spin-spinning');
|
|
693
|
+
resolve(spinning);
|
|
694
|
+
}, 0);
|
|
695
|
+
});
|
|
696
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ztxkui",
|
|
3
|
-
"version": "4.2.23-336",
|
|
3
|
+
"version": "4.2.23-336-beta",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React components library",
|
|
6
6
|
"author": "zt-front-end",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react-window": "^1.8.9",
|
|
35
35
|
"virtuallist-antd": "^0.7.6",
|
|
36
36
|
"ztxkui": "^4.2.23-326",
|
|
37
|
-
"ztxkutils": "2.10.66-
|
|
37
|
+
"ztxkutils": "2.10.66-7-beta"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"analyze": "source-map-explorer 'dist/static/js/*.js'",
|