JQuery fullCalendar 时间差 排序获取距当前最近的时间。

1             let time = (wo: WoDto) => wo.ScheduleTime || wo.ScheduleStartTime;
2 
3             let wo = technician.wos
4                 .filter(x => time(x) != null)
5                 .sort((a, b) =>
6                     Math.abs(moment().diff(moment(time(a)))) -
7                     Math.abs(moment().diff(moment(time(b))))
8             )[0];
9             this.$calendar.fullCalendar('gotoDate', wo ? moment(time(wo)) : moment());

posted @ 2016-03-10 10:34  kumat  阅读(1213)  评论(2编辑  收藏  举报