<div class="content-heading  justify-content-between">
  <div>预编排-笔试编排</div>
  <div class="float-right">
    <div class="row">
      <div>
        <input class="form-control mt-1" type="text" [(ngModel)]="searchText" placeholder="输入关键字进行搜索"/>
      </div>
      <div *ngIf="FrameService.getParamValue('ExamBatchs' , '1') > '1'" class="ml-3">
        <select class="form-control mt-1" [(ngModel)]="exam_batch">
          <option [value]="v.dict_value" *ngFor="let v of batchNameArray">{{v.dict_text}}</option>
        </select>
      </div>

      <div class="btn-group mb-1 mr-1 ml-3" dropdown>
        <button class="btn dropdown-toggle btn-secondary btn-lg" type="button" dropdownToggle>预编排功能
          <span class="caret"></span>
        </button>
        <div *dropdownMenu class="dropdown-menu modal-lg" role="menu">
          <!-- RequestDataType:'map', -->
          <a class="dropdown-item text-danger" href="#"
             (click)="ajax.optrRecord('layout/plan/group/init.htm', {init_flag: 'Active'}, { successMsg:'预编排数据已重置，请重新进行预编排操作！',confirmMsg:'确定要重置所有预编排数据吗？该操作将所有预编排数据移除！', showMsg: true}, {RequestWithLoading: true})">初始化编排</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item text-success" href="#"
             (click)="ajax.optrRecord('layout/plan/group/init.htm', {init_flag: 'InActive'}, {successMsg:'预编排数据已刷新，此操作会自动添加之前未进入预编排的数据信息！',showMsg: true}, {RequestWithLoading: true})">刷新预编排</a>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="card card-default" *ngIf="ajax && ajax.getMap() && ajax.getMap()['SingleArray']">
  <div class="row card-header justify-content-between">
    <div>
    <span class="table-button"
          (click)="showSingleGroup = (showSingleGroup === undefined || showSingleGroup)? false : true">
       <em class="fa-2x fas ml-2"
           [ngClass]="{'fa-angle-double-down': !showSingleGroup,'fa-angle-double-up':(showSingleGroup === undefined || showSingleGroup)}"></em> 未分组科目（{{ajax.getMap()['SingleArray'].length}}）
    </span>
    </div>
    <div class="float-right mr-5" [hidden]="showSingleGroup === false">
      <button class="btn btn-info" type="button" (click)="makeGroup()"> 科目分组</button>
    </div>
  </div>
  <table class="table table-striped table-hover table-bordered" [hidden]="showSingleGroup === false">
    <thead>
    <tr>
      <th class=""></th>
      <th>分组名称</th>
      <th>顺序</th>
      <th>状态</th>
      <th>一次性进场</th>
      <th>桌贴类型</th>
      <th>预约</th>
      <th>省内外分离</th>
      <th class="th-b-1"></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let v of ajax.getMap()['SingleArray'] | arrayFilter:  searchText | attrFilter :{exam_batch: exam_batch}; let i = index">
      <td>
        <div class="form-check">
          <div class="checkbox c-checkbox">
            <label>
              <input type="checkbox" [(ngModel)]="v.checked"/>
              <span class="fa fa-check"></span>{{i + 1}}</label>
          </div>
        </div>
      </td>
      <td><span class="table-button"
                (click)="showModal({'ResponseEntity':v, 'ResponseArray':ajax.getMap()['SubjectArray_' + v.group_id]})"><span
        *ngIf="v.dept_name">{{v.dept_name}} - </span>{{v.group_name}}({{v.subject_id}})</span>
      </td>
      <td>{{v.ly_order}}</td>
      <td [innerHTML]="v.ly_status | frameStatusCustom:['已编排','未编排', 'text-success', 'text-muted']"></td>
      <td [innerHTML]="v.once_flag | frameStatusCustom:['进场一次','多次进场', 'text-danger', 'text-black']"></td>
      <td [innerHTML]="v.aspect_num_flag | frameStatusCustom:['专业考号','准考证号','text-danger', 'text-black']"></td>
      <td [innerHTML]="v.appointment_type | frameStatusCustom:['开放预约','不可预约','text-danger', 'text-black']"></td>
      <td [innerHTML]="v.province_flag | frameStatusCustom:['分别考场','混合考场','text-danger', 'text-black']"></td>

      <td><span class="table-button"
                (click)="showModal({'ResponseEntity':v, 'ResponseArray':ajax.getMap()['SubjectArray_' + v.group_id]})"><em
        class="fa-lg fas fa-edit" [ngClass]="{'text-success':v.ly_status === 'Active'}"></em></span>
      </td>
    </tr>
    </tbody>
  </table>
</div>
<div class="card card-default">
  <table class="table table-striped table-hover table-bordered">
    <thead>
    <tr>
      <th class="th-index">#</th>
      <th>科目名称</th>
      <th class="wd-sm">笔试时长(分钟)</th>
    </tr>
    </thead>
  </table>
</div>
<div class="card card-default" *ngFor="let group of ajax.getMap()['MoreArray'] | arrayFilter:  searchText | attrFilter :{exam_batch: exam_batch}">
  <div class="row card-header justify-content-between bg-gray">
    <div class="row ml-2 text-1-2">【{{group.group_name}}】【<span
      [innerHTML]="group.aspect_num_flag | frameStatusCustom:['专业考号','准考证号','text-danger', 'text-black']"></span>】【<span
      [innerHTML]="group.once_flag | frameStatusCustom:['进场一次','多次进场', 'text-danger', 'text-black']"></span>】【<span
      [innerHTML]="group.appointment_type | frameStatusCustom:['开放预约','不可预约','text-danger', 'text-black']"></span>】
    </div>
    <div class="float-right mr-5">
      <div class="btn-group btn-group-sm mb-1 mr-1 ml-3" dropdown>
        <button class="btn dropdown-toggle btn-secondary btn-lg" type="button" dropdownToggle>分组操作
          <span class="caret"></span>
        </button>
        <div *dropdownMenu class="dropdown-menu modal-lg" role="menu">
          <a class="dropdown-item" href="#"
             (click)="showModal({'ResponseEntity':group, 'ResponseArray':ajax.getMap()['SubjectArray_' + group.group_id]})">编辑分组</a>
          <div class="dropdown-divider"></div>

          <a class="dropdown-item text-danger" href="#"
             (click)="ajax.optrRecord('layout/plan/group/union/delete.htm', {group_id: group.group_id}, { successMsg:'分组【'+group.group_name+'】已打散，每个科目作为单独科目编排！', 'successMsgType': 'Swal', 'confirmMsg': '确定要解散分组【'+group.group_name+'】吗？'}, {RequestWithLoading: true})">解散分组</a>
        </div>
      </div>
    </div>
  </div>
  <table class="table table-striped table-hover table-bordered">
    <tbody>
    <tr *ngFor="let sb of ajax.getMap()['SubjectArray_' + group.group_id] ; let i = index">
      <td class="th-index">{{sb.group_order}}</td>
      <td>{{sb.subject_name}}({{sb.subject_id}})</td>
      <td class="wd-sm">{{sb.exam_minutes}}</td>
    </tr>
    </tbody>
  </table>
</div>
<frame-ajax [url]="'layout/plan/group/list.htm'" [requestData]="{group_type:'Written'}"
            [requestParam]="{RequestDataType:'map'}" #ajax></frame-ajax>
