<!-- 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="title"/>
                    </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="type" nzPlaceHolder="请选择代理商状态">
                            <nz-option nzLabel="大转盘" nzValue="1"></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="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>

        <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" [routerLink]="['/admin/activate/activate-edit']" ><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="50px">编号</th>
            <th nzWidth="150px">活动标题</th>
            <th nzWidth="70px">活动类型</th>
            <th nzWidth="100px">开始时间</th>
            <th nzWidth="100px">结束时间</th>
            <th nzWidth="100px">创建时间</th>
            <th nzWidth="80px" nzRight>活动状态</th>
            <th nzWidth="120px" nzRight>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of ajaxTable.data; let i = index">
            <td>{{i+1}}</td>
            <td>{{data.title}}</td>
            <td>{{data.type | type}}</td>
            <td>{{data.startTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td>{{data.endTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td nzRight>{{data.status | status}}</td>
            <td nzRight class="table-td-operation">
                <a *ngIf="data.status == 1" (click)="getEdit(data.id)">编辑</a>
                <a (click)="startActivity(data.id)" *ngIf="data.status == 1">发布</a>
                <a (click)="endActivity(data.id)" *ngIf="data.status == 2">结束</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)='jumpLotteryRecord(data.id )'>中奖记录</a></li>
                    </ul>
                </nz-dropdown-menu>
            </td>
        </tbody>
    </nz-table>
</div>



