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-weixin-define-detail',
  templateUrl: './weixin-define-detail.component.html',
  styleUrls: ['./weixin-define-detail.component.scss']
})
export class WeixinDefineDetailComponent extends FrameDetailComponent implements OnInit {

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'wx_id': [null, Validators.compose([Validators.required, Validators.min(1), Validators.max(9999)])],
      'wx_code': [null, Validators.compose([Validators.required, Validators.minLength(12), Validators.maxLength(18)])],
      'wx_name': [null, Validators.compose([Validators.required, Validators.minLength(2), Validators.maxLength(64)])],
      'app_id': [null, Validators.compose([Validators.required, Validators.minLength(18), Validators.maxLength(24)])],
      'app_secrect': [null, Validators.compose([Validators.required, Validators.minLength(32), Validators.maxLength(32)])],
      'app_aeskey': [null, Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(64)])],
      'app_qrcode': [null],
      'app_name': [null],
      'app_status': [null, Validators.compose([Validators.required])],
      'record_user_log': [null, Validators.compose([Validators.required])],
      'wx_type': [null, Validators.compose([Validators.required])]
    });
  }

  initDefautEntity() {
    if(this.detailMode === 'add') {
      this.currentEntity.app_status = 'Active';
      this.currentEntity.wx_type = 'WeChat';
      this.currentEntity.record_user_log = 'InActive';
    }
  }

  ngOnInit() {
  }

}
