<div class="modal-header">
    <h4 class="modal-title pull-left">任务分发</h4>
</div>
<div class="modal-body">
    <table class="table table-striped table-hover table-bordered" *ngIf="currStep === 'init'">
        <thead>
            <tr>
                <th>任务名称</th>
                <th>任务数量(内|外)</th>
                <th>剩余量(内|外)</th>
                <th>考场数量</th>
            </tr>
        </thead>
        <tbody>
            <ng-container *ngFor="let v of groupArr; let i = index">
                <tr *ngIf="v.nolayout_total >0">
                    <td class="align-middle">{{v.show_group_name}}</td>
                    <td class="align-middle">{{v.std_total}}({{v.in_province_total}}|{{v.out_province_total}})</td>
                    <td class="align-middle">{{v.nolayout_total}}({{v.in_nolayout_total}}|{{v.out_nolayout_total}})</td>
                    <td class="align-middle">
                        <input class="form-control input-group-sm wd-xs" type="number" [(ngModel)]="v.room_total"/>
                    </td>
                </tr>
            </ng-container>
        </tbody>
    </table>

    <table class="table table-striped table-hover table-bordered" *ngIf="currStep === 'room'">
        <thead>
            <tr>
              <th>任务名称</th>
              <th>剩余数量(男|女)</th>
              <th>剩余数量(内|外)</th>
              <th>考场名称</th>
              <th>考生数量</th>
              <th>性别</th>
              <th>省份</th>
              <th>品种限定</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let v of currGroupArr; let i = index">
                <td class="align-middle" [rowSpan]="v.rowspan" *ngIf="v.room_seq === 1">{{v.show_group_name}}</td>
                <td class="align-middle" [rowSpan]="v.rowspan" *ngIf="v.room_seq === 1">{{v.nolayout_total}}({{v.male_nolayout_total}}|{{v.female_nolayout_total}})</td>
                <td class="align-middle" [rowSpan]="v.rowspan" *ngIf="v.room_seq === 1">{{v.nolayout_total}}({{v.in_nolayout_total}}|{{v.out_nolayout_total}})</td>
                <td class="align-middle">{{v.room_addr}}</td>
                <td class="align-middle">
                    <input class="form-control input-group-sm wd-sm" type="number"  [(ngModel)]="v.real_std_total" />
                </td>
                <td class="align-middle">
                    <ngx-select [items]="'FrameSex' | frameDict" [(ngModel)]="v.std_sex" optionValueField="dict_value" optionTextField="dict_text"></ngx-select>
                </td>
                <td class="align-middle">
                    <ngx-select [items]="provinceArr" [(ngModel)]="v.std_province_flag"  optionValueField="province_id" optionTextField="province_name" ></ngx-select>
                </td>
                <td>
                    <span *ngIf="v.varietyList && v.varietyList.length>1 && (!v.varietyArr || v.varietyArr.length == 0)">
                        <button class="btn btn-primary" (click)="addVariety(v)">添加</button>
                    </span>
                    <span *ngIf="v.varietyArr && v.varietyArr.length > 0">
                        <button class="btn btn-success" (click)="viewVariety(v)">查看</button>
                    </span>
                </td>
            </tr>
        </tbody>
    </table>

    <table class="table table-striped table-hover table-bordered" *ngIf="currStep === 'variety'">
        <thead>
            <tr>
              <th>品种名称</th>
              <th>剩余数量(男|女)</th>
              <th>剩余数量(内|外)</th>
              <th>考生数量</th>
              <th>性别</th>
              <th>省份</th>
              <th>序号</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let v of varietyArr; let i = index;">
                <td class="align-middle">{{v.variety_name}}</td>
                <td class="align-middle">{{v.std_total}}({{v.male_total}}|{{v.female_total}})</td>
                <td class="align-middle">{{v.std_total}}({{v.in_province_total}}|{{v.out_province_total}})</td>
                <td class="align-middle">
                    <input class="form-control input-group-sm wd-sm" type="number" [(ngModel)]="v.real_std_total" />
                </td>
                <td class="align-middle">
                    <ngx-select [items]="'FrameSex' | frameDict"  optionValueField="dict_value" optionTextField="dict_text" [(ngModel)]="v.std_sex"></ngx-select>
                </td>
                <td class="align-middle">
                    <ngx-select [items]="provinceArr" optionValueField="province_id" optionTextField="province_name" [(ngModel)]="v.std_province_flag"></ngx-select>
                </td>
                <td class="align-middle">
                    <input class="form-control input-group-sm wd-sm" type="number" [(ngModel)]="v.order_num" />
                </td>
            </tr>
        </tbody>
    </table>
</div>

<div class="modal-footer justify-content-between">
    <div>
        <div class="row" *ngIf="currStep === 'init'">
            <label class="col-lg-5 col-form-label text-lg-right text-right">评分日期：</label>
            <div class="col-lg-3 col-md-3">
            <input class="form-control wd-sm" type="text" [(ngModel)]="exam_date" maxlength="11" id="exam_dates" (click)="getDate()"/>
            </div>
        </div>
    </div>
    <div>
        <button class="btn btn-primary" type="button" (click)="confirmRoom()" *ngIf="currStep === 'init'">
            确认考场数量
        </button>
        <button class="btn btn-info" type="button" (click)="resetRoom()" *ngIf="currStep === 'room'">
            重新设置考场
        </button>
        <button class="btn btn-primary ml-3" type="button" (click)="confirmSendTask()" *ngIf="currStep === 'room'">
            确认分发
        </button>
        <button class="btn btn-primary ml-3" type="button" (click)="confirmVariety()" *ngIf="currStep === 'variety'">
            确认
        </button>
        <button class="btn btn-primary ml-3" type="button" (click)="currStep='room'" *ngIf="currStep === 'variety'">
            取消
        </button>
        <button class="btn btn-secondary ml-3" type="button" (click)="closeWindow()" *ngIf="currStep !== 'variety'">关闭窗口</button>
    </div>
</div>