import{d as B,W as C,r as d,s as k,aq as _,E as b,_ as $,c as p,e as i,f,h as S,i as w,G as V,k as D,g as h,F as P,j as L,t as N,A as U}from"./index.0308b213.js";const j=B({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},action:{type:String,default:""}},emits:["change","error"],setup(e,{emit:o}){const{token:m}=C(),l=d(null),g=d(window.location.protocol+"//"+window.location.host+`${e.action?e.action:`/adminapi/upload/${e.type}`}`),v=k(()=>({token:m,version:_})),s=d(!1),u=d([]);return{uploadRefs:l,action:g,headers:v,visible:s,fileList:u,handleProgress:(t,a,r)=>{s.value=!0,u.value=r},handleSuccess:(t,a,r)=>{var y;r.every(A=>A.status=="success")&&((y=l.value)==null||y.clearFiles(),s.value=!1,o("change",a,r))},handleError:(t,a,r)=>{var c;b.error(`${a.name}\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25`),(c=l.value)==null||c.abort(),s.value=!1,o("change"),o("error")},handleExceed:()=>{b.error("\u8D85\u51FA\u4E0A\u4F20\u4E0A\u9650\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20")},handleClose:()=>{var t,a;(t=l.value)==null||t.abort(),(a=l.value)==null||a.clearFiles(),s.value=!1}}}}),R={class:"upload"},q={class:"file-list"},G={class:"flex-1"};function I(e,o,m,l,g,v){const s=p("el-upload"),u=p("el-progress"),E=p("el-dialog");return i(),f("div",R,[S(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},{default:w(()=>[V(e.$slots,"default")]),_:3},8,["action","multiple","limit","headers","data","on-progress","on-success","on-exceed","on-error"]),e.showProgress&&e.fileList.length?(i(),D(E,{key:0,modelValue:e.visible,"onUpdate:modelValue":o[0]||(o[0]=n=>e.visible=n),title:"\u4E0A\u4F20\u8FDB\u5EA6","close-on-click-modal":!1,width:"500px",modal:!1,"before-close":e.handleClose},{default:w(()=>[h("div",q,[(i(!0),f(P,null,L(e.fileList,(n,F)=>(i(),f("div",{key:F,class:"m-b-20"},[h("div",null,N(n.name),1),h("div",G,[S(u,{percentage:parseInt(n.percentage)},null,8,["percentage"])])]))),128))])]),_:1},8,["modelValue","before-close"])):U("",!0)])}const z=$(j,[["render",I]]);export{z as U};
