zy-react-library 1.0.98 → 1.0.100
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.
|
@@ -3,8 +3,10 @@ import type { FC } from "react";
|
|
|
3
3
|
export interface SignatureValue {
|
|
4
4
|
/** 签字时间,YYYY-MM-DD HH:mm:ss */
|
|
5
5
|
time: string;
|
|
6
|
-
/** 签字图片的base64编码 */
|
|
6
|
+
/** 签字图片的 base64 编码 */
|
|
7
7
|
base64: string;
|
|
8
|
+
/** 签字图片的 file 对象 */
|
|
9
|
+
file: File;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export interface SignatureProps {
|
|
@@ -14,6 +16,8 @@ export interface SignatureProps {
|
|
|
14
16
|
width?: number;
|
|
15
17
|
/** 签字区域高度,默认为 300 */
|
|
16
18
|
height?: number;
|
|
19
|
+
/** 回显的签字图片 */
|
|
20
|
+
url?: string;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Button, Image, message, Modal } from "antd";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import { useRef, useState } from "react";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import SignatureCanvas from "react-signature-canvas";
|
|
5
5
|
import { base642File } from "../../utils";
|
|
6
6
|
|
|
@@ -12,12 +12,16 @@ function Signature(props) {
|
|
|
12
12
|
onConfirm,
|
|
13
13
|
width = 752,
|
|
14
14
|
height = 300,
|
|
15
|
+
url = "",
|
|
15
16
|
...restProps
|
|
16
17
|
} = props;
|
|
17
18
|
|
|
18
19
|
const [signatureModalOpen, setSignatureModalOpen] = useState(false);
|
|
19
20
|
const signatureCanvas = useRef(null);
|
|
20
21
|
const [base64, setBase64] = useState("");
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setBase64(url);
|
|
24
|
+
}, [url]);
|
|
21
25
|
|
|
22
26
|
const onOk = () => {
|
|
23
27
|
if (signatureCanvas.current.isEmpty()) {
|
|
@@ -49,7 +53,7 @@ function Signature(props) {
|
|
|
49
53
|
</div>
|
|
50
54
|
{base64 && (
|
|
51
55
|
<div style={{ border: "1px dashed #d9d9d9", width, height, marginTop: 16 }}>
|
|
52
|
-
<Image src={base64} />
|
|
56
|
+
<Image src={base64} style={{ width, height, objectFit: "contain" }} />
|
|
53
57
|
</div>
|
|
54
58
|
)}
|
|
55
59
|
<Modal
|