import{V,W as B,Q as P}from"./element-plus-z3MwpXC9.js";import{a as R,j as u,R as b,f as p,d as A}from"./index-DXEGVToZ.js";import{d as j,s as F,r as f,b as y,o as n,c as m,V as k,M as C,I as N,L as D,a as g,U as I,aa as _,T as q,R as M}from"./@vue-TMcuEboY.js";const O=j({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","allSuccess"],setup(e,{emit:a}){const h=R(),i=F(),v=f(`${u.baseUrl}${u.urlPrefix}/upload/${e.type}`),E=y(()=>({token:h.token,version:u.version})),l=f(!1),o=f([]),d=()=>{l.value=!0};let s=0;const c=(t,r)=>{s++,s==o.value.length&&(s=0,o.value=[],a("allSuccess")),a("change",r),t.code==b.SUCCESS&&a("success",t),t.code==b.FAIL&&t.msg&&p.msgError(t.msg)},L=(t,r)=>{var S;s++,s==o.value.length&&(s=0,o.value=[],a("allSuccess")),p.msgError(`${r.name}文件上传失败`),(S=i.value)==null||S.abort(r),l.value=!1,a("change",r),a("error",r)},$=()=>{p.msgError(`超出上传上限${e.limit}，请重新上传`)},U=()=>{o.value=[],l.value=!1},w=y(()=>{switch(e.type){case"image":return".jpg,.png,.gif,.jpeg,.ico";case"video":return".wmv,.avi,.mpg,.mpeg,.3gp,.mov,.mp4,.flv,.rmvb,.mkv";default:return"*"}});return{uploadRefs:i,action:v,headers:E,visible:l,fileList:o,getAccept:w,handleProgress:d,handleSuccess:c,handleError:L,handleExceed:$,handleClose:U}}}),Q={class:"upload"},T={class:"file-list p-4"},W={class:"flex-1"};function z(e,a,h,i,v,E){const l=V,o=B,d=P;return n(),m("div",Q,[k(l,{"file-list":e.fileList,"onUpdate:fileList":a[0]||(a[0]=s=>e.fileList=s),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:C(()=>[N(e.$slots,"default")]),_:3},8,["file-list","action","multiple","limit","headers","data","on-progress","on-success","on-exceed","on-error","accept"]),e.showProgress&&e.fileList.length?(n(),D(d,{key:0,modelValue:e.visible,"onUpdate:modelValue":a[1]||(a[1]=s=>e.visible=s),title:"上传进度","close-on-click-modal":!1,width:"500px",modal:!1,onClose:e.handleClose},{default:C(()=>[g("div",T,[(n(!0),m(I,null,_(e.fileList,(s,c)=>(n(),m("div",{key:c,class:"mb-5"},[g("div",null,q(s.name),1),g("div",W,[k(o,{percentage:parseInt(s.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):M("",!0)])}const K=A(O,[["render",z]]);export{K as U};
