import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { BsModalService } from 'ngx-bootstrap/modal';
import { CookieService } from 'ngx-cookie-service';
import { AjaxService } from '../../../../../core/service/ajax.service';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';

@Component({
  selector: 'app-exam-interview-aspect-total',
  templateUrl: './exam-interview-aspect-total.component.html',
  styleUrls: ['./exam-interview-aspect-total.component.scss']
})
export class ExamInterviewAspectTotalComponent extends FramePageComponent implements OnInit {

  dateArray: any;
  agent:any;
  flag:boolean = true;

  constructor(private modalService: BsModalService, private router: Router, private cookies: CookieService,) {
    super(modalService);
    const agent_id = this.cookies.get('CurrentAgentId');
    if (agent_id !== undefined && agent_id.length > 0) {
      // 去获取
      AjaxService.requestEntity('layout/agent/find.htm', {ly_agent_id: agent_id}, (entity) => {
        this.agent = entity;
        AjaxService.requestArray('exam/judge/extract/date/list.htm', {ly_agent_id: agent_id}, (array) => {
          this.dateArray = array;
        });
      });
    } else {
      this.router.navigate(['/art/layout/agent/page']);
    }
   }

  ngOnInit() {
  }

  changeDate() {
    this.flag=false;
    this.pager.reload({exam_date: this.agent.exam_date});
  }

  downloadAspectTotal() {
    let entity = {
      ly_agent_id: this.agent.ly_agent_id,
      ly_exam_date: this.agent.exam_date,
      report_name:'ExamAspectTotalReport',
      report_title :'考试科目汇总表'
    };
    this.FuncService.ajaxDownload('frame/report/download.htm', entity);
  }

}
