<!-- 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">
                        <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">
    <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="90px">产品编码</th>
            <th nzWidth="120px">成本价</th>
            <th nzWidth="120px">面值</th>
            <th nzWidth="120px">创建时间</th>
            <th nzRight nzWidth="80px">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i + 1}}</td>
            <td>{{data.name}}</td>
            <td>{{data.productId}}</td>
            <td>{{data.costPrice + "RMB"}}</td>
            <td>{{data.price + "RMB"}}</td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td nzRight 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  *ngIf="data.status != 1"><a (click)="getEdit(data.id)">编辑</a></li>
                    </ul>
                </nz-dropdown-menu>
            </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>
            <nz-form-label [nzSpan]="6" nzRequired>产品名称</nz-form-label>
            <nz-form-control [nzSpan]="16" nzErrorTip="请输入产品名称!">
                <input nz-input placeholder="请输入产品名称..."  [formControlName]="'name'" id="'name'" />
            </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 nz-input placeholder="请输入产品编号..."  [formControlName]="'productId'" id="'productId'" />
            </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  nzPlaceHolder="请选择产品分类" (ngModelChange)="getBrandByList($event)"  [formControlName]="'typeId'">
                        <nz-option *ngFor="let item of goodsTypeData" [nzValue]="item.id" nzLabel="{{item.title}}"></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  nzPlaceHolder="请选择品牌"  [formControlName]="'brandId'">
                    <nz-option *ngFor="let item of brandData" [nzValue]="item.id" nzLabel="{{item.title}}"></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-input-number
                        style="width: 200px"
                        formControlName="costPrice"
                        [nzMin]="1"
                        [nzMax]="10000"
                        [nzStep]="1"
                        [nzPrecision]="2"
                        nzPrecisionMode="cut"
                        nzPlaceHolder="请输入成本价!"
                        [nzFormatter]="formatterPercent"
                        [nzParser]="parserPercent"
                ></nz-input-number>
            </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-number
                        style="width: 200px"
                        formControlName="price"
                        [nzMin]="1"
                        [nzMax]="10000"
                        [nzStep]="1"
                        [nzPrecision]="2"
                        nzPrecisionMode="cut"
                        nzPlaceHolder="请输入面值!"
                        [nzFormatter]="formatterPercent"
                        [nzParser]="parserPercent"
                ></nz-input-number>
            </nz-form-control>
        </nz-form-item>
        <nz-form-item>
            <nz-form-label [nzSpan]="6" >排序</nz-form-label>
            <nz-form-control [nzSpan]="16">
                <nz-input-number
                        style="width: 200px"
                        formControlName="sort"
                        [nzMin]="1"
                        [nzMax]="10000"
                        [nzStep]="1"
                        nzPlaceHolder="请输入排序!"
                ></nz-input-number>
            </nz-form-control>
        </nz-form-item>
    </form>
</nz-modal>

