<!-- 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">
                <nz-form-item>
                    <nz-form-label [nzSpan]="6">运营商</nz-form-label>
                    <nz-form-control [nzSpan]="16">
                        <nz-select nzShowSearch nzAllowClear formControlName="operatorType" nzPlaceHolder="请选择运营商">
                            <nz-option nzLabel="电信运营商" nzValue="1"></nz-option>
                            <nz-option nzLabel="移动运营商" nzValue="2"></nz-option>
                            <nz-option nzLabel="联通运营商" nzValue="3"></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 formControlName="rechargePlatform" nzPlaceHolder="请选择充值平台">
                            <nz-option nzLabel="尖椒" [nzValue]="1"></nz-option>
                            <nz-option nzLabel="龙阅" [nzValue]="2"></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 formControlName="phoneRechargeType" nzPlaceHolder="请选择充值类型">
                            <nz-option nzLabel="快充" [nzValue]="1"></nz-option>
                            <nz-option nzLabel="慢充" [nzValue]="2"></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 formControlName="status" nzPlaceHolder="请选择状态">
                            <nz-option nzLabel="上线" [nzValue]="101"></nz-option>
                            <nz-option nzLabel="编辑中" [nzValue]="102"></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>
</div>


<div class="inner-content">
    <span>共计 {{total}} 条数据</span>
    <div class="operating-button">
        <button nz-button nzType="primary" class="right-btn" (click)="getEdit()"><i nz-icon nzType="plus" 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="90px">充值金额</th>
            <th nzWidth="120px">运营商</th>
            <th nzWidth="90px">充值类型</th>
            <th nzWidth="90px">充值平台</th>
            <th nzWidth="80px">商品ID</th>
            <th nzWidth="120px">创建时间</th>
            <th nzRight nzWidth="80px">状态</th>
            <th nzRight nzWidth="160px">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i + 1}}</td>
            <td>{{data.rechargePrice}}</td>
            <td>{{data.operatorType | rechargePrice}}</td>
            <td>{{data.phoneRechargeType== 1? '快充':'慢充'}}</td>
            <td>{{data.rechargePlatform | rechargePlatform}}</td>
            <td>{{data.goodsId == null ? '暂未配置' : data.goodsId}}</td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td nzRight="">{{data.status== 101? '上线':'编辑中'}}</td>
            <td nzRight class="table-td-operation">
                <a *ngIf="data.status != 101" (click)="getEdit(data.id)">编辑</a>
                <a style="margin-left: 20px;" (click)='getForbiddenUser(data.id , data.status)'>{{data.status === 101 ? '下线': '上线'}}</a>
                <a *ngIf="data.status != 101"  style="margin-left: 20px;" (click)="getForbiddenUserD(data.id)">删除</a>
            </td>
        </tbody>
    </nz-table>
</div>

<nz-modal [(nzVisible)]="isVisible" nzTitle="金额编辑" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
    <form nz-form [formGroup]="validateForm" class="login-form">
        <nz-form-item *ngIf="!edit">
            <nz-form-label [nzSpan]="6" nzRequired>充值金额</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择充值金额!">
                <nz-select
                        nzMode="multiple"
                        formControlName="prices"
                        nzPlaceHolder="请选择充值金额"
                >
                    <nz-option *ngFor="let item of priceArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
                </nz-select>
                <input  *ngIf="edit" readonly nz-input formControlName="rechargePrice" />
            </nz-form-control>
        </nz-form-item>
        <nz-form-item *ngIf="edit">
            <nz-form-label [nzSpan]="6" nzRequired>充值金额</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请输入充值金额!">
                <input readonly nz-input formControlName="rechargePrice" />
            </nz-form-control>
        </nz-form-item>
        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired>运营商</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择运营商!">
                <nz-select nzShowSearch nzAllowClear formControlName="operatorType" nzPlaceHolder="请选择运营商！">
                    <nz-option nzLabel="电信运营商" [nzValue]="1"></nz-option>
                    <nz-option nzLabel="移动运营商" [nzValue]="2"></nz-option>
                    <nz-option nzLabel="联通运营商" [nzValue]="3"></nz-option>
                </nz-select>
            </nz-form-control>
        </nz-form-item>

        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired>充值平台</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择充值平台!">
                <nz-select nzShowSearch nzAllowClear nzMode="multiple" formControlName="rechargePlatform" nzPlaceHolder="请选择充值平台">
                    <nz-option *ngFor="let item of platformArray" [nzValue]="item.codeValue" [nzLabel]="item.codeName"></nz-option>
                </nz-select>
            </nz-form-control>
        </nz-form-item>
        <nz-form-item>
            <nz-form-label [nzSpan]="6" nzRequired>充值类型</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请选择充值类型!">
                <nz-select nzShowSearch nzAllowClear formControlName="phoneRechargeType" nzPlaceHolder="请选择充值类型">
                    <nz-option nzLabel="快充" [nzValue] ="1"></nz-option>
                    <nz-option nzLabel="慢充" [nzValue]="2"></nz-option>
                </nz-select>
            </nz-form-control>
        </nz-form-item>
        <nz-form-item *ngIf="edit">
            <nz-form-label [nzSpan]="6" >商品编号</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请输入商品编号!">
                <nz-input-number
                        style="width: 200px"
                        formControlName="productId"
                        [nzMin]="1"
                        [nzMax]="10000"
                        [nzStep]="1"
                        nzPlaceHolder="请输入商品编号!"
                ></nz-input-number>
            </nz-form-control>
        </nz-form-item>
        <nz-form-item *ngIf="edit">
            <nz-form-label [nzSpan]="6" >排序</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请输入排序!">
                <nz-input-number
                        style="width: 200px"
                        formControlName="sort"
                        [nzMin]="1"
                        [nzMax]="100"
                        [nzStep]="1"
                        nzPlaceHolder="请输入排序!"
                ></nz-input-number>
            </nz-form-control>
        </nz-form-item>
    </form>
</nz-modal>
