<div class="modal-header">
  <h4 class="modal-title pull-left">后台补报考</h4>
</div>

<div class="modal-body">
  <div class="card card-default">
    <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-9 col-md-9">
          <ngx-select [items]="ResponseArray" [(ngModel)]="currentEnrol.category_id" [autoClearSearch]="true"
                      placeholder="请选择报考大楼" (ngModelChange)="changeCategory()"
                      optionValueField="category_id" optionTextField="category_name"></ngx-select>
        </div>
      </div>
      <div class="form-group row" *ngIf="aspectArray !== undefined && aspectArray.length > 0">
        <label class="col-lg-2 col-form-label text-lg-right">报考专业</label>
        <div class="col-lg-9 col-md-9">
          <ngx-select [items]="aspectArray" [(ngModel)]="currentEnrol.aspect_id" [autoClearSearch]="true"
                      placeholder="请选择报考专业" (ngModelChange)="changeAspect()"
                      optionValueField="aspect_id" optionTextField="aspect_name"></ngx-select>
        </div>
      </div>
      <div class="form-group row" *ngIf="agentArray !== undefined && agentArray.length > 0">
        <label class="col-lg-2 col-form-label text-lg-right">报考考点</label>
        <div class="col-lg-9 col-md-9">
          <ngx-select [items]="agentArray" [(ngModel)]="currentEnrol.agent_id" [autoClearSearch]="true"
                      placeholder="请选择报考考点"
                      optionValueField="agent_id" optionTextField="agent_name"></ngx-select>
        </div>
      </div>
      <div class="form-group row" *ngIf="aspectVarietyArray !== undefined && aspectVarietyArray.length > 0">
        <label class="col-lg-2 col-form-label text-lg-right">乐器/舞种</label>
        <div class="col-lg-9 col-md-9">
          <ngx-select [items]="aspectVarietyArray" [(ngModel)]="currentEnrol.variety_id" [autoClearSearch]="true"
                      placeholder="请选择乐器/舞种" (ngModelChange)="changeAspectVariety()"
                      optionValueField="variety_id" optionTextField="variety_name"></ngx-select>
        </div>
      </div>
      <div class="form-group row" *ngIf="subjectMap !== undefined">
        <label class="col-lg-2 col-form-label text-lg-right">考试科目</label>
        <div class="col-lg-9 col-md-9">
          <table class="table table-striped table-hover table-bordered">
            <thead>
            <tr>
              <th>科目编号</th>
              <th>科目名称</th>
              <th>科目类型</th>
              <th>乐器舞种</th>
              <th></th>
            </tr>
            </thead>
            <tbody>
            <tr *ngFor="let v of subjectMap['BatchSubjectArray_1']; let i = index">
              <td>{{v.subject_id}}</td>
              <td>
                <span *ngIf="v.subject_group === undefined">{{v.subject_name}}</span>
                <span *ngIf="v.subject_group !== undefined">
                  <ngx-select [items]="subjectGroupArr" [(ngModel)]="v.subject_id"
                          optionValueField="subject_id" optionTextField="subject_name"></ngx-select>
                </span>
              </td>
              <td>{{v.subject_type | frameDict:'ConfSubjectType'}}</td>
              <td><span
                *ngIf="subjectMap['SubjectVariety_'+v.subject_id] && subjectMap['SubjectVariety_'+v.subject_id].length === 1">{{v.variety_name}}</span>
                <span
                  *ngIf="subjectMap['SubjectVariety_'+v.subject_id]!==undefined && subjectMap['SubjectVariety_'+v.subject_id].length>=1">
                  <ngx-select [items]="subjectMap['SubjectVariety_'+v.subject_id]" [(ngModel)]="v.variety_id"
                              [autoClearSearch]="true" (ngModelChange)="queryTracks()"
                              placeholder="请选择乐器/舞种" optionValueField="variety_id"
                              optionTextField="variety_name"></ngx-select>

                </span>
              </td>
              <td><span *ngIf="v.master_group!==undefined && v.master_flag === undefined">
                <em class="fa fa-check table-sort" (click)="setMaster(v)"></em>
              </span></td>
            </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div class="form-group row" *ngIf="tracksMap !== undefined">
        <label class="col-lg-2 col-form-label text-lg-right">曲目信息</label>
        <div class="col-lg-9 col-md-9">
          <table class="table table-striped table-hover table-bordered"
                 *ngFor="let variety of tracksMap.VarietyArray">
            <tr>
              <td [colSpan]="3">{{variety.variety_name}}</td>
            </tr>
            <tr>
              <th class="th-index">#</th>
              <th>类型</th>
              <th></th>
            </tr>
            <tr *ngFor="let t of tracksMap['VarietyTracks_' + variety.variety_id]">
              <td class="align-middle">{{t.tracks_order}}</td>
              <td class="align-middle">{{t.tracks_enrol_type | frameDict :'TracksEnrolType'}}</td>
              <td class="align-middle">
                <!-- 指定曲目 -->
                <span *ngIf="t.tracks_enrol_type === 'Appoint'">{{t.tracks_name}}</span>
                <!-- 考生自选 -->
                <span *ngIf="t.tracks_enrol_type === 'User'">
                    <input class="form-control input-group-sm" [(ngModel)]="t.tracks_name"  >
                  </span>
                <!-- todo 处理曲目库的问题 -->
                <span *ngIf="t.tracks_enrol_type === 'Variety'">
                  <!-- {{t.tracks_name}} -->
                  <ngx-select [items]="tracksArray" [(ngModel)]="t.tracks_id"
                          optionValueField="tracks_id" optionTextField="tracks_name"></ngx-select>
                </span>

              </td>
            </tr>
          </table>
        </div>
      </div>


    </div>
  </div>
</div>
<div class="modal-footer">
  <button class="btn btn-primary" type="button" (click)="saveEnrol()" *ngIf="this.subjectMap!==undefined">确认补报</button>
  <button class="btn btn-secondary ml-3" type="button" (click)="closeWindow()">关闭窗口</button>
</div>
