userInfoModal-97b9ea76.js 17 KB

1
  1. var Le=Object.defineProperty;var me=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var we=(v,_,s)=>_ in v?Le(v,_,{enumerable:!0,configurable:!0,writable:!0,value:s}):v[_]=s,pe=(v,_)=>{for(var s in _||(_={}))$e.call(_,s)&&we(v,s,_[s]);if(me)for(var s of me(_))Ue.call(_,s)&&we(v,s,_[s]);return v};var L=(v,_,s)=>new Promise((t,w)=>{var P=d=>{try{x(s.next(d))}catch(o){w(o)}},M=d=>{try{x(s.throw(d))}catch(o){w(o)}},x=d=>d.done?t(d.value):Promise.resolve(d.value).then(P,M);x((s=s.apply(v,_)).next())});import{d as le,r as m,Z as ae,e as ye,a3 as _e,aa as Fe,al as Ne,bH as je,J as Ae,o as J,m as ne,t as Je,ab as be,j as se,dh as Se,bz as ke,q as Be,y as R,g as O,v as Z,af as T,z as oe,k as ee,w as te,f as E,dq as Ge,I as Ve,bg as qe,bh as Ze}from"./index-610a1d46.js";import{B as xe,b as Ie,u as Ke}from"./index-985aa6f5.js";import{u as Qe,B as et}from"./useForm-c19ef35c.js";import{f as tt}from"./download-a90dd227.js";import{a as at,b as nt}from"./userAccountApi-7c30473f.js";import"./useWindowSizeFn-1829b247.js";import"./index-b6d11df2.js";import"./index-72381a11.js";import"./index-4ed0dc84.js";import"./uuid-98bbe2a6.js";import"./XTUpload.vue_vue_type_style_index_0_scoped_61a00cd1_lang-bad913d6.js";import"./index-981858ed.js";import"./uniqBy-2b2a500d.js";const ot=le({__name:"vueSignature",props:{width:{default:0},height:{default:0},lineWidth:{default:4},lineColor:{default:"#000000"},canvasBack:{default:""},isCrop:{type:Boolean,default:!1},edg:{default:0},fullScreen:{type:Boolean,default:!1},domId:{default:""},imgBack:{default:""},isRepeat:{default:""},noRotation:{type:Boolean,default:!1},imgType:{default:"image/png"},backIsCenter:{type:Boolean,default:!1},acrossDeductWidth:{default:0},acrossDeductHeight:{default:0},verticalDeductWidth:{default:0},verticalDeductHeight:{default:0},recoverPoints:{default:()=>[]}},emits:["onDrawingStatus","onMouseDown","onMouseMove","onMouseUp","onTouchStart","onTouchMove","onTouchEnd"],setup(v,{expose:_,emit:s}){const t=v,w=m(!1),P=m(!1),M=m(!0),x=m(""),d=m([]);let o=m(null),p=m(null),I=m(null),b=m(null);const $=m(0),U=m(0),W=m(1),j=m(!1),A=m(!1);let k=m(null),C=m(null),f=ae({width:0,height:0}),B=ae({width:0,height:0});const Ce=ye(()=>(B.height?B.height:t.fullScreen?f.height:t.height)/(B.width?B.width:t.fullScreen?f.width:t.width)),ce=ye(()=>t.canvasBack?t.canvasBack:"rgba(255, 255, 255, 0)");_e(ce,e=>L(this,null,function*(){yield be(),p.value&&(p.value.style.background=e)})),_e(w,e=>{s("onDrawingStatus",e)});const ue=()=>!t.fullScreen&&t.backIsCenter,Me=e=>{var i,c,l;const a=p.value;let n=(i=o.value)==null?void 0:i.createPattern(C.value,t.isRepeat||"no-repeat");(c=o.value)==null||c.rect(0,0,a.width,a.height),o.value.fillStyle=n,(l=o.value)==null||l.fill(),e&&q(null,null)},K=e=>{const a=p.value;t.canvasBack&&C.value&&X(t.canvasBack)?Me(e):a.style.background=ce.value},re=()=>{const e=p.value;if(t.domId){let a=document.getElementById(t.domId),n=a?a.clientWidth||a.offsetWidth:t.fullScreen?f.width:t.width,i=a?a.clientHeight||a.offsetHeight:t.fullScreen?f.height:t.height;e.height=i,e.width=n,B.width=n,B.height=i}else e.height=t.fullScreen?f.height:t.height,e.width=t.fullScreen?f.width:t.width},V=e=>{var i,c;if(P.value)return!1;const a=p.value;a.style.width=(B.width?B.width:t.fullScreen?f.width:t.width)+"px";const n=parseFloat(window.getComputedStyle(a).width);if(a.style.height=Ce.value*n+"px",o.value=a.getContext("2d"),(i=o.value)==null||i.scale(1*W.value,1*W.value),W.value=n/(B.width?B.width:t.fullScreen?f.width:t.width),(c=o.value)==null||c.scale(1/W.value,1/W.value),t.canvasBack){let l=setInterval(()=>{(C.value&&A.value||!X(t.canvasBack))&&(K(e),clearInterval(l))},100)}else e&&q(null,null)},de=()=>{let e=window.orientation==0||window.orientation==180?t.verticalDeductWidth:t.acrossDeductWidth,a=window.orientation==0||window.orientation==180?t.verticalDeductHeight:t.acrossDeductHeight;f.width=window.navigator.platform.indexOf("Win")||window.navigator.platform.indexOf("Mac")?(document.body.clientHeight||document.body.offsetHeight)-e:(document.body.clientWidth||document.body.offsetWidth)-e,f.height=window.navigator.platform.indexOf("Win")||window.navigator.platform.indexOf("Mac")?(document.body.clientWidth||document.body.offsetWidth)-a:(document.body.clientHeight||document.body.offsetHeight)-a,ve(),P.value=!0,M.value=!1;let n=setInterval(()=>L(this,null,function*(){A.value&&(clearInterval(n),M.value=!0,P.value=!1,yield be(),re(),V(!0))}),100)},X=e=>{let a=[".jpeg",".bmp",".jpg",".gif",".webp",".pcx",".tif",".tga",".exif",".fpx",".svg",".cdr",".pcd",".dxf",".ufo",".eps",".ai",".png",".hdri",".raw",".wmf",".flic",".emf",".ico",".avif",".apng"],n=/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;return e.includes("http://")||e.includes("https://")||n.test(e)||a.some(c=>e.includes(c))},Q=(e,a,n="not")=>new Promise((i,c)=>{let l=document.createElement("canvas"),h=l.getContext("2d"),u,S,r;if(a%90!=0)throw c("旋转角度必须是90的倍数!"),"旋转角度必须是90的倍数!";a<0&&(a=a%360+360);const z=a/90%4,g={sx:0,sy:0,ex:0,ey:0};let D=new Image;D.crossOrigin="anonymous",D.src=e,D.onload=function(){u=D.width,S=D.height,r=u>S?u:S,l.width=r*2,l.height=r*2;let F=B.width?B.width:t.fullScreen?f.width:t.width,y=ue()&&n=="init";switch(z){case 0:g.sx=ue()&&n=="init"&&u>f.width?r-(u-(Y()=="across"?f.width:f.height))/2:r,g.sy=r,g.ex=r+u,g.ey=r+S;break;case 1:g.sx=y?r-t.height:window.orientation==0||window.orientation==180?r-F:r-S,g.sy=r,g.ex=r,g.ey=r+u;break;case 2:g.sx=r-u,g.sy=r-S,g.ex=r,g.ey=r;break;case 3:g.sx=r,g.sy=r-u,g.ex=r+S,g.ey=r+u;break}h.translate(r,r),h.rotate(a*Math.PI/180),h.drawImage(D,0,0);var H=h.getImageData(g.sx,g.sy,g.ex,g.ey);z%2==0?(l.width=u,l.height=S):(l.width=S,l.height=u),h.putImageData(H,0,0),i(l.toDataURL(t.imgType))}}),ve=()=>L(this,null,function*(){A.value=!1;let e=window.orientation==0||window.orientation==180?90:0,a=t.fullScreen?e:0;if(X(t.imgBack)){let n=yield Q(t.imgBack,a,"init");n&&(k.value=new Image,k.value.crossOrigin="anonymous",k.value.src=n)}if(X(t.canvasBack)){let n=yield Q(t.canvasBack,a,"init");n&&(C.value=new Image,C.value.crossOrigin="anonymous",C.value.src=n,C.value.onload=()=>{A.value=!0})}});Fe(()=>{let e=window.orientation==0||window.orientation==180?t.verticalDeductWidth:t.acrossDeductWidth,a=window.orientation==0||window.orientation==180?t.verticalDeductHeight:t.acrossDeductHeight;f.width=(document.body.clientWidth||document.body.offsetWidth)-e,f.height=(document.body.clientHeight||document.body.offsetHeight)-a,ve(),re(),window.addEventListener("orientationchange",de),V(!!(t.recoverPoints&&t.recoverPoints.length)),document.onmouseup=()=>{j.value=!1}});const Y=()=>window.orientation==90||window.orientation==-90?"across":"vertical",De=e=>{e=e||event,e.preventDefault(),j.value=!0,w.value=!0;let a={x:e.offsetX,y:e.offsetY,direction:Y()};he(a),s("onMouseDown",e)},Re=e=>{if(e=e||event,e.preventDefault(),j.value){let a={x:e.offsetX,y:e.offsetY,direction:Y()};ge(a)}s("onMouseMove",e)},Te=e=>{e=e||event,e.preventDefault();let a={x:e.offsetX,y:e.offsetY,direction:Y()};fe(a),j.value=!1,s("onMouseUp",e)},Pe=e=>{if(e=e||event,e.preventDefault(),w.value=!0,e.touches.length===1){let a=p.value,n={x:e.targetTouches[0].clientX-a.getBoundingClientRect().left,y:e.targetTouches[0].clientY-a.getBoundingClientRect().top,direction:Y()};he(n)}s("onTouchStart",e)},We=e=>{if(e=e||event,e.preventDefault(),e.touches.length===1){let a=p.value,n={x:e.targetTouches[0].clientX-a.getBoundingClientRect().left,y:e.targetTouches[0].clientY-a.getBoundingClientRect().top,direction:Y()};ge(n)}s("onTouchMove",e)},He=e=>{if(e=e||event,e.preventDefault(),e.touches.length===1){let a=p.value,n={x:e.targetTouches[0].clientX-a.getBoundingClientRect().left,y:e.targetTouches[0].clientY-a.getBoundingClientRect().top,direction:Y()};fe(n)}else d.value.push({x:-1,y:-1,direction:Y()});s("onTouchEnd",e)},he=e=>{var a,n,i,c,l;$.value=e.x,U.value=e.y,(a=o.value)==null||a.beginPath(),(n=o.value)==null||n.moveTo($.value,U.value),(i=o.value)==null||i.lineTo(e.x,e.y),o.value.lineCap="round",o.value.lineJoin="round",o.value.lineWidth=t.lineWidth*W.value,(c=o.value)==null||c.stroke(),(l=o.value)==null||l.closePath(),d.value.push(e)},ge=e=>{var a,n,i,c,l;(a=o.value)==null||a.beginPath(),(n=o.value)==null||n.moveTo($.value,U.value),(i=o.value)==null||i.lineTo(e.x,e.y),o.value.strokeStyle=t.lineColor,o.value.lineWidth=t.lineWidth*W.value,o.value.lineCap="round",o.value.lineJoin="round",(c=o.value)==null||c.stroke(),(l=o.value)==null||l.closePath(),U.value=e.y,$.value=e.x,d.value.push(e)},fe=e=>{var a,n,i,c,l;(a=o.value)==null||a.beginPath(),(n=o.value)==null||n.moveTo($.value,U.value),(i=o.value)==null||i.lineTo(e.x,e.y),o.value.lineCap="round",o.value.lineJoin="round",(c=o.value)==null||c.stroke(),(l=o.value)==null||l.closePath(),d.value.push(e),d.value.push({x:-1,y:-1})},q=(e,a)=>{if(d.value&&d.value.length||t.recoverPoints&&t.recoverPoints.length){let n=e||p.value,i=a||o.value,c=t.recoverPoints&&t.recoverPoints.length?t.recoverPoints:d.value;c&&c.length&&(w.value=!0),c.reduce((l,h)=>{if(h.x!=-1&&h.y!=-1&&l.x!=-1&&l.y!=-1){i==null||i.beginPath();let u={accX:l.x,accY:l.y,curX:h.x,curY:h.y};t.fullScreen&&((window.orientation==0||window.orientation==180)&&l.direction=="across"&&h.direction=="across"?u={accX:n.width-l.y,accY:l.x,curX:n.width-h.y,curY:h.x}:(window.orientation==90||window.orientation==-90)&&l.direction=="vertical"&&h.direction=="vertical"&&(u={accX:l.y,accY:n.height-l.x,curX:h.y,curY:n.height-h.x})),i.moveTo(u.accX,u.accY),i.lineTo(u.curX,u.curY),i.strokeStyle=t.lineColor,i.lineWidth=t.lineWidth*W.value,i.lineCap="round",i.lineJoin="round",i.stroke(),i.closePath()}return h})}},Ee=()=>new Promise((e,a)=>{var h,u,S,r,z,g,D,F;if(!w.value){a("Warning: Not Signned!");return}let n=p.value,i=o.value.getImageData(0,0,n.width,n.height);if(o.value.globalCompositeOperation="destination-over",t.canvasBack&&t.imgBack&&((h=o.value)==null||h.clearRect(0,0,n.width,n.height),q(null,null)),t.imgBack&&X(t.imgBack)){let y=(u=o.value)==null?void 0:u.createPattern(k.value,t.isRepeat||"no-repeat");(S=o.value)==null||S.rect(0,0,n.width,n.height),o.value.fillStyle=y,(r=o.value)==null||r.fill()}else t.imgBack&&!X(t.imgBack)&&(o.value.fillStyle=t.imgBack,(z=o.value)==null||z.fillRect(0,0,n.width,n.height));x.value=n.toDataURL();let c=x.value;if((g=o.value)==null||g.clearRect(0,0,n.width,n.height),(D=o.value)==null||D.putImageData(i,0,0),o.value.globalCompositeOperation="source-over",t.isCrop){const y=Xe(i.data);let H=document.createElement("canvas");const N=H.getContext("2d");H.width=y[2]-y[0],H.height=y[3]-y[1];const ze=(F=b.value||o.value)==null?void 0:F.getImageData(...y);N.globalCompositeOperation="destination-over",N==null||N.putImageData(ze,0,0),c=H.toDataURL(),H=null}let l=t.fullScreen&&(window.orientation==0||window.orientation==180||(window.orientation==90||window.orientation==-90)&&!t.noRotation)||window.orientation===void 0&&t.noRotation?t.edg:0;Q(c,l).then(y=>{e({base64:y,points:d.value})})}),Oe=()=>{var a;let e=p.value;(a=o.value)==null||a.clearRect(0,0,e.width,e.height),d.value=[],w.value=!1,x.value="",K(!1)},Xe=e=>{var z,g,D,F;if(t.imgBack){if(I.value=document.createElement("canvas"),t.domId){let y=document.getElementById(t.domId),H=y?y.clientWidth||y.offsetWidth:t.fullScreen?f.width:t.width,N=y?y.clientHeight||y.offsetHeight:t.fullScreen?f.height:t.height;I.value.height=N,I.value.width=H,B.width=H,B.height=N}else I.value.height=t.fullScreen?f.height:t.height,I.value.width=t.fullScreen?f.width:t.width;if(b.value=I.value.getContext("2d"),X(t.imgBack)){let y=(z=b.value)==null?void 0:z.createPattern(k.value,t.isRepeat||"no-repeat");(g=b.value)==null||g.rect(0,0,I.value.width,I.value.height),b.value.fillStyle=y,(D=b.value)==null||D.fill()}else X(t.imgBack)||(b.value.fillStyle=t.imgBack,(F=b.value)==null||F.fillRect(0,0,I.value.width,I.value.height));q(I.value,b.value)}let a=I.value||p.value,n=a.width;for(var i=0,c=a.height,l=0,h=0;h<a.width;h++)for(var u=0;u<a.height;u++){var S=(h+a.width*u)*4;(e[S]>0||e[S+1]>0||e[S+2]||e[S+3]>0)&&(l=Math.max(u,l),i=Math.max(h,i),c=Math.min(u,c),n=Math.min(h,n))}return n++,i++,c++,l++,[n,c,i,l]},Ye=e=>{var n;let a=p.value;(n=o.value)==null||n.clearRect(0,0,a.width,a.height),d.value=e,w.value=!0,x.value="",K(!0)};return Ne(()=>{if(t.fullScreen){let e=document.getElementsByTagName("body");e[0].style="height: 100vh"}window.addEventListener("resize",V)}),je(()=>{if(t.fullScreen){let e=document.getElementsByTagName("body");e[0].style=""}window.removeEventListener("resize",V),window.removeEventListener("orientationchange",de)}),_({confirm:Ae(Ee),reset:Oe,recoverDraw:Ye}),(e,a)=>M.value?(J(),ne("canvas",{key:0,ref_key:"canvasRef",ref:p,onMousedown:De,onMousemove:Re,onMouseup:Te,onTouchstart:Pe,onTouchmove:We,onTouchend:He},null,544)):Je("",!0)}});const ie=se(ot,[["__scopeId","data-v-d088b4ff"]]);ie.install=v=>{v.component("vue3OnlineSignature",ie)};const it=le({name:"SignatureModal",components:{vueSignature:ie,BasicModal:xe,Button:Se},emits:["signatureSuccess"],setup(v,{emit:_}){const s=m(""),{createMessage:t}=ke(),w=ae({width:150,height:50,lineWidth:8,lineColor:"#000000",canvasBack:"",isCrop:!1,edg:0,fullScreen:!0,domId:"",imgBack:"",isRepeat:"",noRotation:!1,backIsCenter:!1,recoverPoints:[]}),[P,{setModalProps:M,closeModal:x}]=Ie(b=>L(this,null,function*(){M({confirmLoading:!1})})),d=m(null);return{vueSignatureRef:d,imageSRC:s,params:w,handleCacel:()=>{x()},handleGenerate:()=>{d.value.confirm().then(b=>{s.value=b.base64,_("signatureSuccess",s.value),t.success("生成签名成功"),x()}).catch(b=>{t.error("请在黑框区域内签名后生成签名!")})},handleReset:()=>{d.value.reset()},registerModal:P}}}),lt={class:"!pl-8 !pt-4"},st={style:{border:"solid 1px red"}};function ct(v,_,s,t,w,P){const M=ee("Button"),x=ee("vueSignature"),d=ee("BasicModal");return J(),Be(d,oe(v.$attrs,{destroyOnClose:"",onRegister:v.registerModal,title:"电子签名",width:"30%",showFooter:!0}),{footer:R(()=>[O(M,{type:"default",onClick:v.handleCacel},{default:R(()=>[Z("取消")]),_:1},8,["onClick"]),O(M,{type:"error",onClick:v.handleReset},{default:R(()=>[Z("清空画板")]),_:1},8,["onClick"]),O(M,{type:"primary",onClick:v.handleGenerate},{default:R(()=>[Z("生成签名")]),_:1},8,["onClick"])]),default:R(()=>[T("div",lt,[T("div",st,[O(x,oe({ref:"vueSignatureRef"},v.params),null,16)])])]),_:1},16,["onRegister"])}const ut=se(it,[["render",ct]]),rt=[{label:"姓名",field:"nickname",component:"PlainSlot",slot:"nickname"},{label:"角色",field:"rolename",component:"PlainSlot",slot:"rolename"},{label:"联系电话",field:"phones",component:"PlainSlot",slot:"phones"},{label:"中文签名",field:"signature",component:"PlainSlot",slot:"signature",colProps:{span:24}}],G=v=>(qe("data-v-a8c03c9b"),v=v(),Ze(),v),dt={class:"!pl-8 !pt-4"},vt=G(()=>T("div",{class:"name-label"},"姓名:",-1)),ht={class:"name-content"},gt=G(()=>T("div",{class:"name-label"},"角色:",-1)),ft={class:"name-content"},mt=G(()=>T("div",{class:"name-label"},"联系电话:",-1)),wt={class:"name-content"},pt=G(()=>T("div",{class:"name-label"},"电子签名:",-1)),yt={class:"signatureStyle"},_t=["src"],bt={key:1,class:"img-signature"},St=G(()=>T("div",{class:"ant-upload-text"},"上传签名",-1)),kt=le({__name:"userInfoModal",setup(v){const _=m("个人信息"),s="45%",{createMessage:t}=ke(),w=m(),P=m({}),[M,{openModal:x}]=Ke(),[d,{resetFields:o}]=Qe({labelWidth:100,schemas:rt,showActionButtonGroup:!1,actionColOptions:{span:23},baseColProps:{span:12},wrapperCol:{span:12}}),p=m({}),[I,{setModalProps:b,closeModal:$}]=Ie(k=>L(this,null,function*(){yield o(),b({confirmLoading:!1});const C=yield nt();P.value=C.basicInfo;let f="";C.basicInfo.roles.forEach(B=>{f=B.name+","}),C.basicInfo.roleStr=f.substring(0,f.length-1),p.value=C.basicInfo,w.value=C.basicInfo.signature?C.basicInfo.signature:void 0}));function U(){return L(this,null,function*(){try{const k=P.value;k.signature=w.value?w.value:void 0,b({confirmLoading:!0}),yield at(pe({},k)),t.success("个人信息更新成功!"),$()}finally{b({confirmLoading:!1})}})}function W(){x(!0)}function j(k){w.value=k}function A(k){return L(this,null,function*(){return k.size>1024*1024*2?(t.error("请上传小于2M大小的签名照"),!1):(w.value=yield tt(k),!1)})}return(k,C)=>(J(),Be(E(xe),oe(k.$attrs,{destroyOnClose:"",onRegister:E(I),title:_.value,width:s,onOk:U,showFooter:!0}),{default:R(()=>[T("div",dt,[O(E(et),{onRegister:E(d),layout:"vertical"},{nickname:R(()=>[vt,T("div",ht,te(p.value.nickname),1)]),rolename:R(()=>[gt,T("div",ft,te(p.value.roleStr),1)]),phones:R(()=>[mt,T("div",wt,te(p.value.phone),1)]),signature:R(()=>[pt,T("div",yt,[O(E(Ge),{name:"file",showUploadList:!1,beforeUpload:A,maxSize:"",accept:".jpg,.jpeg,.gif,.png,.webp"},{default:R(()=>[w.value?(J(),ne("img",{key:0,alt:"签名",src:w.value,class:"img-signature"},null,8,_t)):(J(),ne("div",bt,[O(E(Ve),{icon:"icon-xt-add_default|iconfont"}),St]))]),_:1}),O(E(Se),{type:"primary",onClick:W},{default:R(()=>[Z("点击签名")]),_:1})])]),_:1},8,["onRegister"])]),O(E(ut),{onRegister:E(M),onSignatureSuccess:j},null,8,["onRegister"])]),_:1},16,["onRegister","title"]))}});const Yt=se(kt,[["__scopeId","data-v-a8c03c9b"]]);export{Yt as default};