import { Component, OnInit } from '@angular/core';
import { FrameDetailComponent } from 'src/app/routes/frame/core/detail/frame.detail';
import { FormBuilder, Validators } from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { AjaxService } from 'src/app/core/service/ajax.service';

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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) { 
    super(bsModalRef);
    this.detailForm = fb.group({
      'show_std_name': [null, Validators.compose([Validators.required])],
      'show_std_image': [null, Validators.compose([Validators.required])],
      'separate_score': [null, Validators.compose([Validators.required])],
      'show_std_sex': [null, Validators.compose([Validators.required])],
      'min_play_time': [null, null],
      'next_validate': [null, null],
      'clock_num': [null, Validators.compose([Validators.required, Validators.minLength(0), Validators.maxLength(3)])],
      'clock_1_seconds': [null, null],
      'clock_2_seconds': [null, null],
      'clock_3_seconds': [null, null]
    });
  }

  ngOnInit(): void {
  }

  initDefautEntity(): void {
    this.AjaxService.requestEntity('ly/group/param/find.htm', {ly_group_id: this.ResponseEntity.ly_group_id}, (entity) => {
      this.currentEntity = entity;
      //设置默认值
      if(!entity) {
        this.currentEntity = {};
        this.currentEntity.show_std_name = 'InActive';
        this.currentEntity.show_std_image = 'InActive';
        this.currentEntity.separate_score = 'InActive';
        this.currentEntity.show_std_sex = 'InActive';
        this.currentEntity.next_validate = 'InActive';
        this.currentEntity.min_play_time = 3;
        this.currentEntity.clock_num = 0;
        this.currentEntity.clock_1_seconds = 300;
        this.currentEntity.clock_2_seconds = 500;
        this.currentEntity.clock_3_seconds = 600;
        this.currentEntity.ly_group_id = this.ResponseEntity.ly_group_id;
       this.detailMode = 'add';
      }
    });
  }

}
