import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { FrameDetailComponent } from '../../../../frame/core/detail/frame.detail';

@Component({
  selector: 'app-conf-score-panel-sync',
  templateUrl: './conf-score-panel-sync.component.html',
  styleUrls: ['./conf-score-panel-sync.component.scss']
})
export class ConfScorePanelSyncComponent  extends FrameDetailComponent implements OnInit {

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'source_school_id' : [null, Validators.required]
    });
   }

  ngOnInit(): void {
  }

  initDefautEntity(): void {
    this.currentEntity.panel_id = localStorage.getItem('panel_id');
  }

  syncRange() {
    if(!this.currentEntity.source_school_id) {
      this.MsgService.errorToastr('请选择学校！');
      return;
    }
    this.MsgService.confirmAlert('确定要将该学校的评分区间同步过来吗？', () => {
      this.AjaxService.request('ex/score/panel/sync.htm', this.currentEntity, () => {
        this.MsgService.successToastr('同步成功');
        this.closeWindow();
      });
    });
  }

}
