<div class="modal-header">
  <h4 class="modal-title pull-left">编排-面试分组 - 【{{currentEntity.group_name}}】</h4>
</div>
<div class="modal-body mb-1">
  <ng-container *ngIf="curStep === 'time'">
    <div class="card card-default">
      <div class="card-header bg-info">考试日期及考场数</div>
      <div class="card-body">
        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">开考日期</label>
          <div class="col-lg-2 col-md-2">
            <input class="form-control" type="text" [(ngModel)]="currentEntity.group_start_date" id="group_start_date" (click)="getDate()"/>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">结束日期</label>
          <div class="col-lg-2 col-md-2">
            <input class="form-control" type="text" [(ngModel)]="currentEntity.group_end_date" id="group_end_date" (click)="getDate()"/>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">考场数</label>
          <div class="col-lg-2 col-md-2">
            <input class="form-control" type="number" [(ngModel)]="currentEntity.room_total"
                   (keyup)="changeRoomTotal()"/>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">空时段</label>
          <div class="col-lg-2 col-md-2">
            <select class="form-control" frameDict [dictName]="'FrameStatus'" [tipFlag]="false"
                    [(ngModel)]="currentEntity.time_retain"></select>
          </div>
        </div>
        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">统一候考</label>
          <div class="col-lg-2 col-md-2">
            <select class="form-control" frameDict [dictName]="'FrameStatus'" [tipFlag]="false"
                    [(ngModel)]="currentEntity.focus_flag"></select>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">候考地址</label>
          <div class="col-lg-8 col-md-8">
            <input class="form-control" type="text" [readOnly]="currentEntity.focus_flag === 'InActive'"
                   [(ngModel)]="currentEntity.focus_addr"/>
          </div>
        </div>
        <table class="table table-striped table-hover table-bordered">
          <thead>
          <tr>
            <th class="th-index"></th>
            <th>考场地址</th>
            <th>候考地址</th>
          </tr>
          </thead>
          <tbody>
          <tr *ngFor="let v of roomArray; let i = index">
            <td>{{v.room_order}}</td>
            <td><input class="form-control form-control-sm wd-sd" type="text" [(ngModel)]="v.room_addr"/></td>
            <td><input class="form-control form-control-sm wd-sd" type="text" [(ngModel)]="v.room_waiting_addr"/></td>

          </tbody>
        </table>
      </div>
    </div>
    <div class="card card-default" *ngIf="currentEntity.room_total>0 && currentEntity.group_start_date">
      <div class="card-header bg-primary">考试时段定义</div>
      <div class="card-body">
        <div class="form-group row" *ngIf="timeFlag === false">
          <label class="col-lg-2 col-form-label text-lg-right">请选择时段模版</label>
          <div class="col-lg-10 col-md-10">
            <select class="form-control" (change)="changeTimeGroup()" [(ngModel)]="currentEntity.time_group">
              <option value="">请选择时段模版</option>
              <option *ngFor="let g of timeGroupArray" [value]="g.time_group">
                {{g.time_group}}({{g.times_count}}个时段，共【{{g.minutes_total}}】分钟)
              </option>
            </select>
          </div>
        </div>
        <table class="table table-striped table-hover table-bordered">
          <thead>
          <tr>
            <th class="th-index"></th>
            <th class="wd-sm">开始时间</th>
            <th class="wd-sm">结束时间</th>
            <th>时长(分钟)</th>
            <th *ngIf="currentEntity.province_flag === 'InActive'" class="wd-xs">考生数</th>
            <th *ngIf="currentEntity.province_flag === 'Active'" class="wd-xs">省内考生</th>
            <th *ngIf="currentEntity.province_flag === 'Active'" class="wd-xs">外省考生</th>
            <th class="th-b-1"></th>
          </tr>
          </thead>
          <tbody>
          <tr *ngFor="let v of timeArray; let i = index">
            <td>{{i + 1}}</td>
            <td><input class="form-control form-control-sm wd-sm" type="text" [(ngModel)]="v.exam_start_time" id="exam_start_time{{i+1}}" (click)="getDate()" /></td>
            <td><input class="form-control form-control-sm wd-sm" type="text" [(ngModel)]="v.exam_end_time" id="exam_end_time{{i+1}}" (click)="getDate()" /></td>
            <td>{{v.exam_minutes}}</td>
            <td *ngIf="currentEntity.province_flag === 'InActive'"><input class="form-control form-control-sm wd-xs"
                                                                          type="number" [(ngModel)]="v.country_total"/>
            </td>
            <td *ngIf="currentEntity.province_flag === 'Active'"><input class="form-control form-control-sm wd-xs"
                                                                        type="number" [(ngModel)]="v.province_total"/>
            </td>
            <td *ngIf="currentEntity.province_flag === 'Active'"><input class="form-control form-control-sm wd-xs"
                                                                        type="number" [(ngModel)]="v.outside_total"/>
            </td>
            <td>
               <span class="table-button text-danger"
                     (click)="deleteTime(v)"><em
                 class="fa-lg fas fa-trash-alt "></em></span>
            </td>
          </tbody>
        </table>
      </div>
    </div>
    <ng-container *ngIf="timeFlag === true">
      <div class="card card-default">
        <div class="card-header bg-info">请填写时段信息</div>
        <div class="card-body">
          <div class="form-group row">
            <label class="col-lg-2 col-form-label text-lg-right">开始时间</label>
            <div class="col-lg-2 col-md-2">
              <input class="form-control form-control" type="text" [(ngModel)]="currentEntity.exam_start_time" id="exam_start_time" (click)="getDate()"/>
            </div>
            <label class="col-lg-2 col-form-label text-lg-right">结束时间</label>
            <div class="col-lg-2 col-md-2">
              <input class="form-control form-control" type="text" [(ngModel)]="currentEntity.exam_end_time" id="exam_end_time" (click)="getDate()"/>
            </div>
            <div class="col-lg-2 col-md-2">
              <select class="form-control form-control-sm" frameDict [dictName]="'ExamTimeType'"
                      [(ngModel)]="currentEntity.time_type"></select>
            </div>
            <div class="col-lg-2 col-md-2">
              <button class="btn btn-primary" type="button" (click)="addTime()"> 增加时段</button>
            </div>
          </div>
        </div>
      </div>
    </ng-container>
  </ng-container>
  <div class="card card-transparent" *ngIf="timeMap && curStep === 'detail'">
    <div class="card-header">
      <span *ngIf="currentEntity.province_flag === 'InActive'">混排：共【{{currentEntity.group_std_total}}】考生，已安排【
        <span
          [ngClass]="{'text-success': timeMap['CountryTotal'] === currentEntity.group_std_total, 'text-warning': timeMap['CountryTotal'] > currentEntity.group_std_total ,'text-danger': timeMap['CountryTotal'] < currentEntity.group_std_total}">{{timeMap['CountryTotal']}}</span>】
        <span *ngIf="timeMap['CountryTotal'] > currentEntity.group_std_total">，溢出【<span
          class="text-warning">{{timeMap['CountryTotal'] - currentEntity.group_std_total}}</span>】</span>
        <span *ngIf="timeMap['CountryTotal'] < currentEntity.group_std_total">，还差【<span
          class="text-danger">{{currentEntity.group_std_total - timeMap['CountryTotal']}}</span>】</span>

      </span>
      <span *ngIf="currentEntity.province_flag === 'Active'">
        <span>省内：【{{currentEntity.province_std_total}}】，已排【
        <span
          [ngClass]="{'text-success': timeMap['ProvinceTotal'] === currentEntity.province_std_total, 'text-warning': timeMap['ProvinceTotal'] > currentEntity.province_std_total ,'text-danger': timeMap['ProvinceTotal'] < currentEntity.province_std_total}">{{timeMap['ProvinceTotal']}}</span>】
        <span *ngIf="timeMap['ProvinceTotal'] > currentEntity.province_std_total">，溢出【<span
          class="text-warning">{{timeMap['ProvinceTotal'] - currentEntity.province_std_total}}</span>】</span>
        <span *ngIf="timeMap['ProvinceTotal'] < currentEntity.province_std_total">，还差【<span
          class="text-danger">{{currentEntity.province_std_total - timeMap['ProvinceTotal']}}</span>】</span>
      </span>；
        <span>外省：【{{currentEntity.outside_std_total}}】，已排【
        <span
          [ngClass]="{'text-success': timeMap['OutsideTotal'] === currentEntity.outside_std_total, 'text-warning': timeMap['OutsideTotal'] > currentEntity.outside_std_total ,'text-danger': timeMap['OutsideTotal'] < currentEntity.outside_std_total}">{{timeMap['OutsideTotal']}}</span>】
        <span *ngIf="timeMap['OutsideTotal'] > currentEntity.outside_std_total">，溢出【<span
          class="text-warning">{{timeMap['OutsideTotal'] - currentEntity.outside_std_total}}</span>】</span>
        <span *ngIf="timeMap['OutsideTotal'] < currentEntity.outside_std_total">，还差【<span
          class="text-danger">{{currentEntity.outside_std_total - timeMap['OutsideTotal']}}</span>】</span>
      </span>
       </span>
    </div>
    <tabset class="bg-white p-0" justified="true">
      <tab *ngFor="let date of timeMap['DateArray']">
        <ng-template tabHeading>
          <em class="far fa-clock fa-fw"></em> {{date}}
        </ng-template>
        <div>
          <div class="card card-default">
            <div class="card-header bg-info"><span class="ml-2">考场安排</span></div>
            <div class="card-body">
              <table class="table table-striped table-hover table-bordered">
                <thead>
                <tr>
                  <th class="th-index"></th>
                  <th>考试时间</th>
                  <th>时长(分钟)</th>
                  <th *ngIf="currentEntity.province_flag === 'InActive'" class="wd-xs">考生数</th>
                  <th *ngIf="currentEntity.province_flag === 'Active'" class="wd-xs">省内考生</th>
                  <th *ngIf="currentEntity.province_flag === 'Active'" class="wd-xs">外省考生</th>
                  <th class="tb-b-1"></th>
                </tr>
                </thead>
                <tbody>
                <tr *ngFor="let v of timeMap.TimeMap[date]; let i = index">
                  <td>{{i + 1}}</td>
                  <td>{{v.exam_start_time}} - {{v.exam_end_time}}</td>
                  <td>{{v.exam_minutes}}</td>
                  <td *ngIf="currentEntity.province_flag === 'InActive'">
                    <input class="form-control form-control-sm wd-xs" type="number" [(ngModel)]="v.country_total"
                           (keyup)="changeTimeStdTotal(v)"/>
                  </td>
                  <td *ngIf="currentEntity.province_flag === 'Active'">
                    <input class="form-control form-control-sm wd-xs"
                           type="number"
                           [(ngModel)]="v.province_total" (keyup)="changeTimeStdTotal(v)"/>
                  </td>
                  <td *ngIf="currentEntity.province_flag === 'Active'">
                    <input class="form-control form-control-sm wd-xs" type="number" [(ngModel)]="v.outside_total"
                           (keyup)="changeTimeStdTotal(v)"/>
                  </td>
                  <td>
                  <span class="table-button text-danger"
                        (click)="deleteDateTime(date,v)"><em
                    class="fa-lg fas fa-trash-alt "></em></span>
                  </td>

                </tbody>
              </table>
            </div>
          </div>

          <div class="card card-default">
            <div class="card-header bg-primary"><span class="ml-2">考场安排</span></div>
            <div class="card-body">
              <table class="table table-striped table-hover table-bordered">
                <thead>
                <tr>
                  <th class="th-index"></th>
                  <th>考场地址</th>
                  <th>候考地址</th>
                  <th class="wd-sd">状态</th>
                </tr>
                </thead>
                <tbody>
                <tr *ngFor="let v of  timeMap.RoomMap[date]; let i = index">
                  <td>{{v.room_order}}</td>
                  <td><input class="form-control form-control-sm wd-sd" type="text"
                             [readonly]="v.room_status==='InActive'" [(ngModel)]="v.room_addr"/></td>
                  <td><input class="form-control form-control-sm wd-sd" type="text"
                             [readonly]="v.room_status==='InActive'" [(ngModel)]="v.room_waiting_addr"/></td>
                  <td><select class="form-control form-control-sm wd-sd" type="text" [(ngModel)]="v.room_status"
                              frameDict [dictName]="'FrameStatus'" [tipFlag]="false"></select></td>
                </tr>
                </tbody>
              </table>
            </div>
          </div>

        </div>
      </tab>
    </tabset>
  </div>
