|
|
-import{s as w,f as T,a as m,g as E,p as I}from"./utils-f80b730c.js";import{P as N}from"./index-3a5a38fe.js";import{c as S,aj as j,d4 as D,d as A,r as g,e as B,w as y,dm as u,a as K,h as R,al as U,k as _}from"./index-6205d9f4.js";const x=new Date().getFullYear(),[b]=S("date-picker"),q=j({},w,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(x-10,0,1),validator:D},maxDate:{type:Date,default:()=>new Date(x+10,11,31),validator:D}});var z=A({name:b,props:q,emits:["confirm","cancel","change","update:modelValue"],setup(a,{emit:r,slots:v}){const n=g(a.modelValue),l=g(!1),M=()=>{const e=a.minDate.getFullYear(),t=a.maxDate.getFullYear();return m(e,t,"year",a.formatter,a.filter)},i=e=>e===a.minDate.getFullYear(),d=e=>e===a.maxDate.getFullYear(),Y=e=>e===a.minDate.getMonth()+1,V=e=>e===a.maxDate.getMonth()+1,s=e=>{const{minDate:t,columnsType:o}=a,c=o.indexOf(e),h=l.value?a.modelValue[c]:n.value[c];if(h)return+h;switch(e){case"year":return t.getFullYear();case"month":return t.getMonth()+1;case"day":return t.getDate()}},k=()=>{const e=s("year"),t=i(e)?a.minDate.getMonth()+1:1,o=d(e)?a.maxDate.getMonth()+1:12;return m(t,o,"month",a.formatter,a.filter)},C=()=>{const e=s("year"),t=s("month"),o=i(e)&&Y(t)?a.minDate.getDate():1,c=d(e)&&V(t)?a.maxDate.getDate():E(e,t);return m(o,c,"day",a.formatter,a.filter)},f=B(()=>a.columnsType.map(e=>{switch(e){case"year":return M();case"month":return k();case"day":return C();default:return[]}}));y(n,e=>{u(e,a.modelValue)||r("update:modelValue",e)}),y(()=>a.modelValue,(e,t)=>{l.value=u(t,n.value),e=T(e,f.value),u(e,n.value)||(n.value=e),l.value=!1},{immediate:!0});const P=(...e)=>r("change",...e),F=(...e)=>r("cancel",...e),O=(...e)=>r("confirm",...e);return()=>K(N,R({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:f.value,onChange:P,onCancel:F,onConfirm:O},U(a,I)),v)}});const L=_(z);export{L as D};
|
|
|
+import{s as w,f as T,a as m,g as E,p as I}from"./utils-4d65c8d4.js";import{P as N}from"./index-bbae9e2d.js";import{c as S,aj as j,d4 as D,d as A,r as g,e as B,w as y,dm as u,a as K,h as R,al as U,k as _}from"./index-be590f4a.js";const x=new Date().getFullYear(),[b]=S("date-picker"),q=j({},w,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(x-10,0,1),validator:D},maxDate:{type:Date,default:()=>new Date(x+10,11,31),validator:D}});var z=A({name:b,props:q,emits:["confirm","cancel","change","update:modelValue"],setup(a,{emit:r,slots:v}){const n=g(a.modelValue),l=g(!1),M=()=>{const e=a.minDate.getFullYear(),t=a.maxDate.getFullYear();return m(e,t,"year",a.formatter,a.filter)},i=e=>e===a.minDate.getFullYear(),d=e=>e===a.maxDate.getFullYear(),Y=e=>e===a.minDate.getMonth()+1,V=e=>e===a.maxDate.getMonth()+1,s=e=>{const{minDate:t,columnsType:o}=a,c=o.indexOf(e),h=l.value?a.modelValue[c]:n.value[c];if(h)return+h;switch(e){case"year":return t.getFullYear();case"month":return t.getMonth()+1;case"day":return t.getDate()}},k=()=>{const e=s("year"),t=i(e)?a.minDate.getMonth()+1:1,o=d(e)?a.maxDate.getMonth()+1:12;return m(t,o,"month",a.formatter,a.filter)},C=()=>{const e=s("year"),t=s("month"),o=i(e)&&Y(t)?a.minDate.getDate():1,c=d(e)&&V(t)?a.maxDate.getDate():E(e,t);return m(o,c,"day",a.formatter,a.filter)},f=B(()=>a.columnsType.map(e=>{switch(e){case"year":return M();case"month":return k();case"day":return C();default:return[]}}));y(n,e=>{u(e,a.modelValue)||r("update:modelValue",e)}),y(()=>a.modelValue,(e,t)=>{l.value=u(t,n.value),e=T(e,f.value),u(e,n.value)||(n.value=e),l.value=!1},{immediate:!0});const P=(...e)=>r("change",...e),F=(...e)=>r("cancel",...e),O=(...e)=>r("confirm",...e);return()=>K(N,R({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:f.value,onChange:P,onCancel:F,onConfirm:O},U(a,I)),v)}});const L=_(z);export{L as D};
|