<div class="content-heading  justify-content-between">
  <div>编排分组设置管理</div>
  <div class="float-right">
    <div class="row">
      <div class="wd-xl wd-sm mr-1">
        <ngx-select [items]="schoolArray" [(ngModel)]="query.school_id" (ngModelChange)="queryBatchArray()" placeholder="学校"
                    [autoClearSearch]="true" optionValueField="school_id" optionTextField="code_name">
        </ngx-select>
      </div>
      <div class="wd-xl wd-sm mr-1">
        <ngx-select [items]="batchArray" [(ngModel)]="query.batch_id" (ngModelChange)="loadData()" placeholder="批次"
                    [autoClearSearch]="true" optionValueField="batch_id" optionTextField="batch_name">
        </ngx-select>
      </div>
      <div class="btn-group ml-3" dropdown>
        <button class="btn dropdown-toggle btn-secondary" type="button" dropdownToggle>编排分组设置管理
          <span class="caret"></span>
        </button>
        <div *dropdownMenu class="dropdown-menu modal-lg" role="menu">
          <a class="dropdown-item" href="#" (click)="FuncService.ajaxDownload('frame/template/download.htm', {file_name: '模版-笔试考场.xls'})">下载考场模版</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="#" (click)="buildLayout()">生成编排</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="#" (click)="deleteData()">删除编排</a>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="table-responsive bg-white">
  <div class="row" style="justify-content: space-between;margin: 12px;width: 97%;">
    <div>理论考生：{{countMap.nopractice}}，实践考生：{{countMap.practice}}，同等学力考生：{{countMap.equedu}}</div>
    <div class="row">
      <button class="btn btn-info mr-1" type="button" (click)="ModalService.showUploadWindow(bsService,'cf/cfSubject/upload.htm',
      query,{
      uploadTitle:'上传加试',
      templateFile:'模版-笔试加试.xls',
      uploadCallback:uploadCallback.bind(this),
      autoClose:true
      })"> 上传加试</button>
      <div class=" wd-sm mr-1">
        <ngx-select [items]="[{id:0,text:'理论'},{id:1,text:'实践'}]" [(ngModel)]="query.is_practice" (ngModelChange)="ajax.reload()" placeholder="课程性质"
                    [autoClearSearch]="true" [allowClear]="true" optionValueField="id" optionTextField="text">
        </ngx-select>
      </div>
      <div class=" wd-sm mr-1">
        <ngx-select [items]="[{text:'科目1'},{text:'科目2'},{text:'科目3'},{text:'科目4'}]" [(ngModel)]="query.subject_type" (ngModelChange)="ajax.reload()" placeholder="科目类型"
                    [autoClearSearch]="true" [allowClear]="true" optionValueField="text" optionTextField="text">
        </ngx-select>
      </div>
      <button class="btn btn-info" type="button" (click)="makeGroup()"> 合并分组</button>
    </div>
  </div>
  <table class="table table-striped table-hover table-bordered">
    <thead>
    <tr>
      <th align="center">
        <div class="checkbox c-checkbox" style="text-align: center;">
          <label style="padding:0px;margin: 0px;">
            <input type="checkbox"
                   (change)="checkedMasterToggle($event)" />
            <span class="fa fa-check"></span>
          </label>
        </div>
      </th>
      <th>科目编号</th>
      <th>科目名称</th>
      <th>考试开始时间</th>
      <th>考试结束时间</th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let v of ajax.getArray(); let i = index">
      <td>
        <div class="form-check">
          <div class="checkbox c-checkbox">
            <label>
              <input type="checkbox"  [(ngModel)]="v.isChecked"/>
              <span class="fa fa-check"></span>{{i + 1}}</label>
          </div>
        </div>
      </td>
      <td>{{v.subject_code}}</td>
      <td>{{v.subject_name}}</td>
      <td>{{v.exam_start_time}}</td>
      <td>{{v.exam_end_time}}</td>
    </tr>
    </tbody>
  </table>
  <frame-ajax [url]="'cf/cfSubject/list.htm'" [requestData]="query"
              [autoRequest]="false"
              [requestParam]="{RequestDataType:'array', RequestWithLoading:true}" #ajax></frame-ajax>
</div>


