avatar.abfd8a74.js 3.1 KB

1
  1. import{u as S,r as g,ad as T,g as u,o as h,h as U,m as a,k as i,i as s,w as p,j,l as D,N as C,X as H}from"./vendor.0bc3c1d4.js";import{V as W}from"./vue-cropper.es.ba247806.js";import{u as E}from"./index.d15345ba.js";const L={style:{"min-height":"calc(100vh - 50px)"},class:"bg-black"},O=["src"],q=a("br",null,null,-1),F={class:"flex"},G={class:"flex margin-top"},I=C(" \u9009\u62E9 "),P=a("i",{class:"upload el-icon--right"},null,-1),J=a("div",{class:"margin-left-sm"},null,-1),X=C("\u63D0 \u4EA4 "),Z={setup(K){const c=S(),{proxy:r}=H(),d=g(!1),f=g(!1),_=g("\u4FEE\u6539\u5934\u50CF"),o=T({img:c.getters.avatar,autoCrop:!0,autoCropWidth:200,autoCropHeight:200,fixedBox:!0,previews:{}});function $(){d.value=!0}function z(){f.value=!0}function b(){}function x(){r.$refs.cropper.rotateLeft()}function k(){r.$refs.cropper.rotateRight()}function v(t){t=t||1,r.$refs.cropper.changeScale(t)}function w(t){if(t.type.indexOf("image/")==-1)r.$modal.msgError("\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u4E0A\u4F20\u56FE\u7247\u7C7B\u578B,\u5982\uFF1AJPG\uFF0CPNG\u540E\u7F00\u7684\u6587\u4EF6\u3002");else{const e=new FileReader;e.readAsDataURL(t),e.onload=()=>{o.img=e.result}}}function y(){r.$refs.cropper.getCropBlob(t=>{let e=new FormData;e.append("avatarfile",t),E(e).then(m=>{d.value=!1,o.img="http://121.37.6.200:8889"+m.imgUrl,c.commit("SET_AVATAR",o.img),r.$modal.msgSuccess("\u4FEE\u6539\u6210\u529F"),f.value=!1})})}function V(t){o.previews=t}function B(){o.img=c.getters.avatar,o.visible=!1}return(t,e)=>{const m=u("el-col"),N=u("el-row"),n=u("el-button"),R=u("el-upload"),A=u("el-dialog");return h(),U("div",L,[a("div",{class:"grid col-1 align-center",style:{"min-height":"calc(100vh - 50px)"},onClick:e[0]||(e[0]=l=>$())},[a("img",{src:i(o).img,title:"\u70B9\u51FB\u4E0A\u4F20\u5934\u50CF",style:{width:"100%",height:"50%"}},null,8,O)]),s(A,{title:_.value,modelValue:d.value,"onUpdate:modelValue":e[6]||(e[6]=l=>d.value=l),width:"800px","append-to-body":"",onOpened:z,fullscreen:t.$store.state.app.device=="mobile",onClose:B},{default:p(()=>[s(N,null,{default:p(()=>[s(m,{xs:24,md:12,style:{height:"350px"}},{default:p(()=>[f.value?(h(),j(i(W),{key:0,ref:"cropper",img:i(o).img,info:!0,autoCrop:i(o).autoCrop,autoCropWidth:i(o).autoCropWidth,autoCropHeight:i(o).autoCropHeight,fixedBox:i(o).fixedBox,onRealTime:V},null,8,["img","autoCrop","autoCropWidth","autoCropHeight","fixedBox"])):D("",!0)]),_:1})]),_:1}),q,a("div",F,[s(n,{icon:"plus",size:t.$store.state.app.size,onClick:e[1]||(e[1]=l=>v(1))},null,8,["size"]),s(n,{icon:"minus",size:t.$store.state.app.size,onClick:e[2]||(e[2]=l=>v(-1))},null,8,["size"]),s(n,{icon:"refresh-left",size:t.$store.state.app.size,onClick:e[3]||(e[3]=l=>x())},null,8,["size"]),s(n,{icon:"refresh-right",size:t.$store.state.app.size,onClick:e[4]||(e[4]=l=>k())},null,8,["size"])]),a("div",G,[s(R,{action:"#","http-request":b,"show-file-list":!1,"before-upload":w},{default:p(()=>[s(n,{size:t.$store.state.app.size},{default:p(()=>[I,P]),_:1},8,["size"])]),_:1}),J,s(n,{class:"margin-left-sm",type:"primary",size:t.$store.state.app.size,onClick:e[5]||(e[5]=l=>y())},{default:p(()=>[X]),_:1},8,["size"])])]),_:1},8,["title","modelValue","fullscreen"])])}}};export{Z as default};