<div class="panel panel-default">
    <!--标题-->
    <div class="panel-title" style="margin-bottom:0px;">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb" style="margin-bottom:0px;">
                <!-- TODO
                <li class="breadcrumb-item">专业管理</li> -->
                <li class="breadcrumb-item active" aria-current="page">专业申报审批</li>
            </ol>
        </nav>
    </div>

    <div [hidden]="editShowType=='only'" class="panel-title panel-heading jf-org-tab" style="margin-top:0px;margin-bottom:-1px;">
        <div class="panel-control" style="float:left;">
            <ul class="nav nav-tabs">
                <li [class]='0 == isActive? "li-class-active" : "li-class" ' (click)="changeLi($event,0,1)">等待审核</li>
                <li [class]='1 == isActive? "li-class-active" : "li-class" ' (click)="changeLi($event,1,2)">审核完成</li>
               

            </ul>
        </div>
    </div>

    <div class="panel-body ml-sm" [hidden]="editShowType=='only'">
        <div class="card card-default">
            <div class="card-body">
                <!--查询条件-->
                <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>
                                <flex-select [allowClear]="true"
                                    [url] = "'pl/plYearCode/list.htm'"
                                    respDataPath= "array"
                                    optionValueField="year_code"
                                    optionTextField="year_code"
                                    [(ngModel)]="query.yearCode"
                                    placeholder="请选择"
                                    [ngModelOptions]="{standalone: true}"
                                    width = "80"
                                    noResultsFound = "无数据"
                                    >
                                </flex-select>
                            </div>
                        </td>
                        
                        <td></td>
                        </tr>-->
                        <tr>
                           <!-- <td>
                            <div class="input-group mr-1 input-group-sm">
                                <label>申报形式：</label>
                                <select class="custom-select" 
                                    [(ngModel)]="query.applyForm" 
                                    [ngModelOptions]="{standalone: true}"
                                    frameDict [dictName]="'apply_form'" 
                                    [tipFlag]="true" 
                                    style="width:120px;">
                                </select>
                            </div>
                        </td>-->
                        <td>
                            <div class="input-group mr-1 input-group-sm">
                                <label>主考学校：</label>
                                <flex-select [allowClear]="true"
                                    [(items)] = "masterSchoolList"
                                    respDataPath= "array"
                                    optionValueField="id"
                                    optionTextField="org_name"
                                    [(ngModel)]="query.masterSchoolId"
                                    placeholder="请选择"
                                    [ngModelOptions]="{standalone: true}"
                                    width = "200"
                                    noResultsFound = "无数据"
                                    >
                                </flex-select>
                            </div>
                        </td>
                        <td>
                            <div class="input-group mr-1 input-group-sm">
                                <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;专业：</label>
                                <flex-select [allowClear]="true"
                                    [url]= "'pl/plMajor/openMajorList.htm'"
                                    #major_id
                                    respDataPath= "array"
                                    optionValueField="id"
                                    optionTextField="full_name"
                                    [(ngModel)]="query.majorId"
                                    placeholder="请选择"
                                    width = "200"
                                    noResultsFound = "无数据"
                                    [ngModelOptions]="{standalone: true}"
                                    >
                                </flex-select>
                                
                            </div>
                        </td>
                        <td>
                            <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)="resetQuery()">
                                <i class="fa fa-undo"></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)="doAudit()" title="审批">
                                <i class="fa fa-plus"></i> 审批</button>&nbsp;
                           
                                <button class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left"
                                (click)="shouModalWin(auditFileModal,'modal-md')" title="上传批文">
                                <i class="fa fa-plus"></i> 上传批文</button>&nbsp;
                         
                        </div>

                    </div>
                </div>
  -->
                <!--表格-->
                <div class="row">
                    <div class="col-lg-12 ml-0" [hidden]="editShowType=='only'">
                        <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>序号</th>
                                   <!-- <th align="center">年度码</th>-->
                                    <th align="center">申报形式</th>
                                    <th>主考院校</th>
                                    <th>专业代码</th>
                                    <th>专业名称</th>
                                    <th align="center">申报日期</th>
                                    <th>申报文号</th>
                                    <th>状态</th>
                                   <!-- <th align="center">是否驳回</th>-->
                                    <th style="width: 80px;" 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>
                                                <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.year_code}}</td>-->
                                    <td align="center" [innerHTML]="item.apply_form| frameDict:'MajorApplyForm'"></td>
                                    <td>{{item.master_school}}</td>
                                    <td>{{item.major_code}}</td>
                                    <td>{{item.major_name}}</td>
                                    <td align="center">{{item.apply_date.substring(0,10)}}</td>
                                    <td><a href="#" (click)="downloadApplyFile(item.id);">{{item.apply_no}}</a></td>
                                    <td [innerHTML]="item.status| frameDict:'MajorApplyStatus'"></td>
                                    <!--<td align="center">
                                        <div *ngIf="item.is_auth_back===0" class="text-muted">
                                            {{item.is_auth_back| frameDict:  'YesOrNo' }}</div>
                                        <div *ngIf="item.is_auth_back===1" class="text-danger">
                                            {{item.is_auth_back| frameDict: 'YesOrNo' }}</div>
                                    </td>
                                -->
                                    <td align="center">
                                        <a href="#" (click)="proxyGoEdit(item)" title="审批">
                                            <em class="fa-lg fas fa-edit mr-1" style="color:#F56D6D"></em></a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <!-- TODO -->
                        <frame-pager [url]="QUERY_URL" hideSearch="true" hasCheck="true" #framePager (preReqEvent)="search($event)"></frame-pager>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 申报时间过滤界面-->
    <div class="col-lg-12" *ngIf="editShowType != null && editShowType =='only'">
        <ng-container *ngTemplateOutlet="auditModal">
        </ng-container>
    </div>        
