ng-zorro-antd-extension 17.1.0 → 17.3.0
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/README.md +7 -6
- package/configurable-query/configurable-query.component.d.ts +14 -16
- package/configurable-query/type.d.ts +2 -2
- package/esm2022/configurable-query/configurable-query.component.mjs +65 -45
- package/esm2022/configurable-query/type.mjs +1 -1
- package/esm2022/print/nzx-print-content.directive.mjs +22 -0
- package/esm2022/print/nzx-print-v.component.mjs +301 -0
- package/esm2022/print/nzx-print.component.mjs +36 -26
- package/esm2022/print/nzx-print.directive.mjs +11 -7
- package/esm2022/print/nzx-print.module.mjs +20 -6
- package/esm2022/print/public-api.mjs +3 -1
- package/esm2022/table-select/page-table-select/page-table-select.component.mjs +3 -3
- package/esm2022/table-select/table-select/table-select.component.mjs +3 -3
- package/esm2022/util/lib/getElementByTag.mjs +31 -0
- package/esm2022/util/public-api.mjs +2 -1
- package/fesm2022/ng-zorro-antd-extension-configurable-query.mjs +63 -43
- package/fesm2022/ng-zorro-antd-extension-configurable-query.mjs.map +1 -1
- package/fesm2022/ng-zorro-antd-extension-print.mjs +371 -36
- package/fesm2022/ng-zorro-antd-extension-print.mjs.map +1 -1
- package/fesm2022/ng-zorro-antd-extension-table-select.mjs +4 -4
- package/fesm2022/ng-zorro-antd-extension-table-select.mjs.map +1 -1
- package/fesm2022/ng-zorro-antd-extension-util.mjs +32 -1
- package/fesm2022/ng-zorro-antd-extension-util.mjs.map +1 -1
- package/package.json +2 -1
- package/pipes/safe-url.pipe.d.ts +1 -1
- package/print/nzx-print-content.directive.d.ts +10 -0
- package/print/nzx-print-v.component.d.ts +45 -0
- package/print/nzx-print.component.d.ts +7 -7
- package/print/nzx-print.directive.d.ts +2 -1
- package/print/nzx-print.module.d.ts +7 -3
- package/print/public-api.d.ts +2 -0
- package/public-api.d.ts +1 -1
- package/timer-button/timer-button.directive.d.ts +1 -1
- package/util/lib/getElementByTag.d.ts +8 -0
- package/util/public-api.d.ts +1 -0
- package/esm2022/print/util.mjs +0 -9
- package/print/util.d.ts +0 -1
|
@@ -1,27 +1,35 @@
|
|
|
1
|
+
import * as i1$1 from '@angular/common';
|
|
1
2
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
2
3
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Directive, ElementRef, Component, Inject,
|
|
4
|
+
import { Directive, Input, ElementRef, Component, Inject, ViewChild, ContentChild, EventEmitter, Output, ContentChildren, HostListener, NgModule } from '@angular/core';
|
|
5
|
+
import { getElementByTag } from 'ng-zorro-antd-extension/util';
|
|
4
6
|
import * as i1 from '@angular/cdk/platform';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
html.push(elements[index].outerHTML);
|
|
11
|
-
}
|
|
12
|
-
return html.join('\r\n');
|
|
13
|
-
}
|
|
7
|
+
import { Navigation, PageViewMode, CoreViewer } from '@vivliostyle/core';
|
|
8
|
+
import * as i2 from 'ng-zorro-antd/grid';
|
|
9
|
+
import { NzGridModule } from 'ng-zorro-antd/grid';
|
|
10
|
+
import * as i3 from 'ng-zorro-antd/pagination';
|
|
11
|
+
import { NzPaginationModule } from 'ng-zorro-antd/pagination';
|
|
14
12
|
|
|
15
13
|
class NzxPrintContentDirective {
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
constructor(elementRef) {
|
|
15
|
+
this.elementRef = elementRef;
|
|
16
|
+
this.identifierStr = '';
|
|
17
|
+
this.customStyle = '';
|
|
18
|
+
}
|
|
19
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintContentDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
20
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: NzxPrintContentDirective, selector: "[nzxPrintContent]", inputs: { identifierStr: "identifierStr", customStyle: "customStyle" }, ngImport: i0 }); }
|
|
18
21
|
}
|
|
19
22
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintContentDirective, decorators: [{
|
|
20
23
|
type: Directive,
|
|
21
24
|
args: [{
|
|
22
25
|
selector: '[nzxPrintContent]',
|
|
23
26
|
}]
|
|
24
|
-
}] }
|
|
27
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { identifierStr: [{
|
|
28
|
+
type: Input
|
|
29
|
+
}], customStyle: [{
|
|
30
|
+
type: Input
|
|
31
|
+
}] } });
|
|
32
|
+
|
|
25
33
|
/**
|
|
26
34
|
* 使用Paged.js打印
|
|
27
35
|
*/
|
|
@@ -36,6 +44,8 @@ class NzxPrintComponent {
|
|
|
36
44
|
this.width = 814;
|
|
37
45
|
this.height = 1143;
|
|
38
46
|
this.enablePreview = true;
|
|
47
|
+
this.identifierStr = '';
|
|
48
|
+
this.pagedCDN = '';
|
|
39
49
|
this._title = this.document.title;
|
|
40
50
|
this.afterPrint = () => {
|
|
41
51
|
this.iframeEl.contentWindow.parent.document.title = this._title;
|
|
@@ -44,6 +54,11 @@ class NzxPrintComponent {
|
|
|
44
54
|
this.iframeEl.contentWindow.parent.document.title = this.printTitle;
|
|
45
55
|
};
|
|
46
56
|
}
|
|
57
|
+
ngOnInit() {
|
|
58
|
+
if (!this.pagedCDN) {
|
|
59
|
+
throw new Error('pagedCDN is required');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
47
62
|
ngAfterViewInit() {
|
|
48
63
|
this.render();
|
|
49
64
|
}
|
|
@@ -59,10 +74,11 @@ class NzxPrintComponent {
|
|
|
59
74
|
}, 100);
|
|
60
75
|
}
|
|
61
76
|
render() {
|
|
62
|
-
const container = this.document.getElementById('nzx-print-iframe-content');
|
|
63
77
|
this.iframeEl = this.document.createElement('iframe');
|
|
64
78
|
this.iframeEl.height = this.height + '';
|
|
65
79
|
this.iframeEl.width = this.width + '';
|
|
80
|
+
this.iframeEl.style.border = '1px solid #ccc';
|
|
81
|
+
this.iframeEl.style.background = '#fff';
|
|
66
82
|
if (!this.enablePreview) {
|
|
67
83
|
this.iframeEl.style.visibility = 'hidden';
|
|
68
84
|
if (this.platform.FIREFOX) {
|
|
@@ -72,9 +88,9 @@ class NzxPrintComponent {
|
|
|
72
88
|
this.iframeEl.setAttribute('style', 'visibility: hidden; height: 0; width: 0; position: absolute; border: 0');
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
if (this.containerRef) {
|
|
92
|
+
this.containerRef.nativeElement.innerHTML = '';
|
|
93
|
+
this.containerRef.nativeElement.appendChild(this.iframeEl);
|
|
78
94
|
}
|
|
79
95
|
if (this.iframeEl.contentWindow) {
|
|
80
96
|
this.iframeEl.contentWindow.document.open();
|
|
@@ -86,9 +102,9 @@ class NzxPrintComponent {
|
|
|
86
102
|
}
|
|
87
103
|
}
|
|
88
104
|
getTemplateStr() {
|
|
89
|
-
const styles =
|
|
105
|
+
const styles = getElementByTag('style', this.identifierStr);
|
|
90
106
|
const scripts = `
|
|
91
|
-
<script src="
|
|
107
|
+
<script src="${this.pagedCDN}"></script>
|
|
92
108
|
<script>
|
|
93
109
|
class RepeatingTableHeaders extends Paged.Handler {
|
|
94
110
|
constructor(chunker, polisher, caller) {
|
|
@@ -113,7 +129,7 @@ class NzxPrintComponent {
|
|
|
113
129
|
Paged.registerHandlers(RepeatingTableHeaders);
|
|
114
130
|
</script>
|
|
115
131
|
`;
|
|
116
|
-
|
|
132
|
+
let html = `
|
|
117
133
|
<!DOCTYPE html>
|
|
118
134
|
<html>
|
|
119
135
|
<head>
|
|
@@ -157,20 +173,24 @@ class NzxPrintComponent {
|
|
|
157
173
|
</body>
|
|
158
174
|
</html>
|
|
159
175
|
`;
|
|
176
|
+
html = html.replace(/<!---->/g, ' ');
|
|
160
177
|
return html;
|
|
161
178
|
}
|
|
162
179
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintComponent, deps: [{ token: i1.Platform }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
163
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.3", type: NzxPrintComponent, selector: "nzx-print", inputs: { printTitle: "printTitle", width: "width", height: "height", enablePreview: "enablePreview" }, queries: [{ propertyName: "_printEl", first: true, predicate: NzxPrintContentDirective, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: `
|
|
180
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.3", type: NzxPrintComponent, selector: "nzx-print", inputs: { printTitle: "printTitle", width: "width", height: "height", enablePreview: "enablePreview", identifierStr: "identifierStr", pagedCDN: "pagedCDN" }, queries: [{ propertyName: "_printEl", first: true, predicate: NzxPrintContentDirective, descendants: true, read: ElementRef, static: true }], viewQueries: [{ propertyName: "containerRef", first: true, predicate: ["iframeContainer"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: `
|
|
164
181
|
<ng-content select="[nzxPrintHeader]"></ng-content>
|
|
165
|
-
<div
|
|
166
|
-
`, isInline: true
|
|
182
|
+
<div #iframeContainer></div>
|
|
183
|
+
`, isInline: true }); }
|
|
167
184
|
}
|
|
168
185
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintComponent, decorators: [{
|
|
169
186
|
type: Component,
|
|
170
|
-
args: [{
|
|
187
|
+
args: [{
|
|
188
|
+
selector: 'nzx-print',
|
|
189
|
+
template: `
|
|
171
190
|
<ng-content select="[nzxPrintHeader]"></ng-content>
|
|
172
|
-
<div
|
|
173
|
-
`,
|
|
191
|
+
<div #iframeContainer></div>
|
|
192
|
+
`,
|
|
193
|
+
}]
|
|
174
194
|
}], ctorParameters: () => [{ type: i1.Platform }, { type: Document, decorators: [{
|
|
175
195
|
type: Inject,
|
|
176
196
|
args: [DOCUMENT]
|
|
@@ -182,17 +202,319 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
182
202
|
type: Input
|
|
183
203
|
}], enablePreview: [{
|
|
184
204
|
type: Input
|
|
205
|
+
}], identifierStr: [{
|
|
206
|
+
type: Input
|
|
207
|
+
}], pagedCDN: [{
|
|
208
|
+
type: Input
|
|
209
|
+
}], containerRef: [{
|
|
210
|
+
type: ViewChild,
|
|
211
|
+
args: ['iframeContainer', { read: ElementRef, static: true }]
|
|
185
212
|
}], _printEl: [{
|
|
186
213
|
type: ContentChild,
|
|
187
214
|
args: [NzxPrintContentDirective, { read: ElementRef, static: true }]
|
|
188
215
|
}] } });
|
|
189
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Vivliostyle 打印
|
|
219
|
+
*/
|
|
220
|
+
class NzxPrintVComponent {
|
|
221
|
+
constructor(cd) {
|
|
222
|
+
this.cd = cd;
|
|
223
|
+
this.printTitle = 'pdf';
|
|
224
|
+
/**
|
|
225
|
+
* a4 794px1123px
|
|
226
|
+
*/
|
|
227
|
+
this.width = 814;
|
|
228
|
+
this.height = 1143;
|
|
229
|
+
this.enablePreview = true;
|
|
230
|
+
this.pixelRatio = 8;
|
|
231
|
+
this.pageRenderComplete = new EventEmitter();
|
|
232
|
+
this.pageTotal = 0;
|
|
233
|
+
this._title = document.title;
|
|
234
|
+
this._isRenderComplete = false;
|
|
235
|
+
this.handleError = (payload) => {
|
|
236
|
+
console.log('error::', payload);
|
|
237
|
+
};
|
|
238
|
+
this.handleReadyStateChange = (payload) => {
|
|
239
|
+
this._isRenderComplete = false;
|
|
240
|
+
this.pageRenderComplete.emit(false);
|
|
241
|
+
if (this.viewer && this.viewer.readyState === 'complete') {
|
|
242
|
+
const intervalTag = setInterval(() => {
|
|
243
|
+
if (this.iframeEl &&
|
|
244
|
+
this.iframeEl.contentWindow &&
|
|
245
|
+
this.iframeEl.contentWindow.document) {
|
|
246
|
+
const images = this.iframeEl.contentWindow.document.getElementsByTagName('img');
|
|
247
|
+
let allImagesLoaded = true;
|
|
248
|
+
for (let i = 0; i < images.length; i++) {
|
|
249
|
+
if (!images[i].complete) {
|
|
250
|
+
allImagesLoaded = false;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (allImagesLoaded) {
|
|
255
|
+
console.log('All images in iframe loaded successfully');
|
|
256
|
+
this.pageRenderComplete.emit(true);
|
|
257
|
+
this._isRenderComplete = true;
|
|
258
|
+
clearInterval(intervalTag);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}, 1000);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
this.handleHyperlink = (payload) => {
|
|
265
|
+
console.log('handleHyperlink::', payload);
|
|
266
|
+
};
|
|
267
|
+
this.handleLoaded = (payload) => {
|
|
268
|
+
console.log('handleLoaded::', payload);
|
|
269
|
+
};
|
|
270
|
+
this.handleNavigation = (payload) => {
|
|
271
|
+
this.pageTotal = payload.epageCount;
|
|
272
|
+
this.cd.markForCheck();
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
ngAfterViewInit() {
|
|
276
|
+
setTimeout(() => {
|
|
277
|
+
this.createIframeWrapper();
|
|
278
|
+
}, 1000);
|
|
279
|
+
}
|
|
280
|
+
ngOnDestroy() {
|
|
281
|
+
if (this.viewer) {
|
|
282
|
+
this.clearView();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
onPageIndexChange(num) {
|
|
286
|
+
if (this.viewer) {
|
|
287
|
+
this.viewer.navigateToPage(Navigation.EPAGE, num - 1);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
print() {
|
|
291
|
+
if (this._isRenderComplete) {
|
|
292
|
+
this.iframeEl.contentWindow.print();
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
console.warn('rending...');
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
refresh() {
|
|
299
|
+
setTimeout(() => {
|
|
300
|
+
this.createIframeWrapper();
|
|
301
|
+
}, 100);
|
|
302
|
+
}
|
|
303
|
+
createIframeWrapper() {
|
|
304
|
+
if (this.vivViewRef) {
|
|
305
|
+
this.clearView();
|
|
306
|
+
this.iframeEl = document.createElement('iframe');
|
|
307
|
+
this.iframeEl.height = this.height + '';
|
|
308
|
+
this.iframeEl.width = this.width + '';
|
|
309
|
+
this.iframeEl.style.border = '1px solid #ccc';
|
|
310
|
+
this.iframeEl.style.background = '#fff';
|
|
311
|
+
const template = `
|
|
312
|
+
<!DOCTYPE html>
|
|
313
|
+
<html data-vivliostyle-paginated="true">
|
|
314
|
+
<head>
|
|
315
|
+
<meta charset="utf-8" />
|
|
316
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
317
|
+
<base href="/" />
|
|
318
|
+
<title>${this.printTitle}</title>
|
|
319
|
+
<style>
|
|
320
|
+
html[data-vivliostyle-paginated] {
|
|
321
|
+
width: 100%;
|
|
322
|
+
height: 100%;
|
|
323
|
+
}
|
|
324
|
+
html[data-vivliostyle-paginated] body,
|
|
325
|
+
html[data-vivliostyle-paginated] [data-vivliostyle-viewer-viewport] {
|
|
326
|
+
width: 100% !important;
|
|
327
|
+
height: 100% !important;
|
|
328
|
+
background: #fff;
|
|
329
|
+
}
|
|
330
|
+
html[data-vivliostyle-paginated],
|
|
331
|
+
html[data-vivliostyle-paginated] body {
|
|
332
|
+
margin: 0;
|
|
333
|
+
padding: 0;
|
|
334
|
+
}
|
|
335
|
+
</style>
|
|
336
|
+
<style id="vivliostyle-page-rules"></style>
|
|
337
|
+
</head>
|
|
338
|
+
<body>
|
|
339
|
+
<div id="vivliostyle-viewer-viewport"></div>
|
|
340
|
+
</body>
|
|
341
|
+
</html>
|
|
342
|
+
`;
|
|
343
|
+
this.iframeEl.srcdoc = template;
|
|
344
|
+
this.vivViewRef.nativeElement.appendChild(this.iframeEl);
|
|
345
|
+
this.iframeEl.contentWindow.onbeforeprint = () => {
|
|
346
|
+
this.iframeEl.contentWindow.parent.document.title = this.printTitle;
|
|
347
|
+
};
|
|
348
|
+
this.iframeEl.contentWindow.onafterprint = () => {
|
|
349
|
+
this.iframeEl.contentWindow.parent.document.title = this._title;
|
|
350
|
+
};
|
|
351
|
+
this.createVivViewer();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
createVivViewer() {
|
|
355
|
+
this.iframeEl.onload = () => {
|
|
356
|
+
const els = this._printElQueryList.toArray();
|
|
357
|
+
const templates = this.getVivTemplates(els);
|
|
358
|
+
const options = [];
|
|
359
|
+
templates.forEach((template) => {
|
|
360
|
+
const docBlob = new Blob([template], {
|
|
361
|
+
type: 'text/html',
|
|
362
|
+
});
|
|
363
|
+
const docURL = URL.createObjectURL(docBlob);
|
|
364
|
+
options.push({ url: docURL });
|
|
365
|
+
});
|
|
366
|
+
this.viewer = new CoreViewer({
|
|
367
|
+
viewportElement: this.iframeEl.contentWindow?.document.body
|
|
368
|
+
.firstElementChild,
|
|
369
|
+
}, {
|
|
370
|
+
pageViewMode: PageViewMode.SINGLE_PAGE,
|
|
371
|
+
pixelRatio: this.pixelRatio,
|
|
372
|
+
});
|
|
373
|
+
this.viewer.loadDocument(options);
|
|
374
|
+
this.createListener(this.viewer);
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
createListener(viewer) {
|
|
378
|
+
viewer.addListener('error', this.handleError);
|
|
379
|
+
viewer.addListener('readystatechange', this.handleReadyStateChange);
|
|
380
|
+
viewer.addListener('loaded', this.handleLoaded);
|
|
381
|
+
viewer.addListener('hyperlink', this.handleHyperlink);
|
|
382
|
+
viewer.addListener('nav', this.handleNavigation);
|
|
383
|
+
}
|
|
384
|
+
removeListeners(viewer) {
|
|
385
|
+
viewer.removeListener('error', this.handleError);
|
|
386
|
+
viewer.removeListener('readystatechange', this.handleReadyStateChange);
|
|
387
|
+
viewer.removeListener('loaded', this.handleLoaded);
|
|
388
|
+
viewer.removeListener('hyperlink', this.handleHyperlink);
|
|
389
|
+
viewer.removeListener('nav', this.handleNavigation);
|
|
390
|
+
}
|
|
391
|
+
getStyles(identifierStr) {
|
|
392
|
+
const stylesArray = [];
|
|
393
|
+
const styleElements = document.getElementsByTagName('style');
|
|
394
|
+
const length = styleElements.length;
|
|
395
|
+
let identifiers = [];
|
|
396
|
+
if (Array.isArray(identifierStr)) {
|
|
397
|
+
identifiers = [...identifierStr];
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
identifiers = [identifierStr];
|
|
401
|
+
}
|
|
402
|
+
for (let index = 0; index < length; index++) {
|
|
403
|
+
identifiers.forEach((s) => {
|
|
404
|
+
if (styleElements[index].outerHTML.includes(s)) {
|
|
405
|
+
const formateStr = styleElements[index].outerHTML.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
406
|
+
stylesArray.push(formateStr);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
return stylesArray.join('\r\n');
|
|
411
|
+
}
|
|
412
|
+
getVivTemplates(directives) {
|
|
413
|
+
const templates = [];
|
|
414
|
+
directives.forEach((d) => {
|
|
415
|
+
let styles = '';
|
|
416
|
+
if (d.identifierStr || d.identifierStr.length > 0) {
|
|
417
|
+
styles = this.getStyles(d.identifierStr);
|
|
418
|
+
}
|
|
419
|
+
let html = `
|
|
420
|
+
<!DOCTYPE html>
|
|
421
|
+
<html>
|
|
422
|
+
<head>
|
|
423
|
+
<meta charset="utf-8" />
|
|
424
|
+
<title>${this.printTitle}</title>
|
|
425
|
+
<base href="/" />
|
|
426
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
427
|
+
${d.customStyle}
|
|
428
|
+
${styles}
|
|
429
|
+
</head>
|
|
430
|
+
<body>
|
|
431
|
+
${d.elementRef.nativeElement.outerHTML}
|
|
432
|
+
</body>
|
|
433
|
+
</html>
|
|
434
|
+
`;
|
|
435
|
+
html = html.replace(/<!---->/g, ' ');
|
|
436
|
+
templates.push(html);
|
|
437
|
+
});
|
|
438
|
+
return templates;
|
|
439
|
+
}
|
|
440
|
+
clearView() {
|
|
441
|
+
if (this.viewer) {
|
|
442
|
+
this.removeListeners(this.viewer);
|
|
443
|
+
}
|
|
444
|
+
this.vivViewRef.nativeElement.innerHTML = '';
|
|
445
|
+
this.viewer = undefined;
|
|
446
|
+
this._isRenderComplete = false;
|
|
447
|
+
}
|
|
448
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintVComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
449
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.3", type: NzxPrintVComponent, selector: "nzx-print-v", inputs: { printTitle: "printTitle", width: "width", height: "height", enablePreview: "enablePreview", pixelRatio: "pixelRatio" }, outputs: { pageRenderComplete: "pageRenderComplete" }, queries: [{ propertyName: "_printElQueryList", predicate: NzxPrintContentDirective }], viewQueries: [{ propertyName: "vivViewRef", first: true, predicate: ["vivView"], descendants: true }], ngImport: i0, template: `
|
|
450
|
+
<ng-content select="[nzxPrintHeader]"></ng-content>
|
|
451
|
+
|
|
452
|
+
<div #vivView [ngStyle]="{ margin: '10px 0' }"></div>
|
|
453
|
+
|
|
454
|
+
<div nz-row nzJustify="end">
|
|
455
|
+
<ng-template #totalTemplate let-total>共 {{ total }} 页</ng-template>
|
|
456
|
+
<nz-pagination
|
|
457
|
+
[nzPageIndex]="1"
|
|
458
|
+
[nzTotal]="pageTotal"
|
|
459
|
+
[nzPageSize]="1"
|
|
460
|
+
[nzSize]="'small'"
|
|
461
|
+
[nzShowTotal]="totalTemplate"
|
|
462
|
+
nzShowQuickJumper
|
|
463
|
+
(nzPageIndexChange)="onPageIndexChange($event)"
|
|
464
|
+
></nz-pagination>
|
|
465
|
+
</div>
|
|
466
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "component", type: i3.NzPaginationComponent, selector: "nz-pagination", inputs: ["nzShowTotal", "nzItemRender", "nzSize", "nzPageSizeOptions", "nzShowSizeChanger", "nzShowQuickJumper", "nzSimple", "nzDisabled", "nzResponsive", "nzHideOnSinglePage", "nzTotal", "nzPageIndex", "nzPageSize"], outputs: ["nzPageSizeChange", "nzPageIndexChange"], exportAs: ["nzPagination"] }] }); }
|
|
467
|
+
}
|
|
468
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintVComponent, decorators: [{
|
|
469
|
+
type: Component,
|
|
470
|
+
args: [{
|
|
471
|
+
selector: 'nzx-print-v',
|
|
472
|
+
template: `
|
|
473
|
+
<ng-content select="[nzxPrintHeader]"></ng-content>
|
|
474
|
+
|
|
475
|
+
<div #vivView [ngStyle]="{ margin: '10px 0' }"></div>
|
|
476
|
+
|
|
477
|
+
<div nz-row nzJustify="end">
|
|
478
|
+
<ng-template #totalTemplate let-total>共 {{ total }} 页</ng-template>
|
|
479
|
+
<nz-pagination
|
|
480
|
+
[nzPageIndex]="1"
|
|
481
|
+
[nzTotal]="pageTotal"
|
|
482
|
+
[nzPageSize]="1"
|
|
483
|
+
[nzSize]="'small'"
|
|
484
|
+
[nzShowTotal]="totalTemplate"
|
|
485
|
+
nzShowQuickJumper
|
|
486
|
+
(nzPageIndexChange)="onPageIndexChange($event)"
|
|
487
|
+
></nz-pagination>
|
|
488
|
+
</div>
|
|
489
|
+
`,
|
|
490
|
+
}]
|
|
491
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { printTitle: [{
|
|
492
|
+
type: Input
|
|
493
|
+
}], width: [{
|
|
494
|
+
type: Input
|
|
495
|
+
}], height: [{
|
|
496
|
+
type: Input
|
|
497
|
+
}], enablePreview: [{
|
|
498
|
+
type: Input
|
|
499
|
+
}], pixelRatio: [{
|
|
500
|
+
type: Input
|
|
501
|
+
}], pageRenderComplete: [{
|
|
502
|
+
type: Output
|
|
503
|
+
}], vivViewRef: [{
|
|
504
|
+
type: ViewChild,
|
|
505
|
+
args: ['vivView']
|
|
506
|
+
}], _printElQueryList: [{
|
|
507
|
+
type: ContentChildren,
|
|
508
|
+
args: [NzxPrintContentDirective]
|
|
509
|
+
}] } });
|
|
510
|
+
|
|
190
511
|
/**
|
|
191
512
|
* 常规打印
|
|
192
513
|
*/
|
|
193
514
|
class NzxPrintDirective {
|
|
194
515
|
constructor() {
|
|
195
516
|
this.printTitle = 'pdf';
|
|
517
|
+
this.identifierStr = '';
|
|
196
518
|
}
|
|
197
519
|
ngOnInit() {
|
|
198
520
|
if (!this.printEl) {
|
|
@@ -205,9 +527,9 @@ class NzxPrintDirective {
|
|
|
205
527
|
print() {
|
|
206
528
|
const newWin = window.open('', '_blank');
|
|
207
529
|
if (newWin) {
|
|
208
|
-
const styles =
|
|
209
|
-
const links =
|
|
210
|
-
const baseTag =
|
|
530
|
+
const styles = getElementByTag('style', this.identifierStr);
|
|
531
|
+
const links = getElementByTag('link');
|
|
532
|
+
const baseTag = getElementByTag('base');
|
|
211
533
|
const scripts = `
|
|
212
534
|
<script>
|
|
213
535
|
window.onload = function () {
|
|
@@ -218,7 +540,7 @@ class NzxPrintDirective {
|
|
|
218
540
|
};
|
|
219
541
|
</script>
|
|
220
542
|
`;
|
|
221
|
-
|
|
543
|
+
let html = `
|
|
222
544
|
<!DOCTYPE html>
|
|
223
545
|
<html>
|
|
224
546
|
<head>
|
|
@@ -233,6 +555,7 @@ class NzxPrintDirective {
|
|
|
233
555
|
</body>
|
|
234
556
|
</html>
|
|
235
557
|
`;
|
|
558
|
+
html = html.replace(/<!---->/g, ' ');
|
|
236
559
|
newWin.document.open();
|
|
237
560
|
newWin.document.write(html);
|
|
238
561
|
newWin.document.close();
|
|
@@ -256,7 +579,7 @@ class NzxPrintDirective {
|
|
|
256
579
|
}
|
|
257
580
|
}
|
|
258
581
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
259
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: NzxPrintDirective, selector: "button[nzxPrint]", inputs: { printEl: "printEl", printTitle: "printTitle" }, host: { listeners: { "click": "print()" } }, ngImport: i0 }); }
|
|
582
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: NzxPrintDirective, selector: "button[nzxPrint]", inputs: { printEl: "printEl", printTitle: "printTitle", identifierStr: "identifierStr" }, host: { listeners: { "click": "print()" } }, ngImport: i0 }); }
|
|
260
583
|
}
|
|
261
584
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintDirective, decorators: [{
|
|
262
585
|
type: Directive,
|
|
@@ -267,6 +590,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
267
590
|
type: Input
|
|
268
591
|
}], printTitle: [{
|
|
269
592
|
type: Input
|
|
593
|
+
}], identifierStr: [{
|
|
594
|
+
type: Input
|
|
270
595
|
}], print: [{
|
|
271
596
|
type: HostListener,
|
|
272
597
|
args: ['click']
|
|
@@ -275,20 +600,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
275
600
|
class NzxPrintModule {
|
|
276
601
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
277
602
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintModule, declarations: [NzxPrintComponent,
|
|
603
|
+
NzxPrintVComponent,
|
|
604
|
+
NzxPrintDirective,
|
|
605
|
+
NzxPrintContentDirective], imports: [CommonModule, NzGridModule, NzPaginationModule], exports: [NzxPrintComponent,
|
|
606
|
+
NzxPrintVComponent,
|
|
278
607
|
NzxPrintContentDirective,
|
|
279
|
-
NzxPrintDirective]
|
|
280
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintModule, imports: [CommonModule] }); }
|
|
608
|
+
NzxPrintDirective] }); }
|
|
609
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintModule, imports: [CommonModule, NzGridModule, NzPaginationModule] }); }
|
|
281
610
|
}
|
|
282
611
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NzxPrintModule, decorators: [{
|
|
283
612
|
type: NgModule,
|
|
284
613
|
args: [{
|
|
285
614
|
declarations: [
|
|
286
615
|
NzxPrintComponent,
|
|
616
|
+
NzxPrintVComponent,
|
|
617
|
+
NzxPrintDirective,
|
|
618
|
+
NzxPrintContentDirective,
|
|
619
|
+
],
|
|
620
|
+
imports: [CommonModule, NzGridModule, NzPaginationModule],
|
|
621
|
+
exports: [
|
|
622
|
+
NzxPrintComponent,
|
|
623
|
+
NzxPrintVComponent,
|
|
287
624
|
NzxPrintContentDirective,
|
|
288
625
|
NzxPrintDirective,
|
|
289
626
|
],
|
|
290
|
-
imports: [CommonModule],
|
|
291
|
-
exports: [NzxPrintComponent, NzxPrintContentDirective, NzxPrintDirective],
|
|
292
627
|
}]
|
|
293
628
|
}] });
|
|
294
629
|
|
|
@@ -301,5 +636,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
301
636
|
* Generated bundle index. Do not edit.
|
|
302
637
|
*/
|
|
303
638
|
|
|
304
|
-
export { NzxPrintComponent, NzxPrintContentDirective, NzxPrintDirective, NzxPrintModule };
|
|
639
|
+
export { NzxPrintComponent, NzxPrintContentDirective, NzxPrintDirective, NzxPrintModule, NzxPrintVComponent };
|
|
305
640
|
//# sourceMappingURL=ng-zorro-antd-extension-print.mjs.map
|