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 { MsgService } from '../../../../../core/service/msg.service';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import {LayoutMaterialParamComponent} from '../layout-material-param/layout-material-param.component';

@Component({
  selector: 'app-layout-material-aspect',
  templateUrl: './layout-material-aspect.component.html',
  styleUrls: ['./layout-material-aspect.component.scss']
})
export class LayoutMaterialAspectComponent  extends FramePageComponent implements OnInit {
  agent: any;

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


  makeStdTicket(ticket, flag) {
    let msg = '确定要生成该考生准考证吗！';
    if (flag) {
      msg = '确定要重新生成该考生的准考证码？';
    }
    MsgService.confirmAlert(msg, () => {
      this.FuncService.ajaxDownload('layout/material/ticket/make.htm', ticket);
    });
  }

  downloadTicket(v) {
    window.open(this.FrameService.getParamValue('EnrolMaterialWebPath') + '/' + v.ticket_file_name);
  }

  ngOnInit() {
  }

}
