import{V as I,k as S,r as A,I as J,m as M,a0 as R,cz as q,a5 as z,a6 as W,F as G}from"./index.17037962789732.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897325.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import"./index.170379627897324.js";import"./index.170379627897322.js";import"./index.170379627897323.js";import"./index.170379627897315.js";import"./index.170379627897336.js";import"./index.170379627897314.js";import"./index.1703796278973301.js";import{a as v}from"./dayjs.min.1703796278973.js";import K from"./WhenOption.1703796278973.js";import{i as L}from"./regular.1703796278973.js";import{d as h,k as w,v as Q,l as _,w as X,o as p,c,a as l,b as n,u as t,x as Y,F as Z,t as f,B as b}from"./vue.1703796278973.js";const $=h({name:"Timer"}),ge=h({...$,props:{name:{type:[String,Array],default:""},value:{type:Object,default:()=>({})}},emits:["update:value"],setup(k,{expose:x,emit:j}){const d=k,i=w(99),C=[{max:64,message:"最多可输入64个字符"},{validator:async(r,o)=>{if(o){if(!L(o))return Promise.reject(new Error("请输入正确的cron表达式"))}else return Promise.reject(new Error("请输入cron表达式"));return Promise.resolve()}}],e=Q({trigger:"week",when:d.value.when||[],mod:"period",cron:void 0,once:{time:v(new Date).format("HH:mm:ss")},period:{from:v(new Date).startOf("day").format("HH:mm:ss"),to:v(new Date).endOf("day").format("HH:mm:ss"),every:1,unit:"seconds"}}),g=w(),H=_(()=>e.trigger==="cron"),F=_(()=>e.trigger!=="cron"&&e.mod==="once"),U=_(()=>e.trigger!=="cron"&&e.mod==="period"),u=()=>{const r=I(e);r.trigger==="cron"?delete r.when:delete r.cron,r.mod==="period"?delete r.once:delete r.period,j("update:value",r)},P=()=>{e.when=[],e.cron=void 0,u()},O=r=>{r==="hours"?i.value=99999:i.value=99,e.period.every=1,u()};return x({validateFields:()=>new Promise(async r=>{var m;const o=await((m=g.value)==null?void 0:m.validateFields());r(o)})}),Object.assign(e,d.value),e.when=d.value.when||[],X(()=>{var r,o;((o=(r=d.value)==null?void 0:r.period)==null?void 0:o.unit)==="hours"?i.value=99999:i.value=99}),(r,o)=>{const m=S,s=A,V=J,B=M,y=R,D=q,E=z,N=W,T=G;return p(),c(T,{ref_key:"timerForm",ref:g,model:t(e),layout:"vertical",colon:!1},{default:l(()=>[n(s,{name:"trigger"},{default:l(()=>[n(m,{value:t(e).trigger,"onUpdate:value":o[0]||(o[0]=a=>t(e).trigger=a),options:[{label:"按周",value:"week"},{label:"按月",value:"month"},{label:"cron表达式",value:"cron"}],"option-type":"button","button-style":"solid",onChange:P},null,8,["value"])]),_:1}),t(H)?(p(),c(s,{key:0,name:"cron",rules:C},{default:l(()=>[n(V,{placeholder:"corn表达式",value:t(e).cron,"onUpdate:value":o[1]||(o[1]=a=>t(e).cron=a),onChange:u},null,8,["value"])]),_:1})):(p(),Y(Z,{key:1},[n(s,{name:"when"},{default:l(()=>[n(K,{value:t(e).when,"onUpdate:value":o[2]||(o[2]=a=>t(e).when=a),type:t(e).trigger,onChange:u},null,8,["value","type"])]),_:1}),n(s,{name:"mod"},{default:l(()=>[n(m,{value:t(e).mod,"onUpdate:value":o[3]||(o[3]=a=>t(e).mod=a),options:[{label:"周期执行",value:"period"},{label:"执行一次",value:"once"}],"option-type":"button","button-style":"solid",onChange:u},null,8,["value"])]),_:1})],64)),t(F)?(p(),c(y,{key:2,style:{display:"flex",gap:"24px"}},{default:l(()=>[n(s,{name:["once","time"]},{default:l(()=>[n(B,{valueFormat:"HH:mm:ss",value:t(e).once.time,"onUpdate:value":o[4]||(o[4]=a=>t(e).once.time=a),style:{width:"100%"},format:"HH:mm:ss",onChange:u},null,8,["value"])]),_:1}),n(s,null,{default:l(()=>[f(" 执行一次")]),_:1})]),_:1})):b("",!0),t(U)?(p(),c(y,{key:3,style:{display:"flex",gap:"24px"}},{default:l(()=>[n(s,null,{default:l(()=>[n(D,{valueFormat:"HH:mm:ss",value:[t(e).period.from,t(e).period.to],onChange:o[5]||(o[5]=a=>{t(e).period.from=a[0],t(e).period.to=a[1],u()})},null,8,["value"])]),_:1}),n(s,null,{default:l(()=>[f("每")]),_:1}),n(s,{name:["period","every"],rules:[{required:!0,message:"请输入时间"}]},{default:l(()=>[n(N,{placeholder:"请输入时间",style:{"max-width":"170px"},precision:0,min:1,max:t(i),value:t(e).period.every,"onUpdate:value":o[7]||(o[7]=a=>t(e).period.every=a),onChange:u},{addonAfter:l(()=>[n(E,{value:t(e).period.unit,"onUpdate:value":o[6]||(o[6]=a=>t(e).period.unit=a),options:[{label:"秒",value:"seconds"},{label:"分",value:"minutes"},{label:"小时",value:"hours"}],onSelect:O},null,8,["value"])]),_:1},8,["max","value"])]),_:1}),n(s,null,{default:l(()=>[f("执行一次")]),_:1})]),_:1})):b("",!0)]),_:1},8,["model"])}}});export{ge as _};
