Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
todrfu committed Oct 13, 2020
2 parents 38c92b9 + 06b8255 commit 331c479
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
15 changes: 11 additions & 4 deletions docs/v2/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,8 @@ calendar.switchView('month').then(() => {});
## 日期范围选择
> 只支持单个连续时间段
::: tip 提示 👇
调用此方法默认打开 `chooseAreaMode` 配置,非连续性日期选择请调用 `setSelectedDates()`
只支持单个连续时间段,调用此方法默认打开 `chooseAreaMode` 配置,非连续性日期选择请调用 `setSelectedDates()`
:::
```js
Expand Down Expand Up @@ -301,14 +299,18 @@ calendarConfig: {
}
```
### 获取当前年份节假日信息
### 获取日历面板当前年份节假日信息
```js
calendar.getHolidaysOfCurrentYear()
```
### 获取指定年份节假日信息
> ::: tip 提示 👇
指定年份节假日信息需自行扩展才可查询到
:::
```js
const year = 2020
calendar.getHolidaysOfYear(year)
Expand All @@ -324,4 +326,9 @@ const lunar = calendar.convertSolarLunar({
month: 8,
date: 30
})

// 或日期字符串

const lunar = calendar.convertSolarLunar('2020-8-30')

```
Binary file modified screenshot/calendar-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/component/v2/plugins/selectable.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ export default () => {
let toSetDates = toSet.map(item => {
let date = { ...item }
if (typeof date === 'string') {
return dateUtil.transformTimeStr2Dict(item)
return dateUtil.transformDateRow2Dict(item)
}
return item
})
if (enableDates.length) {
toSetDates = dateUtil.uniqueArrayByDate([
...toSetDates,
...enableDates.map(d => dateUtil.transformTimeStr2Dict(d))
...enableDates.map(d => dateUtil.transformDateRow2Dict(d))
])
}
return renderCalendar.call(component, {
Expand All @@ -194,14 +194,14 @@ export default () => {
let toSetDates = toSet.map(item => {
let date = { ...item }
if (typeof date === 'string') {
return dateUtil.transformTimeStr2Dict(item)
return dateUtil.transformDateRow2Dict(item)
}
return item
})
if (disableDates && disableDates.length) {
toSetDates = dateUtil.uniqueArrayByDate([
...toSetDates,
...disableDates.map(d => dateUtil.transformTimeStr2Dict(d))
...disableDates.map(d => dateUtil.transformDateRow2Dict(d))
])
}
return renderCalendar.call(component, {
Expand Down
11 changes: 8 additions & 3 deletions src/component/v2/plugins/solarLunar/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dateUtil } from '../../utils'
import convertSolarLunar from './convertSolarLunar'

export default () => {
Expand Down Expand Up @@ -30,10 +31,14 @@ export default () => {
calendarConfig
}
},
methods(component) {
methods() {
return {
convertSolarLunar: (dataInfo = {}) => {
const { year, month, date } = dataInfo
convertSolarLunar: dateInfo => {
if (!dateInfo) return dateInfo
if (typeof dateInfo === 'string' && dateInfo.includes('-')) {
dateInfo = dateUtil.transformDateRow2Dict(dateInfo)
}
const { year, month, date } = dateInfo
return convertSolarLunar.solar2lunar(year, month, date)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/v2/plugins/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default () => {
if (calendarConfig.weekMode && !calendarData.initializedWeekMode) {
const { defaultDate } = calendarConfig
const target =
(defaultDate && dateUtil.transformTimeStr2Dict(defaultDate)) ||
(defaultDate && dateUtil.transformDateRow2Dict(defaultDate)) ||
dateUtil.todayFMD()
const waitRenderData = this.methods(
component
Expand Down
4 changes: 2 additions & 2 deletions src/component/v2/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DateUtil {
*/
getTimeStamp(dateInfo) {
if (typeof dateInfo === 'string') {
dateInfo = this.transformTimeStr2Dict(dateInfo)
dateInfo = this.transformDateRow2Dict(dateInfo)
}
if (Object.prototype.toString.call(dateInfo) !== '[object Object]') return
const dateUtil = new DateUtil()
Expand Down Expand Up @@ -113,7 +113,7 @@ class DateUtil {
toTimeStr(dateInfo = {}) {
return `${+dateInfo.year}-${+dateInfo.month}-${+dateInfo.date}`
}
transformTimeStr2Dict(dateStr) {
transformDateRow2Dict(dateStr) {
if (typeof dateStr === 'string' && dateStr.includes('-')) {
const [year, month, date] = dateStr.split('-')
return this.tranformStr2NumOfDate({
Expand Down

0 comments on commit 331c479

Please sign in to comment.