<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->

<!--<div class="inner-content">
    <form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)">
        <div nz-row>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="8">班组名称</nz-form-label>
                    <nz-form-control [nzSpan]="14">
                        <input nz-input formControlName="name" />
                    </nz-form-control>
                </nz-form-item>
            </div>
        </div>

        <div nz-row>
            <div nz-col nzSpan="24" class="search-button">
                <button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button>
                <button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button>
            </div>
        </div>
    </form>
</div>-->

<div class="inner-content">
    <nz-row [nzGutter]="16">
        <nz-col [nzSpan]="4">
            <nz-statistic [nzValue]="currentClassGroupCountData['classNum'] == null ? '无' : currentClassGroupCountData['classNum'] + ' 班'" [nzTitle]="'当前班次'"></nz-statistic>
        </nz-col>
        <nz-col [nzSpan]="4">
            <nz-statistic [nzValue]="currentClassGroupCountData['refuelPrice']" [nzTitle]="'加油总金额'" [nzSuffix]="'元'"></nz-statistic>
        </nz-col>
        <nz-col [nzSpan]="4">
            <nz-statistic [nzValue]="currentClassGroupCountData['refuelNum']" [nzTitle]="'加油总笔数'" [nzSuffix]="'笔'"></nz-statistic>
        </nz-col>
        <nz-col [nzSpan]="4">
            <nz-statistic [nzValue]="currentClassGroupCountData['refuelLiters']" [nzTitle]="'加油总升数'" [nzSuffix]="'升'"></nz-statistic>
        </nz-col>
        <nz-col [nzSpan]="4">
            <nz-statistic [nzValue]="currentClassGroupCountData['refundPrice']" [nzTitle]="'退款总金额'" [nzSuffix]="'元'"></nz-statistic>
        </nz-col>
        <nz-col [nzSpan]="4">
            <nz-statistic [nzValue]="currentClassGroupCountData['refundNum']" [nzTitle]="'退款总笔数'" [nzSuffix]="'笔'"></nz-statistic>
        </nz-col>
    </nz-row>

    <div class="gas-count-btn">
        <button nz-button nzType="primary" *ngIf="currentClassGroupCountData.status == 0" (click)="showStartClassGroupModal()"><i nz-icon nzType="plus" nzTheme="outline"></i>开启班次</button>
        <button nz-button nzType="primary" *ngIf="currentClassGroupCountData.status == 1" (click)="getCurrentClassGroupCountData()"><i nz-icon nzType="sync" nzTheme="outline"></i>刷新数据</button>
        <button nz-button nzType="primary" *ngIf="currentClassGroupCountData.status == 1" (click)="showSwapClassGroupModal()"><i nz-icon nzType="swap" nzTheme="outline"></i>交接班组</button>
        <button nz-button nzType="primary" *ngIf="currentClassGroupCountData.status == 1" (click)="showEndClassGroupConfirm()"><i nz-icon nzType="poweroff" nzTheme="outline"></i>结束班次</button>
    </div>
    <nz-divider></nz-divider>


    <span>历史班次，共计 {{dataObject.total?dataObject.total:0}} 条数据</span>
    <div class="operating-button">
      <!--  <button nz-button nzType="primary" class="right-btn"  (click)="showEditClassGroup(null)"><i nz-icon nzType="plus" nzTheme="outline"></i>添加班组</button>-->
    </div>

    <!--数组表格 -->
    <nz-table #basicTable
              [nzData]="dataObject.list"
              [nzTotal]="dataObject.total"
              [nzFrontPagination]="false"
              [nzLoading]="tableLoading"
              [nzPageIndex]="whereObject.pageNum"
              (nzPageIndexChange)="requestData($event)"
              [nzScroll]="{ x: '1150px'}">
        <thead>
        <tr>
            <th nzWidth="80px">班次</th>
            <th nzWidth="100px">班组名称</th>
            <th nzWidth="100px">开始时间</th>
            <th nzWidth="100px">结束时间</th>
            <th nzWidth="100px">状态</th>
            <th nzWidth="100px" nzRight="0px">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of basicTable.data;let i = index">
            <td>{{data.classNum + ' 班'}}</td>
            <td>{{data.gasClassGroupName}}</td>
            <td>{{data.startTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>
                <span *ngIf="data.endTime != null">{{data.endTime | date : 'yyyy-MM-dd HH:mm:ss'}}</span>
                <span *ngIf="data.endTime == null">未结束</span>
            </td>
            <td>{{data.status | gasClassGroupTaskStatus}}</td>
            <td nzRight="0px" class="table-td-operation">
                <a nz-dropdown [nzDropdownMenu]="menu"> 操作列表 <i nz-icon nzType="down"></i> </a>
                <nz-dropdown-menu #menu="nzDropdownMenu">
                    <ul nz-menu nzSelectable>
                        <li nz-menu-item nzDisabled *ngIf="data.status == 1">暂无操作</li>
                        <li nz-menu-item *ngIf="data.status == 2"><a (click)="showClassGroupTaskDataModal(data)">查看汇总</a></li>
                    </ul>
                </nz-dropdown-menu>
            </td>
        </tr>
        </tbody>
    </nz-table>
</div>

<nz-modal [(nzVisible)]="classGroupCountDataModal" nzTitle="班次汇总" (nzOnCancel)="closeClassGroupTaskDataModal()" nzWidth="350px" [nzFooter]="null">
    <nz-descriptions [nzColumn]="{ xxl: 1, xl: 1, lg: 1, md: 1, sm: 1, xs: 1 }">
        <nz-descriptions-item nzTitle="开始时间">{{classGroupCountData['startTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="结束时间">{{classGroupCountData['endTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油金额汇总">{{classGroupCountData['refuelPrice']}} 元</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油笔数汇总">{{classGroupCountData['refuelNum']}} 笔</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油升数汇总">{{classGroupCountData['refuelLiters']}} 升</nz-descriptions-item>
        <nz-descriptions-item nzTitle="退款金额汇总">{{classGroupCountData['refundPrice']}} 元</nz-descriptions-item>
        <nz-descriptions-item nzTitle="退款笔数汇总">{{classGroupCountData['refundNum']}} 笔</nz-descriptions-item>
        <nz-descriptions-item nzTitle="退款升数汇总">{{classGroupCountData['refundLiters']}} 升</nz-descriptions-item>
    </nz-descriptions>

    <nz-table #oilCountTable [nzData]="classGroupCountData['groupTaskOilCountList']" [nzShowPagination]="false">
        <thead>
        <tr>
            <th>油号</th>
            <th>金额</th>
            <th>升数</th>
            <th>笔数</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let item of oilCountTable.data">
            <td>{{ item.oilNo }}#</td>
            <td>{{ item.refuelPrice }}元</td>
            <td>{{ item.refuelLiters }}升</td>
            <td>{{ item.refuelNum }}笔</td>
        </tr>
        </tbody>
    </nz-table>
    <div style="width: 100%;text-align: center;margin-top: 10px;">
        <button nz-button nzType="primary" (click)="showPrintModal(classGroupCountData)">打印小票</button>
    </div>
</nz-modal>

<nz-modal [(nzVisible)]="printModal" nzTitle="选择打印方式" nzWidth="350"   (nzOnCancel)="printModal = false" [nzFooter]="null">
    <form nz-form>
        <nz-form-item>
            <nz-form-control>
                <button nz-button nzType="primary" nzBlock (click)="showPrintDiv()">热敏打印机</button>
            </nz-form-control>
        </nz-form-item>

        <nz-form-item>
            <nz-form-control>
                <button nz-button nzType="primary" nzBlock (click)="cloudPrint()">云打印机</button>
            </nz-form-control>
        </nz-form-item>
    </form>
</nz-modal>

<nz-modal [(nzVisible)]="startClassGroupModal" nzTitle="开启班次" (nzOnCancel)="closeStartClassGroupModal()" nzWidth="500px" [nzFooter]="null">
    <form nz-form [formGroup]="startClassGroupModalForm">
        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired>班组</nz-form-label>
            <nz-form-control [nzSpan]="14">
                <nz-select ngModel="lucy" [nzPlaceHolder]="'请选择班组'" formControlName="gasClassGroupId">
                    <nz-option *ngFor="let item of classGroupArray" nzValue="{{item.id}}" nzLabel="{{item.name}}"></nz-option>
                </nz-select>
            </nz-form-control>
        </nz-form-item>
        <div style="text-align: center;">
            <button nz-button nzType="primary" style="width: 150px;" (click)="submitStartClassGroup()">开启</button>
        </div>
    </form>
</nz-modal>

<nz-modal [(nzVisible)]="swapClassGroupModal" nzTitle="交换班次" (nzOnCancel)="closeSwapClassGroupModal()" nzWidth="500px" [nzFooter]="null">
    <form nz-form [formGroup]="swapClassGroupModalForm">
        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired>班组</nz-form-label>
            <nz-form-control [nzSpan]="14">
                <nz-select ngModel="lucy" [nzPlaceHolder]="'请选择班组'" formControlName="gasClassGroupId">
                    <nz-option *ngFor="let item of classGroupArray" nzValue="{{item.id}}" nzLabel="{{item.name}}"></nz-option>
                </nz-select>
            </nz-form-control>
        </nz-form-item>
        <div style="text-align: center;">
            <button nz-button nzType="primary" style="width: 150px;" (click)="submitSwapClassGroupConfirm()">交换</button>
        </div>
    </form>
</nz-modal>
