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

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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, private cookies: CookieService) {
    super(bsModalRef);
    this.valForm = 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.editModel === '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');
    }
  }


}
