import{l as U,aA as q,e as A,A as b,a as C,ah as r,m as w,p as D,U as o,O as m,q as u,a2 as H,R as k,P as K,V as Z,H as S,u as J,I as O,M as G,J as Q,n as W,ay as X,az as Y}from"./vendor-98154105-1779868775780v=1.0.0.js";import{U as ee}from"./index-0f3e2c06-1779868775780v=1.0.0.js";import{v as te,w as ae,x as se,c as f}from"./eleVendor-dbf96bf3-1779868775780v=1.0.0.js";import{u as le}from"./upload-a2386bf9-1779868775780v=1.0.0.js";import{_ as oe}from"./_plugin-vue_export-helper-8c5478df-1779868775780v=1.0.0.js";const z=d=>(X("data-v-3a2e7e38"),d=d(),Y(),d),ue={class:"upload-empty"},ie=["src"],ne=["onClick"],re=z(()=>u("span",null,"\u67E5\u770B",-1)),de=["onClick"],ce=z(()=>u("span",null,"\u5220\u9664",-1)),pe={class:"percent-box"},me={class:"el-upload__tip"},fe=U({name:"UploadImgs"}),ge=U({...fe,props:{fileList:{default:()=>[]},api:{},drag:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},limit:{default:5},fileSize:{default:5},fileType:{default:()=>["image/jpeg","image/png","image/gif"]},height:{default:"150px"},width:{default:"150px"},borderRadius:{default:"8px"}},emits:["update:fileList","uploadFile","getFileInfo"],setup(d,{emit:B}){q(e=>({"45699dc8":e.borderRadius,"04777f1c":e.width,"70a96a91":e.height}));const l=d,P=A(()=>l.limit>c.value.length),i=b(te,void 0),g=b(ae,void 0),F=A(()=>l.disabled||(i==null?void 0:i.disabled)),c=A({set(e){_("update:fileList",e)},get(){return l.fileList}}),L=e=>{const t=e.size/1024/1024<l.fileSize,a=l.fileType;return a.includes(e.type)||f({title:"\u6E29\u99A8\u63D0\u793A",message:"\u4E0A\u4F20\u56FE\u7247\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01",type:"warning"}),t||f({title:"\u6E29\u99A8\u63D0\u793A",message:`\u4E0A\u4F20\u56FE\u7247\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${l.fileSize}M\uFF01`,type:"warning"}),_("getFileInfo",e),a.includes(e.type)&&t},$=async e=>{var v;let t=new FormData,p=await new ee().formatImage(e.file);t.append("file",p),t.append("size",`${l.fileSize}`);try{const n=await((v=l.api)!=null?v:le)(t,!0,s=>e.onProgress(s));if(await W(),e.file.percent=100,n.code!==0){e.onError(n.msg);return}const E={fileUrl:n.data,imgPath:n.data};e.onSuccess(E)}catch(h){e.onError(h)}},_=B,M=(e,t)=>{!e||(t.url=e.fileUrl,t.imgPath=e.imgPath,_("update:fileList",c.value),g!=null&&g.prop&&(i==null||i.validateField([g.prop])),t.percent=100,f({title:"\u6E29\u99A8\u63D0\u793A",message:"\u56FE\u7247\u4E0A\u4F20\u6210\u529F\uFF01",type:"success"}))},V=e=>{let t=c.value.filter(a=>a.url!==e.url||a.name!==e.name);_("update:fileList",t)},T=(e,t,a)=>{const p=Math.round(e.loaded*100/e.total)<90?Math.round(e.loaded*100/e.total):90;t.percent!=100&&(t.percent=p)},x=e=>{f({title:"\u6E29\u99A8\u63D0\u793A",message:e,type:"error"})},N=()=>{f({title:"\u6E29\u99A8\u63D0\u793A",message:`\u5F53\u524D\u6700\u591A\u53EA\u80FD\u4E0A\u4F20 ${l.limit} \u5F20\u56FE\u7247\uFF0C\u8BF7\u79FB\u9664\u540E\u4E0A\u4F20\uFF01`,type:"warning"})},I=C(""),y=C(!1),R=e=>{I.value=e.url,y.value=!0};return(e,t)=>{const a=r("el-icon"),p=r("ZoomIn"),v=r("Delete"),h=r("el-progress"),n=r("el-upload"),E=r("el-image-viewer");return w(),D("div",{class:"upload-box",style:Q({"--upload-block":P.value?"block":"none"})},[o(n,{action:"#","list-type":"picture-card",class:O(["upload",F.value?"disabled":"",e.drag?"no-border":""]),"file-list":c.value,"onUpdate:fileList":t[1]||(t[1]=s=>c.value=s),multiple:!0,disabled:F.value,limit:e.limit,"http-request":$,"before-upload":L,"on-exceed":N,"on-success":M,"on-error":x,"on-progress":T,drag:e.drag,accept:e.fileType.join(","),teleported:!0},{file:m(({file:s})=>[u("img",{src:s.url,class:"upload-image"},null,8,ie),u("div",{class:"upload-handle",onClick:t[0]||(t[0]=H(()=>{},["stop"]))},[u("div",{class:"handle-icon",onClick:j=>R(s)},[o(a,null,{default:m(()=>[o(p)]),_:1}),re],8,ne),F.value?k("",!0):(w(),D("div",{key:0,class:"handle-icon",onClick:j=>V(s)},[o(a,null,{default:m(()=>[o(v)]),_:1}),ce],8,de))]),K(u("div",pe,[o(h,{type:"circle",percentage:s.percent},null,8,["percentage"])],512),[[Z,s.percent&&s.percent!==100]])]),default:m(()=>[u("div",ue,[S(e.$slots,"empty",{},()=>[o(a,null,{default:m(()=>[o(J(se))]),_:1})],!0)])]),_:3},8,["class","file-list","disabled","limit","drag","accept"]),u("div",me,[S(e.$slots,"tip",{},void 0,!0)]),y.value?(w(),G(E,{key:0,onClose:t[2]||(t[2]=s=>y.value=!1),"url-list":[I.value]},null,8,["url-list"])):k("",!0)],4)}}});const Ee=oe(ge,[["__scopeId","data-v-3a2e7e38"]]);export{Ee as I};
