import{y as z,az as x,c as h,i as C,r as w,al as r,z as A,A as D,R as u,J as p,B as o,W as K,M as I,K as Z,S as q,C as k,u as H,D as J,I as W,E as G,n as O}from"./vendor-866bb149-1782572373740v=1.0.0.js";import{s as Q,i as X,_ as Y}from"./index-f6f689f9-1782572373740v=1.0.0.js";import{f as ee,e as te,a4 as se,c as m}from"./eleVendor-48a7d3b8-1782572373740v=1.0.0.js";const ae={class:"upload-empty"},le=["src"],ue=["onClick"],oe=["onClick"],ie={class:"percent-box"},ne={class:"el-upload__tip"},re=z({name:"UploadImgs"}),de=z({...re,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:"110px"},width:{default:"110px"},borderRadius:{default:"8px"}},emits:["update:fileList","uploadFile","getFileInfo"],setup(B,{emit:S}){x(e=>({"9a349988":e.borderRadius,"8d0437b0":e.width,"5c6fa705":e.height}));const l=B,P=h(()=>l.limit>d.value.length),i=C(ee,void 0),f=C(te,void 0),F=h(()=>l.disabled||(i==null?void 0:i.disabled)),d=h({set(e){g("update:fileList",e)},get(){return l.fileList}}),U=e=>{const t=e.size/1024/1024<l.fileSize,s=l.fileType;return s.includes(e.type)||m({title:"\u6E29\u99A8\u63D0\u793A",message:"\u4E0A\u4F20\u56FE\u7247\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01",type:"warning"}),t||m({title:"\u6E29\u99A8\u63D0\u793A",message:`\u4E0A\u4F20\u56FE\u7247\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${l.fileSize}M\uFF01`,type:"warning"}),g("getFileInfo",e),s.includes(e.type)&&t},L=async e=>{var _;let t=new FormData,c=await new Q().formatImage(e.file);t.append("image",c),t.append("size",`${l.fileSize}`);try{const n=await((_=l.api)!=null?_:X)(t,!0,a=>e.onProgress(a));if(await O(),e.file.percent=100,n.code!==200){e.onError(n.message);return}const E={imgUrl:n.data.imgUrl,imgPath:n.data.imgPath};e.onSuccess(E)}catch(v){e.onError(v)}},g=S,$=(e,t)=>{!e||(t.url=e.imgUrl,t.imgPath=e.imgPath,g("update:fileList",d.value),f!=null&&f.prop&&(i==null||i.validateField([f.prop])),t.percent=100,m({title:"\u6E29\u99A8\u63D0\u793A",message:"\u56FE\u7247\u4E0A\u4F20\u6210\u529F\uFF01",type:"success"}))},M=e=>{let t=d.value.filter(s=>s.url!==e.url||s.name!==e.name);g("update:fileList",t)},V=(e,t,s)=>{const c=Math.round(e.loaded*100/e.total)<90?Math.round(e.loaded*100/e.total):90;t.percent!=100&&(t.percent=c)},T=e=>{m({title:"\u6E29\u99A8\u63D0\u793A",message:e,type:"error"})},N=()=>{m({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"})},b=w(""),y=w(!1),R=e=>{b.value=e.url,y.value=!0};return(e,t)=>{const s=r("el-icon"),c=r("ZoomIn"),_=r("Delete"),v=r("el-progress"),n=r("el-upload"),E=r("el-image-viewer");return A(),D("div",{class:"upload-box",style:G({"--upload-block":P.value?"block":"none"})},[u(n,{action:"#","list-type":"picture-card",class:J(["upload",F.value?"disabled":"",e.drag?"no-border":""]),"file-list":d.value,"onUpdate:fileList":t[1]||(t[1]=a=>d.value=a),multiple:!0,disabled:F.value,limit:e.limit,"http-request":L,"before-upload":U,"on-exceed":N,"on-success":$,"on-error":T,"on-progress":V,drag:e.drag,accept:e.fileType.join(","),teleported:!0},{file:p(({file:a})=>[o("img",{src:a.url,class:"upload-image"},null,8,le),o("div",{class:"upload-handle",onClick:t[0]||(t[0]=K(()=>{},["stop"]))},[o("div",{class:"handle-icon",onClick:j=>R(a)},[u(s,null,{default:p(()=>[u(c)]),_:1}),t[3]||(t[3]=o("span",null,"\u67E5\u770B",-1))],8,ue),F.value?I("v-if",!0):(A(),D("div",{key:0,class:"handle-icon",onClick:j=>M(a)},[u(s,null,{default:p(()=>[u(_)]),_:1}),t[4]||(t[4]=o("span",null,"\u5220\u9664",-1))],8,oe))]),Z(o("div",ie,[u(v,{type:"circle",percentage:a.percent},null,8,["percentage"])],512),[[q,a.percent&&a.percent!==100]])]),default:p(()=>[o("div",ae,[k(e.$slots,"empty",{},()=>[u(s,null,{default:p(()=>[u(H(se))]),_:1})],!0)])]),_:3},8,["class","file-list","disabled","limit","drag","accept"]),o("div",ne,[k(e.$slots,"tip",{},void 0,!0)]),y.value?(A(),W(E,{key:0,onClose:t[2]||(t[2]=a=>y.value=!1),"url-list":[b.value]},null,8,["url-list"])):I("v-if",!0)],4)}}});const fe=Y(de,[["__scopeId","data-v-46dd93d0"]]);export{fe as I};
