import{Y as B,Z as U,M as w}from"./element-plus.55d71530.js";import{a as V,h as p,R as C,f,d as D}from"./index.e2bd5212.js";import{d as P,s as R,r as m,b as F,o as u,c as g,V as L,M as b,I as N,L as j,a as h,U as I,aa as M,T as _,R as q}from"./@vue.96c135a1.js";const O=P({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 v=V(),i=R(),E=m(`${p.baseUrl}${p.urlPrefix}/upload/${e.type}`),S=F(()=>({token:v.token,version:p.version})),r=m(!1),l=m([]),d=(o,t,n)=>{r.value=!0};let s=0;const c=(o,t,n)=>{s++,s==l.value.length&&(s=0,l.value=[],a("allSuccess")),a("change",t),o.code==C.SUCCESS&&a("success",o),o.code==C.FAIL&&o.msg&&f.msgError(o.msg)},y=(o,t)=>{var n;s++,s==l.value.length&&(s=0,l.value=[],a("allSuccess")),f.msgError(`${t.name}\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25`),(n=i.value)==null||n.abort(t),r.value=!1,a("change",t),a("error",t)},k=()=>{f.msgError(`\u8D85\u51FA\u4E0A\u4F20\u4E0A\u9650${e.limit}\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20`)},A=()=>{l.value=[],r.value=!1},$=F(()=>{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:E,headers:S,visible:r,fileList:l,getAccept:$,handleProgress:d,handleSuccess:c,handleError:y,handleExceed:k,handleClose:A}}}),T={class:"upload"},Y={class:"file-list p-4"},Z={class:"flex-1"};function z(e,a,v,i,E,S){const r=B,l=U,d=w;return u(),g("div",T,[L(r,{"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:b(()=>[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?(u(),j(d,{key:0,modelValue:e.visible,"onUpdate:modelValue":a[1]||(a[1]=s=>e.visible=s),title:"\u4E0A\u4F20\u8FDB\u5EA6","close-on-click-modal":!1,width:"500px",modal:!1,onClose:e.handleClose},{default:b(()=>[h("div",Y,[(u(!0),g(I,null,M(e.fileList,(s,c)=>(u(),g("div",{key:c,class:"mb-5"},[h("div",null,_(s.name),1),h("div",Z,[L(l,{percentage:parseInt(s.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):q("",!0)])}const K=D(O,[["render",z]]);export{K as U};
