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

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

    recordList = [];
    isLoading = false;

    totalNum: Number;
    pageNum: Number = 1;
    pageCount: Number = pageSize;

    startTime;
    endTime;
    timeFormat = 'yyyy-MM-dd';
    obj = {
        startTime: '',
        endTime: '',
        searchStr: '',
        source: ''
    };

    constructor(private workSer: WorkService) {
    }

    ngOnInit() {
        this.getList();
    }

    //获取列表
    getList() {
        const data = {
            pageNum: this.pageNum,
            pageCount: this.pageCount,
            obj: this.obj
        };
        this.workSer.findPage(data).subscribe(
            (res) => {
                this.recordList = res.data.data;
                this.totalNum = res.data.totalNum;
            }
        );
    }

    //搜索
    search() {
        this.pageNum = 1;
        this.getList();
    }

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

    //查看
    lookRecord(data) {

    }

    showAddModal() {

    }

}
