import{Button as r,Image as e,Modal as i,message as t}from"antd";import n from"dayjs";import{useState as o,useRef as c,useEffect as a}from"react";import d from"react-signature-canvas";import{base642File as l}from"../../utils/index.js";import{jsxs as h,Fragment as m,jsx as s}from"react/jsx-runtime";function p(p){const{onConfirm:u,width:f=752,height:g=300,url:y="",...C}=p,[b,k]=o(!1),v=c(null),[w,x]=o("");return a(()=>{x(y)},[y]),h(m,{children:[s("div",{children:s(r,{type:"primary",onClick:()=>{k(!0)},children:w?"重新签字":"手写签字"})}),w&&s("div",{style:{border:"1px dashed #d9d9d9",width:"100%",height:g,marginTop:16},children:s(e,{src:w,style:{width:"100%",height:g,objectFit:"contain"}})}),s(i,{title:"签字",width:800,open:b,maskClosable:!1,onCancel:()=>k(!1),footer:[s(r,{onClick:()=>v.current.clear(),children:"重签"},"clear"),s(r,{onClick:()=>{k(!1),v.current.clear()},children:"取消"},"cancel"),s(r,{type:"primary",onClick:()=>{if(v.current.isEmpty())return void t.warning("请签名");const r=v.current.toDataURL();x(r),u({time:n().format("YYYY-MM-DD HH:mm:ss"),base64:r,file:l(r)}),v.current.clear(),k(!1)},children:"确定"},"ok")],children:s("div",{style:{border:"1px dashed #d9d9d9"},children:s(d,{ref:v,penColor:"black",canvasProps:{width:f,height:g},backgroundColor:"rgb(255,255,255)",...C})})})]})}p.displayName="Signature";export{p as default};
