import{c as e,r as a,V as l,w as t,q as r,v as u,N as o,B as m,e as n,z as s,y as d,D as p,C as i,A as v,o as y,ab as h,a9 as w}from"./base-lib.js?v=1761009159";import{M as c,ax as b,k as f}from"./utils-lib.js?v=1761009159";import{bs as V}from"./firewall.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const k={class:"flex"},_=e({__name:"repair-crontab",props:{compData:{default:()=>{}}},setup(e,{expose:_}){const x=e,g=a(null),j=a({type:"day",week:1,where1:1,hour:1,minute:19}),D=l([{label:"每天",value:"day"},{label:"N天",value:"day-n"},{label:"每星期",value:"week"},{label:"每月",value:"month"}]),M=l([{label:"周一",value:1},{label:"周二",value:2},{label:"周三",value:3},{label:"周四",value:4},{label:"周五",value:5},{label:"周六",value:6},{label:"周日",value:7}]);t(()=>x.compData,e=>{C("day")});const U={type:[{validator:(e,a,l)=>"day-n"!==a&&"month"!==a||!(j.value.where1<0||j.value.where1>31)?j.value.hour<0||j.value.hour>23?l(new Error("请输入正确小时范围[0-23]")):j.value.minute<0||j.value.minute>59?l(new Error("请输入正确分钟范围[0-59]")):void l():l(new Error("请输入正确天数范围[0-31]")),trigger:["blur","change"]}]},C=e=>{j.value.type=e;let a=Math.round(5*Math.random()),l=Math.round(59*Math.random());j.value.hour=a,j.value.minute=l,"day-n"===e?j.value.where1=3:"week"===e?j.value.week=1:j.value.where1=3},E=()=>{g.value.resetFields(),x.compData.refreshEvent()};return r(()=>{}),_({onConfirm:async e=>{await g.value.validate();let a=c.load("正在处理中，请稍后...");try{var l=y({id:x.compData.id,type:j.value.type,hour:j.value.hour,minute:j.value.minute});"day-n"!==j.value.type&&"month"!==j.value.type||(l.where1=j.value.where1),"week"===j.value.type&&(l.week=j.value.week);const a=await V({data:JSON.stringify(l)});c.request(a),E(),e()}catch(t){}finally{a.close()}},onCancel:E}),(e,a)=>{const l=b,t=f,r=h,y=w;return u(),o(y,{ref_key:"repairCronRef",ref:g,model:d(j),rules:U,class:"p-[2rem] addfrom","label-width":"5rem"},{default:m(()=>[n(r,{label:"检测频率",prop:"type"},{default:m(()=>[s("div",k,[n(l,{class:"!w-[8rem] mr-4",modelValue:d(j).type,"onUpdate:modelValue":a[0]||(a[0]=e=>d(j).type=e),options:d(D),change:C},null,8,["modelValue","options"]),"week"===d(j).type?(u(),o(l,{key:0,class:"!w-[8rem] mr-4",modelValue:d(j).week,"onUpdate:modelValue":a[1]||(a[1]=e=>d(j).week=e),options:d(M)},null,8,["modelValue","options"])):p("",!0),"day-n"===d(j).type||"month"===d(j).type?(u(),o(t,{key:1,type:"number",class:"mr-4",width:"12rem",min:"0",max:"31",modelValue:d(j).where1,"onUpdate:modelValue":a[2]||(a[2]=e=>d(j).where1=e)},{append:m(()=>[i(v("day-n"===d(j).type?"天":"日"),1)]),_:1},8,["modelValue"])):p("",!0),n(t,{type:"number",width:"12rem",class:"mr-4",min:"0",max:"23",modelValue:d(j).hour,"onUpdate:modelValue":a[3]||(a[3]=e=>d(j).hour=e)},{append:m(()=>a[5]||(a[5]=[i("小时",-1)])),_:1},8,["modelValue"]),n(t,{type:"number",width:"12rem",min:"0",max:"59",modelValue:d(j).minute,"onUpdate:modelValue":a[4]||(a[4]=e=>d(j).minute=e)},{append:m(()=>a[6]||(a[6]=[i("分",-1)])),_:1},8,["modelValue"])])]),_:1})]),_:1},8,["model"])}}});export{_ as default};
