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-param-sync',
  templateUrl: './conf-param-sync.component.html',
  styleUrls: ['./conf-param-sync.component.scss']
})
export class ConfParamSyncComponent extends FrameDetailComponent implements OnInit {


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

  ngOnInit(): void {
  }

 

  //同步参数
  syncParam() {
    if(!this.currentEntity.source_school_id || !this.currentEntity.target_school_id) {
      this.MsgService.errorToastr('请选择学校！');
      return;
    }
    if(this.currentEntity.source_school_id == this.currentEntity.target_school_id) {
      this.MsgService.errorToastr('源学校和目标学校不能相同！');
      return;
    }
    this.MsgService.confirmAlert('确定要同步参数吗？', () => {
      this.AjaxService.request('ex/param/sync.htm', this.currentEntity, () => {
        this.MsgService.successToastr('同步成功');
        this.closeWindow();
      });
    });
  }

}
