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