1 |
- import{d as e,r as t,J as r,b as a,c as l,w as o,e as n,y as s,W as p,ae as d,X as u,A as i,z as x,C as c,l as m,b9 as b,ba as v,E as f,j as g,k as y}from"./index-83368bfa.js";import{_ as h}from"./u-popup.2862f6be.js";import{_ as w}from"./_plugin-vue_export-helper.1b428a4d.js";const D=w(e({__name:"select-date",emits:["confirm"],setup(e,{expose:w,emit:D}){const _=t(!1),$=t([]),k=()=>{const e=new Date,t=[],r=[],a=[],l=e.getFullYear(),o=e.getMonth(),n=e.getDate();for(let f=1990;f<=e.getFullYear()+2;f++)t.push(f);for(let f=1;f<=12;f++)r.push(f);let s=Y(l,o+1);for(let f=1;f<=s;f++)a.push(f);let p=[t.indexOf(l),o,n-1],d=`${l}-${o+1<10?"0"+(o+1):o+1}-${n<10?"0"+n:n}`,u=`${l}-${o+1<10?"0"+(o+1):o+1}-${n<10?"0"+n:n} 00:00:00`,i=`${l}-${o+1<10?"0"+(o+1):o+1}-${n<10?"0"+n:n} 23:59:59`,x=new Date(e.getFullYear(),o-1,e.getDate()),c=new Date(e.getFullYear(),o-3,e.getDate()),m=new Date(e.getFullYear(),o-6,e.getDate()),b=new Date(e.getFullYear()-1,o,e.getDate());const v=e=>{const t=e.getFullYear(),r=e.getMonth()+1,a=e.getDate();return`${t}-${r<10?"0"+r:r}-${a<10?"0"+a:a} 00:00:00`};return{years:t,months:r,days:a,curIndex:p,nowDate:d,nowDateStart:u,nowDateEnd:i,lastMonth:v(x),lastThreeMonth:v(c),halfYear:v(m),lastYear:v(b)}},Y=(e,t)=>new Date(e,t,0).getDate(),C=r({years:k().years,months:k().months,days:k().days,curIndex:k().curIndex,nowDate:[k().nowDateStart,k().nowDateEnd]}),j=e=>{const t=e.detail.value;let r=C.years[t[0]],a=C.months[t[1]],l=C.days[t[2]];C.days=((e,t)=>{let r=Y(e,t),a=[];for(let l=1;l<=r;l++)a.push(l);return a})(r,a),"first"==I.value.type?C.nowDate[0]=`${r}-${a<10?"0"+a:a}-${l<10?"0"+l:l} 00:00:00`:"second"==I.value.type&&(C.nowDate[1]=`${r}-${a<10?"0"+a:a}-${l<10?"0"+l:l} 23:59:59`)},E=r([{time:[k().lastMonth,k().nowDateEnd],type:"lastMonth",name:"近1个月"},{time:[k().lastThreeMonth,k().nowDateEnd],type:"lastThreeMonth",name:"近3个月"},{time:[k().halfYear,k().nowDateEnd],type:"halfYear",name:"近半年"},{time:[k().lastYear,k().nowDateEnd],type:"lastYear",name:"近一年"}]),I=t({type:"first",time:[]}),M=()=>{if("first"==I.value.type||"second"==I.value.type){if($.value=C.nowDate,new Date($.value[0]).getTime()>new Date($.value[1]).getTime())return void c({title:"开始时间不能大于结束时间",icon:"none"})}else $.value=I.value.time;D("confirm",$.value),_.value=!1},F=()=>{I.value.type="first",C.curIndex=k().curIndex,C.nowDate=[k().nowDateStart,k().nowDateEnd]},T=()=>{D("confirm",[]),_.value=!1};return w({show:_}),(e,t)=>{const r=m,c=b,w=v,D=f,$=g(y("u-popup"),h);return a(),l($,{show:_.value,onClose:t[2]||(t[2]=e=>_.value=!1),mode:"bottom",round:10,zIndex:"10090"},{default:o((()=>[n(r,{class:"popup-common relative"},{default:o((()=>[n(r,{class:"title"},{default:o((()=>[s("选择时间")])),_:1}),n(r,{class:"absolute top-[36rpx] right-[36rpx] text-[24rpx] text-[var(--text-color-light6)] leading-[30rpx] z-10",onClick:T},{default:o((()=>[s("清除")])),_:1}),n(r,{class:"px-[var(--popup-sidebar-m)] mb-[20rpx] mt-[10rpx]"},{default:o((()=>[n(r,{class:"flex items-center justify-between mb-[30rpx]"},{default:o((()=>[(a(!0),p(u,null,d(E,((e,t)=>(a(),l(r,{class:i(["w-[160rpx] h-[66rpx] box-border flex-center rounded-[33rpx] bg-[var(--temp-bg)] text-center text-[26rpx] text-[var(--text-color-light6)] border-[2rpx] border-solid border-[var(--temp-bg)]",{"text-primary !border-[var(--primary-color)] !bg-[var(--primary-color-light)]":I.value.type==e.type}]),key:"a"+t,onClick:t=>{return r=e,I.value.type=r.type,I.value.time=r.time,C.nowDate[0]=I.value.time[0],void(C.nowDate[1]=I.value.time[1]);var r}},{default:o((()=>[s(x(e.name),1)])),_:2},1032,["class","onClick"])))),128))])),_:1}),n(r,{class:"flex items-center justify-between"},{default:o((()=>[n(r,{class:i(["w-[316rpx] h-[66rpx] box-border leading-[62rpx] rounded-[33rpx] bg-[var(--temp-bg)] text-center text-[26rpx] text-[var(--text-color-light6)] border-[2rpx] border-solid border-[var(--temp-bg)]",{"text-primary !border-[var(--primary-color)] !bg-[var(--primary-color-light)]":"first"==I.value.type}]),onClick:t[0]||(t[0]=e=>I.value.type="first")},{default:o((()=>[s(x(C.nowDate[0].substr(0,10)),1)])),_:1},8,["class"]),n(r,{class:"nc-iconfont nc-icon-jianV6xx"}),n(r,{class:i(["w-[316rpx] h-[66rpx] box-border leading-[62rpx] rounded-[33rpx] bg-[var(--temp-bg)] text-center text-[26rpx] text-[var(--text-color-light6)] border-[2rpx] border-solid border-[var(--temp-bg)]",{"text-primary !border-[var(--primary-color)] !bg-[var(--primary-color-light)]":"second"==I.value.type}]),onClick:t[1]||(t[1]=e=>I.value.type="second")},{default:o((()=>[s(x(C.nowDate[1].substr(0,10)),1)])),_:1},8,["class"])])),_:1})])),_:1}),n(r,{class:"gradation-picker"},{default:o((()=>[n(w,{"indicator-class":"!h-[80rpx] !bg-[var(--temp-bg)]",value:C.curIndex,onChange:j,class:"w-[750rpx] px-[60rpx] h-[396rpx] box-border"},{default:o((()=>[n(c,null,{default:o((()=>[(a(!0),p(u,null,d(C.years,((e,t)=>(a(),l(r,{class:"text-center leading-[80rpx] text-[28rpx]",key:t},{default:o((()=>[s(x(e)+"年",1)])),_:2},1024)))),128))])),_:1}),n(c,null,{default:o((()=>[(a(!0),p(u,null,d(C.months,((e,t)=>(a(),l(r,{class:"text-center leading-[80rpx] text-[28rpx]",key:t},{default:o((()=>[s(x(e)+"月",1)])),_:2},1024)))),128))])),_:1}),n(c,null,{default:o((()=>[(a(!0),p(u,null,d(C.days,((e,t)=>(a(),l(r,{class:"text-center leading-[80rpx] text-[28rpx]",key:t},{default:o((()=>[s(x(e)+"日",1)])),_:2},1024)))),128))])),_:1})])),_:1},8,["value"])])),_:1}),n(r,{class:"btn-wrap flex justify-between items-center !pt-[30rpx]"},{default:o((()=>[n(D,{class:"btn flex-1 !leading-[76rpx] mr-[20rpx] !text-[var(--primary-color)] border-[2rpx] border-solid border-[var(--primary-color)] rounded-[100rpx] bg-transparent box-border","hover-class":"none",onClick:F},{default:o((()=>[s("重置")])),_:1}),n(D,{class:"btn flex-1 border-[0] rounded-[100rpx] primary-btn-bg",shape:"circle","hover-class":"none",onClick:M},{default:o((()=>[s("确定")])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])}}}),[["__scopeId","data-v-070c0e06"]]);export{D as s};
|