import { Component, OnInit } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { AjaxService } from '../../../../../core/service/ajax.service';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import { ConfAgentAspectAppointmentDetailComponent } from '../conf-agent-aspect-appointment-detail/conf-agent-aspect-appointment-detail.component';

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

  agentArr = [];
  aspectArr = [];
  appointment : any;

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

  ngOnInit(): void {
    this.appointment = {};
    AjaxService.requestArray('conf/agent/all.htm',{}, (array) => {
      this.agentArr = array;
      this.requestAspect();
    });
  }

  onModalClose() {
    this.ajax.reload();
  }

  requestAspect() {
    AjaxService.requestArray('conf/aspect/appointment/list.htm', {agent_id: this.appointment.agent_id }, (array) => {
      this.aspectArr = array;
    });
  }

  requestAppointment() {
    this.ajax.reload({agent_id: this.appointment.agent_id, aspect_id: this.appointment.aspect_id});
  }

  //编辑容量
  editAppointment(v) {
    this.showComponentModal(ConfAgentAspectAppointmentDetailComponent, {
      ResponseEntity: v
    });
  }

}
