import { Component, OnInit } from '@angular/core';
import {pageSize} from '../../app.constants';
import {WorkService} from '../work.service';

@Component({
  selector: 'smart-work-handle',
  templateUrl: './work-handle.component.html',
  styles: []
})
export class WorkHandleComponent implements OnInit {

    timeFormat = 'yyyy-MM-dd';
    eventList;
    timeBegin;
    timeEnd;
    pageCount = pageSize;
    pageNum = 1;
    totalNum;

    obj = {
        pageCount:null,
        pageNum:null,
        searchStr:'',
        type:null,
        status:null,
        source:null,
        startTime:'',
        endTime:'',
    };
  constructor(private workSer:WorkService) { }

  ngOnInit() {
        this.getList();
  }

  getList(){
      const obj = {
          pageCount:this.pageCount,
          pageNum:this.pageNum,
          searchStr:this.obj.searchStr,
          type:this.obj.type,
          status:this.obj.status,
          source:this.obj.source,
          startTime:this.obj.startTime,
          endTime:this.obj.endTime,
      };
      this.workSer.find(obj).subscribe(
          (res)=>{
            if(res.errCode == 10000){
                this.eventList = res.data.data;
                this.totalNum = res.data.totalNum;
            }else{

            }
          }
      )
  }

    change(e){
        this.pageNum = e;
        this.getList();
    }

}