</div>

<div class="modal-footer justify-content-between">
  <div>
    <button class="btn btn-primary" type="button" *ngIf="timeArray && curStep === 'time' && timeArray.length>1"
            (click)="FuncService.sortArray(timeArray, 'exam_start_time')">
      排序
    </button>
    <button class="btn btn-primary ml-2" type="button" *ngIf="curStep === 'time'  && timeFlag === false"
            (click)="timeFlag = true"> 增加时段
    </button>
    <button class="btn btn-primary ml-2" type="button" *ngIf="timeFlag === true"
            (click)="timeFlag = false"> 关闭时段编辑
    </button>
    <button class="btn btn-primary ml-2" type="button" *ngIf="curStep === 'detail'"
            (click)="timeMap === undefined; curStep = 'time'"> 重新定义时段
    </button>
  </div>
  <div>
    <button class="btn btn-primary" type="button" (click)="arrangeGroup()"
            *ngIf="curStep === 'detail'">
      确定编排信息
    </button>
    <button class="btn btn-primary" type="button" (click)="confirmTime()"
            *ngIf="curStep === 'time' && timeFlag === false && timeArray && timeArray.length > 0">
      确认考场及时段
    </button>
    <button class="btn btn-secondary ml-2" type="button" (click)="closeWindow()">关闭窗口</button>
  </div>
</div>
