2023-12-07 16:41:06 +08:00
|
|
|
import{V as U,W as V,J as D}from"./element-plus.7a22678c.js";import{a as P,j as p,R as y,f as m,d as R}from"./index.19a6a9db.js";import{d as _,s as L,r as f,b as C,t as j,o as c,c as g,T as b,K as k,G as N,J as I,a as v,U as J,a6 as q,S as G,Q as K}from"./@vue.108c970a.js";const O=_({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=L(),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"},W={class:"flex-1"};function z(e,a,h,n,E,F){const o=U,u=V,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(J,null,q(e.fileList,(t,i)=>(c(),g("div",{key:i,class:"mb-5"},[v("div",null,G(t.name),1),v("div",W,[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};
|