import{c as e,aA as a,r as t,g as s,V as l,o,w as r,v as i,x as u,e as n,B as p,C as c,y as m,z as d,A as f,F as _,N as v,I as h,J as w,G as b,b3 as g,aw as x,b5 as y,ax as k,ay as D}from"./base-lib.js?v=1761009159";import{fS as z,x as j,b as q}from"./utils-lib.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const C={class:"p-[2rem]"},O={class:"h-[40rem] border border-lighter mt-[1rem]"},E={class:"ml-[0.5rem]"},I={class:"mt-8px leading-8 text-small list-disc ml-2rem"},A=e({__name:"upload",props:{compData:{default:()=>({path:"",size:100,uploadData:()=>({multiple:!0,limit:1e3}),refreshEvent:()=>{}})}},setup(e,{expose:A}){const F=q(),S=e,B=a("popupSetFooter"),G=a("buttonText"),H=a("popupClose");let J=!0;const M=t(),N=t([]),T=s(()=>S.compData.uploadData.accept||l([".json"].join(","))),V=s(()=>S.compData.uploadData.multiple),K=s(()=>S.compData.uploadData.limit),L={"x-http-token":window.vite_public_request_token},P=z(),Q=window.location.protocol+"//"+window.location.host+"/files?action=upload",R=o({f_size:0,f_path:S.compData.path,f_name:"",f_start:0,request_time:P.request_time,request_token:P.request_token}),U=()=>{F.success("导入成功"),S.compData.refreshEvent&&S.compData.refreshEvent(N.value,H)},W=(e,a,t)=>{t.push(a),F.error("导入失败")},X=e=>{R.f_size=e.size,R.f_name=e.name,R.f_start=0},Y=(e,a)=>{const t=e.name.substring(e.name.lastIndexOf(".")+1),s=T.value;if(-1===s.indexOf(t))return!1;N.value=a.filter(e=>{let a=e.name.substring(e.name.lastIndexOf(".")+1);return-1!==s.indexOf(a)})||[]},Z=(e,a,t)=>{R.f_start=e.percent,N.value=t.map(t=>(t.uid===a.uid&&(t.percentage=e.percent),t))};return r(()=>N.value.length,e=>{if(0===e)return void B(!1);const a=["success","fail","ready"];for(let t=0;t<N.value.length;t++)if(!a.includes(N.value[t].status))return void B(!1);N.value.some(e=>"success"!==e.status)&&(G.value=J?"开始上传":"重新上传",B(!0))}),A({onConfirm:()=>{N.value.map(e=>{"success"!==e.status&&(e.status="ready")}),J=!1,M.value.submit(),B(!1)}}),(e,a)=>{const t=b,s=g,l=x,o=y,r=k,z=D;return i(),u("div",C,[n(s,{class:"upload-demo",ref_key:"upload",ref:M,name:"blob",data:m(R),action:Q,headers:L,accept:m(T),limit:m(K),multiple:m(V),"show-file-list":!1,"auto-upload":!1,"file-list":m(N),"on-error":W,"on-success":U,"on-progress":Z,"on-change":Y,"before-upload":X},{default:p(()=>[n(t,{type:"primary"},{default:p(()=>a[0]||(a[0]=[c("选择文件",-1)])),_:1,__:[0]})]),_:1},8,["data","accept","limit","multiple","file-list"]),d("div",O,[n(z,{height:"400",data:m(N)},{empty:p(()=>[n(r,{description:"只支持'".concat(m(T),"'文件格式导入")},null,8,["description"])]),default:p(()=>[n(l,{prop:"name","show-overflow-tooltip":!0,label:"名称"},{default:p(e=>[a[1]||(a[1]=d("i",{class:"text-supplement svgtofont-el-document"},null,-1)),d("span",E,f(e.row.name),1)]),_:1}),n(l,{prop:"name",label:"是否成功",width:"300"},{default:p(e=>["success"===e.row.status?(i(),u(_,{key:0},[c("上传成功！")],64)):"fail"===e.row.status?(i(),u(_,{key:1},[c("上传失败!")],64)):"ready"===e.row.status?(i(),u(_,{key:2},[c("等待上传")],64)):(i(),v(o,{key:3,percentage:Math.floor(e.row.percentage)},null,8,["percentage"]))]),_:1}),n(l,{width:"120",prop:"size",label:"大小"},{default:p(e=>[c(f(m(j)(e.row.size)),1)]),_:1}),n(l,{prop:"name",width:"180",align:"right","show-overflow-tooltip":!0,label:"操作"},{default:p(e=>[h(n(t,{type:"text",size:"small",onClick:a=>{return t=e.row,void(N.value=N.value.filter(e=>e.name!==t.name));var t}},{default:p(()=>a[2]||(a[2]=[c("删除",-1)])),_:2,__:[2]},1032,["onClick"]),[[w,"ready"===e.row.status||"fail"===e.row.status]])]),_:1})]),_:1},8,["data"])]),d("ul",I,[d("li",null,"仅支持"+f(m(T)),1)])])}}});export{A as default};