<div class="table-responsive bg-white" >
  <table class="table table-striped table-hover table-bordered">
    <thead>
    <tr>
      <th>分组名称</th>
      <th>编排顺序</th>
      <th>准考人数</th>
      <th>省内人数</th>
      <th>省内考场</th>
      <th>是否按专业排序</th>
      <th>编排状态</th>
      <th></th>
    </tr>
    </thead>

    <tbody *ngFor="let v of group.getArray(); let i = index">
    <tr >
      <td>{{v.group_name}}</td>
      <td>{{v.ly_order}}</td>
      <td>{{v.total}}</td>
      <td>{{v.provence}}</td>
      <td [innerHTML]="v.provence_flag | frameStatus"></td>
      <td [innerHTML]="v.aspect_order | frameStatus"></td>
      <td>{{v.status | frameDict: 'YesOrNo'}}</td>
      <td>
        <div class="btn-group btn-group-sm" dropdown style="margin-top:-2px">
        <button class="btn dropdown-toggle btn-secondary btn-sm" type="button" dropdownToggle>分组操作
          <span class="caret"></span>
        </button>
        <div *dropdownMenu class="dropdown-menu" role="menu">
          <a class="dropdown-item" href="#" *ngIf="v.status==0"
             (click)="ModalService.showUploadWindow(bsService,'ly/lyRoom/upload.htm',
              {ly_group_id: v.group_id},{
                uploadTitle:'上传考场',
                templateFile:'模版-笔试考场.xls',
                uploadCallback:uploadCallback.bind(this),
                autoClose:true
              })">上传考场</a>
          <a class="dropdown-item text-danger" href="#" *ngIf="v.status==0"
             (click)="group.optrRecord('ly/lyRoom/deleteByGroup.htm', v, {successMsg:'考场已删除！', confirmMsg: '谨慎操作，确定要删除考场吗？', successMsgType:'Swal'})">删除分组考场</a>
          <a class="dropdown-item text-danger" href="#" *ngIf="v.status==0"
             (click)="deleteGroup(v)">解散分组</a>
          <a class="dropdown-item text-danger" href="#" (click)="showModal({ResponseEntity:v,ResponseArray:v.cfSubjectList})" *ngIf="v.status==0">修改分组</a>
        </div>
        </div>
      </td>
    </tr>
    <tr >

      <td colspan="8">

        <div class="card-header bg-info" (click)="v.showSubject=!v.showSubject">科目明细<em [ngClass]="v.showSubject?'fa fa-angle-double-down':'fa fa-angle-double-right'"></em></div>
        <table class="table table-striped table-hover table-bordered" [hidden]="!v.showSubject">
          <thead>
          <tr>
            <th>科目编号</th>
            <th>科目名称</th>
            <th>考试开始时间</th>
            <th>考试结束时间</th>
          </tr>
          </thead>
          <tbody>
              <tr *ngFor="let s of v.cfSubjectList; let i = index">
                <td>{{s.subject_code}}</td>
                <td>{{s.subject_name}}</td>
                <td>{{s.exam_start_time}}</td>
                <td>{{s.exam_end_time}}</td>
              </tr>
          </tbody>
        </table>
      </td>
    </tr>
    <tr >
      <td colspan="8">
        <div class="card-header bg-info" (click)="v.showRooms=!v.showRooms">考场信息<em [ngClass]="v.showSubject?'fa fa-angle-double-down':'fa fa-angle-double-right'"></em></div>
        <table class="table table-striped table-hover table-bordered" [hidden]="!v.showRooms">
          <thead>
          <tr>
            <th>考场编号</th>
            <th>教室编号</th>
            <th>考场容量</th>
            <th>省内考场</th>
          </tr>
          </thead>
          <tbody>
          <tr *ngFor="let r of v.lyRooms; let i = index">
            <td>{{r.room_code}}</td>
            <td>{{r.room_name}}</td>
            <td>{{r.room_capacity}}</td>
            <td [innerHTML]="r.is_provence | frameStatus"></td>
          </tr>
          </tbody>
        </table>
      </td>
    </tr>
    </tbody>
  </table>
  <frame-ajax [url]="'ly/lyGroup/list.htm'" [requestData]="query"
              [autoRequest]="false"
              [requestParam]="{RequestDataType:'array', RequestWithLoading:true}" #group></frame-ajax>
</div>
