<!-- 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="type" 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="showType" nzPlaceHolder="请选择展示区域">
                            <nz-option nzLabel="小程序" [nzValue]="1"></nz-option>
                            <nz-option nzLabel="H5" [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="rechargeType" 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>

        <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)="getMemberGoods()">获取关联商品</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"
            (nzPageIndexChange)="getRequest(false , searchForm.value)"
            (nzPageSizeChange)="getRequest(false , searchForm.value)">
        <thead nzSingleSort>
        <tr>
            <th>编号</th>
            <th>金额类型</th>
            <th>充值类型</th>
            <th>展示区域</th>
<!--            <th>供货商编号</th>-->
<!--            <th>商品ID</th>-->
            <th>充值金额</th>
            <th>支付金额</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i + 1}}</td>
            <td>{{data.type | rechargePrice}}</td>
            <td>{{data.rechargeType== 1? '快充':'慢充'}}</td>
            <td>{{data.showType | showType}}</td>
            <td>{{data.price}}</td>
            <td>{{data.realPrice}}</td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td class="table-td-operation">
                <a (click)="getEdit(data.id)">编辑</a>
                <a style="margin-left: 20px;" (click)='getForbiddenUser(data.id , data.status)'>{{data.status === 1 ? '禁用': '启用'}}</a>
                <a 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 nzShowSearch nzAllowClear formControlName="type" 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 formControlName="showType" nzPlaceHolder="请选择展示区域">
                    <nz-option nzLabel="小程序" [nzValue] ="1"></nz-option>
                    <nz-option nzLabel="H5" [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 formControlName="rechargeType" 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>
            <nz-form-label [nzSpan]="6" nzRequired>商品排序</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请输入商品排序!">
                <input [type]="'number'" nz-input formControlName="sort" />
            </nz-form-control>
        </nz-form-item>
<!--        <nz-form-item>-->
<!--            <nz-form-label [nzSpan]="6" nzRequired>供货商编号</nz-form-label>-->
<!--            <nz-form-control [nzSpan]="16" nzErrorTip="请输入供货商编号!">-->
<!--                <input [type]="'number'" nz-input formControlName="channel" />-->
<!--            </nz-form-control>-->
<!--        </nz-form-item>-->
<!--        <nz-form-item>-->
<!--            <nz-form-label [nzSpan]="6" nzRequired>商品ID</nz-form-label>-->
<!--            <nz-form-control [nzSpan]="16" nzErrorTip="请输入商品ID!">-->
<!--                    <input [type]="'number'" nz-input formControlName="goodsId" />-->
<!--            </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-input-group nzSuffix="RMB" nzPrefix="￥">
                    <input [type]="'number'" (ngModelChange)="getPrice()" nz-input formControlName="price" />
                </nz-input-group>
            </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-input-group nzSuffix="%" >
                    <input [type]="'number'" (ngModelChange)="getPrice()" nz-input formControlName="discount" />
                </nz-input-group>
            </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-input-group nzSuffix="RMB" nzPrefix="￥">
                    <input [type]="'number'" nz-input [(ngModel)]="realPrice" formControlName="realPrice" />
                </nz-input-group>
            </nz-form-control>
        </nz-form-item>
    </form>
</nz-modal>

<nz-modal [(nzVisible)]="isVisibleGoods" nzWidth="900" nzTitle="渠道商获取关联商品" (nzOnCancel)="handleCancelGoods()" (nzOnOk)="handleCancelGoods()">
    <nz-table #basicTable [nzData]="goodsArray">
        <thead>
        <tr>
            <th>供货商编号</th>
            <th>商品ID</th>
            <th>渠道商标识符</th>
            <th>折扣比例</th>
            <th>商品名称</th>
            <th>渠道商名称</th>
            <th>状态</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of basicTable.data">
            <td>{{data.channel}}</td>
            <td>{{data.goodsId}}</td>
            <td>{{data.channelMark | channelMark}}</td>
            <td>{{data.discountRatio}}%</td>
            <td>{{data.goodsName}}</td>
            <td>{{data.memberName}}</td>
            <td>{{data.state == 1 ? '上架' : '下架'}}</td>
        </tr>
        </tbody>
    </nz-table>
</nz-modal>
