<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->

<!--条件搜索-->
<div class="inner-content">
    <form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
        <div nz-row>
            <div nz-col nzSpan="8" *ngIf="secUser['objectType'] == 2">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">油站</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择油站" formControlName="storeId" (ngModelChange)="selectGasChange($event)">
                            <nz-option *ngFor="let item of gasArray" nzLabel="{{item.storeName}}" nzValue="{{item.id}}"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8" *ngIf="userSession['secUser']['objectType'] == 1 || userSession['secUser']['objectType'] == 2 || userSession['secUser']['objectType'] == 3 || (userSession['secUser']['objectType'] == 8 && userSession['gasStaff'] != null && userSession['gasStaff']['positionType'] != 2)">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">加油员</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择加油员" formControlName="staffId">
                            <nz-option *ngFor="let item of gasStaffArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">订单号</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <input nz-input formControlName="orderNo"/>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">油号</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择订单状态" formControlName="oilNo">
                            <nz-option *ngFor="let item of oilNoArray" nzLabel="{{item.codeName}}" nzValue="{{item.codeValue}}"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">状态</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择订单状态" formControlName="status">
                            <nz-option nzLabel="待支付" nzValue="1"></nz-option>
                            <nz-option nzLabel="已支付" nzValue="2"></nz-option>
                            <nz-option nzLabel="已完成" nzValue="3"></nz-option>
                            <nz-option nzLabel="已退款" nzValue="4"></nz-option>
                            <nz-option nzLabel="已取消" nzValue="5"></nz-option>
                            <nz-option nzLabel="退款中" nzValue="6"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">创建时间</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-range-picker
                                formControlName="createTime"
                                [nzShowTime]="{ nzHideDisabledOptions: true}"
                                nzFormat="yyyy-MM-dd HH:mm:ss"
                        ></nz-range-picker>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <div nz-col nzSpan="8">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">支付时间</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-range-picker
                                formControlName="payTime"
                                [nzShowTime]="{ nzHideDisabledOptions: true}"
                                nzFormat="yyyy-MM-dd HH:mm:ss"
                        ></nz-range-picker>
                    </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">
    <span>总笔数：{{dataCount.refuelNum}} 笔，总加油金额：{{dataCount.refuelPrice}} 元，总升数：{{dataCount.refuelLiters}} 升</span>
    <div class="operating-button">
        <button nz-button nzType="primary" class="right-btn" (click)="excelOrder()" ><i nz-icon nzType="import" nzTheme="outline"></i>导出订单</button>
    </div>

    <nz-table
            class="table"
            #ajaxTable
            nzShowSizeChanger
            [nzFrontPagination]="false"
            [nzData]="requestData"
            [nzLoading]="loading"
            [nzTotal]="total"
            [(nzPageIndex)]="pageNum"
            [(nzPageSize)]="pageSize"
            [nzScroll]="{ x: '1200px' }"
            (nzPageIndexChange)="getRequest(false , searchForm.value)"
            (nzPageSizeChange)="getRequest(false , searchForm.value)">
        <thead nzSingleSort>
        <tr>
            <th nzWidth="60px">编号</th>
            <th nzWidth="200px">订单号</th>
            <th nzWidth="180px">油站名称</th>
            <th nzWidth="100px">加油员</th>
            <th nzWidth="90px">类型</th>
            <th nzWidth="90px">油号</th>
            <th nzWidth="90px">油枪号</th>
            <th nzWidth="90px">油枪价</th>
            <th nzWidth="90px">平台价</th>
            <th nzWidth="90px">加油升数</th>
            <th nzWidth="90px">加油金额</th>
            <th nzWidth="120px">使用优惠券</th>
            <th nzWidth="120px">优惠券名称</th>
            <th nzWidth="90px">优惠金额</th>
            <th nzWidth="90px">应付金额</th>
            <th nzWidth="90px">金币抵扣</th>
            <th nzWidth="90px">实付金额</th>
            <th nzWidth="120px">创建时间</th>
            <th nzWidth="120px">支付时间</th>
            <th nzRight nzWidth="80px">状态</th>
            <th nzWidth="105px" nzRight>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i + 1}}</td>
            <td>{{data.orderNo}}</td>
            <td>{{data.gasName}}</td>
            <td>{{data.gasStaffName?data.gasStaffName:'未知'}}</td>
            <td>{{data.gasOilType == 1 ? '汽油': '柴油'}}</td>
            <td>{{data.gasOilNo + "#"}}</td>
            <td>{{data.gasGunNo + "号"}}</td>
            <td>{{data.gasPriceGun}}</td>
            <td>{{data.gasPricePreferences}}</td>
            <td>{{data.gasOilLiters}}</td>
            <td>{{data.totalPrice}}</td>
            <td>{{data.memDiscountName?'是':'否'}}</td>
            <td>{{data.memDiscountName?data.memDiscountName:'否'}}</td>
            <td>{{data.deductionPrice}}</td>
            <td>{{data.payablePrice}}</td>
            <td>{{data.payGold / 100}}</td>
            <td>{{data.payRealPrice}}</td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td>{{data.payTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
            <td nzRight>{{data.status | orderCouponStatus}}</td>
            <td nzRight class="table-td-operation">
                <a style="float: left;width: 100%;margin-bottom: 10px;" *ngIf="BTN_GAS_ORDER_PRINT && (secUser['objectType'] == 3 || secUser['objectType'] == 8) && data.printStatus == false" (click)="showPrintModal(data.orderId, data)">打印小票</a>
                <a style="float: left;width: 100%;margin-bottom: 10px;" *ngIf="BTN_GAS_ORDER_PRINT && (secUser['objectType'] == 3 || secUser['objectType'] == 8) && data.printStatus == true" (click)="showPrintModal(data.orderId, data)">已打印({{data.printNum+'次'}})</a>
                <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><a (click)="getDetail(data.orderNo)">详情</a></li>
                        <li nz-menu-item *ngIf="BTN_GAS_ORDER_REFUND && (secUser['objectType'] == 3) && (data.status == 2 || data.status == 3)" ><a (click)="showModal(data.orderId)">退款</a></li>
                    </ul>
                </nz-dropdown-menu>
            </td>
        </tbody>
    </nz-table>
</div>


<nz-modal [(nzVisible)]="isVisible" nzTitle="退款理由" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
    <nz-form-item>
        <nz-form-label nzRequired>退款理由</nz-form-label>
        <nz-form-control>
            <textarea [(ngModel)]="refundContent" nz-input rows="2" placeholder="请输入退款理由"></textarea>
        </nz-form-control>
    </nz-form-item>
</nz-modal>

<nz-modal [(nzVisible)]="isVisibleDetail" nzTitle="订单详情" nzWidth="900"   (nzOnCancel)="isVisibleDetail= false" (nzOnOk)="isVisibleDetail= false" [nzFooter]="null">
    <nz-descriptions  nzBordered [nzColumn]="{ xxl: 3, xl: 2, lg: 2, md: 2, sm: 2, xs: 1 }">
        <nz-descriptions-item nzTitle="油站名称">{{data['gasName']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="油站地址">{{data['gasAddress']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="订单号">{{data['orderNo']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="类型">{{data['gasOilType'] == 1 ? '汽油': '柴油'}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="油号">{{data['gasOilNo']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="油枪号">{{data['gasGunNo']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="油枪价">{{data['gasPriceGun']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="优惠价">{{data['gasPricePreferences']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油升数">{{data['gasOilLiters']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油金额">{{data['totalPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="优惠金额">{{data['deductionPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="支付金额">{{data['payRealPrice']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油折扣">{{data['gasDiscount']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="加油补贴">{{data['gasOilSubsidy']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="每升优惠">{{data['gasLitersPreferences']}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="生成时间">{{data['createTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item nzTitle="状态">{{data['status'] | gasOrderStatus}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['status'] == 4" nzTitle="退款金额">{{data['refundPrice']}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['status'] == 4" nzTitle="退款时间">{{data['refundTime'] | date: 'yyyy-MM-dd HH:mm:ss'}}</nz-descriptions-item>
        <nz-descriptions-item *ngIf="data['status'] == 4" nzTitle="退款原因">{{data['refundContent']}}</nz-descriptions-item>
    </nz-descriptions>

</nz-modal>

<nz-modal [(nzVisible)]="printModal" nzTitle="选择打印方式" nzWidth="200"   (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>

<!--<div id="div_print">
    <div style="float: left;margin-bottom: 150px;">
        <div style="line-height: 30px; color:#000;">
            <span  style="font-size: 13px;float: left;width: 100%;">{{printDataObject.gasName}}</span>
            <span  style="font-size: 13px;float: left;width: 100%;margin-left: 60px;">（客户存根）</span>
        </div>
        <table style="width: 100%;">
            <tbody>
            <tr><td class="print_td">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</td></tr>
            <tr>
                <td class="print_td">流水号：<span>{{printDataObject.orderNo}}</span></td>
            </tr>
            <tr><td class="print_td">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</td></tr>
            <tr>
                <td class="print_td">时间：<span>{{printDataObject.createTime | date: 'yyyy-MM-dd HH:mm:ss'}}</span></td>
            </tr>
            <tr>
                <td class="print_td">来源：<span>嗨森逛</span></td>
            </tr>
            <tr>
                <td class="print_td">油枪：<span>{{printDataObject.gasGunNo}}</span></td>
            </tr>
            <tr>
                <td class="print_td">油品：<span>{{printDataObject.gasOilNo}}</span></td>
            </tr>
            <tr>
                <td class="print_td">升数：<span>{{printDataObject.gasOilLiters}}升</span></td>
            </tr>
            <tr>
                <td class="print_td">实际加油升数以油站加油机为准！</td>
            </tr>
            <tr><td style="float: left;margin-top: 10px;font-size: 30px;color: black">加油金额</td></tr>
            <tr><td style="font-size: 30px;color: black">￥{{printDataObject.oilPrice}}元</td></tr>
            <tr><td class="print_td">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</td></tr>
            <tr><td style="float: left;color: black;margin-left: 35px;">开心又省钱； 来”嗨森逛“</td></tr>
            </tbody>
        </table>
    </div>
    <div style="float: left;margin-bottom: 50px;">
        <div style="line-height: 30px; color:#000;">
            <span  style="font-size: 13px;float: left;width: 100%;">{{printDataObject.gasName}}</span>
            <span  style="font-size: 13px;float: left;width: 100%;margin-left: 60px;">（收银员存根）</span>
        </div>
        <table style="width: 100%;">
            <tbody>
            <tr><td class="print_td">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</td></tr>
            <tr>
                <td class="print_td">流水号：<span>{{printDataObject.orderNo}}</span></td>
            </tr>
            <tr><td class="print_td">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</td></tr>
            <tr>
                <td class="print_td">时间：<span>{{printDataObject.createTime | date: 'yyyy-MM-dd HH:mm:ss'}}</span></td>
            </tr>
            <tr>
                <td class="print_td">来源：<span>嗨森逛</span></td>
            </tr>
            <tr>
                <td class="print_td">油枪：<span>{{printDataObject.gasGunNo}}</span></td>
            </tr>
            <tr>
                <td class="print_td">油品：<span>{{printDataObject.gasOilNo}}</span></td>
            </tr>
            <tr>
                <td class="print_td">升数：<span>{{printDataObject.gasOilLiters}}升</span></td>
            </tr>
            <tr>
                <td class="print_td">实际加油升数以油站加油机为准！</td>
            </tr>
            <tr><td style="float: left;margin-top: 10px;font-size: 30px;color: black">加油金额</td></tr>
            <tr><td style="font-size: 30px;color: black">￥{{printDataObject.oilPrice}}元</td></tr>
            <tr><td class="print_td">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</td></tr>
            <tr><td style="float: left;color: black;margin-left: 35px;">开心又省钱； 来”嗨森逛“</td></tr>
            </tbody>
        </table>
    </div>
&lt;!&ndash;    <table border=1 cellspacing=0 cellpadding=1 width="100%" style="border-collapse:collapse" bordercolor="#333333">
        <thead>
        <tr>
            <td width="10%">
                <div align=center><b>表格页眉</b></div>
            </td>
            <td width="25%">
                <div align=center><b>品名</b></div>
            </td>
            <td width="10%">
                <div align=center><b>颜色</b></div>
            </td>
            <td width="10%">
                <div align=center><b>规格</b></div>
            </td>
            <td width="10%">
                <div align=center><b>数量</b></div>
            </td>
            <td width="15%">
                <div align=center><b>单价</b></div>
            </td>
            <td width="20%">
                <div align=center><b>金额</b></div>
            </td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>&nbsp;1</td>
            <td>名称01</td>
            <td>浅灰色</td>
            <td>185/10</td>
            <td>1</td>
            <td>248.00</td>
            <td>248.00</td>
        </tr>
        <tr>
            <td>&nbsp;2</td>
            <td>名称02</td>
            <td>浅灰色</td>
            <td>185/10</td>
            <td>1</td>
            <td>248.00</td>
            <td>248.00</td>
        </tr>
        <tr>
            <td>&nbsp;3</td>
            <td>名称03</td>
            <td>浅灰色</td>
            <td>185/10</td>
            <td>1</td>
            <td>248.00</td>
            <td>248.00</td>
        </tr>
        <tr>
            <td>&nbsp;4</td>
            <td>名称04</td>
            <td>浅灰色</td>
            <td>185/10</td>
            <td>1</td>
            <td>248.00</td>
            <td>248.00</td>
        </tr>
    </table>&ndash;&gt;
</div>-->
