cmat 0.0.109 → 0.0.110
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/fesm2022/cmat-components-adapter.mjs +9 -9
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +9 -9
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +3 -3
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +12 -12
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +9 -9
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +3 -3
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +3 -3
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +28 -28
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-custom-formly.mjs +98 -98
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +15 -15
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-date-range.mjs +5 -5
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +3 -3
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +6 -6
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +3 -3
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +3 -3
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +3 -3
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +3 -3
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +3 -3
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +6 -6
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +3 -3
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +3 -3
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +3 -3
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +3 -3
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-loading-overlay.mjs +3 -3
- package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +3 -3
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +3 -3
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +42 -42
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +39 -39
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +3 -3
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +9 -9
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +3 -3
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +12 -12
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +9 -9
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +9 -9
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +3 -3
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +3 -3
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +3 -3
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +3 -3
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +9 -9
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +6 -4
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +3 -3
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +3 -3
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +9 -9
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +3 -3
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +3 -3
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +12 -12
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +9 -9
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +18 -18
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +7 -7
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +9 -9
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +6 -6
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +3 -3
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +3 -3
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +21 -21
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +9 -9
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +6 -6
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +3 -3
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +6 -6
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +3 -3
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +3 -3
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +3 -3
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +3 -3
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +3 -3
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +3 -3
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-services-alert.mjs +3 -3
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +6 -6
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +6 -6
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +3 -3
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +3 -3
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +6 -6
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +3 -3
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +3 -3
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +3 -3
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-print.mjs +676 -0
- package/fesm2022/cmat-services-print.mjs.map +1 -0
- package/fesm2022/cmat-services-splash-screen.mjs +3 -3
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +3 -3
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +3 -3
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat-validators.mjs.map +1 -1
- package/fesm2022/cmat-version.mjs.map +1 -1
- package/fesm2022/cmat.mjs +1231 -562
- package/fesm2022/cmat.mjs.map +1 -1
- package/package.json +5 -1
- package/styles/components/bundle.scss +13 -0
- package/styles/overrides/angular-material.scss +23 -0
- package/types/cmat-services-print.d.ts +94 -0
- package/types/cmat.d.ts +92 -2
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/** 打印覆盖样式:最小干预,保留页面原始视觉效果 */
|
|
5
|
+
const PRINT_OVERRIDE_CSS = `
|
|
6
|
+
@page { size: A4 var(--orientation); margin: var(--margins); }
|
|
7
|
+
|
|
8
|
+
/* 强制亮色背景 */
|
|
9
|
+
html, body {
|
|
10
|
+
background: #fff !important;
|
|
11
|
+
color-scheme: light !important;
|
|
12
|
+
}
|
|
13
|
+
body {
|
|
14
|
+
margin: 0 !important;
|
|
15
|
+
padding: 16px !important;
|
|
16
|
+
overflow: visible !important;
|
|
17
|
+
height: auto !important;
|
|
18
|
+
min-height: auto !important;
|
|
19
|
+
-webkit-print-color-adjust: exact;
|
|
20
|
+
print-color-adjust: exact;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* 页眉页脚 */
|
|
24
|
+
.cmat-print-header {
|
|
25
|
+
text-align: center;
|
|
26
|
+
margin-bottom: 16px;
|
|
27
|
+
padding-bottom: 10px;
|
|
28
|
+
border-bottom: 2px solid #333;
|
|
29
|
+
}
|
|
30
|
+
.cmat-print-header h1 {
|
|
31
|
+
font-size: 18pt;
|
|
32
|
+
margin: 0 0 4px 0;
|
|
33
|
+
font-weight: 700;
|
|
34
|
+
}
|
|
35
|
+
.cmat-print-header .cmat-print-time {
|
|
36
|
+
font-size: 9pt;
|
|
37
|
+
color: #666;
|
|
38
|
+
}
|
|
39
|
+
.cmat-print-footer {
|
|
40
|
+
margin-top: 24px;
|
|
41
|
+
padding-top: 8px;
|
|
42
|
+
border-top: 1px solid #ccc;
|
|
43
|
+
font-size: 9pt;
|
|
44
|
+
color: #999;
|
|
45
|
+
text-align: center;
|
|
46
|
+
}
|
|
47
|
+
.cmat-print-body {
|
|
48
|
+
width: 100%;
|
|
49
|
+
padding-top: 8px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* 移除滚动容器的滚动约束,仅针对实际可滚动元素 */
|
|
53
|
+
.cmat-print-body {
|
|
54
|
+
overflow: visible !important;
|
|
55
|
+
max-height: none !important;
|
|
56
|
+
}
|
|
57
|
+
.cmat-print-body .scrollbar-custom,
|
|
58
|
+
.cmat-print-body .overflow-y-auto,
|
|
59
|
+
.cmat-print-body .overflow-auto,
|
|
60
|
+
.cmat-print-body .mat-drawer-content,
|
|
61
|
+
.cmat-print-body .cdk-virtual-scroll-content-wrapper {
|
|
62
|
+
overflow: visible !important;
|
|
63
|
+
max-height: none !important;
|
|
64
|
+
height: auto !important;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.no-print, [data-print-exclude], .print\\:hidden {
|
|
68
|
+
display: none !important;
|
|
69
|
+
}
|
|
70
|
+
/* 隐藏 datetimepicker toggle 按钮并重置标签偏移 */
|
|
71
|
+
cmat-datetimepicker-toggle, .cmat-datetimepicker-toggle {
|
|
72
|
+
display: none !important;
|
|
73
|
+
}
|
|
74
|
+
.cmat-print-body .mat-mdc-form-field:has(.cmat-datetimepicker-toggle) {
|
|
75
|
+
--cmat-prefix-label-offset: 0px !important;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* 分页控制 */
|
|
79
|
+
.page-break-before { page-break-before: always; }
|
|
80
|
+
.page-break-after { page-break-after: always; }
|
|
81
|
+
.page-break-inside { page-break-inside: avoid; }
|
|
82
|
+
|
|
83
|
+
/* 防止表单字段和小组件被分页截断(不包含 formly-field,因为它可能包含多个字段,导致第一页空白) */
|
|
84
|
+
.cmat-print-body .mat-mdc-form-field,
|
|
85
|
+
.cmat-print-body .mat-mdc-chip-grid,
|
|
86
|
+
.cmat-print-body .mat-mdc-chip-row,
|
|
87
|
+
.cmat-print-body mat-slider,
|
|
88
|
+
.cmat-print-body mat-slide-toggle,
|
|
89
|
+
.cmat-print-body .mat-mdc-checkbox,
|
|
90
|
+
.cmat-print-body .mat-mdc-radio-button,
|
|
91
|
+
.cmat-print-body cmat-date-range,
|
|
92
|
+
.cmat-print-body .range {
|
|
93
|
+
break-inside: avoid !important;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* 打印时强制表格使用桌面布局(A4纸宽 < 960px 断点,会触发移动端卡片布局) */
|
|
97
|
+
.mat-mdc-table:not(.normal-mobile-table) {
|
|
98
|
+
display: table !important;
|
|
99
|
+
}
|
|
100
|
+
.mat-mdc-table:not(.normal-mobile-table) .mat-mdc-header-row {
|
|
101
|
+
display: table-row !important;
|
|
102
|
+
position: static !important;
|
|
103
|
+
}
|
|
104
|
+
.mat-mdc-table:not(.normal-mobile-table) tbody {
|
|
105
|
+
display: table-row-group !important;
|
|
106
|
+
}
|
|
107
|
+
.mat-mdc-table:not(.normal-mobile-table) .mat-mdc-row {
|
|
108
|
+
display: table-row !important;
|
|
109
|
+
height: auto !important;
|
|
110
|
+
position: static !important;
|
|
111
|
+
border-radius: 0 !important;
|
|
112
|
+
box-shadow: none !important;
|
|
113
|
+
padding: 0 !important;
|
|
114
|
+
max-height: none !important;
|
|
115
|
+
overflow: visible !important;
|
|
116
|
+
flex-direction: unset !important;
|
|
117
|
+
}
|
|
118
|
+
.mat-mdc-table:not(.normal-mobile-table) .mat-mdc-cell {
|
|
119
|
+
display: table-cell !important;
|
|
120
|
+
padding: 8px 12px !important;
|
|
121
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.12) !important;
|
|
122
|
+
}
|
|
123
|
+
.mat-mdc-table:not(.normal-mobile-table) .mat-mdc-header-cell {
|
|
124
|
+
display: table-cell !important;
|
|
125
|
+
padding: 8px 12px !important;
|
|
126
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.12) !important;
|
|
127
|
+
font-weight: 600 !important;
|
|
128
|
+
position: static !important;
|
|
129
|
+
}
|
|
130
|
+
/* 奇偶行背景 */
|
|
131
|
+
.mat-mdc-table:not(.normal-mobile-table) .mat-mdc-row:nth-child(even) {
|
|
132
|
+
background-color: rgb(248 250 252) !important;
|
|
133
|
+
}
|
|
134
|
+
.mat-mdc-table:not(.normal-mobile-table) .mat-mdc-row:nth-child(odd) {
|
|
135
|
+
background-color: #fff !important;
|
|
136
|
+
}
|
|
137
|
+
/* has-label-on-mobile 在打印时不显示前缀标签 */
|
|
138
|
+
.has-label-on-mobile::before {
|
|
139
|
+
display: none !important;
|
|
140
|
+
}
|
|
141
|
+
/* 禁止表头跨页重复 */
|
|
142
|
+
.mat-mdc-table .mat-mdc-header-row {
|
|
143
|
+
position: static !important;
|
|
144
|
+
}
|
|
145
|
+
thead {
|
|
146
|
+
display: table-header-group !important;
|
|
147
|
+
}
|
|
148
|
+
thead tr {
|
|
149
|
+
position: static !important;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* 保留所有边框和背景色 */
|
|
153
|
+
*, *::before, *::after {
|
|
154
|
+
-webkit-print-color-adjust: exact !important;
|
|
155
|
+
print-color-adjust: exact !important;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 移除 focus ring(打印无意义),但不影响 border/box-shadow */
|
|
159
|
+
.mat-mdc-form-field-focus-overlay {
|
|
160
|
+
display: none !important;
|
|
161
|
+
}
|
|
162
|
+
.mat-mdc-focus-indicator::after {
|
|
163
|
+
display: none !important;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* 确保表单字段间有合理间距,顶部留空防止 float-label 跨页被裁切 */
|
|
167
|
+
.cmat-print-body .mat-mdc-form-field {
|
|
168
|
+
margin-bottom: 0.25em !important;
|
|
169
|
+
margin-top: 0.5em !important;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* Repeat 容器内的字段减少顶部间距 */
|
|
173
|
+
.cmat-print-body .repeat-field .mat-mdc-form-field {
|
|
174
|
+
margin-top: 0 !important;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.cmat-print-body formly-field {
|
|
178
|
+
display: block;
|
|
179
|
+
margin-bottom: 0.25em !important;
|
|
180
|
+
}
|
|
181
|
+
/* 修复 flex-auto 在打印上下文中的布局问题 */
|
|
182
|
+
.cmat-print-body formly-form.flex-auto,
|
|
183
|
+
.cmat-print-body formly-form[class*="flex-auto"] {
|
|
184
|
+
flex: none !important;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* 确保 mat-hint(Description)可见,但不过宽 */
|
|
188
|
+
.cmat-print-body .mat-mdc-form-field-subscript-wrapper {
|
|
189
|
+
overflow: visible !important;
|
|
190
|
+
height: auto !important;
|
|
191
|
+
max-height: none !important;
|
|
192
|
+
position: relative !important;
|
|
193
|
+
padding-top: 2px !important;
|
|
194
|
+
}
|
|
195
|
+
.cmat-print-body .mat-mdc-form-field-hint {
|
|
196
|
+
color: #555 !important;
|
|
197
|
+
opacity: 1 !important;
|
|
198
|
+
display: block !important;
|
|
199
|
+
line-height: 1.2 !important;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Chips:确保打印时正确布局 */
|
|
203
|
+
.cmat-print-body .mat-mdc-chip-grid {
|
|
204
|
+
display: flex !important;
|
|
205
|
+
flex-wrap: wrap !important;
|
|
206
|
+
gap: 4px !important;
|
|
207
|
+
align-items: center !important;
|
|
208
|
+
}
|
|
209
|
+
.cmat-print-body .mat-mdc-chip-row {
|
|
210
|
+
display: inline-flex !important;
|
|
211
|
+
align-items: center !important;
|
|
212
|
+
|
|
213
|
+
.mat-mdc-chip-action{
|
|
214
|
+
padding-right:12px !important;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/* 隐藏 chip 内的输入框和自动补全 */
|
|
218
|
+
.cmat-print-body .mat-mdc-chip-grid input {
|
|
219
|
+
display: none !important;
|
|
220
|
+
}
|
|
221
|
+
.cmat-print-body .mat-mdc-autocomplete {
|
|
222
|
+
display: none !important;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Color Picker:确保色块按钮的 ::after 伪元素背景色被打印 */
|
|
226
|
+
.cmat-print-body .mat-mdc-form-field-icon-prefix button {
|
|
227
|
+
overflow: visible !important;
|
|
228
|
+
padding: 4px !important;
|
|
229
|
+
width: 32px !important;
|
|
230
|
+
height: 32px !important;
|
|
231
|
+
min-width: 32px !important;
|
|
232
|
+
min-height: 32px !important;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* 通用:防止 overflow-hidden 裁切 border */
|
|
236
|
+
.cmat-print-body .overflow-hidden {
|
|
237
|
+
overflow: visible !important;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* ─── 容器类型打印适配 ─── */
|
|
241
|
+
|
|
242
|
+
/* Tabs:展开所有标签页内容,隐藏标签导航 */
|
|
243
|
+
.cmat-print-body .mat-mdc-tab-header {
|
|
244
|
+
display: none !important;
|
|
245
|
+
}
|
|
246
|
+
.cmat-print-body .mat-mdc-tab-body-wrapper {
|
|
247
|
+
overflow: visible !important;
|
|
248
|
+
height: auto !important;
|
|
249
|
+
}
|
|
250
|
+
.cmat-print-body .mat-mdc-tab-body {
|
|
251
|
+
display: block !important;
|
|
252
|
+
visibility: visible !important;
|
|
253
|
+
opacity: 1 !important;
|
|
254
|
+
height: auto !important;
|
|
255
|
+
border-bottom: 1px dashed #ccc;
|
|
256
|
+
padding-bottom: 12px;
|
|
257
|
+
margin-bottom: 12px;
|
|
258
|
+
}
|
|
259
|
+
/* 在 tab body 前显示标签名 */
|
|
260
|
+
.cmat-print-body .mat-mdc-tab-body::before {
|
|
261
|
+
content: attr(aria-label);
|
|
262
|
+
display: block;
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
font-size: 1.1em;
|
|
265
|
+
margin-bottom: 8px;
|
|
266
|
+
color: #333;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* Stepper:展开所有步骤,隐藏导航按钮 */
|
|
270
|
+
.cmat-print-body .mat-horizontal-stepper-header-container {
|
|
271
|
+
display: none !important;
|
|
272
|
+
}
|
|
273
|
+
.cmat-print-body .mat-stepper-horizontal-line {
|
|
274
|
+
display: none !important;
|
|
275
|
+
}
|
|
276
|
+
.cmat-print-body .mat-step {
|
|
277
|
+
display: block !important;
|
|
278
|
+
visibility: visible !important;
|
|
279
|
+
opacity: 1 !important;
|
|
280
|
+
height: auto !important;
|
|
281
|
+
overflow: visible !important;
|
|
282
|
+
margin-bottom: 16px;
|
|
283
|
+
padding-bottom: 12px;
|
|
284
|
+
border-bottom: 1px dashed #ccc;
|
|
285
|
+
}
|
|
286
|
+
/* 显示步骤标签 */
|
|
287
|
+
.cmat-print-body .mat-step-label {
|
|
288
|
+
display: block !important;
|
|
289
|
+
font-weight: 600;
|
|
290
|
+
font-size: 1.1em;
|
|
291
|
+
margin-bottom: 8px;
|
|
292
|
+
color: #333;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* Expansion:强制展开面板 */
|
|
296
|
+
.cmat-print-body .mat-expansion-panel {
|
|
297
|
+
break-inside: avoid;
|
|
298
|
+
margin-bottom: 8px;
|
|
299
|
+
}
|
|
300
|
+
.cmat-print-body .mat-expansion-panel-content {
|
|
301
|
+
height: auto !important;
|
|
302
|
+
visibility: visible !important;
|
|
303
|
+
opacity: 1 !important;
|
|
304
|
+
overflow: visible !important;
|
|
305
|
+
display: block !important;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
`;
|
|
310
|
+
class CmatPrintService {
|
|
311
|
+
/**
|
|
312
|
+
* 打印指定 DOM 元素
|
|
313
|
+
* 保留原始 DOM 结构和样式,同步表单控件的当前值
|
|
314
|
+
*/
|
|
315
|
+
printElement(element, options) {
|
|
316
|
+
const clone = element.cloneNode(true);
|
|
317
|
+
// 同步表单控件的 live value 到克隆节点的 attribute
|
|
318
|
+
this._syncFormValues(element, clone);
|
|
319
|
+
// 移除不需要打印的元素
|
|
320
|
+
this._prepareForPrint(element, clone, options);
|
|
321
|
+
const contentHtml = clone.outerHTML;
|
|
322
|
+
this._print(contentHtml, options);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 通过 CSS 选择器打印第一个匹配的元素
|
|
326
|
+
*/
|
|
327
|
+
printSelector(selector, options) {
|
|
328
|
+
const element = document.querySelector(selector);
|
|
329
|
+
if (!element) {
|
|
330
|
+
console.warn(`[CmatPrintService] 未找到匹配选择器的元素: ${selector}`);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
this.printElement(element, options);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 打印原始 HTML 字符串(不进行 DOM 转换,直接注入)
|
|
337
|
+
*/
|
|
338
|
+
printHtml(html, options) {
|
|
339
|
+
this._print(html, options);
|
|
340
|
+
}
|
|
341
|
+
// ─── 私有方法 ───────────────────────────────────────────────
|
|
342
|
+
/**
|
|
343
|
+
* 同步原始 DOM 中表单控件的当前值到克隆节点
|
|
344
|
+
* cloneNode() 不会复制 input.value 等 live property,
|
|
345
|
+
* 必须手动同步为 HTML attribute 才能在 iframe 中正确渲染
|
|
346
|
+
*/
|
|
347
|
+
_syncFormValues(original, clone) {
|
|
348
|
+
const origFields = original.querySelectorAll('input, textarea, select');
|
|
349
|
+
const cloneFields = clone.querySelectorAll('input, textarea, select');
|
|
350
|
+
origFields.forEach((origField, i) => {
|
|
351
|
+
const cloneField = cloneFields[i];
|
|
352
|
+
if (!cloneField)
|
|
353
|
+
return;
|
|
354
|
+
if (origField instanceof HTMLInputElement) {
|
|
355
|
+
const cloneInput = cloneField;
|
|
356
|
+
// 同步 value attribute
|
|
357
|
+
cloneInput.setAttribute('value', origField.value);
|
|
358
|
+
// 同步 checked 状态
|
|
359
|
+
if (origField.type === 'checkbox' || origField.type === 'radio') {
|
|
360
|
+
if (origField.checked) {
|
|
361
|
+
cloneInput.setAttribute('checked', '');
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
cloneInput.removeAttribute('checked');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (origField instanceof HTMLTextAreaElement) {
|
|
369
|
+
// textarea 的值通过 textContent 同步
|
|
370
|
+
cloneField.textContent = origField.value;
|
|
371
|
+
}
|
|
372
|
+
else if (origField instanceof HTMLSelectElement) {
|
|
373
|
+
const cloneSelect = cloneField;
|
|
374
|
+
Array.from(origField.options).forEach((opt, idx) => {
|
|
375
|
+
const cloneOpt = cloneSelect.options[idx];
|
|
376
|
+
if (!cloneOpt)
|
|
377
|
+
return;
|
|
378
|
+
if (opt.selected) {
|
|
379
|
+
cloneOpt.setAttribute('selected', '');
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
cloneOpt.removeAttribute('selected');
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* 最小化打印准备:DOM 转换 + 清理
|
|
390
|
+
* 对无法正确打印的组件进行 DOM 替换,对关键元素复制 computed style
|
|
391
|
+
*/
|
|
392
|
+
_prepareForPrint(original, root, options) {
|
|
393
|
+
// 移除标记为不打印的元素
|
|
394
|
+
root.querySelectorAll('.print\\:hidden, [data-print-exclude]').forEach(el => el.remove());
|
|
395
|
+
// 移除所有按钮(保留 form-field 前缀/后缀按钮、chip 内按钮和 slide-toggle 开关)
|
|
396
|
+
root.querySelectorAll('button').forEach((el) => {
|
|
397
|
+
const isPrefixSuffix = el.closest('.mat-mdc-form-field-icon-prefix, .mat-mdc-form-field-icon-suffix, ' +
|
|
398
|
+
'.mat-mdc-form-field-text-prefix, .mat-mdc-form-field-text-suffix');
|
|
399
|
+
const isChipButton = el.closest('.mat-mdc-chip-row');
|
|
400
|
+
const isSwitch = el.classList.contains('mdc-switch');
|
|
401
|
+
if (!isPrefixSuffix && !isChipButton && !isSwitch) {
|
|
402
|
+
el.remove();
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
// ── Chips:移除删除按钮的内容(图标),保持 chip 布局 ──
|
|
406
|
+
root.querySelectorAll('.mat-mdc-chip-row button[matChipRemove]').forEach((btn) => {
|
|
407
|
+
btn.innerHTML = '';
|
|
408
|
+
btn.style.cssText = 'display:none !important;';
|
|
409
|
+
});
|
|
410
|
+
// ── Description (mat-hint):强制紧凑布局 ──
|
|
411
|
+
root.querySelectorAll('.mat-mdc-form-field-subscript-wrapper').forEach((wrapper) => {
|
|
412
|
+
wrapper.style.cssText += ';overflow:visible!important;height:auto!important;min-height:0!important;max-height:none!important;' +
|
|
413
|
+
'position:relative!important;padding:0!important;margin:0!important;line-height:1!important;font-size:0.85em!important;';
|
|
414
|
+
});
|
|
415
|
+
// ── 复制关键元素的 computed style 为 inline style ──
|
|
416
|
+
this._inlineComputedStyles(original, root);
|
|
417
|
+
// ── Expansion:强制展开所有面板 ──
|
|
418
|
+
root.querySelectorAll('.mat-expansion-panel').forEach((panel) => {
|
|
419
|
+
panel.classList.add('mat-expanded');
|
|
420
|
+
});
|
|
421
|
+
// 移除用户自定义排除选择器
|
|
422
|
+
options?.excludeSelectors?.forEach((selector) => {
|
|
423
|
+
root.querySelectorAll(selector).forEach(el => el.remove());
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* 将原始页面中关键元素的 computed style 复制为 inline style
|
|
428
|
+
* 确保 iframe 中即使 CSS 规则不生效,样式也能通过 inline style 保留
|
|
429
|
+
*/
|
|
430
|
+
_inlineComputedStyles(original, root) {
|
|
431
|
+
// 需要复制 computed style 的选择器列表
|
|
432
|
+
// 注意:不包含 .mdc-switch* 和 .mdc-slider*,这些组件的 computed style 可能包含 opacity:0 等不适合打印的值
|
|
433
|
+
const selectors = [
|
|
434
|
+
'.mat-mdc-form-field-subscript-wrapper',
|
|
435
|
+
'.mat-mdc-chip-row',
|
|
436
|
+
'.mat-mdc-chip',
|
|
437
|
+
];
|
|
438
|
+
// 从原始元素(而非 document)查找匹配元素,确保索引与克隆节点匹配
|
|
439
|
+
for (const selector of selectors) {
|
|
440
|
+
const originals = original.querySelectorAll(selector);
|
|
441
|
+
const clones = root.querySelectorAll(selector);
|
|
442
|
+
originals.forEach((orig, i) => {
|
|
443
|
+
const clone = clones[i];
|
|
444
|
+
if (!clone)
|
|
445
|
+
return;
|
|
446
|
+
const computed = getComputedStyle(orig);
|
|
447
|
+
// 复制关键属性
|
|
448
|
+
const props = ['display', 'visibility', 'opacity', 'overflow', 'width', 'height',
|
|
449
|
+
'min-width', 'min-height', 'max-width', 'max-height', 'padding', 'margin',
|
|
450
|
+
'border', 'border-radius', 'background-color', 'color', 'font-size', 'font-weight',
|
|
451
|
+
'line-height', 'position', 'top', 'left', 'right', 'bottom', 'flex', 'flex-direction',
|
|
452
|
+
'align-items', 'justify-content', 'gap', 'box-shadow', 'transform'];
|
|
453
|
+
for (const prop of props) {
|
|
454
|
+
const val = computed.getPropertyValue(prop);
|
|
455
|
+
if (val) {
|
|
456
|
+
clone.style.setProperty(prop, val, 'important');
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/** 构建完整 HTML 并注入 iframe 执行打印 */
|
|
463
|
+
_print(contentHtml, options) {
|
|
464
|
+
const title = options?.title ?? '打印';
|
|
465
|
+
const orientation = options?.orientation ?? 'portrait';
|
|
466
|
+
const margins = options?.margins ?? { top: 15, right: 15, bottom: 15, left: 15 };
|
|
467
|
+
const now = new Date();
|
|
468
|
+
const timeStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
|
|
469
|
+
// 页眉
|
|
470
|
+
let headerHtml = '';
|
|
471
|
+
if (options?.header !== null) {
|
|
472
|
+
headerHtml = options?.header ?? `
|
|
473
|
+
<div class="cmat-print-header">
|
|
474
|
+
<h1>${this._escapeHtml(title)}</h1>
|
|
475
|
+
<div class="cmat-print-time">打印时间:${timeStr}</div>
|
|
476
|
+
</div>
|
|
477
|
+
`;
|
|
478
|
+
}
|
|
479
|
+
// 页脚
|
|
480
|
+
let footerHtml = '';
|
|
481
|
+
if (options?.footer !== null) {
|
|
482
|
+
footerHtml = options?.footer ?? `
|
|
483
|
+
<div class="cmat-print-footer">
|
|
484
|
+
此文档由系统生成 · ${timeStr}
|
|
485
|
+
</div>
|
|
486
|
+
`;
|
|
487
|
+
}
|
|
488
|
+
// 收集页面已有样式(通过 styleSheets API 完整收集)
|
|
489
|
+
const pageStyles = this._collectAllStyles();
|
|
490
|
+
// 收集 CSS 自定义属性(变量),确保 iframe 中边框颜色等不丢失
|
|
491
|
+
const cssVars = this._collectCssVariables();
|
|
492
|
+
// 复制原始页面的 html/body class(保留主题类名)
|
|
493
|
+
const htmlClass = document.documentElement.className || 'light';
|
|
494
|
+
const bodyClass = this._getPrintBodyClass();
|
|
495
|
+
// 打印覆盖样式
|
|
496
|
+
const marginStr = `${margins.top}mm ${margins.right}mm ${margins.bottom}mm ${margins.left}mm`;
|
|
497
|
+
const overrideCss = PRINT_OVERRIDE_CSS
|
|
498
|
+
.replace('var(--orientation)', orientation)
|
|
499
|
+
.replace('var(--margins)', marginStr);
|
|
500
|
+
const fullHtml = `<!DOCTYPE html>
|
|
501
|
+
<html lang="zh-CN" class="${htmlClass}" style="${cssVars}">
|
|
502
|
+
<head>
|
|
503
|
+
<meta charset="utf-8">
|
|
504
|
+
<base href="${document.baseURI}">
|
|
505
|
+
<title>${this._escapeHtml(title)}</title>
|
|
506
|
+
${pageStyles}
|
|
507
|
+
<style>${overrideCss}${options?.customCss ?? ''}</style>
|
|
508
|
+
</head>
|
|
509
|
+
<body class="${bodyClass}">
|
|
510
|
+
${headerHtml}
|
|
511
|
+
<div class="cmat-print-body">${contentHtml}</div>
|
|
512
|
+
${footerHtml}
|
|
513
|
+
</body>
|
|
514
|
+
</html>`;
|
|
515
|
+
this._renderAndPrint(fullHtml, options);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* 通过 document.styleSheets API 收集所有样式规则
|
|
519
|
+
* 关键处理:将 @media screen 转换为同时适用于 print
|
|
520
|
+
* (因为 iframe 调用 print() 时媒体类型切换为 print,screen-only 规则会失效)
|
|
521
|
+
*/
|
|
522
|
+
_collectAllStyles() {
|
|
523
|
+
const cssTexts = [];
|
|
524
|
+
try {
|
|
525
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
526
|
+
try {
|
|
527
|
+
const rules = sheet.cssRules;
|
|
528
|
+
if (!rules || rules.length === 0)
|
|
529
|
+
continue;
|
|
530
|
+
let cssText = '';
|
|
531
|
+
for (const rule of Array.from(rules)) {
|
|
532
|
+
cssText += rule.cssText + '\n';
|
|
533
|
+
}
|
|
534
|
+
if (cssText.trim()) {
|
|
535
|
+
cssTexts.push(`<style>${this._transformMediaForPrint(cssText)}</style>`);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
catch {
|
|
539
|
+
// 跨域样式表无法读取 cssRules,使用 <link> 回退
|
|
540
|
+
if (sheet.href) {
|
|
541
|
+
cssTexts.push(`<link rel="stylesheet" href="${sheet.href}" media="all">`);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
catch (e) {
|
|
547
|
+
console.warn('[CmatPrintService] 样式收集异常:', e);
|
|
548
|
+
}
|
|
549
|
+
return cssTexts.join('\n ');
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* 将 @media screen 相关查询转换为同时适用 print
|
|
553
|
+
* 确保打印时不丢失屏幕样式(如表格奇偶行、border 等)
|
|
554
|
+
*/
|
|
555
|
+
_transformMediaForPrint(css) {
|
|
556
|
+
// @media screen and (...) → @media (...)
|
|
557
|
+
// @media screen → 移除 media 类型限制
|
|
558
|
+
return css
|
|
559
|
+
.replace(/@media\s+screen\s+and\s*\(/g, '@media (')
|
|
560
|
+
.replace(/@media\s+screen\s*\{/g, '@media all {')
|
|
561
|
+
.replace(/@media\s+only\s+screen\s+and\s*\(/g, '@media (')
|
|
562
|
+
.replace(/@media\s+only\s+screen\s*\{/g, '@media all {');
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* 收集页面 :root 上的所有 CSS 自定义属性(变量)
|
|
566
|
+
* 这些变量定义了 Material/Tailwind 的边框颜色、主题色等
|
|
567
|
+
* 克隆到 iframe 时祖先链断裂,需要手动复制
|
|
568
|
+
*/
|
|
569
|
+
_collectCssVariables() {
|
|
570
|
+
const vars = [];
|
|
571
|
+
const rootStyles = getComputedStyle(document.documentElement);
|
|
572
|
+
// 从 document.styleSheets 中提取 :root 规则里的自定义属性
|
|
573
|
+
try {
|
|
574
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
575
|
+
try {
|
|
576
|
+
const rules = sheet.cssRules;
|
|
577
|
+
if (!rules)
|
|
578
|
+
continue;
|
|
579
|
+
for (const rule of Array.from(rules)) {
|
|
580
|
+
if (rule instanceof CSSStyleRule) {
|
|
581
|
+
const selector = rule.selectorText;
|
|
582
|
+
if (selector === ':root' || selector === 'html' || selector === ':root, html') {
|
|
583
|
+
const props = Array.from({ length: rule.style.length }, (_, i) => rule.style[i]);
|
|
584
|
+
for (const prop of props) {
|
|
585
|
+
if (prop.startsWith('--')) {
|
|
586
|
+
vars.push(`${prop}: ${rule.style.getPropertyValue(prop)}`);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
catch {
|
|
594
|
+
// 跨域样式表跳过
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
catch (e) {
|
|
599
|
+
console.warn('[CmatPrintService] CSS变量收集异常:', e);
|
|
600
|
+
}
|
|
601
|
+
// 补充:从 computed style 获取运行时可能动态设置的变量
|
|
602
|
+
// 遍历常见的 Material/Tailwind 变量前缀
|
|
603
|
+
const prefixes = ['--mdc-', '--mat-', '--md-', '--tw-', '--ck-', '--color-', '--border-'];
|
|
604
|
+
const rootProps = Array.from({ length: rootStyles.length }, (_, i) => rootStyles[i]);
|
|
605
|
+
for (const prop of rootProps) {
|
|
606
|
+
if (prop.startsWith('--') && prefixes.some(p => prop.startsWith(p))) {
|
|
607
|
+
const value = rootStyles.getPropertyValue(prop);
|
|
608
|
+
if (value && !vars.some(v => v.startsWith(prop + ':'))) {
|
|
609
|
+
vars.push(`${prop}: ${value.trim()}`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return vars.join('; ');
|
|
614
|
+
}
|
|
615
|
+
/** 获取打印用的 body class(复制原始页面的主题类名,移除布局类名) */
|
|
616
|
+
_getPrintBodyClass() {
|
|
617
|
+
const bodyClasses = document.body.className.split(/\s+/);
|
|
618
|
+
// 保留主题相关 class,移除布局/滚动类
|
|
619
|
+
const excludeClasses = new Set(['overflow-hidden', 'h-full', 'w-full', 'h-screen', 'w-screen']);
|
|
620
|
+
return bodyClasses
|
|
621
|
+
.filter(c => c && !excludeClasses.has(c))
|
|
622
|
+
.join(' ');
|
|
623
|
+
}
|
|
624
|
+
/** 创建隐藏 iframe,写入内容,触发打印 */
|
|
625
|
+
_renderAndPrint(html, options) {
|
|
626
|
+
const iframe = document.createElement('iframe');
|
|
627
|
+
iframe.style.cssText = 'position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; visibility: hidden;';
|
|
628
|
+
document.body.appendChild(iframe);
|
|
629
|
+
const cleanup = () => {
|
|
630
|
+
iframe.remove();
|
|
631
|
+
options?.afterPrint?.();
|
|
632
|
+
};
|
|
633
|
+
iframe.onload = () => {
|
|
634
|
+
// 给渲染一点时间(图片、字体等)
|
|
635
|
+
setTimeout(() => {
|
|
636
|
+
try {
|
|
637
|
+
iframe.contentWindow?.focus();
|
|
638
|
+
iframe.contentWindow?.print();
|
|
639
|
+
}
|
|
640
|
+
catch (e) {
|
|
641
|
+
console.error('[CmatPrintService] 打印失败:', e);
|
|
642
|
+
}
|
|
643
|
+
// 监听打印完成(兼容处理)
|
|
644
|
+
if (iframe.contentWindow) {
|
|
645
|
+
iframe.contentWindow.onafterprint = cleanup;
|
|
646
|
+
// 兜底:部分浏览器不触发 onafterprint
|
|
647
|
+
setTimeout(cleanup, 60000);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
cleanup();
|
|
651
|
+
}
|
|
652
|
+
}, 300);
|
|
653
|
+
};
|
|
654
|
+
// 使用 srcdoc 替代已废弃的 document.write
|
|
655
|
+
iframe.srcdoc = html;
|
|
656
|
+
}
|
|
657
|
+
/** HTML 转义 */
|
|
658
|
+
_escapeHtml(text) {
|
|
659
|
+
const div = document.createElement('div');
|
|
660
|
+
div.textContent = text;
|
|
661
|
+
return div.innerHTML;
|
|
662
|
+
}
|
|
663
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
664
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatPrintService, providedIn: 'root' }); }
|
|
665
|
+
}
|
|
666
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatPrintService, decorators: [{
|
|
667
|
+
type: Injectable,
|
|
668
|
+
args: [{ providedIn: 'root' }]
|
|
669
|
+
}] });
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Generated bundle index. Do not edit.
|
|
673
|
+
*/
|
|
674
|
+
|
|
675
|
+
export { CmatPrintService };
|
|
676
|
+
//# sourceMappingURL=cmat-services-print.mjs.map
|