<div class="modal-header">
  <h4 class="modal-title pull-left">专业方向【{{currentEntity.aspect_name}}】考试科目配置</h4>
</div>
<div class="modal-body">
  <table class="table table-striped table-hover table-bordered" [hidden]="curStep !== 'page'">
    <thead>
    <tr>
      <th class="th-b-2">排序</th>
      <th>科目名称</th>
      <th>科目类型</th>
      <th>乐器/舞种</th>
      <th>分值</th>
      <th>计入总分</th>
      <!--
      <th>报考说明</th>
      -->
      <th>合分分组</th>
      <th>主副项分组</th>
      <th class="th-b-2"></th>
    </tr>
    </thead>
    <tbody>
    <ng-container *ngFor="let v of currentEntity.aspect_batchs | numberArray">
      <tr *ngIf="currentEntity.aspect_batchs > 1">
        <td colspan="9" class="bg-info">{{FrameService.getFrameDictText('ExamBatchName', v)}}</td>
      </tr>
      <tr *ngFor="let s of getBatchSubject(v); let i = index">
        <td>{{s.subject_order}}</td>
        <td>{{s.subject_alias?s.subject_alias:s.subject_name}}({{s.subject_id}})</td>
        <td>{{s.subject_type | frameDict : 'ConfSubjectType'}}</td>
        <td>{{s.variety_name}}</td>
        <td>{{s.subject_score}}</td>
        <td [innerHTML]="s.total_status | frameStatusCustom : ['计入总分','不计总分']"></td>

        <!--
          <td><span *ngIf="s.subject_enrol_explain || s.as_enrol_explain" class="text-success"
                    [tooltip]="s.subject_enrol_explain === undefined?s.as_enrol_explain:s.subject_enrol_explain">有报考说明</span>
         -->
          <td>{{s.score_group}}<span *ngIf="s.score_group">({{s.score_group_value}})</span></td>
          <td>{{s.master_group}}</td>
          <td><span class="table-button" (click)="editSubject(s)"><em
            class="fa-lg fas fa-edit"></em></span>
            <span class="table-button ml-3 text-danger"
                  (click)="deleteSubject(s)"><em
              class="fa-lg fas fa-trash-alt "></em></span>

          </td>
        </tr>
      </ng-container>
      </tbody>
    </table>
    <div class="card card-default" [formGroup]="detailForm" *ngIf="subject" [hidden]="curStep === 'page'">
      <div class="card-body">
        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">考试科目</label>
          <div class="col-lg-3 col-md-3" *ngIf="curStep === 'add'">
            <ngx-select [items]="allSubjectArray" [(ngModel)]="subject.subject_id" formControlName="subject_id"
                       
                        optionValueField="subject_id" optionTextField="subject_name"></ngx-select>
            <form-valid [form]="detailForm" fieldName="subject_id"></form-valid>
            <!-- [disabled]="curStep === 'edit'" -->
          </div>
          <div class="col-lg-3 col-md-3" *ngIf="curStep === 'edit'"><input class="form-control" type="text"
                                                                           [readonly]="true"
                                                                           [value]="subject.subject_name"/>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">考试批次</label>
          <div class="col-lg-3 col-md-3">
            <select class="form-control" formControlName="aspect_batch" [(ngModel)]="subject.aspect_batch"
                    [disabled]="curStep === 'edit'">
              <option [value]="kv.batch_id" *ngFor="let kv of batchArray">{{kv.batch_name}}</option>
            </select>
            <form-valid [form]="detailForm" fieldName="aspect_batch"></form-valid>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">乐器/舞种</label>
          <div class="col-lg-3 col-md-3">
            <ngx-select [items]="ResponseArray" [(ngModel)]="subject.variety_id" formControlName="variety_id"
            optionValueField="variety_id" optionTextField="variety_name"></ngx-select>
            <!-- [disabled]="curStep === 'edit'" -->
          </div>
        </div>
        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">科目排序</label>
          <div class="col-lg-3 col-md-3">
            <input class="form-control" type="number" formControlName="subject_order" maxlength="6"
                   [(ngModel)]="subject.subject_order"/>
            <form-valid [form]="detailForm" fieldName="subject_order"></form-valid>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">科目分值</label>
          <div class="col-lg-3 col-md-3">
            <input class="form-control" type="number" formControlName="subject_score" maxlength="6"
                   [(ngModel)]="subject.subject_score"/>
            <form-valid [form]="detailForm" fieldName="subject_score"></form-valid>
            <form-valid [form]="detailForm" fieldName="subject_score" errorCode="min"></form-valid>
          </div>
          <label class="col-lg-1 col-form-label text-lg-right">计入总分</label>
          <div class="col-lg-3 col-md-3">
            <select class="form-control" formControlName="total_status" [(ngModel)]="subject.total_status" frameDict
                    [dictName]="'FrameStatus'"> </select>
            <form-valid [form]="detailForm" fieldName="total_status"></form-valid>
          </div>
        </div>
        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">多选多分组</label>
          <div class="col-lg-3 col-md-3">
            <input class="form-control" type="text" formControlName="subject_group" maxlength="32"
                   [(ngModel)]="subject.subject_group"/>
          </div>

          <ng-container *ngIf="subject.subject_group !== undefined && subject.subject_group.length > 0 ">
            <label class="col-lg-1 col-form-label text-lg-right">需要几个科目</label>
            <div class="col-lg-3 col-md-3">

              <input class="form-control" type="number" formControlName="subject_group_num" maxlength="1"
                     [(ngModel)]="subject.subject_group_num"/>
              <form-valid [form]="detailForm" fieldName="subject_group_num" errorCode="min"></form-valid>
              <form-valid [form]="detailForm" fieldName="subject_group_num" errorCode="max"></form-valid>
            </div>
          </ng-container>
        </div>

        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">合分分组</label>
          <div class="col-lg-3 col-md-3">
            <input class="form-control" type="text" formControlName="score_group" maxlength="32"
                   [(ngModel)]="subject.score_group"/>
          </div>

          <ng-container *ngIf="subject.score_group !== undefined && subject.score_group.length > 0 ">
            <label class="col-lg-1 col-form-label text-lg-right">合分分值</label>
            <div class="col-lg-3 col-md-3">
              <input class="form-control" type="number" formControlName="score_group_value" maxlength="32"
                     [(ngModel)]="subject.score_group_value"/>
            </div>
          </ng-container>

          <ng-container *ngIf="subject.score_group !== undefined && subject.score_group.length > 0 ">
            <label class="col-lg-1 col-form-label text-lg-right">自定义合分</label>
            <div class="col-lg-3 col-md-3">
              <input class="form-control" type="text" formControlName="score_group_type" maxlength="32"
                     [(ngModel)]="subject.score_group_type"/>
            </div>
          </ng-container>
        </div>


        <div class="form-group row">
          <label class="col-lg-1 col-form-label text-lg-right">主副项分组</label>
          <div class="col-lg-3 col-md-3">
            <input class="form-control" type="text" formControlName="master_group" maxlength="32"
                   [(ngModel)]="subject.master_group"/>
          </div>
          <ng-container *ngIf="subject.master_group !== undefined && subject.master_group.length > 0 ">
            <label class="col-lg-1 col-form-label text-lg-right">主副项分值</label>
            <div class="col-lg-3 col-md-3">
              <input class="form-control" type="number" formControlName="master_group_score" maxlength="4"
                     [(ngModel)]="subject.master_group_score"/>
            </div>
            <label class="col-lg-1 col-form-label text-lg-right">自动匹配</label>
            <div class="col-lg-3 col-md-3">
              <select class="form-control" formControlName="master_group_auto" frameDict [dictName]="'FrameStatus'"
                      [(ngModel)]="subject.master_group_auto"></select>
            </div>
          </ng-container>
        </div>
        <!--
        <div class="form-group row">
          <label class="col-lg-1 col-form-labe2 text-lg-right">报考说明（显示给考生）</label>
          <div class="col-lg-11 col-md-11">
            <textarea class="form-control" type="text" formControlName="as_enrol_explain" rows="6"
                      [(ngModel)]="subject.as_enrol_explain"></textarea>
          </div>
        </div>
        -->
      </div>
    </div>
  </div>
  <div class="modal-footer justify-content-between">
    <div>
    </div>
    <div>
      <button class="btn btn-primary" type="button" (click)="addSubject()" [hidden]="curStep !=='page'"> 增加考试科目</button>
      <button class="btn btn-primary ml-2" type="button" (click)="saveSubject()" [hidden]="curStep === 'page'">保存科目
      </button>
      <button class="btn btn-secondary ml-2" type="button" (click)="curStep = 'page'" [hidden]="curStep ==='page'">取消操作
      </button>
      <button class="btn btn-secondary ml-2" type="button" (click)="closeWindow()" [hidden]="curStep !=='page'">关闭窗口
      </button>
    </div>
  </div>
  <frame-ajax #ajax [url]="'conf/aspect/subject/list.htm'" [ajaxDataType]="'array'" [autoRequest]="true"
              [requestData]="{aspect_id: currentEntity.aspect_id}"></frame-ajax>

