import { Component, OnInit } from '@angular/core';
import {BsModalRef} from 'ngx-bootstrap';
import {FormBuilder, Validators} from '@angular/forms';
import {FrameEditComponent} from '../../../frame/core/FrameEditComponent';
import {CookieService} from 'ngx-cookie-service';

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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, private cookies: CookieService) {
    super(bsModalRef);
    this.valForm = fb.group({
      'template_name': [null, Validators.compose([Validators.required, Validators.minLength(1), Validators.maxLength(128)])],
      'template_status': [null],
      'template_code': [null],
      'business_type': [null],
      'template_value': [null]
    });
  }
  initDefautEntity() {
    if (this.editModel === 'add') {
      this.currentEntity.wx_id = this.cookies.get('CurrentWxId');
      this.currentEntity.template_status = 'Active';
    }
  }

  ngOnInit() {
  }

}
