<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>批次：</label>
            <flex-select [allowClear]="true" [(items)]="timeList" optionValueField="exam_year_month"
              optionTextField="examyearmonth" [(ngModel)]="query.year_code" placeholder="请选择"
              [ngModelOptions]="{standalone: true}" width="100" noResultsFound="无数据">
            </flex-select>
          </div>
        </td>
        

        <td>
          <button class="btn btn-primary btn-rounded btn-outline btn-sm  mr-1">
            <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" [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>序号</th>
              <th align="center">批次</th>
              <th>考区名称</th>
              <th align="center">状态</th>
              <th align="center">准考证背面标题</th>
              <th>准考证背面信息</th>
              <th>审核意见</th>
              <th style="width: 80px;" align="center">操作</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let item of framePager.getRecords(); let i = index" >
              
              <td>{{framePager.pageStart+i}}</td>
              <td align="center">{{item.examyearmonth}}</td>
              <td align="center">{{item.org_code}}-{{item.org_name}}</td>
              <td align="center">{{item.status}}</td>
              <td>{{item.title}}</td>
              <td>{{carouselContentFilter(item.content)}}</td>
              <td>{{carouselContentFilter(item.auth_remark)}}</td>

              
              <td align="center">
                <a href="#" *ngIf="item.id>0" (click)="goEdit(editTemplateModal,'only','modal-lg',item)" title="审批"><em
                    class="fa-lg fas fa-edit mr-1"></em></a>
                
              </td>
            </tr>
          </tbody>
        </table>
        <frame-pager [url]="QUERY_URL" 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="item && editShowType != null &&editShowType =='only'">
    <ng-container *ngTemplateOutlet="editTemplateModal">
    </ng-container>
  </div>
</div>




<!--编辑界面模板-->
<ng-template #editFormTemplate>
  <form [formGroup]="formModel" *ngIf="item" (ngSubmit)="save()" class="form-validate form-horizontal" novalidate>
    <input type="hidden" formControlName="id" [formControl]="formModel.controls['id']" />

    <div class="row mt-3">
      <label class="col-lg-2 col-form-label text-lg-right">批次</label>

      <div class="col-lg-4">
        <flex-select [allowClear]="true" [(items)]="timeList" optionValueField="exam_year_month"
          optionTextField="examyearmonth" [(ngModel)]="item.year_code" placeholder="请选择" width="200"
          noResultsFound="无数据" formControlName="year_code" [formControl]="formModel.controls['year_code']"  disabled="true">
        </flex-select>
        <span class="text-danger"
          *ngIf="formModel.controls['year_code'].hasError('required') && (formModel.controls['year_code'].dirty ||formModel.controls['year_code'].touched)">请选择批次</span>
      </div>

      <label class="col-lg-2 col-form-label text-lg-right">考区</label>
      <div class="col-lg-4">

          <flex-select [allowClear]="true" [(items)]="examAgentArray" optionValueField="org_code" optionTextField="org_name" [disabled]="flag"
          [(ngModel)]="item.org_code" placeholder="请选择" width="220" noResultsFound="无数据"
          formControlName="org_code" [formControl]="formModel.get('org_code')">
        </flex-select>
        <span class="text-danger"
          *ngIf="formModel.get('org_code').hasError('required') && (formModel.get('org_code').dirty || formModel.get('org_code').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">
          <input class="form-control" type="text" placeholder="请填写标题,如2024年上半年高等教育自学考试XX考区特别提示" maxlength="64" formControlName="title"
          [formControl]="formModel.controls['title']" [(ngModel)]="item.title" />
        <span class="text-danger"
          *ngIf="formModel.get('title').hasError('required') && (formModel.get('title').dirty || formModel.get('title').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" maxlength="512" formControlName="content" [(ngModel)]="item.content" rows="8" [formControl]="formModel.get('content')" placeholder="请填写准考证背面内容,如一、本次考试XX考区各考点将使用“智能安检门”、“金属探测仪”和人脸识别验证设备等多种方式对考生进行入场安检和身份验证。建议考生提前60分钟到达考点，做好入场安检准备。二、考生的车辆禁止进入考点，请考生尽量选择公共交通出行。如自驾车前往考点的，请提前了解考点周边公共停车场位置，并预留充足的停车及前往考点时间，以便能按时到达考点参加考试。"></textarea>
    <span class="text-danger"
    *ngIf="formModel.get('content').hasError('required') && (formModel.get('content').dirty || formModel.get('content').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 col-form-label">
      <label class="radio-inline c-radio" style="margin: 0px !important">
          <input type="radio" name="auth_type" value="1" [(ngModel)]="item.auth_type" (click)="this.item.auth_remark='审批通过'"
              formControlName="auth_type" [formControl]="formModel.controls['auth_type']" />&nbsp;审批通过&nbsp;
          <span class="fa fa-circle" style="margin: 0px !important"></span>
      </label>
      &nbsp;&nbsp;
      <label class="radio-inline c-radio" style="margin: 0px !important">
              <input type="radio" name="auth_type" value="2" [(ngModel)]="item.auth_type" (click)="this.item.auth_remark='审批驳回'"
                  formControlName="auth_type" [formControl]="formModel.controls['auth_type']" />&nbsp;审批驳回&nbsp;
              <span class="fa fa-circle" style="margin: 0px !important"></span>
      </label>
      &nbsp;&nbsp;
      <label class="radio-inline c-radio" style="margin: 0px !important">
              <input type="radio" name="auth_type" value="0" [(ngModel)]="item.auth_type" (click)="this.item.auth_remark='审批不通过'"
                  formControlName="auth_type" [formControl]="formModel.controls['auth_type']" />&nbsp;审批不通过&nbsp;
              <span class="fa fa-circle" style="margin: 0px !important"></span>
      </label>
      <span class="text-danger" *ngIf="formModel.get('auth_type').hasError('required') && (formModel.get('auth_type').dirty || formModel.get('auth_type').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" [(ngModel)]="item.auth_remark" formControlName="auth_remark" [formControl]="formModel.controls['auth_remark']" rows="3" maxlength="512"></textarea>
        <span class="text-danger" *ngIf="formModel.get('auth_remark').hasError('required') && (formModel.get('auth_remark').dirty || formModel.get('auth_remark').touched)">请输入审批意见</span>
     </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>  <span *ngIf="!item?.id">审批</span>
      </div>

      <button type="button" class="close" (click)="hideModal()">×</button>
    </div>

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

    </div>
    <div class="modal-footer">
      
      <button class="btn btn-info" *ngIf="item.status == '等待自治区考试院审核'" (click)="audit()">
        <i class="fa fa-info-circle"> </i> 审批
      </button>
      <button class="btn btn-info" *ngIf="item.status == '审核通过'||item.status == '审核不通过'" (click)="callback()">
          <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>



