import{Y as U,P,I as D}from"./element-plus.ae8e286c.js";import{a as R,e as p,R as y,f as m,d as V}from"./index.71fc8348.js";import{d as _,s as L,r as f,b as C,t as N,o as c,c as g,T as b,K as k,G as j,J as I,a as v,U as q,a6 as G,S as J,Q as K}from"./@vue.108c970a.js";const O=_({components:{},props:{type:{type:String,default:"image"},multiple:{type:Boolean,default:!0},limit:{type:Number,default:10},data:{type:Object,default:()=>({})},showProgress:{type:Boolean,default:!1}},emits:["change","error","success"],setup(e,{emit:a}){const h=R(),n=L(),E=f(`${p.baseUrl}${p.urlPrefix}/upload/${e.type}`),F=C(()=>({token:h.token,version:p.version})),o=f(!1),u=f([]),d=(s,l,r)=>{o.value=!0,u.value=N(r)},t=(s,l,r)=>{var S;r.every(B=>B.status=="success")&&((S=n.value)==null||S.clearFiles(),o.value=!1),a("change",l),s.code==y.SUCCESS&&a("success",s),s.code==y.FAIL&&s.msg&&m.msgError(s.msg)},i=(s,l)=>{var r;m.msgError(`${l.name}\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25`),(r=n.value)==null||r.abort(l),o.value=!1,a("change",l),a("error",l)},A=()=>{m.msgError(`\u8D85\u51FA\u4E0A\u4F20\u4E0A\u9650${e.limit}\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20`)},$=()=>{var s;(s=n.value)==null||s.clearFiles(),o.value=!1},w=C(()=>{switch(e.type){case"image":return".jpg,.png,.gif,.jpeg";case"video":return".wmv,.avi,.mpg,.mpeg,.3gp,.mov,.mp4,.flv,.rmvb,.mkv";default:return"*"}});return{uploadRefs:n,action:E,headers:F,visible:o,fileList:u,getAccept:w,handleProgress:d,handleSuccess:t,handleError:i,handleExceed:A,handleClose:$}}}),Q={class:"upload"},T={class:"file-list p-4"},Y={class:"flex-1"};function z(e,a,h,n,E,F){const o=P,u=U,d=D;return c(),g("div",Q,[b(o,{ref:"uploadRefs",action:e.action,multiple:e.multiple,limit:e.limit,"show-file-list":!1,headers:e.headers,data:e.data,"on-progress":e.handleProgress,"on-success":e.handleSuccess,"on-exceed":e.handleExceed,"on-error":e.handleError,accept:e.getAccept},{default:k(()=>[j(e.$slots,"default")]),_:3},8,["action","multiple","limit","headers","data","on-progress","on-success","on-exceed","on-error","accept"]),e.showProgress&&e.fileList.length?(c(),I(d,{key:0,modelValue:e.visible,"onUpdate:modelValue":a[0]||(a[0]=t=>e.visible=t),title:"\u4E0A\u4F20\u8FDB\u5EA6","close-on-click-modal":!1,width:"500px",modal:!1,onClose:e.handleClose},{default:k(()=>[v("div",T,[(c(!0),g(q,null,G(e.fileList,(t,i)=>(c(),g("div",{key:i,class:"mb-5"},[v("div",null,J(t.name),1),v("div",Y,[b(u,{percentage:parseInt(t.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):K("",!0)])}const Z=V(O,[["render",z]]);export{Z as U};
