import { Component, OnInit, EventEmitter, Output } from '@angular/core';

@Component({
  selector: 'smart-new-type',
  templateUrl: './new-type.component.html',
  styles: [
      `.ant-form-item{
          margin: 24px 0;
      }`
  ]
})
export class NewTypeComponent implements OnInit {
    @Output() data = new EventEmitter<any>();
    isNew = false;
    modalTitle;
    name;  //名称
    modalMsg = false;  //message

  constructor() { }

  ngOnInit() {}

    showModal(title): void {
        this.isNew = true;
        this.name = null;
        this.modalTitle = title;
    }

    handleOk() {
        if(!this.name){
            this.modalMsg = true;
            return false;
        }else{
            this.modalMsg = false;
            this.isNew = false;
            this.data.emit(this.name);
        }
    }

    handleCancel(): void {
        this.isNew = false;
    }
}
