Skip to content

Commit

Permalink
设置label年月日类型为字符串时标记不显示
Browse files Browse the repository at this point in the history
  • Loading branch information
Dengrong Fu authored and Dengrong Fu committed Jun 23, 2018
1 parent d1e3221 commit 244d4d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pages":[
"pages/index/index",
"pages/calendarTemplate/index",
"pages/index/index",
"pages/calendar/index",
"pages/datepickerTemplate/index"
],
Expand Down
30 changes: 17 additions & 13 deletions src/pages/calendarTemplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ const conf = {
* 日历初次渲染完成后触发事件,如设置事件标记
*/
afterCalendarRender() {
setTodoLabels({
pos: 'bottom',
dotColor: '#40',
days: [{
year: 2018,
month: 5,
day: 12,
}, {
year: 2018,
month: 5,
day: 15,
}],
});
const data = [{
year: '2018',
month: '6',
day: '15',
}, {
year: 2018,
month: 6,
day: 18,
}];
// 异步请求
setTimeout(() => {
setTodoLabels({
pos: 'bottom',
dotColor: '#40',
days: data,
});
}, 1000);
},
});
},
Expand Down
8 changes: 4 additions & 4 deletions src/template/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const conf = {
if (calendar.todoLabels) {
// 过滤所有待办日期中当月有待办事项的日期
shouldMarkerTodoDay = calendar.todoLabels.filter(item => {
return item.year === dYear && item.month === dMonth;
return +item.year === dYear && +item.month === dMonth;
});
}
shouldMarkerTodoDay.forEach(item => {
Expand All @@ -376,13 +376,13 @@ const conf = {
days.map((_item, idx) => {
if (_item.day === item.day) {
days[ idx ].hasTodo = true;
if (selectedDays[ 0 ].day === item.day) days[ idx ].showTodoLabel = true;
if (selectedDays[ 0 ].day === +item.day) days[ idx ].showTodoLabel = true;
}
});
} else {
days[ item.day - 1 ].hasTodo = true;
// showTodoLabel 是否显示待办标记
if (selectedDays[ 0 ].day === item.day) days[ selectedDays[ 0 ].day - 1 ].showTodoLabel = true;
if (selectedDays[ 0 ].day === +item.day) days[ selectedDays[ 0 ].day - 1 ].showTodoLabel = true;
}
});
if (days[ idx ].showTodoLabel) days[ idx ].showTodoLabel = false;
Expand Down Expand Up @@ -445,7 +445,7 @@ const conf = {
if (!todos.length) return;
const todoLabels = conf.filterTodos.call(this, todos);
const { days, curYear, curMonth } = this.data.calendar;
const currentMonthTodoLabels = todoLabels.filter(item => curYear === item.year && curMonth === item.month);
const currentMonthTodoLabels = todoLabels.filter(item => curYear === +item.year && curMonth === +item.month);
days.map(item => {
item.showTodoLabel = false;
});
Expand Down

0 comments on commit 244d4d9

Please sign in to comment.