xufenglei
2018-07-31 e2750980d182c135384dd3b691b2d28e297b7145
src/app/routes/statistics/calendar/calendar.component.ts
@@ -14,7 +14,13 @@
export class CalendarComponent implements OnInit, OnDestroy {
    data: any = {};
    public calendarDayCells:{
       [key : string] : {
         'status': string,
         'statusName': string,
         'data': {}
       }
    } = {};
    constructor(
        private deviceService: DeviceService,
        private http: _HttpClient,
@@ -23,34 +29,30 @@
    }
    ngOnInit() {
        const searchData = [];
        for (let i = 0; i < 50; i += 1) {
            searchData.push({
                index: i + 1,
                point: `监测站点-${i}`,
                value: Math.floor(Math.random() * 100)
            });
        const day = Number(moment().format('DD'));
        for(let index = 1;index <= day; index++) {
            this.calendarDayCells[('0'+index).slice(-2)] = {
                status: 'processing',
                statusName: '加载中',
                data: {}
            }
        }
        this.data = {
            searchData: searchData
        };
        // console.log(this.calendarDayCells);
    }
    ngOnDestroy(): void {
    }
    sort(sortName, sortValue) {
        this.data.searchData = [
            ...(<any[]>this.data.searchData).sort((a, b) => {
                if (a[sortName] > b[sortName]) {
                    return (sortValue === 'ascend') ? 1 : -1;
                } else if (a[sortName] < b[sortName]) {
                    return (sortValue === 'ascend') ? -1 : 1;
                } else {
                    return 0;
                }
            })
        ];
    // 日历单元格 被点击
    calendarClick(mo: moment.Moment) {
        console.log(mo.format('DD'));
    }
    public isExpire(mo: moment.Moment):boolean {
        //  console.log(moment().valueOf());
        //  console.log(mo.valueOf());
        //  console.log(moment().valueOf() < mo.valueOf());
         return moment().valueOf() < mo.valueOf();
    }
    loadCalendar(event) {
        console.log(event);
    }
}