import {Component, OnInit} from '@angular/core';
import {ConfAspectDetailComponent} from '../conf-aspect-detail/conf-aspect-detail.component';
import {ConfAspectVarietyComponent} from '../conf-aspect-variety/conf-aspect-variety.component';
import {ConfAspectSubjectComponent} from '../conf-aspect-subject/conf-aspect-subject.component';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import { BsModalService } from 'ngx-bootstrap/modal';
import { ConfFeePageComponent } from '../../fee/conf-fee-page/conf-fee-page.component';

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

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

  ngOnInit() {
  }

  getFeeNote(v) {
    return ConfFeePageComponent.getFeeConfig(v, v.aspect_batchs);
  }

  getShowSubjects(v) {
    let value = '一试' + (v.show_subjects_1 === 'Active' ? '显示' : '隐藏') + '(' + (v.total_1 === undefined ? '<span class="text-danger">0</span>' : v.total_1)  + ')';

    if (v.aspect_batchs > 1) {
      value = value + '/二试' + (v.show_subjects_2 === 'Active' ? '显示' : '隐藏') + '(' + (v.total_2 === undefined ? '<span class="text-danger">0</span>' : v.total_2)  + ')';
    }
    if (v.aspect_batchs > 2) {
      value = value + '/三试' + (v.show_subjects_3 === 'Active' ? '显示' : '隐藏') + '(' + (v.total_3 === undefined ? '<span class="text-danger">0</span>' : v.total_3)  + ')';
    }
    return value;
  }

  showAspectVariety(ap) {
    this.showComponentModal(ConfAspectVarietyComponent, {
      'ResponseEntity': ap
    });
  }

  showAspectSubject(ap) {
    this.showComponentModal(ConfAspectSubjectComponent, {
      'ResponseEntity': ap,
      'arrayUrl': 'conf/aspect/variety/list.htm',
      'arrayParam': {
        aspect_id: ap.aspect_id
      }
    });
  }
}
