Commit 6837a8d3 authored by 田翔's avatar 田翔

fix: 手写签名与富文本修复

parent 5fca5b48
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.0.0", "version": "5.0.1",
"description": "5.0.0 初始调用隐藏规则", "description": "5.0.1 手写签名与富文本修复",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -12,43 +12,51 @@ const Signature = (props) => { ...@@ -12,43 +12,51 @@ const Signature = (props) => {
const canvasRef = useRef(null) const canvasRef = useRef(null)
const open = () => { const open = () => {
if (addons && !disabled) { if (addons) {
setVisible(true) setVisible(true)
} }
} }
const onOk = async () => { const onOk = async () => {
if (addons) { if (disabled) {
const dataUrl = canvasRef.current.toDataURL(); // 获取 Base64 编码的字符串 setVisible(false)
const byteString = atob(dataUrl.split(',')[1]); // 将 Base64 编码的字符串转换为字节数组 } else {
const mimeString = dataUrl.split(',')[0].split(':')[1].split(';')[0]; // 获取 MIME 类型 if (addons) {
const ab = new ArrayBuffer(byteString.length); const dataUrl = canvasRef.current.toDataURL(); // 获取 Base64 编码的字符串
const ia = new Uint8Array(ab); const byteString = atob(dataUrl.split(',')[1]); // 将 Base64 编码的字符串转换为字节数组
for (let i = 0; i < byteString.length; i++) { const mimeString = dataUrl.split(',')[0].split(':')[1].split(';')[0]; // 获取 MIME 类型
ia[i] = byteString.charCodeAt(i); const ab = new ArrayBuffer(byteString.length);
} const ia = new Uint8Array(ab);
const file = new Blob([ab], { type: mimeString }); // 将字节数组转换为文件流 for (let i = 0; i < byteString.length; i++) {
const formData = new FormData(); // 创建表单数据对象 ia[i] = byteString.charCodeAt(i);
formData.append('file', file, 'signature.png'); // 添加文件流到表 }
const { code, data } = await UploadFileReturnUrl(formData) const file = new Blob([ab], { type: mimeString }); // 将字节数组转换为文件流
if (code === 0) { const formData = new FormData(); // 创建表单数据对象
onChange(data) formData.append('file', file, 'signature.png'); // 添加文件流到表
setVisible(false) const { code, data } = await UploadFileReturnUrl(formData)
} else { if (code === 0) {
message.error('生成图片失败!') onChange(data)
setVisible(false)
} else {
message.error('生成图片失败!')
}
} }
} }
} }
useEffect(() => { useEffect(() => {
addons?.setValue(addons?.dataPath, presetValue || '') addons?.setValue(addons?.dataPath, presetValue || '9fa1dce1-2441-468d-b2d9-6129a6bd690f\\signature.png')
}, [presetValue]) }, [presetValue])
return ( return (
<div className={styles.signature}> <div className={styles.signature}>
<div className={styles.content} onClick={open}> <div className={styles.content}>
{ {
value ? <img src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${value}`}></img> : <div className={styles.text}>点击签名</div> value ? (
<img onClick={open} src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${value}`}></img>
) : (
disabled ? null : <div onClick={open} className={styles.text}>点击签名</div>
)
} }
</div> </div>
<Drag <Drag
...@@ -58,12 +66,18 @@ const Signature = (props) => { ...@@ -58,12 +66,18 @@ const Signature = (props) => {
onCancel={() => setVisible(false)} onCancel={() => setVisible(false)}
destroyOnClose destroyOnClose
> >
<div style={{ background: '#aaa', borderRadius: '5px' }}> {
<ReactSignatureCanvas disabled ? (
ref={canvasRef} <img src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${value}`}></img>
canvasProps={{ width: 500, height: 300 }} ) : (
/> <div style={{ background: '#aaa', borderRadius: '5px' }}>
</div> <ReactSignatureCanvas
ref={canvasRef}
canvasProps={{ width: 500, height: 300 }}
/>
</div>
)
}
</Drag> </Drag>
</div> </div>
) )
......
...@@ -44,14 +44,14 @@ const RichTextDefault = (props, ref) => { ...@@ -44,14 +44,14 @@ const RichTextDefault = (props, ref) => {
return ( return (
<div className={styles.richTextDefault}> <div className={styles.richTextDefault}>
<Input style={{ color: 'blue' }} value={value ? '点击查看详情' : ''} onFocus={iconClick} /> <Input style={{ color: 'blue' }} value={value ? '点击查看详情' : ''} onClick={iconClick} />
<Drag <Drag
width='60%' width='60%'
title={`${title}默认值`} title={`${title}默认值`}
onCancel={() => setVisible(false)} onCancel={() => setVisible(false)}
visible={visible} visible={visible}
onOk={onOk} onOk={onOk}
destroyOnClose getContainer={document.body}
> >
<div className={styles.richText}> <div className={styles.richText}>
<Toolbar <Toolbar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment