import {Component, OnInit, ViewChild} 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';
import {ExamJudgeExtractLogDetailComponent} from '../exam-judge-extract-log-detail/exam-judge-extract-log-detail.component';

@Component({
  selector: 'app-exam-judge-extract-log',
  templateUrl: './exam-judge-extract-log.component.html',
  styleUrls: ['./exam-judge-extract-log.component.scss']
})
export class ExamJudgeExtractLogComponent extends FramePageComponent implements OnInit {

  agent: any;

  constructor(private router: Router, private cookies: CookieService, modalService: BsModalService) {
    super(modalService);
    this.modalComponent = ExamJudgeExtractLogDetailComponent;
    // 获取缓存中的微信编号
    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;
        setTimeout(() => {
          if (this.ajax) {
            this.ajax.reload();
          }
        }, 1);
      });
    } else {
      this.router.navigate(['/art/layout/agent/page']);
    }
  }

  showDetail(extract, batch_id) {
    extract.batch_id = batch_id;
    this.showModal({
      ResponseEntity: extract,
      arrayUrl: 'exam/judge/extract/log/detail.htm',
      arrayParam: {extract_id: extract.extract_id, batch_id: batch_id}
    });
  }

  ngOnInit() {

  }

}
