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