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,o as r,x as c,c as f,a as p,F as D,h as H,t as M,A as w,u as v,M as y,B as C,b as x}from"./vue.1703796278973.js";const S=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:m}){const u=i(o.type||"week"),s=i(),g=a=>{u.value=void 0,m("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()}},d=a=>{u.value=a;let t=e(new Date).valueOf(),l=_(a);a==="today"&&(l=e().subtract(0,"days").startOf("day").valueOf(),t=e().subtract(0,"days").endOf("day").valueOf()),s.value=[e(l).format("YYYY-MM-DD HH:mm:ss"),e(t).format("YYYY-MM-DD HH:mm:ss")],m("change",{start:l,end:t,type:a})};return d(u.value),(a,t)=>{const l=b,k=O,Y=h;return r(),c("div",null,[o.quickBtn?(r(),f(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=>d(n.target.value))},{default:p(()=>[(r(!0),c(D,null,H(o.quickBtnList,n=>(r(),f(l,{key:n.value,value:n.value},{default:p(()=>[M(w(n.label),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])):C("",!0),x(Y,{format:"YYYY-MM-DD HH:mm:ss",valueFormat:"YYYY-MM-DD HH:mm:ss",style:{"margin-left":"12px"},"show-time":{format:"HH:mm:ss"},onChange:g,value:v(s),"onUpdate:value":t[2]||(t[2]=n=>y(s)?s.value=n:null),allowClear:!1},null,8,["value"])])}}});export{S as _};
