import{a1 as b,k as O,aR as h}from"./index.17037962789732.js";import"./index.170379627897322.js";import"./index.170379627897323.js";import"./index.170379627897315.js";import"./index.1703796278973301.js";import{a as e}from"./dayjs.min.1703796278973.js";import{d as B,k as i,m as D,o as s,x as c,c as p,a as f,F as M,h as w,t as C,A as H,u as v,M as y,B as x,b as T}from"./vue.1703796278973.js";const A=B({__name:"TimeSelect",props:{quickBtn:{type:Boolean,default:!0},quickBtnList:{type:Array,default:[{label:"今日",value:"today"},{label:"近一周",value:"week"},{label:"近一月",value:"month"},{label:"近一年",value:"year"}]},type:{type:String,default:"today"}},emits:["change"],setup(o,{emit:d}){const u=i(o.type||"week"),r=i(),g=a=>{u.value=void 0,d("change",{start:e(a[0]).valueOf(),end:e(a[1]).valueOf(),type:void 0})},_=a=>{switch(a){case"hour":return e().subtract(1,"hours").valueOf();case"week":return e().subtract(6,"days").valueOf();case"month":return e().subtract(29,"days").valueOf();case"year":return e().subtract(365,"days").valueOf();default:return e().startOf("day").valueOf()}},m=a=>{u.value=a;let t=e(new Date).valueOf(),l=_(a);a==="yesterday"&&(l=e().subtract(1,"days").startOf("day").valueOf(),t=e().subtract(1,"days").endOf("day").valueOf()),r.value=[e(l).format("YYYY-MM-DD HH:mm:ss"),e(t).format("YYYY-MM-DD HH:mm:ss")],d("change",{start:l,end:t,type:a})};return m(u.value),D(()=>u.value,{deep:!0,immediate:!0}),(a,t)=>{const l=b,k=O,Y=h;return s(),c("div",null,[o.quickBtn?(s(),p(k,{key:0,"default-value":"today","button-style":"solid",value:v(u),"onUpdate:value":t[0]||(t[0]=n=>y(u)?u.value=n:null),onChange:t[1]||(t[1]=n=>m(n.target.value))},{default:f(()=>[(s(!0),c(M,null,w(o.quickBtnList,n=>(s(),p(l,{key:n.value,value:n.value},{default:f(()=>[C(H(n.label),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])):x("",!0),T(Y,{format:"YYYY-MM-DD HH:mm:ss",valueFormat:"YYYY-MM-DD HH:mm:ss",style:{"margin-left":"12px"},onChange:g,value:v(r),"onUpdate:value":t[2]||(t[2]=n=>y(r)?r.value=n:null),allowClear:!1},null,8,["value"])])}}});export{A as _};
