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

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

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