</div>

<!-- 审核界面******************************************** -->
<ng-template #auditModal>
    <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]="auditTemplate"></div>
          </div>
      
          <div class="modal-footer">
            <button class="btn btn-info" (click)="auditFunc()" *ngIf="item && (item.status == 1 || item.status == 4)"><!--待审批显示提交按钮-->
                <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>
      
<ng-template #auditTemplate>
    <form [formGroup]="formModel" *ngIf="item" class="form-validate form-horizontal" novalidate="">
        <div class="row mb-1">
                <label class="col-lg-2 col-form-label text-lg-right">主考学校</label>
                <div class="col-lg-8">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>主考学校代码</th>
                                <th>主考学校名称</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>{{item.masterSchool.org_code_bz}}</td>
                                <td>{{item.masterSchool.org_name}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
        </div>

        <div class="row mb-2">
            <label class="col-lg-2 col-form-label text-lg-right">申报形式</label>
            <div class="col-lg-8 col-form-label ">
                    <span [innerHTML]="item.apply_form| frameDict:'MajorApplyForm'"></span>
              
            </div>
        </div>

        <!--申请的专业列表-->
        <div class="row mb-1">
            <!-- 审核流程列表 -->
            <label class="col-lg-2 col-form-label text-lg-right">申报专业</label>
            <div class="col-lg-8">
                <table class="table table-sm table-striped table-hover table-bordered bg-white">
                    <thead>
                        <tr>
                            
                            <th>专业代码</th>
                            <th>专业名称</th>
                            <th align="center">专业层次</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let it of applyMajorList; let i = index">
                           
                            <td>{{it.major_code}}</td>
                            <td>{{it.major_name}}</td>
                            <td align="center" [innerHTML]="it.major_level| frameDict:'MajorLevel'"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 审核记录查询 
        <div class="row mb-1">
            
            <label class="col-lg-2 col-form-label text-lg-right">审核记录</label>
            <div class="col-lg-8">
                <table class="table table-sm table-striped table-hover table-bordered bg-white">
                    <thead>
                        <tr>
                            <th>审核类型</th>
                            <th align="center">审核时间</th>
                            <th>审核人</th>
                            <th>审核意见</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let it of authList; let i = index">
                            <td>{{it.auth_type | frameDict:'MajorApplyAuthType'}}</td>
                            <td align="center">{{it.auth_time}}</td>
                            <td>{{it.optr_name}}</td>
                            <td>{{it.auth_remark}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        -->
        <div class="row mb-1">
            <label class="col-lg-2 col-form-label text-lg-right">申报文书号</label>
            <div class="col-lg-8">
                <input class="form-control" formControlName="apply_no" type="text" [(ngModel)]="item.apply_no" 
                [formControl]="formModel.controls['apply_no']" width="40" disabled/>
            </div>
        </div>
        <div class="row mb-1">
            <label class="col-lg-2 col-form-label text-lg-right">申报资料</label>
            <div class="col-lg-8 form-inline">
                <!--<button class="btn btn-info" (click)="uploadFile()">
                    <i class="fa fa-info-circle"> </i> 上传
                </button>-->&nbsp;&nbsp;&nbsp;&nbsp;
                <span *ngIf="item.id && item.file_name">{{item.file_name}}</span> &nbsp;&nbsp;
                <button *ngIf="item.id && item.file_name" (click)="downloadApplyFile(item.id)"  class="btn btn-warning btn-xs ml-2">
                    <i class="fa icon-cloud-download"></i>下载
                </button>
            </div>
        </div>
        <div class="row mb-1" *ngIf="item && (item.status == 1 || item.status == 4)">
            <label class="col-lg-2 col-form-label text-lg-right">审批类型</label>
            <div class="col-lg-8 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" 
                            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" 
                            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 mb-1" *ngIf="item && (item.status == 1 || item.status == 4)">
            <label class="col-lg-2 col-form-label text-lg-right">审批意见</label>
            <div class="col-lg-8">
                <textarea class="form-control" [(ngModel)]="item.auth_remark" formControlName="auth_remark" [formControl]="formModel.controls['auth_remark']" rows="3"></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 #auditFileTemplate>
    <div class="form-inline mt-1">
        <label class="col-lg-3 col-form-label text-lg-right">年  度  码</label>
        <flex-select [allowClear]="true"
            [(items)] = "yearCodeList"
            respDataPath= "array"
            optionValueField="year_code"
            optionTextField="year_code"
            [(ngModel)]="importQuery.yearCode"
            placeholder="请选择"
            [ngModelOptions]="{standalone: true}"
            width = "100"
            noResultsFound = "无数据">
        </flex-select>
    </div>
    <div class="form-inline mt-1">
        <label class="col-lg-3 col-form-label text-lg-right">申报形式</label>
        <select class="custom-select" 
            [ngModelOptions]="{standalone: true}"
            [(ngModel)]="importQuery.applyForm" 
            frameDict [dictName]="'MajorApplyForm'"
            (change)="freshAuditFile(this)"
            [tipFlag]="true" style="width:100">
        </select>&nbsp;
        <button class="btn btn-primary mr-1 btn-sm" data-toggle="tooltip" data-placement="left" (click)="importFunc();" title="导入">
            <i class="fa icon-cloud-download"></i> 导入</button>&nbsp;
    </div>
    <div class="table-responsive mt-2">
        <table class="table table-bordered table-hover table-striped">
            <thead>
                <tr>
                    <th>年度码</th>
                    <th>申报形式</th>
                    <th>审批批文</th>
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let item of auditFileList; let i = index">
                    <td>{{item.year_code}}</td>
                    <td [innerHTML]="item.apply_form| frameDict:'MajorApplyForm'"></td>
                    <td><a href="#" (click)="downloadAuditFile(item.id);">{{item.file_path}}</a></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="row">
        <frame-uploader #uploader [silenceUpload]="true" [autoUpload]="true" [(uploadUrl)]="UPLOAD_URL"></frame-uploader>
    </div>
</ng-template>
<!--审批批文模态窗口-->
<ng-template #auditFileModal>
    <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>

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

      <div class="modal-footer">
        <button class="btn btn-info" (click)="hideModal();">
          <i class="fa fa-info-circle"> </i> 关闭
        </button>
      </div>
    </div>
  </ng-template>