WokerTask/public/admin/assets/index.d1b9575e.js

2 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-01-16 18:33:37 +08:00
import{K as P,Y as U,M as V}from"./element-plus.ff90c99c.js";import{a as D,j as p,R as C,f as m,d as R}from"./index.71302537.js";import{d as _,s as L,r as f,b as S,t as j,o as c,c as g,W as b,Q as k,J as N,P as I,a as v,F as q,a9 as J,V as K,T as M}from"./@vue.f8dfc830.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=D(),n=L(),E=f(`${p.baseUrl}${p.urlPrefix}/upload/${e.type}`),F=S(()=>({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 y;r.every(B=>B.status=="success")&&((y=n.value)==null||y.clearFiles(),o.value=!1),a("change",l),s.code==C.SUCCESS&&a("success",s),s.code==C.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=S(()=>{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 Y(e,a,h,n,E,F){const o=P,u=U,d=V;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(q,null,J(e.fileList,(t,i)=>(c(),g("div",{key:i,class:"mb-5"},[v("div",null,K(t.name),1),v("div",W,[b(u,{percentage:parseInt(t.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","onClose"])):M("",!0)])}const Z=R(O,[["render",Y]]);export{Z as U};