import{r as d,ak as H,o as F,g as U,a as n,u as v,n as _,b as N,bb as Y,f as c,i as h}from"./app-BYcXwl4U.js";import{u as B}from"./app-a6cKceqE.js";import{_ as I}from"./app-Ufpj4Ll4.js";import{T as z}from"./app-CWQ1YUQz.js";import"./app-B5UbDc9M.js";const P=["name","value"],R={class:"flex items-center gap-3",style:{padding:"0",margin:"0"}},Z=n("div",{class:"ui field"},":",-1),j=n("div",{class:"ui field"},":",-1),q={class:"comment"},A=n("span",{class:"disabled"},"|",-1),G=n("span",{class:"disabled"},"|",-1),J=n("span",{class:"disabled"},"|",-1),K=n("span",{class:"disabled"},"|",-1),L=n("span",{class:"disabled"},"|",-1),te={__name:"DatetimeInput",props:["v-name","v-timestamp"],setup(T,{expose:$}){B();const k=T,a=function(t,e){if(t=t.toString(),e<=t.length)return t;for(let l=0;l<e-t.length;l++)t="0"+t;return t},{timestamp:y,day:s,hour:u,minute:o,second:i,hasDayError:D,hasHourError:x,hasMinuteError:M,hasSecondError:V}=function(){let t=k.vTimestamp;t!=null?(t=parseInt(t),isNaN(t)&&(t=0)):t=0;let e="",l="",f="",p="";if(t>0){let r=new Date;r.setTime(t*1e3);let g=r.getFullYear().toString(),w=a((r.getMonth()+1).toString(),2);e=g+"-"+w+"-"+a(r.getDate().toString(),2),l=a(r.getHours().toString(),2),f=a(r.getMinutes().toString(),2),p=a(r.getSeconds().toString(),2)}return{timestamp:d(t),day:d(e),hour:d(l),minute:d(f),second:d(p),hasDayError:d(!1),hasHourError:d(!1),hasMinuteError:d(!1),hasSecondError:d(!1)}}(),m=function(){if(!/^\d{4}-\d{1,2}-\d{1,2}$/.test(s.value)){D.value=!0,y.value=0;return}let t=s.value.split("-"),e=parseInt(t[0]),l=parseInt(t[1]);if(l<1||l>12){D.value=!0;return}let f=parseInt(t[2]);if(f<1||f>32){D.value=!0;return}if(D.value=!1,!/^\d+$/.test(u.value)){x.value=!0;return}let p=parseInt(u.value);if(isNaN(p)){x.value=!0;return}if(p<0||p>=24){x.value=!0;return}if(x.value=!1,!/^\d+$/.test(o.value)){M.value=!0;return}let r=parseInt(o.value);if(isNaN(r)){M.value=!0;return}if(r<0||r>=60){M.value=!0;return}if(M.value=!1,!/^\d+$/.test(i.value)){V.value=!0;return}let g=parseInt(i.value);if(isNaN(g)){V.value=!0;return}if(g<0||g>=60){V.value=!0;return}V.value=!1;let w=new Date(e,l-1,f,p,r,g);y.value=Math.floor(w.getTime()/1e3)},E=function(){return y.value},b=function(){let t=new Date;t.setFullYear(t.getFullYear()+1),s.value=t.getFullYear()+"-"+a(t.getMonth()+1,2)+"-"+a(t.getDate(),2),u.value=a(t.getHours(),2),o.value=a(t.getMinutes(),2),i.value=a(t.getSeconds(),2),m()},S=function(t){let e=new Date;e.setTime(e.getTime()+t*86400*1e3),s.value=e.getFullYear()+"-"+a(e.getMonth()+1,2)+"-"+a(e.getDate(),2),u.value=a(e.getHours(),2),o.value=a(e.getMinutes(),2),i.value=a(e.getSeconds(),2),m()},C=function(t){let e=new Date;e.setTime(e.getTime()+t*3600*1e3),s.value=e.getFullYear()+"-"+a(e.getMonth()+1,2)+"-"+a(e.getDate(),2),u.value=a(e.getHours(),2),o.value=a(e.getMinutes(),2),i.value=a(e.getSeconds(),2),m()};return $({resultTimestamp:E}),H(()=>{y.value<0&&(s.value=new Date().format("Y-m-d"),u.value="23",o.value="59",i.value="59"),m()}),(t,e)=>(F(),U("div",null,[n("input",{type:"hidden",name:t.vName,value:v(y)},null,8,P),n("div",R,[n("div",{class:_(["ui field",{error:v(D)}])},[N(z,{type:"text",modelValue:v(s),"onUpdate:modelValue":e[0]||(e[0]=l=>Y(s)?s.value=l:null),placeholder:"YYYY-MM-DD",style:{width:"8.2em"},maxlength:"10",onChange:m},null,8,["modelValue"])],2),n("div",{class:_(["ui field",{error:v(x)}])},[N(I,{type:"text",modelValue:v(u),"onUpdate:modelValue":e[1]||(e[1]=l=>Y(u)?u.value=l:null),maxlength:"2",style:{width:"3.6em"},placeholder:"时",onInput:m},null,8,["modelValue"])],2),Z,n("div",{class:_(["ui field",{error:v(M)}])},[N(I,{type:"text",modelValue:v(o),"onUpdate:modelValue":e[2]||(e[2]=l=>Y(o)?o.value=l:null),maxlength:"2",style:{width:"3.6em"},placeholder:"分",onInput:m},null,8,["modelValue"])],2),j,n("div",{class:_(["ui field",{error:v(V)}])},[N(I,{type:"text",modelValue:v(i),"onUpdate:modelValue":e[3]||(e[3]=l=>Y(i)?i.value=l:null),maxlength:"2",style:{width:"3.6em"},placeholder:"秒",onInput:m},null,8,["modelValue"])],2)]),n("p",q,[c("常用时间："),n("a",{href:"",onClick:e[4]||(e[4]=h(l=>C(1),["prevent"]))},"  1小时  "),A,c(),n("a",{href:"",onClick:e[5]||(e[5]=h(l=>S(1),["prevent"]))},"  1天  "),G,c(),n("a",{href:"",onClick:e[6]||(e[6]=h(l=>S(3),["prevent"]))},"  3天  "),J,c(),n("a",{href:"",onClick:e[7]||(e[7]=h(l=>S(7),["prevent"]))},"  1周  "),K,c(),n("a",{href:"",onClick:e[8]||(e[8]=h(l=>S(30),["prevent"]))},"  30天  "),L,c(),n("a",{href:"",onClick:e[9]||(e[9]=h(l=>b(),["prevent"]))},"  1年  ")])]))}};export{te as _};
