ydb-components-material 0.1.80 → 0.1.82
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/build/docs/404.html +3 -3
- package/build/docs/_demos/:uuid +3 -3
- package/build/docs/colorful-button.html +3 -3
- package/build/docs/colorful-input.html +3 -3
- package/build/docs/index.html +3 -3
- package/build/docs/umi.41f52bba.js +1 -0
- package/build/docs/{umi.111d5bd3.css → umi.fb5ec9e5.css} +1 -1
- package/build/docs/~demos/:uuid.html +3 -3
- package/build/docs/~demos/colorful-button-demo.html +3 -3
- package/build/docs/~demos/colorful-input-demo.html +3 -3
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +9 -9
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +1 -1
- package/dist/BizComps.css +1 -1
- package/dist/BizComps.js +2 -2
- package/dist/BizComps.js.map +1 -1
- package/es/api.js +6 -0
- package/es/components/file-item/checkPoint.scss +1 -1
- package/es/components/file-item/index.js +59 -26
- package/es/components/print/index.d.ts +18 -0
- package/es/components/print/index.js +100 -0
- package/es/components/print/index.scss +63 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/lib/api.js +7 -1
- package/lib/components/file-item/checkPoint.scss +1 -1
- package/lib/components/file-item/index.js +59 -26
- package/lib/components/print/index.d.ts +18 -0
- package/lib/components/print/index.js +105 -0
- package/lib/components/print/index.scss +63 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lowcode/print-button/meta.ts +149 -0
- package/lowcode_es/meta.js +3 -2
- package/lowcode_es/print-button/meta.d.ts +22 -0
- package/lowcode_es/print-button/meta.js +127 -0
- package/lowcode_lib/meta.js +8 -7
- package/lowcode_lib/print-button/meta.d.ts +22 -0
- package/lowcode_lib/print-button/meta.js +132 -0
- package/package.json +3 -3
- package/build/docs/umi.1c99ba62.js +0 -1
package/es/api.js
CHANGED
|
@@ -141,6 +141,12 @@ export var previewApi = function previewApi(params, config) {
|
|
|
141
141
|
export var getMaterialLib = function getMaterialLib(params, config) {
|
|
142
142
|
return post("https://zwfwpt.sxzwfw.gov.cn/DeclarationAPI/declaration/material/queryFileByCardNo", params, config);
|
|
143
143
|
};
|
|
144
|
+
export var getUrlById = function getUrlById(params, config) {
|
|
145
|
+
return get("https://zwfwpt.sxzwfw.gov.cn:10009/DeclarationAPI/declaration/material/file/files/api/presigned-url", params, config);
|
|
146
|
+
};
|
|
147
|
+
export var onlinePreview = function onlinePreview(params, config) {
|
|
148
|
+
return get("https://zwfwpt.sxzwfw.gov.cn:10009/DeclarationAPI/declaration/material/onlinePreview", params, config);
|
|
149
|
+
};
|
|
144
150
|
export var getMaterialPreview = function getMaterialPreview(params, config) {
|
|
145
151
|
return get(window.baseUrl + "/declaration/material/onlinePreview", params, config);
|
|
146
152
|
};
|
|
@@ -148,20 +148,53 @@ var FileItem = function FileItem(_ref) {
|
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
// 预览材料
|
|
151
|
-
var preview = function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
151
|
+
var preview = /*#__PURE__*/function () {
|
|
152
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
153
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
154
|
+
while (1) switch (_context.prev = _context.next) {
|
|
155
|
+
case 0:
|
|
156
|
+
if (fileUrl) {
|
|
157
|
+
_context.next = 1;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
return _context.abrupt("return");
|
|
161
|
+
case 1:
|
|
162
|
+
console.log('fileUrl', fileUrl, fileId);
|
|
163
|
+
setPreviewIframeUrl(fileUrl);
|
|
164
|
+
setIsShowPreview(true);
|
|
165
|
+
// if (!fileId) return;
|
|
166
|
+
// const urlRes = await getUrlById({
|
|
167
|
+
// id: fileId,
|
|
168
|
+
// effectiveTime: 3600000
|
|
169
|
+
// })
|
|
170
|
+
// if (urlRes.presignedUrlList && urlRes.presignedUrlList.length > 0) {
|
|
171
|
+
// // fetch(`${baseUrl}/declaration/material/onlinePreview?url=${urlRes.presignedUrlList[2]}`, {
|
|
172
|
+
// // method: 'GET',
|
|
173
|
+
// // headers: {
|
|
174
|
+
// // 'Authorization': tokenTY
|
|
175
|
+
// // }
|
|
176
|
+
// // })
|
|
177
|
+
// // .then(response => response.json())
|
|
178
|
+
// // .then(res => {
|
|
179
|
+
// // setPreviewIframeUrl(res.url)
|
|
180
|
+
// // setIsShowPreview(true)
|
|
181
|
+
// // })
|
|
182
|
+
// const res = await onlinePreview({
|
|
183
|
+
// url: urlRes.presignedUrlList[2],
|
|
184
|
+
// })
|
|
185
|
+
// setPreviewIframeUrl(res.url)
|
|
186
|
+
// setIsShowPreview(true)
|
|
187
|
+
// }
|
|
188
|
+
case 2:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context.stop();
|
|
191
|
+
}
|
|
192
|
+
}, _callee);
|
|
193
|
+
}));
|
|
194
|
+
return function preview() {
|
|
195
|
+
return _ref2.apply(this, arguments);
|
|
196
|
+
};
|
|
197
|
+
}();
|
|
165
198
|
|
|
166
199
|
// 预览材料中的材料
|
|
167
200
|
var previewMaterial = function previewMaterial(id, url) {
|
|
@@ -251,36 +284,36 @@ var FileItem = function FileItem(_ref) {
|
|
|
251
284
|
});
|
|
252
285
|
};
|
|
253
286
|
var showGuide = /*#__PURE__*/function () {
|
|
254
|
-
var
|
|
287
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
255
288
|
var guideImgRes;
|
|
256
|
-
return _regeneratorRuntime.wrap(function (
|
|
257
|
-
while (1) switch (
|
|
289
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
290
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
258
291
|
case 0:
|
|
259
292
|
if (guideImg) {
|
|
260
|
-
|
|
293
|
+
_context2.next = 1;
|
|
261
294
|
break;
|
|
262
295
|
}
|
|
263
|
-
return
|
|
296
|
+
return _context2.abrupt("return");
|
|
264
297
|
case 1:
|
|
265
|
-
|
|
298
|
+
_context2.next = 2;
|
|
266
299
|
return getGuideImg({
|
|
267
300
|
id: guideImg,
|
|
268
301
|
effectiveTime: 3600000
|
|
269
302
|
});
|
|
270
303
|
case 2:
|
|
271
|
-
guideImgRes =
|
|
304
|
+
guideImgRes = _context2.sent;
|
|
272
305
|
if (guideImgRes.presignedUrl) {
|
|
273
306
|
setGuideurl(guideImgRes.presignedUrl);
|
|
274
307
|
setIsShowGuide(true);
|
|
275
308
|
}
|
|
276
309
|
case 3:
|
|
277
310
|
case "end":
|
|
278
|
-
return
|
|
311
|
+
return _context2.stop();
|
|
279
312
|
}
|
|
280
|
-
},
|
|
313
|
+
}, _callee2);
|
|
281
314
|
}));
|
|
282
315
|
return function showGuide() {
|
|
283
|
-
return
|
|
316
|
+
return _ref3.apply(this, arguments);
|
|
284
317
|
};
|
|
285
318
|
}();
|
|
286
319
|
var selectMaterialOk = function selectMaterialOk() {
|
|
@@ -557,9 +590,9 @@ var FileItem = function FileItem(_ref) {
|
|
|
557
590
|
return setIsShowPreview(false);
|
|
558
591
|
}
|
|
559
592
|
}), /*#__PURE__*/React.createElement("iframe", {
|
|
560
|
-
src: previewIframeUrl,
|
|
593
|
+
src: previewIframeUrl + '#toolbar=0&navpanes=0&scrollbar=0&messages=0&statusbar=0',
|
|
561
594
|
frameborder: "0",
|
|
562
|
-
height: "
|
|
595
|
+
height: "600px",
|
|
563
596
|
width: "100%"
|
|
564
597
|
})), isShowMaterialPreview && /*#__PURE__*/React.createElement("div", {
|
|
565
598
|
className: "preview"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export interface PrintButtonProps {
|
|
4
|
+
/** 按钮文本 */
|
|
5
|
+
text?: string;
|
|
6
|
+
/** 打印前回调 */
|
|
7
|
+
onBeforePrint?: () => void | Promise<void>;
|
|
8
|
+
/** 打印后回调 */
|
|
9
|
+
onAfterPrint?: () => void;
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** 自定义类名 */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** 按钮类型 */
|
|
15
|
+
type?: 'primary' | 'default' | 'text';
|
|
16
|
+
}
|
|
17
|
+
export declare const PrintButton: React.FC<PrintButtonProps>;
|
|
18
|
+
export default PrintButton;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import "./index.scss";
|
|
5
|
+
export var PrintButton = function PrintButton(_ref) {
|
|
6
|
+
var _ref$text = _ref.text,
|
|
7
|
+
text = _ref$text === void 0 ? '打印' : _ref$text,
|
|
8
|
+
onBeforePrint = _ref.onBeforePrint,
|
|
9
|
+
onAfterPrint = _ref.onAfterPrint,
|
|
10
|
+
_ref$disabled = _ref.disabled,
|
|
11
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
12
|
+
_ref$className = _ref.className,
|
|
13
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
14
|
+
_ref$type = _ref.type,
|
|
15
|
+
type = _ref$type === void 0 ? 'primary' : _ref$type;
|
|
16
|
+
var handlePrint = /*#__PURE__*/function () {
|
|
17
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
18
|
+
var printContent, printWindow, styles, _t;
|
|
19
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
20
|
+
while (1) switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
if (!disabled) {
|
|
23
|
+
_context.next = 1;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
return _context.abrupt("return");
|
|
27
|
+
case 1:
|
|
28
|
+
_context.prev = 1;
|
|
29
|
+
_context.next = 2;
|
|
30
|
+
return onBeforePrint === null || onBeforePrint === void 0 ? void 0 : onBeforePrint();
|
|
31
|
+
case 2:
|
|
32
|
+
// 获取打印内容 - 整个页面
|
|
33
|
+
printContent = document.body;
|
|
34
|
+
if (printContent) {
|
|
35
|
+
_context.next = 3;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
console.warn('未找到打印内容');
|
|
39
|
+
return _context.abrupt("return");
|
|
40
|
+
case 3:
|
|
41
|
+
// 创建打印窗口
|
|
42
|
+
printWindow = window.open('', '_blank');
|
|
43
|
+
if (printWindow) {
|
|
44
|
+
_context.next = 4;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
console.warn('无法打开打印窗口');
|
|
48
|
+
return _context.abrupt("return");
|
|
49
|
+
case 4:
|
|
50
|
+
// 复制当前页面样式
|
|
51
|
+
styles = Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).map(function (el) {
|
|
52
|
+
return el.outerHTML;
|
|
53
|
+
}).join('\n'); // 构建打印内容
|
|
54
|
+
printWindow.document.write("\n <!DOCTYPE html>\n <html>\n <head>\n <title>\u6253\u5370</title>\n " + styles + "\n <style>\n @media print {\n body { margin: 0; padding: 20px; }\n .no-print { display: none !important; }\n }\n </style>\n </head>\n <body>\n " + printContent.innerHTML + "\n </body>\n </html>\n ");
|
|
55
|
+
printWindow.document.close();
|
|
56
|
+
printWindow.focus();
|
|
57
|
+
|
|
58
|
+
// 执行打印
|
|
59
|
+
setTimeout(function () {
|
|
60
|
+
printWindow.print();
|
|
61
|
+
printWindow.close();
|
|
62
|
+
onAfterPrint === null || onAfterPrint === void 0 ? void 0 : onAfterPrint();
|
|
63
|
+
}, 250);
|
|
64
|
+
_context.next = 6;
|
|
65
|
+
break;
|
|
66
|
+
case 5:
|
|
67
|
+
_context.prev = 5;
|
|
68
|
+
_t = _context["catch"](1);
|
|
69
|
+
console.error('打印失败:', _t);
|
|
70
|
+
case 6:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee, null, [[1, 5]]);
|
|
75
|
+
}));
|
|
76
|
+
return function handlePrint() {
|
|
77
|
+
return _ref2.apply(this, arguments);
|
|
78
|
+
};
|
|
79
|
+
}();
|
|
80
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
className: "print-button-wrapper no-print " + className
|
|
82
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
83
|
+
className: "print-btn print-btn-" + type,
|
|
84
|
+
onClick: handlePrint,
|
|
85
|
+
disabled: disabled
|
|
86
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
87
|
+
className: "print-icon",
|
|
88
|
+
viewBox: "0 0 24 24",
|
|
89
|
+
fill: "none",
|
|
90
|
+
stroke: "currentColor",
|
|
91
|
+
strokeWidth: "2"
|
|
92
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
93
|
+
d: "M6 9V2h12v7"
|
|
94
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
95
|
+
d: "M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"
|
|
96
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
97
|
+
d: "M6 14h12v8H6z"
|
|
98
|
+
})), text));
|
|
99
|
+
};
|
|
100
|
+
export default PrintButton;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* index.css */
|
|
2
|
+
.print-button-wrapper {
|
|
3
|
+
display: inline-block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.print-btn {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
gap: 8px;
|
|
11
|
+
padding: 8px 16px;
|
|
12
|
+
border: none;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
font-size: 14px;
|
|
16
|
+
transition: all 0.3s ease;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.print-btn:disabled {
|
|
20
|
+
opacity: 0.6;
|
|
21
|
+
cursor: not-allowed;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.print-icon {
|
|
25
|
+
width: 16px;
|
|
26
|
+
height: 16px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.print-btn-primary {
|
|
30
|
+
background-color: #1890ff;
|
|
31
|
+
color: #fff;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.print-btn-primary:hover:not(:disabled) {
|
|
35
|
+
background-color: #40a9ff;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.print-btn-default {
|
|
39
|
+
background-color: #fff;
|
|
40
|
+
color: #333;
|
|
41
|
+
border: 1px solid #d9d9d9;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.print-btn-default:hover:not(:disabled) {
|
|
45
|
+
border-color: #1890ff;
|
|
46
|
+
color: #1890ff;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.print-btn-text {
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
color: #1890ff;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.print-btn-text:hover:not(:disabled) {
|
|
55
|
+
background-color: rgba(24, 144, 255, 0.1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* 打印时隐藏的元素 */
|
|
59
|
+
@media print {
|
|
60
|
+
.no-print {
|
|
61
|
+
display: none !important;
|
|
62
|
+
}
|
|
63
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -37,5 +37,7 @@ export type { AddressCascaderProps } from './components/address-cascade';
|
|
|
37
37
|
export { default as AddressCascader } from './components/address-cascade';
|
|
38
38
|
export type { PreviewMaterialProps } from './components/preview-material';
|
|
39
39
|
export { default as PreviewMaterial } from './components/preview-material';
|
|
40
|
+
export type { PrintButtonProps } from './components/print';
|
|
41
|
+
export { default as PrintButton } from './components/print';
|
|
40
42
|
declare const bizCssPrefix = "bizpack";
|
|
41
43
|
export { bizCssPrefix };
|
package/es/index.js
CHANGED
|
@@ -24,5 +24,6 @@ export { default as QRCodeImg } from "./components/qr-code";
|
|
|
24
24
|
export { default as AddressSelect } from "./components/address-select";
|
|
25
25
|
export { default as AddressCascader } from "./components/address-cascade";
|
|
26
26
|
export { default as PreviewMaterial } from "./components/preview-material";
|
|
27
|
+
export { default as PrintButton } from "./components/print";
|
|
27
28
|
var bizCssPrefix = 'bizpack';
|
|
28
29
|
export { bizCssPrefix };
|
package/lib/api.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.signurl = exports.signFileDownApi = exports.qrySealApi = exports.previewApi = exports.post = exports.getSignOrderIdApi = exports.getSignFileApi = exports.getSealUrlApi = exports.getPcSealUrlApi = exports.getMaterialPreview = exports.getMaterialLib = exports.getIcons = exports.getGuideImg = exports.get = exports.fileUploadApi = exports.documentDownload = exports.createbycategory = exports.contractSignUrl = exports.contractFinish = exports.checkSignState = void 0;
|
|
5
|
+
exports.signurl = exports.signFileDownApi = exports.qrySealApi = exports.previewApi = exports.post = exports.onlinePreview = exports.getUrlById = exports.getSignOrderIdApi = exports.getSignFileApi = exports.getSealUrlApi = exports.getPcSealUrlApi = exports.getMaterialPreview = exports.getMaterialLib = exports.getIcons = exports.getGuideImg = exports.get = exports.fileUploadApi = exports.documentDownload = exports.createbycategory = exports.contractSignUrl = exports.contractFinish = exports.checkSignState = void 0;
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
8
|
var post = exports.post = /*#__PURE__*/function () {
|
|
@@ -146,6 +146,12 @@ var previewApi = exports.previewApi = function previewApi(params, config) {
|
|
|
146
146
|
var getMaterialLib = exports.getMaterialLib = function getMaterialLib(params, config) {
|
|
147
147
|
return post("https://zwfwpt.sxzwfw.gov.cn/DeclarationAPI/declaration/material/queryFileByCardNo", params, config);
|
|
148
148
|
};
|
|
149
|
+
var getUrlById = exports.getUrlById = function getUrlById(params, config) {
|
|
150
|
+
return get("https://zwfwpt.sxzwfw.gov.cn:10009/DeclarationAPI/declaration/material/file/files/api/presigned-url", params, config);
|
|
151
|
+
};
|
|
152
|
+
var onlinePreview = exports.onlinePreview = function onlinePreview(params, config) {
|
|
153
|
+
return get("https://zwfwpt.sxzwfw.gov.cn:10009/DeclarationAPI/declaration/material/onlinePreview", params, config);
|
|
154
|
+
};
|
|
149
155
|
var getMaterialPreview = exports.getMaterialPreview = function getMaterialPreview(params, config) {
|
|
150
156
|
return get(window.baseUrl + "/declaration/material/onlinePreview", params, config);
|
|
151
157
|
};
|
|
@@ -154,20 +154,53 @@ var FileItem = function FileItem(_ref) {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
// 预览材料
|
|
157
|
-
var preview = function
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
157
|
+
var preview = /*#__PURE__*/function () {
|
|
158
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
159
|
+
return _regenerator["default"].wrap(function (_context) {
|
|
160
|
+
while (1) switch (_context.prev = _context.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
if (fileUrl) {
|
|
163
|
+
_context.next = 1;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return _context.abrupt("return");
|
|
167
|
+
case 1:
|
|
168
|
+
console.log('fileUrl', fileUrl, fileId);
|
|
169
|
+
setPreviewIframeUrl(fileUrl);
|
|
170
|
+
setIsShowPreview(true);
|
|
171
|
+
// if (!fileId) return;
|
|
172
|
+
// const urlRes = await getUrlById({
|
|
173
|
+
// id: fileId,
|
|
174
|
+
// effectiveTime: 3600000
|
|
175
|
+
// })
|
|
176
|
+
// if (urlRes.presignedUrlList && urlRes.presignedUrlList.length > 0) {
|
|
177
|
+
// // fetch(`${baseUrl}/declaration/material/onlinePreview?url=${urlRes.presignedUrlList[2]}`, {
|
|
178
|
+
// // method: 'GET',
|
|
179
|
+
// // headers: {
|
|
180
|
+
// // 'Authorization': tokenTY
|
|
181
|
+
// // }
|
|
182
|
+
// // })
|
|
183
|
+
// // .then(response => response.json())
|
|
184
|
+
// // .then(res => {
|
|
185
|
+
// // setPreviewIframeUrl(res.url)
|
|
186
|
+
// // setIsShowPreview(true)
|
|
187
|
+
// // })
|
|
188
|
+
// const res = await onlinePreview({
|
|
189
|
+
// url: urlRes.presignedUrlList[2],
|
|
190
|
+
// })
|
|
191
|
+
// setPreviewIframeUrl(res.url)
|
|
192
|
+
// setIsShowPreview(true)
|
|
193
|
+
// }
|
|
194
|
+
case 2:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context.stop();
|
|
197
|
+
}
|
|
198
|
+
}, _callee);
|
|
199
|
+
}));
|
|
200
|
+
return function preview() {
|
|
201
|
+
return _ref2.apply(this, arguments);
|
|
202
|
+
};
|
|
203
|
+
}();
|
|
171
204
|
|
|
172
205
|
// 预览材料中的材料
|
|
173
206
|
var previewMaterial = function previewMaterial(id, url) {
|
|
@@ -257,36 +290,36 @@ var FileItem = function FileItem(_ref) {
|
|
|
257
290
|
});
|
|
258
291
|
};
|
|
259
292
|
var showGuide = /*#__PURE__*/function () {
|
|
260
|
-
var
|
|
293
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
261
294
|
var guideImgRes;
|
|
262
|
-
return _regenerator["default"].wrap(function (
|
|
263
|
-
while (1) switch (
|
|
295
|
+
return _regenerator["default"].wrap(function (_context2) {
|
|
296
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
264
297
|
case 0:
|
|
265
298
|
if (guideImg) {
|
|
266
|
-
|
|
299
|
+
_context2.next = 1;
|
|
267
300
|
break;
|
|
268
301
|
}
|
|
269
|
-
return
|
|
302
|
+
return _context2.abrupt("return");
|
|
270
303
|
case 1:
|
|
271
|
-
|
|
304
|
+
_context2.next = 2;
|
|
272
305
|
return (0, _api.getGuideImg)({
|
|
273
306
|
id: guideImg,
|
|
274
307
|
effectiveTime: 3600000
|
|
275
308
|
});
|
|
276
309
|
case 2:
|
|
277
|
-
guideImgRes =
|
|
310
|
+
guideImgRes = _context2.sent;
|
|
278
311
|
if (guideImgRes.presignedUrl) {
|
|
279
312
|
setGuideurl(guideImgRes.presignedUrl);
|
|
280
313
|
setIsShowGuide(true);
|
|
281
314
|
}
|
|
282
315
|
case 3:
|
|
283
316
|
case "end":
|
|
284
|
-
return
|
|
317
|
+
return _context2.stop();
|
|
285
318
|
}
|
|
286
|
-
},
|
|
319
|
+
}, _callee2);
|
|
287
320
|
}));
|
|
288
321
|
return function showGuide() {
|
|
289
|
-
return
|
|
322
|
+
return _ref3.apply(this, arguments);
|
|
290
323
|
};
|
|
291
324
|
}();
|
|
292
325
|
var selectMaterialOk = function selectMaterialOk() {
|
|
@@ -563,9 +596,9 @@ var FileItem = function FileItem(_ref) {
|
|
|
563
596
|
return setIsShowPreview(false);
|
|
564
597
|
}
|
|
565
598
|
}), /*#__PURE__*/_react["default"].createElement("iframe", {
|
|
566
|
-
src: previewIframeUrl,
|
|
599
|
+
src: previewIframeUrl + '#toolbar=0&navpanes=0&scrollbar=0&messages=0&statusbar=0',
|
|
567
600
|
frameborder: "0",
|
|
568
|
-
height: "
|
|
601
|
+
height: "600px",
|
|
569
602
|
width: "100%"
|
|
570
603
|
})), isShowMaterialPreview && /*#__PURE__*/_react["default"].createElement("div", {
|
|
571
604
|
className: "preview"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export interface PrintButtonProps {
|
|
4
|
+
/** 按钮文本 */
|
|
5
|
+
text?: string;
|
|
6
|
+
/** 打印前回调 */
|
|
7
|
+
onBeforePrint?: () => void | Promise<void>;
|
|
8
|
+
/** 打印后回调 */
|
|
9
|
+
onAfterPrint?: () => void;
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** 自定义类名 */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** 按钮类型 */
|
|
15
|
+
type?: 'primary' | 'default' | 'text';
|
|
16
|
+
}
|
|
17
|
+
export declare const PrintButton: React.FC<PrintButtonProps>;
|
|
18
|
+
export default PrintButton;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports["default"] = exports.PrintButton = void 0;
|
|
6
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
require("./index.scss");
|
|
10
|
+
var PrintButton = exports.PrintButton = function PrintButton(_ref) {
|
|
11
|
+
var _ref$text = _ref.text,
|
|
12
|
+
text = _ref$text === void 0 ? '打印' : _ref$text,
|
|
13
|
+
onBeforePrint = _ref.onBeforePrint,
|
|
14
|
+
onAfterPrint = _ref.onAfterPrint,
|
|
15
|
+
_ref$disabled = _ref.disabled,
|
|
16
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
17
|
+
_ref$className = _ref.className,
|
|
18
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
19
|
+
_ref$type = _ref.type,
|
|
20
|
+
type = _ref$type === void 0 ? 'primary' : _ref$type;
|
|
21
|
+
var handlePrint = /*#__PURE__*/function () {
|
|
22
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
23
|
+
var printContent, printWindow, styles, _t;
|
|
24
|
+
return _regenerator["default"].wrap(function (_context) {
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
if (!disabled) {
|
|
28
|
+
_context.next = 1;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return _context.abrupt("return");
|
|
32
|
+
case 1:
|
|
33
|
+
_context.prev = 1;
|
|
34
|
+
_context.next = 2;
|
|
35
|
+
return onBeforePrint === null || onBeforePrint === void 0 ? void 0 : onBeforePrint();
|
|
36
|
+
case 2:
|
|
37
|
+
// 获取打印内容 - 整个页面
|
|
38
|
+
printContent = document.body;
|
|
39
|
+
if (printContent) {
|
|
40
|
+
_context.next = 3;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
console.warn('未找到打印内容');
|
|
44
|
+
return _context.abrupt("return");
|
|
45
|
+
case 3:
|
|
46
|
+
// 创建打印窗口
|
|
47
|
+
printWindow = window.open('', '_blank');
|
|
48
|
+
if (printWindow) {
|
|
49
|
+
_context.next = 4;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
console.warn('无法打开打印窗口');
|
|
53
|
+
return _context.abrupt("return");
|
|
54
|
+
case 4:
|
|
55
|
+
// 复制当前页面样式
|
|
56
|
+
styles = Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).map(function (el) {
|
|
57
|
+
return el.outerHTML;
|
|
58
|
+
}).join('\n'); // 构建打印内容
|
|
59
|
+
printWindow.document.write("\n <!DOCTYPE html>\n <html>\n <head>\n <title>\u6253\u5370</title>\n " + styles + "\n <style>\n @media print {\n body { margin: 0; padding: 20px; }\n .no-print { display: none !important; }\n }\n </style>\n </head>\n <body>\n " + printContent.innerHTML + "\n </body>\n </html>\n ");
|
|
60
|
+
printWindow.document.close();
|
|
61
|
+
printWindow.focus();
|
|
62
|
+
|
|
63
|
+
// 执行打印
|
|
64
|
+
setTimeout(function () {
|
|
65
|
+
printWindow.print();
|
|
66
|
+
printWindow.close();
|
|
67
|
+
onAfterPrint === null || onAfterPrint === void 0 ? void 0 : onAfterPrint();
|
|
68
|
+
}, 250);
|
|
69
|
+
_context.next = 6;
|
|
70
|
+
break;
|
|
71
|
+
case 5:
|
|
72
|
+
_context.prev = 5;
|
|
73
|
+
_t = _context["catch"](1);
|
|
74
|
+
console.error('打印失败:', _t);
|
|
75
|
+
case 6:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context.stop();
|
|
78
|
+
}
|
|
79
|
+
}, _callee, null, [[1, 5]]);
|
|
80
|
+
}));
|
|
81
|
+
return function handlePrint() {
|
|
82
|
+
return _ref2.apply(this, arguments);
|
|
83
|
+
};
|
|
84
|
+
}();
|
|
85
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
86
|
+
className: "print-button-wrapper no-print " + className
|
|
87
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
88
|
+
className: "print-btn print-btn-" + type,
|
|
89
|
+
onClick: handlePrint,
|
|
90
|
+
disabled: disabled
|
|
91
|
+
}, /*#__PURE__*/_react["default"].createElement("svg", {
|
|
92
|
+
className: "print-icon",
|
|
93
|
+
viewBox: "0 0 24 24",
|
|
94
|
+
fill: "none",
|
|
95
|
+
stroke: "currentColor",
|
|
96
|
+
strokeWidth: "2"
|
|
97
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
98
|
+
d: "M6 9V2h12v7"
|
|
99
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
100
|
+
d: "M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"
|
|
101
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
102
|
+
d: "M6 14h12v8H6z"
|
|
103
|
+
})), text));
|
|
104
|
+
};
|
|
105
|
+
var _default = exports["default"] = PrintButton;
|