<div class="panel panel-default">
  <div>
    <!--标题-->
    <div class="panel-title">
      <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
          <li class="breadcrumb-item">转至外省</li>
          <li class="breadcrumb-item active" aria-current="page">转至外省回执处理</li>
        </ol>
      </nav>
    </div>
  </div>

  <div class="panel-body ml-sm " [hidden]="editShowType=='only'">
    <!--查询条件-->
    <div class="row mb-3 ml-1" [hidden]="editShowType=='only'">
      <div class="col-lg-12">
        <form (ngSubmit)="framePager.goSearch()" class="form-inline">
          <!-- 支持排序 -->
          <table><tr>
            <td>
          <div class="input-group mr-1 input-group-sm">
            <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;关键字：</label>
            <input name="query" [(ngModel)]="query.query" class="input-sm form-control" type="text" value="" maxlength="64"
              placeholder="请输入查询关键字">
          </div>
        </td>
        <td>
          <div class="input-group mr-1 input-group-sm">
            <label class="ml-sm">转考批次：</label>
            <flex-select [allowClear]="true" [url]="TIME_URL" respDataPath="array" optionValueField="id"
              optionTextField="year_time" [(ngModel)]="query.time_config_id" placeholder="请选择" [ngModelOptions]="{standalone: true}"
              width="80" noResultsFound="无数据">
            </flex-select>
          </div>
        </td>
        </tr>
        <tr>
            <td>
          <div class="input-group mr-1 input-group-sm">
            <label class="ml-sm">转至省份：</label>
            <flex-select [allowClear]="true" [url]="PROV_URL" respDataPath="array" optionValueField="province_id"
              optionTextField="province_name" [(ngModel)]="query.prov_code" placeholder="请选择" [ngModelOptions]="{standalone: true}"
              width="80" noResultsFound="无数据">
            </flex-select>
          </div>
          </td>
          <td *ngIf="logOrgType == 0">
          <div  class="input-group mr-1 input-group-sm">
            <label class="ml-sm">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;状态：</label>
            <select name="status" 
                width = "100"
                [(ngModel)]="query.status" 
                frameDict [dictName]="'TurnStatus'" 
                [ngModelOptions]="{standalone: true}"
                class="form-control">
            </select>
          </div>
        </td>
        <td>
          <button class="btn btn-primary btn-rounded btn-outline btn-sm  mr-1">
            <i class="fa fa-search"></i> 查询</button>
          </td>
          </tr></table>
          </form>
      </div>
    </div>

    <!-- 工具栏 -->
    <div class="row mb-2" [hidden]="editShowType=='only'">
      <div class="col-lg-12">
        <div class="pull-left" style="text-align: right;">
          <button class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left" (click)="showAudit(editTemplateModal,'only')"
            title="转至外省回执">
            <i class="fa fa-check"></i>转至外省回执处理</button>
            <!--
            <button class="btn btn-primary mr-1 btn-sm" (click)="printPage()" data-toggle="tooltip" data-placement="left"
            title="转出介绍信">
            <i class="fa icon-printer"> 转出介绍信</i>
          </button>

          <button class="btn btn-primary mr-1 btn-sm" (click)="print()" data-toggle="tooltip" data-placement="left"
            title="成绩证明">
            <i class="fa icon-printer"> 打印成绩证明(考办与考生)</i>
          </button>
          <button class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left" title="转出申请表" (click)= "printTurnout()">
            <i class="fa icon-login">  转出登记表</i>
          </button>
          <button  *ngIf="logOrgType == 0" class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left" title="数据上报国家平台后，点击该按钮修改申请单状态为转至省外。" (click)= "changeStatus()">
            <i class="fa icon-login">  转至省外</i>
          </button>
          -->
         
        </div>

      </div>
    </div>

    <!--表格-->
    <div class="row" [hidden]="editShowType=='only'">
      <div class="col-sm-12 ml-0">
        <table class="table table-sm table-striped table-hover table-bordered bg-white">
          <thead>
            <tr>
              <th>
                <div class="checkbox c-checkbox">
                  <label>
                    <input type="checkbox" (change)="framePager.checkedMasterToggle($event)" />
                    <span class="fa fa-check"></span>
                  </label>
                </div>
              </th>
              <th align="center">批次</th>
              <th>身份证号</th>
              <th>考生姓名</th>
              <th align="center">转出准考证</th>
              <th>专业代码</th>
              <th>专业名称</th>
              <th>转至省份</th>
              <th>外省准考证</th>
              <th>审核机构</th>
              <th>状态</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let item of framePager.getRecords(); let i = index">
              <td>
                <div class="checkbox c-checkbox input-group-sm">
                  <label>
                    <input type="checkbox" [value]="item.id" [(checked)]="item.isChecked" [(ngModel)]="item.isChecked" />
                    <span class="fa fa-check"></span>
                  </label>
                </div>
              </td>
              <td align="center">{{item.year}}{{item.time| frameDict: 'time'}}</td>
              <td>{{item.cert_no}}</td>
              <td>{{item.std_name}}</td>
              <td align="center">{{item.out_ticket_no}}</td>
              <td>{{item.major_code}}</td>
              <td>{{item.major_name}}</td>
              <td>{{item.province_name}}</td>
              <td>{{item.in_ticket_no}}</td>
              <td>{{item.org_name}}</td>
              <td *ngIf="item.std_source === 1 && item.status === 1"> 待市考办审核</td>
              <td *ngIf="item.std_source === 3 && item.status === 1"> 待主考学校审核</td>
              <td *ngIf="item.status === 3 || item.status === 4|| item.status === 5|| item.status === 6|| item.status === 7">{{item.status | frameDict: 'TurnStatus'}}</td>
            </tr>
          </tbody>
        </table>
        <frame-pager [url]="QUERY_URL" [autoLoad]="false" hideSearch="true" hasCheck="true" #framePager (preReqEvent)="search($event)"></frame-pager>
      </div>
      <!-- 编辑页面 -->
      <div class="col-lg-12" *ngIf="item && editShowType != null &&editShowType!='modal'">
        <ng-container *ngTemplateOutlet="editTemplateModal">
        </ng-container>
      </div>

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

