Skip to content

Commit

Permalink
Merge pull request #147 from treadpit/develop
Browse files Browse the repository at this point in the history
add  cancel all selected day function
  • Loading branch information
todrfu authored Aug 1, 2019
2 parents 9ff4ab8 + e6199fb commit 8baf138
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
28 changes: 17 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ import { jump } from '../../component/calendar/main.js';
})
```

#### 4. 跳转至指定日期
#### 5. 跳转至指定日期

```js

Expand All @@ -194,15 +194,21 @@ this.calendar.jump();
this.calendar.jump(2018, 6, 6); // 跳转至2018-6-6
```

#### 5. 获取当前选择的日期
#### 6. 获取当前选择的日期

```js
console.log(this.calendar.getSelectedDay());
```

#### 6. 待办事项
#### 7. 取消所有选中日期

##### 6.1 设置待办标记
```js
this.calendar.cancelAllSelectedDay();
```

#### 8. 待办事项

##### 8.1 设置待办标记

```js
// 待办事项中若有 todoText 字段,则会在待办日期下面显示指定文字,如自定义节日等。
Expand All @@ -226,7 +232,7 @@ this.calendar.setTodoLabels({
});
```

##### 6.2 删除代办标记
##### 8.2 删除代办标记

```js
this.calendar.deleteTodoLabels([{
Expand All @@ -240,18 +246,18 @@ this.calendar.deleteTodoLabels([{
}]);
```

##### 6.3 清空代办标记
##### 8.3 清空代办标记

```js
this.calendar.clearTodoLabels();
```

##### 6.4 获取所有代办日期
##### 8.4 获取所有代办日期
```js
this.calendar.getTodoLabels();
```

#### 7. 禁选指定日期
#### 9. 禁选指定日期

注意:若入参为空数组,则清空所有禁选日期

Expand All @@ -263,7 +269,7 @@ this.calendar.disableDay([{
}]);
```

#### 8. 指定可选日期
#### 10. 指定可选日期

```js
// 指定可选时间区域
Expand All @@ -272,7 +278,7 @@ this.calendar.enableArea(['2018-11-12', '2018-11-30']);
this.calendar.enableDays(['2018-11-12', '2018-12-3', '2019-1-3']);
```

#### 9. 选中指定日期
#### 11. 选中指定日期

<p class="tip">该方法仅在多选模式下可用,初始化日历时请配置 multi。参数为数组,不传参则默认全选当前月份所有日期</p>

Expand All @@ -292,7 +298,7 @@ const toSet = [
this.calendar.setSelectedDays(toSet);
```

#### 10. 周月视图切换
#### 12. 周月视图切换

`switchView('week')`,默认值为'month';

Expand Down
3 changes: 2 additions & 1 deletion src/component/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Component({
},
properties: {
calendarConfig: {
type: Object
type: Object,
value: {}
}
},
lifetimes: {
Expand Down
18 changes: 18 additions & 0 deletions src/component/calendar/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,23 @@ export function getSelectedDay(componentId) {
bindCurrentComponent(componentId, this);
return getData('calendar.selectedDay');
}

/**
* 取消所有选中日期
* @param {string} componentId
*/
export function cancelAllSelectedDay(componentId) {
bindCurrentComponent(componentId, this);
const days = [...getData('calendar.days')];
days.map(item => {
item.choosed = false;
});
setData({
'calendar.days': days,
'calendar.selectedDay': []
});
}

/**
* 跳转至指定日期
*/
Expand Down Expand Up @@ -1325,6 +1342,7 @@ function mountEventsOnPage(page) {
enableArea,
enableDays,
getSelectedDay,
cancelAllSelectedDay,
setTodoLabels,
deleteTodoLabels,
clearTodoLabels,
Expand Down

0 comments on commit 8baf138

Please sign in to comment.