<div class="content-heading  justify-content-between">
    <div>面试编排</div>
    <div class="float-right">
        <div class="row">
            <div class="wd-xl wd-sm">
                <ngx-select [items]="schoolArr" [(ngModel)]="param.school_id"
                    (ngModelChange)="requestBatch(param.school_id)" [autoClearSearch]="true"
                    optionValueField="school_id" optionTextField="school_name">
                </ngx-select>
            </div>
            <div class="wd-xl wd-sm ml-3">
                <ngx-select [items]="batchArr" [(ngModel)]="param.batch_id" (ngModelChange)="requestGroup()"
                    [autoClearSearch]="true" optionValueField="batch_id" optionTextField="batch_name">
                </ngx-select>
            </div>
            <div  class="wd-xl wd-sm ml-3 mr-3">
                <input class="form-control" type="text" [(ngModel)]="searchText" placeholder="输入关键字进行搜索" />
            </div>
        </div>
    </div>
</div>

<!--单分组-->
<div class="card card-default" *ngIf="ajax && ajax.getMap() && ajax.getMap()['SingleArr']">
    <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>
                <span class="ml-2 mb-2">未合并分组科目（{{ajax.getMap()['SingleArr'].length}}）</span>
            </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>
            </tr>
        </thead>
        <tbody>
            <tr
                *ngFor="let v of ajax.getMap()['SingleArr'] | arrayFilter:  searchText ; 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>{{v.batch_name}}</td>
                <td><span class="table-button"
                        [ngClass]="{'text-primary':(v.ly_status==='Complete' && v.room_total === undefined),'text-info':(v.ly_status==='Complete' && v.room_total >0),'text-success':(v.ly_status==='Publish')}"
                        (click)="showModal({'ResponseEntity':v, 'ResponseArray':ajax.getMap()['SubjectArray_' + v.ly_group_id]})">
                        {{v.group_name}}({{v.subject_code}})</span>
                </td>
                <td [innerHTML]="v.ly_status | frameDict:'LayoutGroupStatus'"
                    [ngClass]="{'text-primary':v.ly_status==='Complete', 'text-success':v.ly_status === 'Publish'}">
                </td>
                <td>
                    <span [tooltip]="'省内：' + v.province_std_total + '；省外：' + v.outside_std_total"  *ngIf="v.std_total > 0">{{v.std_total}}</span>
                </td>
                <td>
                    <button class="btn" [ngClass]="{'btn-primary': v.ly_status == 'Init', 'btn-success': (v.ly_status == 'Ready' || v.ly_status == 'Complete')}" (click)="showModal({'ResponseEntity':v, 'ResponseArray':ajax.getMap()['SubjectArray_' + v.ly_group_id]})">编辑分组</button>
                    <button class="btn ml-2" [ngClass]="{'btn-primary': (v.param_flag == 'InActive' || !v.param_flag), 'btn-success': v.param_flag == 'Active'}" (click)="showGroupParam(v)">分组参数</button>
                    <button class="btn ml-2" [ngClass]="{'btn-primary': (v.room_flag == 'InActive' || !v.room_flag), 'btn-success': v.room_flag == 'Active'}" (click)="showGroupRoom(v)">分组考场</button>
                    <!--
                    <div class="btn-group btn-group-sm" dropdown style="margin-top:-2px">
                        <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="#"
                                [ngClass]="{'text-primary':(v.ly_status==='Complete' && v.room_total === undefined),'text-info':(v.ly_status==='Complete' && v.room_total >0),'text-success':(v.ly_status==='Publish')}"
                                (click)="showModal({'ResponseEntity':v, 'ResponseArray':ajax.getMap()['SubjectArray_' + v.ly_group_id]})">编辑分组</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item text-primary" href="#"  (click)="showGroupParam(v)">分组参数</a>
                            <div class="dropdown-divider" ></div>
                            <a class="dropdown-item text-primary" href="#"   (click)="showGroupRoom(v)">分组考场</a> 
                        </div>
                    </div>-->
                </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>科目名称</th>
        <th>乐器/舞种</th>
        <th class="wd-sm">评分人数</th>
        <th class="wd-sm">评分顺序</th>
        <th class="wd-sm">是否启用</th>
      </tr>
      </thead>
    </table>
</div>

