import{V as B,W as V,J as D}from"./element-plus.fa1aa32c.js";import{a as U,i as p,R as L,f as m,d as P}from"./index.0abf9e5c.js";import{d as R,s as _,r as f,e as b,t as j,o as i,c as g,V as A,M as C,I as N,L as I,a as h,W,a8 as q,U as J,S as M}from"./@vue.cab01781.js";const O=R({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"],setup(e,{emit:o}){const v=U(),r=_(),E=f(`${p.baseUrl}${p.urlPrefix}/upload/${e.type}`),F=b(()=>({["like-admin"]:v.token,version:p.version})),a=f(!1),n=f([]),c=(s,u,t)=>{a.value=!0,n.value=j(t)},l=(s,u,t)=>{var y;t.every(w=>w.status=="success")&&((y=r.value)==null||y.clearFiles(),a.value=!1,o("change")),s.code==L.FAILED&&s.msg&&m.msgError(s.msg)},d=(s,u)=>{var t;m.msgError(`${u.name}\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25`),(t=r.value)==null||t.abort(u),a.value=!1,o("change"),o("error")},S=()=>{m.msgError(`\u8D85\u51FA\u4E0A\u4F20\u4E0A\u9650${e.limit}\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20`)},$=()=>{var s;(s=r.value)==null||s.clearFiles(),a.value=!1},k=b(()=>{switch(e.type){case"image":return".jpj,.png,.gif,.jpeg,.ico,.bmp";case"video":return".wmv,.avi,.mov,.mp4,.flv,.rmvb";default:return"*"}});return{uploadRefs:r,action:E,headers:F,visible:a,fileList:n,getAccept:k,handleProgress:c,handleSuccess:l,handleError:d,handleExceed:S,handleClose:$}}}),z={class:"upload"},G={class:"file-list p-4"},H={class:"flex-1"};function K(e,o,v,r,E,F){const a=B,n=V,c=D;return i(),g("div",z,[A(a,{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,["action","multiple","limit","headers","data","on-progress","on-success","on-exceed","on-error","accept"]),e.showProgress&&e.fileList.length?(i(),I(c,{key:0,modelValue:e.visible,"onUpdate:modelValue":o[0]||(o[0]=l=>e.visible=l),title:"\u4E0A\u4F20\u8FDB\u5EA6","close-on-click-modal":!1,width:"500px",modal:!1,onClose:e.handleClose},{default:C(()=>[h("div",G,[(i(!0),g(W,null,q(e.fileList,(l,d)=>(i(),g("div",{key:d,class:"mb-5"},[h("div",null,J(l.name),1),h("div",H,[A(n,{percentage:parseInt(l.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):M("",!0)])}const Z=P(O,[["render",K]]);export{Z as U};