<!--编辑界面模板-->
<ng-template #editFormTemplate>
  <form [formGroup]="formModel" (ngSubmit)="audit()" class="form-validate form-horizontal" novalidate>
      
    <div class="row mt-3" style="padding-top:0px;margin-top: 0px;">
        

      <div class="col-lg-12">
        <table class="table table-sm table-striped table-hover table-bordered bg-white">
          <thead>
            <tr>
              <th>序号</th>
              <th>考试日期</th>
              <th>课程代码</th>
              <th>课程名称</th>
              <th>学分</th>
              <th>课程性质</th>
              <th>成绩来源</th>
              <th>成绩</th>
              <th>备注</th>
              
            </tr>
          </thead>
          <tr *ngFor="let item of courseList; let i =index">
            <td>{{i+1}}</td>
            <td>{{item.exam_date}}</td>
            <td>{{item.course_code}}</td>
            <td>{{item.course_name}}</td>
            <td>{{item.course_score}}</td>
            <td>{{item.course_exam_type | frameDict: 'CourseNature'}}</td>
            <td>{{item.score_source | frameDict: 'ScoreSource'}}</td>
            <td>{{item.origin_score}}</td>
            <td>{{item.out_remark}}</td>
            
          </tr>
        </table>
      </div>
    </div>

    <div class="row mt-3">
      <div class="col-lg-12">
        <table class="table table-sm table-striped table-hover table-bordered bg-white">
          <tr>
            <td rowspan="5" width="10%" align="center">
              <img src="{{applyInfo.photo_path}}" alt="考生头像" style="width: 180px;height: 240px;border:solid 1.5px #000000;" />
            </td>
            <td width="10%" align="right">姓名：</td>
            <td width="30%">{{applyInfo.std_name}}</td>
          </tr>
          <tr>
            <td align="right">准考证：</td>
            <td>{{applyInfo.out_ticket_no}}</td>
          </tr>
          <tr>
            <td align="right">身份证：</td>
            <td>{{applyInfo.cert_no}}</td>
          </tr>
          <tr>
            <td align="right">转至省份：</td>
            <td>{{applyInfo.province_name}}</td>
          </tr>
          <tr>
            <td align="right">外省准考证：</td>
            <td>{{applyInfo.in_ticket_no}}</td>
          </tr>
        </table>
      </div>
    </div>

    <div class="row mt-3">
      <label class="col-lg-2 col-form-label text-lg-right">外省接收状态：</label>
      <div class="col-lg-4">
          

        <select [(ngModel)]="receive_status" formControlName="receive_status" [formControl]="formModel.controls['receive_status']"
          frameDict [dictName]="'OutProvStatus'" [(dictValue)]="receive_status" class="form-control">
        </select>
        <span class="text-danger" *ngIf="formModel.get('receive_status').hasError('required') && (formModel.get('receive_status').dirty || formModel.get('receive_status').touched)">请选择外省接收状态</span>
      </div>
    </div>

    <div class="row mt-3">
      <label class="col-lg-2 col-form-label text-lg-right">外省接收说明：</label>
      <div class="col-lg-10">
        <textarea class="form-control" formControlName="back_reason" [formControl]="formModel.controls['back_reason']"
          placeholder="请填写外省接收说明" [(ngModel)]="back_reason" rows="5"></textarea>
      </div>
    </div>


  </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)="hideModal()">×</button>
    </div>

    <div class="modal-body">
      <div [ngTemplateOutlet]="editFormTemplate"></div>

    </div>
    <div class="modal-footer">
      <button *ngIf="(logOrgType == 0 && applyInfo.status =='5')" class="btn btn-info" (click)="audit()">
        <i class="fa fa-info-circle"> </i> 转至外省回执处理
      </button>
      <button class="btn btn-default" (click)="hideModal()">
        <i class="icon-close"> </i> 取消
      </button>
    </div>
  </div>
</ng-template>