import{d as w,an as T,X as D,ar as M,as as R,f as h,p as C,i as r,a as E,c as b,k as a,m as n,j as l,ap as K,l as y,v as Z,t as q,n as B,e as x,at as H,B as X,z as G,M as p,au as J,_ as O}from"./index-deffec86.js";const Q={class:"upload-box"},W={class:"upload-empty"},Y=["src"],ee=["onClick"],te=["onClick"],ue={class:"el-upload__tip"},se={class:"el-upload__tip"},le=w({name:"UploadImgs"}),ae=w({...le,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"],setup(k,{emit:S}){T(e=>({"76563d40":e.borderRadius,"37ae9684":e.width,b7557fae:e.height}));const s=k,i=D(M,void 0),c=D(R,void 0),g=h(()=>s.disabled||(i==null?void 0:i.disabled)),m=h({set(e){_("update:fileList",e)},get(){return s.fileList}}),z=e=>{const t=e.size/1024/1024<s.fileSize,u=s.fileType;return u.includes(e.type)||p({title:"\u6E29\u99A8\u63D0\u793A",message:"\u4E0A\u4F20\u56FE\u7247\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01",type:"warning"}),t||p({title:"\u6E29\u99A8\u63D0\u793A",message:`\u4E0A\u4F20\u56FE\u7247\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${s.fileSize}M\uFF01`,type:"warning"}),u.includes(e.type)&&t},I=async e=>{var u;let t=new FormData;t.append("image",e.file),t.append("size",s.fileSize.toString());try{const d=(u=s.api)!=null?u:J,{data:f}=await d(t),v={fileUrl:f.imgUrl,imgPath:f.imgPath};e.onSuccess(v)}catch(d){e.onError(d)}},_=S,L=(e,t)=>{!e||(t.url=e.fileUrl,t.imgPath=e.imgPath,_("update:fileList",m.value),c!=null&&c.prop&&(i==null||i.validateField([c.prop])),p({title:"\u6E29\u99A8\u63D0\u793A",message:"\u56FE\u7247\u4E0A\u4F20\u6210\u529F\uFF01",type:"success"}))},U=e=>{let t=m.value.filter(u=>u.url!==e.url||u.name!==e.name);_("update:fileList",t)},V=()=>{p({title:"\u6E29\u99A8\u63D0\u793A",message:"\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01",type:"error"})},$=()=>{p({title:"\u6E29\u99A8\u63D0\u793A",message:`\u5F53\u524D\u6700\u591A\u53EA\u80FD\u4E0A\u4F20 ${s.limit} \u5F20\u56FE\u7247\uFF0C\u8BF7\u79FB\u9664\u540E\u4E0A\u4F20\uFF01`,type:"warning"})},A=C(""),F=C(!1),j=e=>{A.value=e.url,F.value=!0};return(e,t)=>{const u=r("el-icon"),d=r("ZoomIn"),f=r("Delete"),v=r("el-upload"),P=r("el-image-viewer");return E(),b("div",Q,[a(v,{action:"#","list-type":"picture-card",class:X(["upload",g.value?"disabled":"",e.drag?"no-border":""]),"file-list":m.value,"onUpdate:fileList":t[1]||(t[1]=o=>m.value=o),multiple:!0,disabled:g.value,limit:e.limit,"http-request":I,"before-upload":z,"on-exceed":$,"on-success":L,"on-error":V,drag:e.drag,accept:e.fileType.join(","),teleported:!0},{file:n(({file:o})=>[l("img",{src:o.url,class:"upload-image"},null,8,Y),l("div",{class:"upload-handle",onClick:t[0]||(t[0]=K(()=>{},["stop"]))},[l("div",{class:"handle-icon",onClick:N=>j(o)},[a(u,null,{default:n(()=>[a(d)]),_:1}),t[3]||(t[3]=l("span",null,"\u67E5\u770B",-1))],8,ee),g.value?y("v-if",!0):(E(),b("div",{key:0,class:"handle-icon",onClick:N=>U(o)},[a(u,null,{default:n(()=>[a(f)]),_:1}),t[4]||(t[4]=l("span",null,"\u5220\u9664",-1))],8,te))])]),tip:n(()=>[l("div",ue,[y(' <slot name="tip"></slot> '),Z(" \u53EA\u80FD\u4E0A\u4F20jpg/png/jpeg\u6587\u4EF6,\u4E14\u4E0D\u8D85\u8FC7"+q(e.fileSize)+"MB ",1)])]),default:n(()=>[l("div",W,[B(e.$slots,"empty",{},()=>[a(u,null,{default:n(()=>[a(x(H))]),_:1})],!0)])]),_:3},8,["class","file-list","disabled","limit","drag","accept"]),l("div",se,[B(e.$slots,"tip",{},void 0,!0)]),F.value?(E(),G(P,{key:0,onClose:t[2]||(t[2]=o=>F.value=!1),"url-list":[A.value]},null,8,["url-list"])):y("v-if",!0)])}}});const oe=O(ae,[["__scopeId","data-v-d194ce46"]]);export{oe as I};
