import {Component, OnInit} from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import {ConfVarietyDetailComponent} from '../conf-variety-detail/conf-variety-detail.component';
import {ConfVarietyTracksComponent} from '../conf-variety-tracks/conf-variety-tracks.component';

@Component({
  selector: 'app-conf-variety-page',
  templateUrl: './conf-variety-page.component.html',
  styleUrls: ['./conf-variety-page.component.scss']
})
export class ConfVarietyPageComponent extends FramePageComponent implements OnInit {

  constructor(private modalService: BsModalService) {
    super(modalService);
    this.modalComponent = ConfVarietyDetailComponent;
  }

  ngOnInit() {
  }

  getVarietyTracksConfig(v) {
    let text = '';
    if (v.enrol_tracks_1 > 0) {
      if (v.enrol_tracks_2 === undefined) {
        text = `报【${v.enrol_tracks_1}】首/考【${v.exam_tracks_1}】首`;
      } else {
        text = `初试【${v.enrol_tracks_1}】/【${v.exam_tracks_1}】`;
      }
    }
    if (v.enrol_tracks_2 > 0) {
      if (text.length > 0) {
        text = text + '，';
      }
      text = text + `复试【${v.enrol_tracks_2}】/【${v.exam_tracks_2}】`;
    }
    if (v.enrol_tracks_3 > 0) {
      if (text.length > 0) {
        text = text + '，';
      }
      text = text + `复试【${v.enrol_tracks_3}】/【${v.exam_tracks_3}】`;
    }
    return text;
  }

  showVarietyTracks(v) {
    this.showComponentModal(ConfVarietyTracksComponent, {
      'ResponseEntity': v,
      'arrayUrl': 'conf/variety/tracks/list.htm',
      'arrayParam': {
        variety_id: v.variety_id
      }
    });
  }
}
