import {Component, OnInit} from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import {FrameEditComponent} from '../../../../frame/core/FrameEditComponent';
import {BsModalRef} from 'ngx-bootstrap';
import {DomSanitizer} from '@angular/platform-browser';

@Component({
  selector: 'app-conf-material-detail',
  templateUrl: './conf-material-detail.component.html',
  styleUrls: ['./conf-material-detail.component.scss']
})
export class ConfMaterialDetailComponent extends FrameEditComponent implements OnInit {

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, sanitizer: DomSanitizer) {
    super(bsModalRef, sanitizer);
    this.valForm = fb.group({
      'material_type': [null, Validators.compose([Validators.required])],
      'material_name': [null, Validators.compose([Validators.required, Validators.minLength(1), Validators.maxLength(128)])],
      'upload_business': [null],
      'audit_business': [null],
      'material_status': [null, Validators.compose([Validators.required])],
      'audit_auto_status': [null, Validators.compose([Validators.required])],
      'audit_auto_param': [null],
      'material_order': [null, Validators.compose([Validators.required])],
      'material_explain': [null, Validators.compose([Validators.maxLength(2000)])]
    });
  }

  ngOnInit() {
  }

  initDefautEntity() {
    if (this.editModel === 'add') {
      this.currentEntity.audit_auto_status = 'InActive';
      this.currentEntity.material_status = 'Active';
    }
  }


}
