<!-- 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="6">
                <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>

        <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="50px">编号</th>
            <th nzWidth="80px">标题</th>
            <th nzWidth="80px">图片</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.title}}</td>
            <td>
                <img class="head_img" src="{{imageUrl + data.img}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt="">
            </td>
            <td>{{data.createdTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td>{{data.updatedTime | date: 'yyyy-MM-dd HH:mm'}}</td>
            <td nzRight="0px" class="table-td-operation">
                <a (click)="getEdit(data.id)">编辑</a>
                <nz-divider nzType="vertical"></nz-divider>
                <a (click)="showDeleteConfirm(data.id)">删除</a>
            </td>
        </tbody>
    </nz-table>
</div>

<nz-modal [(nzVisible)]="isVisible" nzTitle="编辑" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
    <form nz-form [formGroup]="validateForm">
        <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>标题</nz-form-label>
            <nz-form-control [nzSpan]="12" nzErrorTip="请输入标题!">
                <input nz-input placeholder="请输入标题..."  [formControlName]="'title'" />
            </nz-form-control>
        </nz-form-item>
        <nz-form-item>
            <nz-form-label [nzSpan]="4">使用业务</nz-form-label>
            <nz-form-control [nzSpan]="12">
                <input nz-input placeholder="请输入使用业务..."  [formControlName]="'userService'" />
            </nz-form-control>
        </nz-form-item>

        <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>图片</nz-form-label>
            <nz-form-control [nzSpan]="20" nzErrorTip="请上传图片!">
                <nz-upload
                        nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile"
                        nzListType="picture-card"
                        [(nzFileList)]="imgFile"
                        [nzShowButton]="imgFile.length < 1"
                        [nzPreview]="handlePreview"
                >
                    <i nz-icon nzType="plus"></i>
                    <div class="ant-upload-text">上传图片</div>
                </nz-upload>
                <nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false">
                    <ng-template #modalContent>
                        <img [src]="previewImage" [ngStyle]="{ width: '100%' }" />
                    </ng-template>
                </nz-modal>
            </nz-form-control>
        </nz-form-item>
    </form>
</nz-modal>
