<ng-container *ngIf="agent">
  <div class="content-heading  justify-content-between">
    <div>面试编排 - {{agent?.ly_agent_name}}</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">
            <!-- <a class="dropdown-item text-success" href="#"  (click)="refreshVideoGroup()">刷新视频分组</a>
            <div class="dropdown-divider"></div> -->
            <a class="dropdown-item text-success" href="#"
               (click)="ajax.optrRecord('layout/agent/refresh.htm',{ly_agent_id: agent.ly_agent_id},{ successMsg:'编排数据已刷新！'}, {RequestWithLoading: true})">刷新数据</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item text-warning" href="#" (click)="ajax.optrRecord('layout/group/interview/publish/agent.htm',{ly_agent_id: agent.ly_agent_id},{confirmMsg:'确定要将该考点的所有面试项目进行发布吗？',  successMsg:'该考点所有面试项目已发布！', showMsg:true}, {RequestWithLoading: true})">发布编排</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item text-warning" href="#" (click)="ajax.optrRecord('layout/group/interview/publish/agent/school.htm',{ly_agent_id: agent.ly_agent_id},{confirmMsg:'确定要将该考点的所有面试项目进行发布吗？',  successMsg:'该考点所有面试项目已发布！', showMsg:true}, {RequestWithLoading: true})">特殊编排</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#" (click)="optrAllGroup(true)">展开所有</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#" (click)="optrAllGroup(false)">折叠所有</a>
            <!-- <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#" (click)="syncUmp()">同步到UMP</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> <span
      class="ml-2 mb-2">未分组科目（{{ajax.getMap()['SingleArray'].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 *ngIf="FrameService.getParamValue('ExamBatchs' , '1') > '1'">批次</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"
                  [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]})"><span
          *ngIf="v.dept_name">{{v.dept_name}} - </span> 
          <span *ngIf="v.aspect_name">{{v.aspect_name}} - </span>{{v.group_name}}({{v.subject_id}})</span>
        </td>
        <td *ngIf="FrameService.getParamValue('ExamBatchs' , '1') > '1'"><span *ngIf="v.exam_batch === 0"
                                                                               class="text-danger">混合</span>
          <span *ngIf="v.exam_batch !== 0">{{v.exam_batch | frameDict : 'ExamBatchName'}}</span></td>
        <td>{{v.ly_order}}</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.group_std_total > 0">{{v.group_std_total}}</span>
        </td>
        <td>
          <span [ngClass]="{'text-danger': v.pack_flag === 'Active'}">{{v.pack_flag === 'Active'?('分组面试(' + v.pack_std_num +')'):'单独面试' }}</span>
        </td>
        <td [innerHTML]="v.appointment_type | frameDict:'InterviewAppointmentType'"></td>
        <td>

          <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" href="#" (click)="showParamModal(v)">分组参数</a>

              <div class="dropdown-divider" *ngIf="v.ly_status === 'Ready'"></div>
              <a class="dropdown-item text-primary" href="#" *ngIf="v.ly_status === 'Ready'"
                 (click)="startArrange(v)">开始编排</a>
              <div class="dropdown-divider" *ngIf="v.ly_status === 'Complete' || v.ly_status === 'Publish'"></div>
              <a class="dropdown-item text-warning" href="#"
                 *ngIf="v.ly_status === 'Complete' || v.ly_status === 'Publish'"
                 (click)="editArrange(v)">修改编排</a>

              <div class="dropdown-divider" *ngIf="v.ly_status === 'Complete'"></div>
              <a class="dropdown-item text-info" href="#"
                 *ngIf="v.ly_status === 'Complete'" (click)="ajax.optrRecord('layout/group/interview/publish/group.htm',{ly_group_id: v.ly_group_id},{confirmMsg:'确定要单独将该面试项目进行发布吗？',  successMsg:'面试项目已发布！', showMsg: true}, {RequestWithLoading: true})">发布编排</a>

              <div class="dropdown-divider" *ngIf="v.ly_status === 'Complete' || v.ly_status === 'Publish'"></div>
              <a class="dropdown-item text-danger" href="#" *ngIf="v.ly_status === 'Complete' || v.ly_status === 'Publish'"
                 (click)="ajax.optrRecord('layout/group/interview/reset.htm', {ly_group_id: v.ly_group_id}, {'confirmMsg': '请慎重！确定要重置分组【'+v.group_name+'】的编排信息吗？', 'successMsgType': 'Swal', successMsg:'分组【'+v.group_name+'】的编排信息已重置，请重新进行编排！', showMsg: true}, {RequestWithLoading: true})">重置编排</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 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()['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">
       <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.group_std_total > 0">(共:{{group.group_std_total}}人)</span>(评委:{{group.room_judge_num}})<span
         *ngIf="group.pagerless_flag === 'Active'" class="text-success">(无纸化评分)</span>】
       </span>【<span
        [innerHTML]="group.once_flag | frameStatusCustom:['单专业考场','混合考场', 'text-primary', 'text-danger']"></span>】【<span
        [innerHTML]="group.appointment_type | frameDict:'InterviewAppointmentType'"></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">
        <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" href="#" (click)="showParamModal(group)">分组参数</a>

            <div class="dropdown-divider" *ngIf="group.ly_status === 'Ready'"></div>
            <a class="dropdown-item text-primary" href="#" *ngIf="group.ly_status === 'Ready'"
               (click)="startArrange(group)">开始编排</a>
            <div class="dropdown-divider" *ngIf="group.ly_status === 'Complete' || group.ly_status === 'Publish'"></div>
            <a class="dropdown-item text-warning" href="#"
               *ngIf="group.ly_status === 'Complete' || group.ly_status === 'Publish'"
               (click)="editArrange(group)">修改编排</a>

            <div class="dropdown-divider" *ngIf="group.ly_status === 'Complete' || group.ly_status === 'Publish'"></div>
            <a class="dropdown-item text-danger" href="#" *ngIf="group.ly_status === 'Complete' || group.ly_status === 'Publish'"
               (click)="ajax.optrRecord('layout/group/interview/reset.htm', {ly_group_id: group.ly_group_id}, {'confirmMsg': '请慎重！确定要重置分组【'+group.group_name+'】的编排信息吗？', 'successMsgType': 'Swal', successMsg:'分组【'+group.group_name+'】的编排信息已重置，请重新进行编排！', showMsg: true}, {RequestWithLoading: true})">重置编排</a>

            <div class="dropdown-divider" *ngIf="group.ly_status === 'Complete'"></div>
            <a class="dropdown-item text-info" href="#"
               *ngIf="group.ly_status === 'Complete'" (click)="ajax.optrRecord('layout/group/interview/publish/group.htm',{ly_group_id: group.ly_group_id},{confirmMsg:'确定要单独将该面试项目进行发布吗？', successMsg:'面试项目已发布！', showMsg: true}, {RequestWithLoading: true})">发布编排</a>


            <div class="dropdown-divider" *ngIf="group.ly_status !== 'Publish'"></div>
            <a class="dropdown-item text-danger" href="#" *ngIf="group.ly_status !== 'Publish'"
               (click)="ajax.optrRecord('layout/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>
        </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.subject_name}}({{sb.subject_id}})</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.subject_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]="'layout/group/list.htm'" [requestData]="{group_type:'Interview',ly_agent_id: agent.ly_agent_id}"
              [requestParam]="{RequestDataType:'map', RequestWithLoading:true}" #ajax></frame-ajax>
</ng-container>
