CropperImg.9751bcfa.js 2.0 KB

1
  1. import{W as g}from"./vue-cropper.es.c79321c5.js";import{e as l}from"./emitter.233282e9.js";import{_ as C}from"./lodash.d9f7faa7.js";import{r as i,A as x,ai as _,o as B,c as w,a as u,J as W,U as d,u as h,O as y,S as M,F as H}from"./vue.adf17aba.js";import"./index.34b03be2.js";import"./elementPlus.4833989a.js";import"./echarts.72dc8373.js";const S={style:{"padding-top":"8px"}},z=["src"],I={__name:"CropperImg",setup(k){const s=i(),r=i({width:100,height:100}),e=i({img:"",size:1,info:!1,autoCrop:!0,autoCropWidth:600,autoCropHeight:100,canScale:!1,full:!1,fixedBox:!0,centerBox:!0,canMove:!1,enlarge:1,mode:"contain",original:!1,outputType:"png"}),p=i();let t;l.on("img-src",o=>{e.value.img=o}),l.on("img-data",o=>{e.value.autoCropWidth=1200,e.value.autoCropHeight=628,t=Math.min(p.value.offsetWidth/o.width,1);const n=o.width*t,a=o.height*t;r.value.width=n,r.value.height=a,e.value.autoCropWidth=e.value.autoCropWidth*t,e.value.autoCropHeight=e.value.autoCropHeight*t});const c=i("");function m(o){const n=parseInt((o.axis.x1/t).toFixed(0)),a=parseInt((o.axis.y1/t).toFixed(0));l.emit("send-img-leftTop",{left:n,top:a,width:1200,height:628}),s.value.getCropData(f=>{c.value=f})}const v=C.debounce(m,100);return x(()=>{l.all.clear()}),(o,n)=>{const a=_("el-text");return B(),w(H,null,[u("div",{ref_key:"outContianer",ref:p,style:{width:"100%"}},[u("div",{style:W({width:r.value.width+"px",height:r.value.height+"px"})},[d(h(g),{ref_key:"cropper",ref:s,img:e.value.img,canScale:e.value.canScale,full:e.value.full,outputSize:e.value.size,centerBox:e.value.centerBox,autoCrop:e.value.autoCrop,autoCropWidth:e.value.autoCropWidth,autoCropHeight:e.value.autoCropHeight,fixedBox:e.value.fixedBox,canMove:e.value.canMove,mode:e.value.mode,info:e.value.info,onCropMoving:h(v)},null,8,["img","canScale","full","outputSize","centerBox","autoCrop","autoCropWidth","autoCropHeight","fixedBox","canMove","mode","info","onCropMoving"])],4)],512),u("div",S,[d(a,{class:"mx-1"},{default:y(()=>[M("预览:")]),_:1}),u("img",{src:c.value,style:{width:"30%"}},null,8,z)])],64)}}},A=I;export{A as default};