From 188f16a34a6a501d70cbaf986cd06a283d8798db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0o=E5=BC=A0=E4=B8=8D=E6=AD=AAo0?= Date: Thu, 14 Jul 2022 23:35:55 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(component):=20datePicker=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datePicker/components/DatePanel.vue | 160 +++++ .../datePicker/components/MonthPanel.vue | 85 +++ .../datePicker/components/PanelFoot.vue | 47 ++ .../datePicker/components/TimePanel.vue | 53 ++ .../datePicker/components/YearPanel.vue | 43 ++ .../component/src/component/datePicker/day.ts | 45 +- .../src/component/datePicker/index.less | 7 + .../src/component/datePicker/index.vue | 591 ++++-------------- .../src/component/datePicker/interface.ts | 18 + .../document/zh-CN/components/datePicker.md | 8 +- 10 files changed, 593 insertions(+), 464 deletions(-) create mode 100644 package/component/src/component/datePicker/components/DatePanel.vue create mode 100644 package/component/src/component/datePicker/components/MonthPanel.vue create mode 100644 package/component/src/component/datePicker/components/PanelFoot.vue create mode 100644 package/component/src/component/datePicker/components/TimePanel.vue create mode 100644 package/component/src/component/datePicker/components/YearPanel.vue diff --git a/package/component/src/component/datePicker/components/DatePanel.vue b/package/component/src/component/datePicker/components/DatePanel.vue new file mode 100644 index 00000000..9a08e15f --- /dev/null +++ b/package/component/src/component/datePicker/components/DatePanel.vue @@ -0,0 +1,160 @@ + + + \ No newline at end of file diff --git a/package/component/src/component/datePicker/components/MonthPanel.vue b/package/component/src/component/datePicker/components/MonthPanel.vue new file mode 100644 index 00000000..68f3a357 --- /dev/null +++ b/package/component/src/component/datePicker/components/MonthPanel.vue @@ -0,0 +1,85 @@ + + + \ No newline at end of file diff --git a/package/component/src/component/datePicker/components/PanelFoot.vue b/package/component/src/component/datePicker/components/PanelFoot.vue new file mode 100644 index 00000000..05c2ae8e --- /dev/null +++ b/package/component/src/component/datePicker/components/PanelFoot.vue @@ -0,0 +1,47 @@ + + + \ No newline at end of file diff --git a/package/component/src/component/datePicker/components/TimePanel.vue b/package/component/src/component/datePicker/components/TimePanel.vue new file mode 100644 index 00000000..867d794f --- /dev/null +++ b/package/component/src/component/datePicker/components/TimePanel.vue @@ -0,0 +1,53 @@ + + + \ No newline at end of file diff --git a/package/component/src/component/datePicker/components/YearPanel.vue b/package/component/src/component/datePicker/components/YearPanel.vue new file mode 100644 index 00000000..cdce3c82 --- /dev/null +++ b/package/component/src/component/datePicker/components/YearPanel.vue @@ -0,0 +1,43 @@ + + + \ No newline at end of file diff --git a/package/component/src/component/datePicker/day.ts b/package/component/src/component/datePicker/day.ts index 9e46ecc4..3c66e814 100644 --- a/package/component/src/component/datePicker/day.ts +++ b/package/component/src/component/datePicker/day.ts @@ -52,4 +52,47 @@ const getDayLength = (year: number, month: number): number => { return new Date(year, month + 1, 0).getDate(); }; -export { getDayLength, getYears, getDate, getMonth, getYear, getDay }; + +// 设置日期列表 +const setDateList = (year: number, month: number) => { + const curDays = getDayLength(year, month); // 当月天数 + const prevDays = getDayLength(year, month - 1); // 上月天数 + const curFirstDayWeek = new Date(year, month, 1).getDay(); // 当月第一天星期几 + const list: any[] = []; + // 填充上月天数 + for (let i = prevDays - curFirstDayWeek + 1; i <= prevDays; i++) { + list.push({ + day: i, + value: +new Date(year, month - 1, i), + isRange: false, + isSelected: false, + type: "prev", + }); + } + // 填充当月天数 + for (let i = 1; i <= curDays; i++) { + list.push({ + day: i, + value: +new Date(year, month, i), + isRange: false, + isSelected: false, + type: "current", + }); + } + // 填充下月天数 + const nextDays = 7 - (list.length % 7); + if (nextDays !== 7) { + for (let i = 1; i <= nextDays; i++) { + list.push({ + day: i, + value: +new Date(year, month + 1, i), + isRange: false, + isSelected: false, + type: "next", + }); + } + } + return list; +}; + +export { getDayLength, getYears, getDate, getMonth, getYear,getDay,setDateList }; diff --git a/package/component/src/component/datePicker/index.less b/package/component/src/component/datePicker/index.less index cc81a475..06d3546a 100644 --- a/package/component/src/component/datePicker/index.less +++ b/package/component/src/component/datePicker/index.less @@ -459,3 +459,10 @@ html #layuicss-laydate { height: 71px; line-height: 71px; } +.laydate-range-hover{ + background-color: var(--global-checked-color) !important; + color: white !important; +} +.layui-laydate-content .layui-disabled:hover{ + background-color: transparent !important; +} \ No newline at end of file diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index ae7a5ca4..6c31ef58 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -1,277 +1,19 @@