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

@Component({
  selector: 'app-layout-material-written-seat',
  templateUrl: './layout-material-written-seat.component.html',
  styleUrls: ['./layout-material-written-seat.component.scss']
})
export class LayoutMaterialWrittenSeatComponent extends FrameDetailComponent implements OnInit {

  stdArray: [];
  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);

    this.stdArray= [];
  }

  initDefautEntity() {

    // 每页列数
    this.currentEntity.row_margin = 0;
    // 默认不显示学校名称
    this.currentEntity.school_name_flag = 'InActive';

    // 是否显示考生姓名
    this.currentEntity.std_name_flag = 'Active';
    this.currentEntity.std_name_font = 16;
    // 座位号
    this.currentEntity.room_seq_flag = 'Active';
    this.currentEntity.room_seq_font = 16;

    this.currentEntity.ticket_font = 20;
    this.currentEntity.std_image_width = 60;
    this.currentEntity.std_image_height = 72;
    this.currentEntity.subject_name_font = 22;
    this.currentEntity.room_name_flag = 'Active';
    this.currentEntity.room_addr_font = 14;
    this.currentEntity.school_name_font = 12;

    this.currentEntity.ly_room_id = 0;
    AjaxService.requestArray('layout/group/written/room/list.htm', this.currentEntity, (array) => {
      for(const room of array) {
        room.room_addr = room.room_name + ' ' + room.room_addr + '（'+room.real_std_total+'）';
      }
      this.ResponseArray = array;
      setTimeout(()=>{
        this.currentEntity.ly_room_id = array[0].ly_room_id;
        this.requestRoomStd();
      },1000 );
    })
    console.log(this.currentEntity);
  }

  requestRoomStd() {
    AjaxService.requestArray('layout/material/written/room/std/list.htm', this.currentEntity, (array) => {
      this.stdArray = array;
    })
  }

  ngOnInit() {
  }

}

