import { Component, OnInit } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { VideoAppReportStdComponent } from '../video-app-report-std/video-app-report-std.component';
import { MsgService } from '../../../../../core/service/msg.service';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import { AjaxService } from '../../../../../core/service/ajax.service';

@Component({
  selector: 'app-video-app-report',
  templateUrl: './video-app-report.component.html',
  styleUrls: ['./video-app-report.component.scss']
})
export class VideoAppReportComponent extends FramePageComponent implements OnInit {

  agentArray = [];
  dateArray = [];
  roomArray = [];
  array = [];
  no_vieo_total = 0;
  video: any;

  constructor(private modalService: BsModalService) { 
    super(modalService);
    this.goInit();
  }

  ngOnInit() {
    this.rquestVideo();
  }

  goInit() {
    this.agentArray = [];
    this.dateArray = [];
    this.roomArray = [];
    this.video = {};
    AjaxService.requestArray('conf/agent/list/dept.htm', {}, (array) => {
      this.agentArray = array;
      if (this.agentArray.length === 1) {
        this.video.agent_id = this.agentArray[0].ly_agent_id;
        this.video.ly_agent_id = this.agentArray[0].ly_agent_id;
        this.rquestVideo();
      }
    });
  }

  requestDate() {
    this.video.agent_id = this.video.ly_agent_id;
    AjaxService.requestArray('exam/checkin/init/date.htm', this.video, (array) => {
        this.dateArray = array;
      if (this.dateArray.length === 1) {
        this.video.exam_date = this.dateArray[0].exam_date;
        this.rquestVideo();
      }
    });
  }

  // changeDate() {
  //   // AjaxService.requestArray('exam/interview/video/room/list.htm', this.video, (array) => {
  //   //   this.roomArray = array;
  //   // });
  // }

  rquestVideo() {
    AjaxService.requestArray('exam/video/app/stat.htm', this.video, (array) => {
      this.array = array;
      this.no_vieo_total = 0;
      for(const arr of this.array) {
        this.no_vieo_total += (arr.total_num-arr.record_num);
      }
    });
  }


  showStdModal(aspect: any, type: any) {
    if(type) {
      aspect.type = type;
    }
    this.showComponentModal(VideoAppReportStdComponent,  {ResponseEntity: aspect} );
  }



  trans() {

   
  }

  delete() {
   


  }


  down() {

    AjaxService.requestEntity('exam/video/app/down.htm', {}, (entity) => {
     // MsgService.showThreadRunning(this.bsService, entity, {threadTitle: '正在下载数据，请稍候'});
    });
  }
}
