import {Component, OnInit, ViewChild} from '@angular/core';
import {UploaderComponent} from '../../../../../core/uploader/uploader.component';
import {MsgService} from '../../../../../core/msg/msg.service';
import {FramePageComponent} from '../../../../frame/core/FramePageComponent';
import {BsModalService} from 'ngx-bootstrap';
import {AgentStdAspectComponent} from '../agent-std-aspect/agent-std-aspect.component';
import {FrameService} from '../../../../../core/frame/frame.service';
import { StdUploadComponent } from './std-upload/std-upload.component';
import {AgentStdInfoComponent} from '../agent-std-info/agent-std-info.component';

@Component({
  selector: 'app-agent-std',
  templateUrl: './agent-std.component.html'
})
export class AgentStdComponent extends FramePageComponent implements OnInit {

  @ViewChild('uploader', {static: false}) uploader: UploaderComponent;

  // 当前在哪个步骤上
  viewStep = 'page';
  uploadParam: any;

  constructor(private modalService: BsModalService) {
    super(modalService);
    this.uploadParam = {auto_reg: true, auto_enrol: true, auto_pay: true, none_trans: true};
  }

  ngOnInit() {
  }

  goPage() {
    this.viewStep = 'page';
  }

  reload() {
    MsgService.successToaster('上传文件已处理，处理结果请查看下载文件！');
    this.pager.reload();
    this.viewStep = 'page';
  }


  showAspectModal(std: any) {
    this.modalComponent = AgentStdAspectComponent;
    this.showComponentModal(AgentStdAspectComponent,{
      mapUrl: 'school/school/std/aspect/init.htm', mapParam: {
        std_id: std.std_id,
        aspect_id: std.aspect_id
      }
    }, {'class' : 'modal-5'});
  }

  showStdModal(std: any) {
    this.modalComponent = AgentStdInfoComponent;
    this.showModal({mapUrl:'school/school/std/find.htm',mapParam:{std_id: std.std_id}});
  }

  showUploadModal(std: any) {
    this.showComponentModal(StdUploadComponent,{}, {'class' : 'modal-5'});
  }

  goDownloadTicket(std: any){
    window.open(FrameService.getParamValue('MateialWebPath') + 'StdTicket/' + std.ticket_file);
  }
}
