import{K as e,V as l,P as a,_ as u}from"./utils-lib.js?v=1761009159";import{c as t,aA as s,g as r,e as n,C as i,b9 as m,b$ as c,q as o,v as d,x as v,y as p,z as _}from"./base-lib.js?v=1761009159";import{d as b,j as k,b as h,h as y}from"./form-item.js?v=1761009159";import{addIncrementTask as w}from"./database.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";const f={class:"my-[1.6rem]"},g=u(t({__name:"add-increment",props:{compData:{default:()=>{}}},setup(u,{expose:t}){const g=u,D=[{label:"每天",value:"daily"},{label:"每周",value:"weekly"},{label:"相隔N天",value:"interval"},{label:"相隔N小时",value:"hours"}],N=[{label:"周一",value:"1"},{label:"周二",value:"2"},{label:"周三",value:"3"},{label:"周四",value:"4"},{label:"周五",value:"5"},{label:"周六",value:"6"},{label:"周日",value:"0"}],B=[{label:"小时",value:"hour"},{label:"分钟",value:"minute"}],P=s("popupClose",()=>{}),j=(e,l,a)=>{!/^\d+$/.test(String(e))||Number(e)<=0?l(new Error(a)):l()},{BtForm:T,submit:x}=e({data:()=>{var e,l,a,u,t,s,r,n,i,m,c,o,d,v,p,_,b,k,h;return{schedule_time:(null==(a=null==(l=null==(e=g.compData)?void 0:e.backupPlan)?void 0:l.full_backup_schedule)?void 0:a.type)||"daily",weekday:(null==(s=null==(t=null==(u=g.compData)?void 0:u.backupPlan)?void 0:t.full_backup_schedule)?void 0:s.weekday)||"1",interval_days:(null==(i=null==(n=null==(r=g.compData)?void 0:r.backupPlan)?void 0:n.full_backup_schedule)?void 0:i.interval_days)||"1",interval_hours:(null==(o=null==(c=null==(m=g.compData)?void 0:m.backupPlan)?void 0:c.full_backup_schedule)?void 0:o.interval_hours)||"24",allBackupTime:((e="08:00:00")=>{const l=new Date;if(!e)return l;const[a,u,t]=e.split(":").map(Number);return l.setHours(isNaN(a)?0:a,isNaN(u)?0:u,isNaN(t)?0:t,0),l})(null==(h=null==(k=null==(b=g.compData)?void 0:b.backupPlan)?void 0:k.full_backup_schedule)?void 0:h.time),start_date:(()=>{var e,l,a,u,t,s;const r=(null==(a=null==(l=null==(e=g.compData)?void 0:e.backupPlan)?void 0:l.full_backup_schedule)?void 0:a.start_date)?new Date(null==(s=null==(t=null==(u=g.compData)?void 0:u.backupPlan)?void 0:t.full_backup_schedule)?void 0:s.start_date):new Date;return r.setHours(8,0,0,0),r})(),incrementBackupNum:(null==(v=null==(d=g.compData)?void 0:d.backupPlan)?void 0:v.incremental_backup_interval)||"1",incrementBackupType:(null==(_=null==(p=g.compData)?void 0:p.backupPlan)?void 0:_.incremental_backup_interval)?"minute":"hour"}},options:e=>r(()=>[b([k("全量备份","schedule_time",D,{attrs:{class:"!w-[10rem]"}}),..."weekly"===e.value.schedule_time?[k("","weekday",N,{attrs:{class:"!w-[8rem] ml-[1rem]"}})]:[],..."interval"===e.value.schedule_time?[h("","interval_days",{attrs:{class:"!w-[8rem] ml-[1rem]"},slots:{unit:()=>n("span",null,[i("天")])},rules:[{validator:(e,l,a)=>j(l,a,"请输入正确的整数"),trigger:"blur"}]}),y("开始日期",()=>n(m,{class:"!w-[13rem]",modelValue:e.value.start_date,"onUpdate:modelValue":l=>e.value.start_date=l,format:"YYYY-MM-DD","value-format":"x"},null),"start_date",{rules:[{required:!0,message:"请选择开始日期",trigger:["blur","change"]}]})]:[],..."hours"===e.value.schedule_time?[h("","interval_hours",{attrs:{class:"!w-[12rem] ml-[1rem]"},slots:{unit:()=>n("span",{class:"ml-[1rem] inline-block w-[4rem]"},[i("小时")])},rules:[{validator:(e,l,a)=>j(l,a,"请输入正确的整数"),trigger:"blur"}]})]:[y("执行时间",()=>n(c,{class:"!w-[13rem]",modelValue:e.value.allBackupTime,"onUpdate:modelValue":l=>e.value.allBackupTime=l,format:"HH:mm:ss"},null),"allBackupTime",{rules:[{required:!0,message:"请选择执行时间",trigger:["blur","change"]}]})]]),b([y("增量备份",()=>n("span",null,null),"null"),h("每隔","incrementBackupNum",{attrs:{class:"!w-[8rem]"},labelAttrs:{labelWidth:"3.5rem"},rules:[{validator:(e,l,a)=>j(l,a,"请输入正确的整数"),trigger:"blur"}]}),k("","incrementBackupType",B,{attrs:{class:"!w-[8rem] ml-[1rem]"}})])]),submit:async(e,l,a)=>{await l(),H(e,P)}}),H=async(e,u)=>{const t={id:g.compData.id,schedule_type:e.value.schedule_time,incremental_backup_interval:"hour"===e.value.incrementBackupType?60*Number(e.value.incrementBackupNum):Number(e.value.incrementBackupNum),..."hours"!==e.value.schedule_time?{schedule_time:l(e.value.allBackupTime,"HH:mm:ss")}:{interval_hours:e.value.interval_hours},..."weekly"===e.value.schedule_time?{weekday:e.value.weekday}:{},..."interval"===e.value.schedule_time?{interval_days:e.value.interval_days,start_date:l(e.value.start_date,"yyyy-MM-dd")}:{}};await a({loading:"正在保存，请稍候...",request:w(t),message:!0}),g.compData.refreshEvent(),u()};return o(()=>{(async()=>{})()}),t({onConfirm:x}),(e,l)=>(d(),v("div",f,[n(p(T),{labelWidth:"8rem"}),l[0]||(l[0]=_("ul",{class:"mt-8px leading-8 text-small list-disc ml-[4.5rem]"},[_("li",null,"配置保存后，如果备份任务处于启用状态，将按新配置执行。")],-1))]))}}),[["__scopeId","data-v-5a6ea0df"]]);export{g as default};
