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

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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, private cookies: CookieService) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'param_name': [null, Validators.compose([Validators.required, Validators.minLength(2), Validators.maxLength(32)])],
      'param_value': [null],
      'param_type': [null, Validators.required],
      'param_desc': [null]
    });
  }
  initDefautEntity() {
    if (this.detailMode === 'add') {
      this.currentEntity.wx_id = this.cookies.get('CurrentWxId');
    }
  }

  ngOnInit() {
  }

  swithWeixin(wx) {
    if (wx === 0) {
      this.currentEntity.wx_id = 0;
    } else {
      this.currentEntity.wx_id = this.cookies.get('CurrentWxId');
    }
  }


}
