2024-10-12 19:40:17 +08:00
|
|
|
import{W as B,X as w,K as U}from"./element-plus.ab0703f2.js";import{a as P,i as p,R as S,f,d as V}from"./index.5ab034a5.js";import{d as D,s as R,r as m,b as C,o as u,c as g,W as b,Q as y,J as N,P as j,a as v,F as I,a9 as W,V as _,T as q}from"./@vue.340249d8.js";const J=D({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=P(),i=R(),E=m(`${p.baseUrl}${p.urlPrefix}/upload/${e.type}`),F=C(()=>({token:h.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==S.SUCCESS&&a("success",o),o.code==S.FAIL&&o.msg&&f.msgError(o.msg)},L=(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},$=C(()=>{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:F,visible:r,fileList:l,getAccept:$,handleProgress:d,handleSuccess:c,handleError:L,handleExceed:k,handleClose:A}}}),K={class:"upload"},O={class:"file-list p-4"},Q={class:"flex-1"};function T(e,a,h,i,E,F){const r=B,l=w,d=U;return u(),g("div",K,[b(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:y(()=>[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:y(()=>[v("div",O,[(u(!0),g(I,null,W(e.fileList,(s,c)=>(u(),g("div",{key:c,class:"mb-5"},[v("div",null,_(s.name),1),v("div",Q,[b(l,{percentage:parseInt(s.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):q("",!0)])}const H=V(J,[["render",T]]);export{H as U};
|