import{W as F}from"./vue-cropper.es.c79321c5.js";import{y as H,z as O}from"./index.ad3efb29.js";import{_ as P}from"./_plugin-vue_export-helper.c27b6911.js";import{i as j,r as m,k as q,Z as A,ai as s,o as h,c as E,U as t,O as l,M as G,u as z,R as J,S as C,n as M,aF as Z,aG as K,a as Q}from"./vue.adf17aba.js";import"./elementPlus.4833989a.js";import"./echarts.72dc8373.js";const X=i=>(Z("data-v-390f61c0"),i=i(),K(),i),Y=X(()=>Q("br",null,null,-1)),ee={__name:"index",props:{modelValue:{type:Boolean,default:!1,required:!0}},emits:["uploadImg"],setup(i,{expose:y,emit:w}){const _=H(),{proxy:d}=j();m(!1);const g=m(!1),I=m("修改头像"),v=w,R=i,f=q({get(){return R.modelValue},set(o){v("update:modelValue",o)}}),a=A({img:_.userInfos.avatar,fileName:"",autoCrop:!0,autoCropWidth:200,autoCropHeight:200,fixedBox:!0,outputType:"png"});function V(){f.value=!0}function b(){M(()=>{g.value=!0})}function k(){}function B(){d.$refs.cropper.rotateLeft()}function T(){d.$refs.cropper.rotateRight()}function N(o){if(o.type.indexOf("image/")==-1)d.$modal.msgError("文件格式错误，请上传图片类型,如：JPG，PNG后缀的文件。");else{const e=new FileReader;e.readAsDataURL(o),e.onload=()=>{a.img=e.result,a.fileName=o.name}}}function $(){d.$refs.cropper.getCropData(o=>{let e=new Image;e.src=o,e.onload=async()=>{let r=U(e);const n=O(r,a.fileName);v("uploadImg",n)}})}function U(o){let e=document.createElement("canvas"),r=e.getContext("2d"),n=o.width,u=o.height;return e.width=n,e.height=u,r.fillStyle="#fff",r.fillRect(0,0,e.width,e.height),r.drawImage(o,0,0,n,u),e.toDataURL("image/jpeg",.8)}function S(){a.visible=!1,a.img=_.userInfos.avatar}return y({updateAvatar:o=>{a.img=o}}),(o,e)=>{const r=s("el-avatar"),n=s("el-col"),u=s("el-row"),x=s("Plus"),L=s("el-icon"),c=s("el-button"),W=s("el-upload"),D=s("el-dialog");return h(),E("div",{class:"user-info-head",onClick:e[4]||(e[4]=p=>V())},[t(r,{size:100,src:a.img},null,8,["src"]),t(D,{title:I.value,modelValue:f.value,"onUpdate:modelValue":e[3]||(e[3]=p=>f.value=p),width:"600px","append-to-body":"",onOpened:b,onClose:S},{default:l(()=>[t(u,null,{default:l(()=>[t(n,{class:"flex justify-center"},{default:l(()=>[g.value?(h(),G(z(F),{key:0,ref:"cropper",img:a.img,info:!0,autoCrop:a.autoCrop,autoCropWidth:a.autoCropWidth,autoCropHeight:a.autoCropHeight,fixedBox:a.fixedBox,outputType:a.outputType,onRealTime:o.realTime,centerBox:!0,class:"cropper"},null,8,["img","autoCrop","autoCropWidth","autoCropHeight","fixedBox","outputType","onRealTime"])):J("",!0)]),_:1})]),_:1}),Y,t(u,{class:"flex justify-center"},{default:l(()=>[t(n,{lg:2,md:2},{default:l(()=>[t(W,{action:"#","http-request":k,"show-file-list":!1,"before-upload":N},{default:l(()=>[t(c,{type:"success"},{default:l(()=>[C(" 选择 "),t(L,{class:"el-icon--right"},{default:l(()=>[t(x)]),_:1})]),_:1})]),_:1})]),_:1}),t(n,{lg:{span:1,offset:2},md:2},{default:l(()=>[t(c,{icon:"RefreshLeft",onClick:e[0]||(e[0]=p=>B())})]),_:1}),t(n,{lg:{span:1,offset:2},md:2},{default:l(()=>[t(c,{icon:"RefreshRight",onClick:e[1]||(e[1]=p=>T())})]),_:1}),t(n,{lg:{span:2,offset:2},md:2},{default:l(()=>[t(c,{type:"primary",onClick:e[2]||(e[2]=p=>$())},{default:l(()=>[C("更新头像")]),_:1})]),_:1})]),_:1})]),_:1},8,["title","modelValue"])])}}},ie=P(ee,[["__scopeId","data-v-390f61c0"]]);export{ie as default};
