import{c4 as a,M as e,aK as l,P as t,l as s,$ as o}from"./utils-lib.js?v=1761009159";import{_ as n}from"./index105.js?v=1761009159";import{_ as m}from"./index103.js?v=1761009159";import{c as r,r as i,o as c,V as u,g as d,q as p,H as _,v as b,x as v,e as f,B as g,I as y,y as x,z as h,N as j,C as q,D as w,ai as V,ah as k}from"./base-lib.js?v=1761009159";import{g as S}from"./useStore2.js?v=1761009159";import{getTableInfo as C,getModulesTableInfo as z}from"./database.js?v=1761009159";import{y as D}from"./useMethod4.js?v=1761009159";import{a as N}from"./column.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./validator.js?v=1761009159";import"./index106.js?v=1761009159";const J={class:"p-[20px]"},O={class:"flex items-center mt-[16px] leading-[3rem]"},U={key:0,class:"flex items-center mt-16px"},H=r({__name:"table-back",props:{compData:{default:()=>({name:"",id:0})}},setup(r,{expose:H}){const I=r,{refs:{tabActive:L}}=S(),{name:M,id:Q}=I.compData,A=i("mongodb"===L.value?"bson":"db"),B=i(!1),F=i([]),K=i([]),P=c({id:Q,table_list:K.value,storage_type:A.value,file_type:A.value,password:""}),$=u([N({key:"mongodb"==L.value?"collection_name":"table_name"}),{prop:"mongodb"==L.value?"collection_name":"table_name",label:"表名"},{prop:"mongodb"==L.value?"count":"rows_count",label:"行数"},{prop:"mongodb"===L.value?"size":"pgsql"===L.value?"table_size":"data_size",label:"大小"}]),E=d(()=>{let a=[{content:"分表导出：一张表存储为一个SQL文件。"},{content:"合并导出：将选中的表导出到一个SQL文件内"},{content:"备份格式：打包后压缩包内的文件格式"}];return"mysql"==L.value&&a.push({content:"压缩密码：设置备份压缩密码后请注意保存好密码！",class:"text-warning"}),a}),G=a=>{K.value=a};return p(()=>{(async()=>{const{data:a}=await t({loading:B,request:"mysql"===L.value?C({db_name:M}):z({data:JSON.stringify({db_name:M})},L.value)});"mysql"===L.value&&(F.value=a.tables),"mongodb"===L.value&&(F.value=a.data.collection_list),"pgsql"===L.value&&(F.value=a.data.table_list)})()}),H({onConfirm:async a=>{var t,s;try{if(0===K.value.length)return void e.error("请至少选择一项要备份的表");let l={...P,collection_list:K.value.map(a=>a.collection_name),table_list:JSON.stringify(K.value.map(a=>"".concat(a.schema,".").concat(a.table_name)))};switch(L.value){case"mongodb":l.file_type=P.storage_type,l.storage_type="table";break;case"pgsql":l.table_list=K.value.map(a=>"".concat(a.schema,".").concat(a.table_name));break;case"mysql":l.table_list=JSON.stringify(K.value.map(a=>"".concat(a.table_name)))}const o=await D(l);e.request(o),null==(s=(t=I.compData).refreshFn)||s.call(t),a()}catch(o){l(o,"数据库-表备份-onConfirm")}}}),(e,l)=>{const t=s,r=V,i=k,c=m,u=n,d=o,p=_("bt-loading"),S=_("focus");return b(),v("div",J,[f(u,null,{content:g(()=>[y(f(t,{onSelectionChange:G,"max-height":"260",column:x($),data:x(F)},null,8,["column","data"]),[[p,x(B)],[p,"正在加载列表，请稍后...","title"]])]),"footer-left":g(()=>[h("div",null,[h("div",O,[l[8]||(l[8]=h("span",{class:"mr-[16px]"},"备份方式",-1)),"mongodb"!==x(L)?(b(),j(i,{key:0,modelValue:x(P).storage_type,"onUpdate:modelValue":l[0]||(l[0]=a=>x(P).storage_type=a)},{default:g(()=>[f(r,{value:"db"},{default:g(()=>l[4]||(l[4]=[q("合并导出",-1)])),_:1,__:[4]}),f(r,{value:"table"},{default:g(()=>l[5]||(l[5]=[q("分表导出",-1)])),_:1,__:[5]})]),_:1},8,["modelValue"])):w("",!0),"mongodb"==x(L)?(b(),j(i,{key:1,modelValue:x(P).storage_type,"onUpdate:modelValue":l[1]||(l[1]=a=>x(P).storage_type=a)},{default:g(()=>[f(r,{value:"bson"},{default:g(()=>l[6]||(l[6]=[q("bson",-1)])),_:1,__:[6]}),f(r,{value:"json"},{default:g(()=>l[7]||(l[7]=[q("json",-1)])),_:1,__:[7]})]),_:1},8,["modelValue"])):w("",!0)]),"mysql"==x(L)?(b(),v("div",U,[l[9]||(l[9]=h("span",{class:"mr-16px !w-[6.4rem]"},"压缩密码",-1)),y(f(c,{placeholder:"请输入压缩密码，可为空",modelValue:x(P).password,"onUpdate:modelValue":l[2]||(l[2]=a=>x(P).password=a),icon:"el-refresh",onIconClick:l[3]||(l[3]=()=>x(P).password=x(a)(16))},null,8,["modelValue"]),[[S]])])):w("",!0)])]),_:1}),f(d,{options:x(E),"list-style":"disc",class:"ml-[20px] mt-[36px]"},null,8,["options"])])}}});export{H as default};