<div class="card card-default"   *ngFor="let group of ajax.getMap()['MoreArr']  | arrayFilter:  searchText">
    <div class="row card-header justify-content-between bg-gray">
      <div class="row ml-2 text-1-2">
       <span class="table-button"
             [ngClass]="{'text-success':group.ly_status==='Publish','text-primary':group.ly_status==='Ready' ,'text-info':group.ly_status==='Complete'}"
             (click)="group.show_flag = (group.show_flag === undefined || group.show_flag)? false : true">
      【<span  *ngIf="group.dept_name">{{group.dept_name}} - </span>{{group.group_name}}
      <span [tooltip]="'省内：' + group.province_std_total + '；省外：' + group.outside_std_total"
         *ngIf="group.std_total > 0">(共:{{group.std_total}}人)</span>(评委:{{group.room_judge_num}})
         <span *ngIf="group.pagerless_flag === 'Active'" class="text-success">(无纸化评分)</span>】
       </span>
        <span *ngIf="group.checkin_flag === 'Active'">【需要检录】</span>
        <span *ngIf="group.pack_flag === 'Active'" class="text-info">【群体面试({{group.pack_std_num}})】</span>
      </div>

      <div class="float-right mr-5">

        <button class="btn" [ngClass]="{'btn-primary': group.ly_status == 'Init', 'btn-success': (group.ly_status == 'Ready' || group.ly_status == 'Complete')}" (click)="showModal({'ResponseEntity':group, 'ResponseArray':ajax.getMap()['SubjectArray_' + group.ly_group_id]})">编辑分组</button>
        <button class="btn ml-2" [ngClass]="{'btn-primary': (group.param_flag == 'InActive' || !group.param_flag), 'btn-success': group.param_flag == 'Active'}" (click)="showGroupParam(group)">分组参数</button>
        <button class="btn btn-primary ml-2" (click)="ajax.optrRecord('ly/group/union/delete.htm', {ly_group_id: group.ly_group_id}, {'confirmMsg': '确定要解散分组【'+group.group_name+'】吗？', 'successMsgType': 'Swal', showMsg: true, successMsg:'分组【'+group.group_name+'】已打散，每个科目作为单独科目编排！'}, {RequestWithLoading: true})">解散分组</button>
        <button class="btn ml-2" [ngClass]="{'btn-primary': (group.room_flag == 'InActive' || !group.room_flag), 'btn-success': group.room_flag == 'Active'}" (click)="showGroupRoom(group)">分组考场</button>
        

        <!-- <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.ly_group_id]})">编辑分组</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item text-primary" href="#"  (click)="showGroupParam(group)">分组参数</a>
            <div class="dropdown-divider" ></div>
            <a class="dropdown-item text-primary" href="#"  (click)="ajax.optrRecord('ly/group/union/delete.htm', {ly_group_id: group.ly_group_id}, {'confirmMsg': '确定要解散分组【'+group.group_name+'】吗？', 'successMsgType': 'Swal', showMsg: true, successMsg:'分组【'+group.group_name+'】已打散，每个科目作为单独科目编排！'}, {RequestWithLoading: true})">解散分组</a>
            <div class="dropdown-divider" ></div>
            <a class="dropdown-item text-primary" href="#"  (click)="showGroupRoom(group)">分组考场</a>
         </div>
        </div> -->

      </div>
    </div>

    <table class="table table-striped table-hover table-bordered" [hidden]="group.show_flag === false">
      <tbody>
        <tr *ngFor="let sb of ajax.getMap()['SubjectArray_' + group.ly_group_id] ; let i = index">
            <td class="th-index">{{i+1}}</td>
            <td>{{sb.batch_name}}</td>
            <td>{{sb.subject_name}}({{sb.subject_code}})</td>
            <td><span *ngIf="sb.variety_id">{{sb.variety_name}}({{sb.variety_id}})</span></td>
            <td><span [tooltip]="'省内：' + sb.province_std_total + '；省外：' + sb.outside_std_total">{{sb.std_total}}</span></td>
            <td class="wd-sm">{{sb.group_order}}</td>
            <td class="wd-sm"><span [innerHTML]="sb.score_status | frameStatus"></span></td>
        </tr>
      </tbody>
    </table>
  </div>

  <frame-ajax [url]="'ly/group/list/all.htm'" [requestData]="{school_id: param.school_id, batch_id: param.batch_id}"
  [requestParam]="{RequestDataType:'map', RequestWithLoading:true}" #ajax></frame-ajax>