import{J as U,X as L,L as D}from"./element-plus.9816852d.js";import{a as P,j as p,R as y,f as m,d as R}from"./index.4eaf9bd5.js";import{d as V,s as _,r as f,e as C,t as j,o as c,c as g,U as b,L as k,H as N,K as I,a as v,T as q,a7 as H,S as J,Q as K}from"./@vue.51d7f2d8.js";const O=V({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=P(),n=_(),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=j(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"},X={class:"flex-1"};function z(e,a,h,n,E,F){const o=U,u=L,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(()=>[N(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,H(e.fileList,(t,i)=>(c(),g("div",{key:i,class:"mb-5"},[v("div",null,J(t.name),1),v("div",X,[b(u,{percentage:parseInt(t.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):K("",!0)])}const Z=R(O,[["render",z]]);export{Z as U};