<div class="panel panel-default">
  <!--标题-->
  <div class="panel-title">
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb">
        <!-- TODO -->
        <li class="breadcrumb-item active" aria-current="page">试卷交接</li>
      </ol>
    </nav>
  </div>
  <div class="panel-body ml-sm" [hidden]="this.editShowType=='only'">
    <div class="card card-default">
      <div class="card-body">
        <!--查询条件-->
        <div class="row mb-3 ml-1" [hidden]="this.editShowType=='only'">
          <div class="col-lg-12">
            <form class="form-inline">
              <table>
                <tr>
                  <td>
              <div class="input-group mr-1 input-group-sm">
                <label>考试批次：</label>
                <select class="custom-select"  [(ngModel)]="query.exam_time_id" [ngModelOptions]="{standalone: true}" (change)="changePoint()">
                  <option value="">--请选择--</option>
                  <option *ngFor="let item of examTimeIdArray; let i = index" [value]="item.id">{{item.exam_year_month}}</option>
                  </select>
              </div>
            </td>
            <td>
              <div class="input-group mr-1 input-group-sm" *ngIf="curOrg.org_type == 0">
                <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考区：</label>
                <select class="custom-select" style="width:200px;"  [(ngModel)]="query.exam_area_id" [ngModelOptions]="{standalone: true}" (change)="changePoint()">
                  <option value="">全区</option>
                  <option *ngFor="let item of examAreaArray" [value]="item.id">{{item.org_name}}</option>
                  </select>
              </div>
            </td>
            <td>
              <div class="input-group mr-1 input-group-sm">
                <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考点：</label>
                <select class="custom-select" style="width:200px;"  [(ngModel)]="query.exam_agent_id" [ngModelOptions]="{standalone: true}">
                  <option value="">所有考点</option>
                  <option *ngFor="let item of agentArray" [value]="item.id">{{item.exam_name}}</option>
                  </select>
              </div>
            </td>
            <td></td>
            </tr>
            <tr>
                <td>
              <div class="input-group mr-1 input-group-sm">
                <label>课程代码：</label>
                <input name="keyword" [(ngModel)]="query.course_code" class="input-sm form-control" type="text" value="" maxlength="64">
              </div>
              </td>
              <td>
              <div class="input-group mr-1 input-group-sm">
                <label> 评阅方式：</label>
                <select class="custom-select"  [(ngModel)]="query.is_net_mark" [ngModelOptions]="{standalone: true}">
                  <option value="">全部</option>
                  <option value="1">网评</option>
                  <option value="2">非网评</option>
                </select>
              </div>
              </td>
              <td>
              <div class="input-group mr-1 input-group-sm">
                <label> 分考区：</label>
                <select class="custom-select"  [(ngModel)]="query.isAreaAllExp" [ngModelOptions]="{standalone: true}">
                  <option value="">否</option>
                  <option value="1">是</option>
                </select>
              </div>
            </td>
            <td algin="right">
              <button class="btn btn-primary btn-rounded btn-outline btn-sm  mr-1" (click)="framePager.goSearch()">
                <i class="fa fa-search"></i> 查询</button>
              <button class="btn btn-primary btn-rounded btn-outline btn-sm  mr-1" (click)="reset()">
                <i class="fa fa-undo"></i> 重置</button>
              </td>
              </tr>
              </table>
              </form>
          </div>
        </div>

        <!-- 工具栏 -->
        <div class="row mb-2" [hidden]="this.editShowType=='only'">
          <div class="col-lg-12">
            <div class="pull-left" style="text-align: right;">

              <button id="exportPdf" (click)="exportPdf();" class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left" title="导出">
                <i class="fa icon-cloud-download"></i> PDF导出</button>

              <button id="exportExcel" (click)="exportExcel();" class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left" title="导出">
                <i class="fa icon-cloud-download"></i> EXCEL导出</button>
            </div>


          </div>
        </div>

        <!--表格-->
        <div class="row">
          <div class="col-lg-12 ml-0" [hidden]="this.editShowType=='only'">
            <table class="table table-sm table-striped table-hover table-bordered bg-white">
              <thead>
                <tr>
                  <th>
                    <div class="checkbox c-checkbox">
                      <label class="nomargin">
                        <input type="checkbox" (change)="framePager.checkedMasterToggle($event)" />
                        <span class="fa fa-check"></span>
                      </label>
                    </div>
                  </th>

                  <th>序号</th>
                  <th align="center">考试时间</th>
                  <th align="center">时段</th>
                  <th align="center">课程代码</th>
                  <th>课程名称</th>
                  <th align="center">大袋</th>
                  <th align="center">中袋</th>
                  <th align="center">小袋</th>

                </tr>
              </thead>
              <tbody>
                <tr *ngFor="let item of framePager.getRecords(); let i = index">
                  <td>
                    <div class="checkbox c-checkbox input-group-sm">
                      <label nomargin>
                        <input type="checkbox" [value]="item.id" [(checked)]="item.isChecked" [(ngModel)]="item.isChecked" />
                        <span class="fa fa-check"></span>
                      </label>
                    </div>
                  </td>
                  <td>{{framePager.pageStart + i}}</td>
                  <td align="center">{{item.sum_exam_times}}</td>
                  <td align="center">{{item.exam_times}}</td>
                  <td align="center">{{item.course_code}}</td>
                  <td>{{item.course_name}}</td>
                  <td align="right">{{item.sum_bag_30==0?'':item.sum_bag_30}}</td>
                  <td align="right">{{item.sum_bag_15==0?'':item.sum_bag_15}}</td>
                  <td align="right">{{item.sum_bag_5==0?'':item.sum_bag_5}}</td>
                </tr>
              </tbody>
            </table>
            <!-- TODO -->
            <frame-pager [url]="QUERY_URL" hideSearch="true" hasCheck="true" #framePager (preReqEvent)="this.search($event)"></frame-pager>
          </div>

          <!-- 编辑页面 -->
          <div class="col-lg-12" *ngIf="this.item && this.editShowType != null &&this.editShowType!='modal'">
            <ng-container *ngTemplateOutlet="editTemplateModal">
            </ng-container>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- only编辑页面 -->
  <div class="col-lg-12" *ngIf="this.item && this.editShowType != null && this.editShowType =='only'">
    <ng-container *ngTemplateOutlet="editTemplateModal">
    </ng-container>
  </div>
</div>



<ng-template #editFormTemplate>
  <form [formGroup]="formModel" *ngIf="item" class="form-validate form-horizontal" novalidate="">
    <input type="hidden" class="form-control" formControlName="id" [(ngModel)]="this.item.id" [formControl]="this.formModel.controls['id']"
    />
  </form>
</ng-template>

<ng-template #editTemplateModal>
  <div class="modal-content">
    <div class="modal-header info-success-qm">
      <div class="pull-left">
        <em class="fa-lg fas fa-edit "></em> 编辑页面
      </div>
      <button type="button" class="close" (click)="this.hideModal()">×</button>
    </div>

    <!-- 1@3 -->
    <div class="modal-body">
      <div [ngTemplateOutlet]="editFormTemplate"></div>
    </div>

    <div class="modal-footer">
      <button class="btn btn-info" (click)="this.save()">
        <i class="fa fa-info-circle"> </i> 保存
      </button>
      <button class="btn btn-default" (click)="this.hideModal()">
        <i class="icon-close"> </i> 取消
      </button>
    </div>
  </div>
</ng-template>