import {Component, OnInit} from '@angular/core';
import {ConfAgentDetailComponent} from '../conf-agent-detail/conf-agent-detail.component';
import {ConfAgentCategoryComponent} from '../conf-agent-category/conf-agent-category.component';
import {ConfAgentAspectComponent} from '../conf-agent-aspect/conf-agent-aspect.component';
import {ConfAgentProvinceComponent} from '../conf-agent-province/conf-agent-province.component';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import { BsModalService } from 'ngx-bootstrap/modal';

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

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

  ngOnInit() {
  }


  getEnrolTime(agent) {
    if (agent.enrol_status === 'InActive') {
      return '<span class="text-danger">未开启报名</span>';
    }
    if (agent.enrol_start_time === undefined) {
      return '<span class="text-warning">未设置开始时间</span>';
    }
    return `<span class="">${agent.enrol_start_time} - ${agent.enrol_end_time}</span>`;
  }

  getPayTime(agent) {
    if (agent.pay_status === 'InActive') {
      return '<span class="text-danger">未开启缴费</span>';
    }
    if (agent.pay_start_time === undefined) {
      return '<span class="text-warning">未设置开始时间</span>';
    }
    return `<span class="">${agent.pay_start_time} - ${agent.pay_end_time}</span>`;
  }

  showProvince(ap) {
    this.showComponentModal(ConfAgentProvinceComponent, {
      'ResponseEntity': ap
    });
  }

  showCategory(ap) {
    this.showComponentModal(ConfAgentCategoryComponent, {
      'ResponseEntity': ap,
      'arrayUrl': 'conf/agent/category/list.htm',
      'arrayParam': {
        agent_id: ap.agent_id
      }
    });
  }


  showAspect(ap) {
    this.showComponentModal(ConfAgentAspectComponent, {
      'ResponseEntity': ap,
      'arrayUrl': 'conf/agent/aspect/list.htm',
      'arrayParam': {
        agent_id: ap.agent_id
      }
    });
  }
}
