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

<div class="inner-content">
    <span>共计 {{total}} 条数据</span>
    <nz-table
            class="table"
            #ajaxTable
            nzShowSizeChanger
            [nzFrontPagination]="false"
            [nzData]="requestData"
            [nzLoading]="loading"
            [nzTotal]="total"
            [(nzPageIndex)]="pageNum"
            [(nzPageSize)]="pageSize"
            [nzScroll]="{ x: '1200px' }"
            (nzPageIndexChange)="getRequest(false , {})"
            (nzPageSizeChange)="getRequest(false , {})">
        <thead nzSingleSort>
        <tr>
            <th nzWidth="50px">编号</th>
            <th nzWidth="80px">优惠券KEY</th>
            <th nzWidth="80px">优惠券名称</th>
            <th nzWidth="80px">优惠券类型</th>
            <th nzWidth="70px">优惠内容</th>
            <th nzWidth="70px">有效天数</th>
            <th nzWidth="100px">截止日期</th>
            <th nzWidth="100px">创建时间</th>
            <th nzWidth="100px">状态</th>
            <th nzWidth="80px" nzRight="0px">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i + 1}}</td>
            <td>{{data['highDiscount'].discountKey}}</td>
            <td>{{data['highDiscount'].discountName}}</td>
            <td>{{data['highDiscount'].discountType | discountType}}</td>
            <td>
                <span *ngIf="data['highDiscount'].discountType === 1">
                      满{{data['highDiscount'].discountCondition}}抵扣{{data['highDiscount'].discountPrice}}
                </span>
                <span *ngIf="data['highDiscount'].discountType === 2">
                      抵扣{{data['highDiscount'].discountPrice}}
                </span>
                <span *ngIf="data['highDiscount'].discountType === 3">
                      {{data['highDiscount'].discountPrice}}折
                </span>
            </td>
            <td>{{data['highDiscount'].effectiveDay}}</td>
            <td>{{data['highDiscount'].salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td>{{data['highDiscount'].createTime}}</td>
            <td>{{data['highDiscount'].status | discountStatus}}</td>
            <td nzRight="0px" class="table-td-operation">
                <a (click)="getDetail(data.id)">使用情况</a>

            </td>
        </tbody>
    </nz-table>
</div>

<nz-modal [(nzVisible)]="isVisible" nzTitle="使用情况" nzWidth="1000" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
    <form nz-form [formGroup]="searchForm" (ngSubmit)="getRequestCode(true , searchForm.value)">
        <div nz-row>
            <div nz-col nzSpan="9">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">优惠券状态</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="status" nzPlaceHolder="请选择优惠券状态">
                            <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-select>
                    </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>

    <span>共计 {{totalCode}} 条数据</span>
    <nz-table
            class="table"
            #ajaxTableCode
            nzShowSizeChanger
            [nzFrontPagination]="false"
            [nzData]="requestDataCode"
            [nzLoading]="loadingCode"
            [nzTotal]="totalCode"
            [(nzPageIndex)]="pageNumCode"
            [(nzPageSize)]="pageSizeCode"
            (nzPageIndexChange)="getRequestCode(false , searchForm.value)"
            (nzPageSizeChange)="getRequestCode(false , searchForm.value)">
        <thead nzSingleSort>
        <tr>
            <th nzWidth="50px">编号</th>
            <th nzWidth="70px">优惠券名称</th>
            <th nzWidth="70px">用户名称</th>
            <th nzWidth="70px">二维码生成时间</th>
            <th nzWidth="50px">状态</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTableCode.data; let i = index">
            <td>{{i+1}}</td>
            <td>{{data['highDiscount'].discountName}}</td>
            <td>
              {{data['highUser'] == null ? '暂无':  data['highUser'].name}}
            </td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td>{{data.status | couponCode}}</td>
        </tbody>
    </nz-table>

</nz-modal>