<!-- 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="storeName"/>
                    </nz-form-control>
                </nz-form-item>
            </div>
            <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="telephone"/>
                    </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>
    <span *ngIf="id != null" style="margin-left: 30px;;">
        商戶名称:
        <span style="font-weight: bold; font-size: 20px">{{name}}</span>
    </span>
    <div class="operating-button"  *ngIf="id == null" >
        <button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/merchantStore/store-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button>
        <nz-upload
                [nzAccept]="'.xls,.xlsx'"
                nzAction="{{WEB_SERVE_URL}}highMerchantStore/importMerchantStore"
                [nzHeaders]="{ authorization: 'authorization-text' }"
                (nzChange)="handleChange($event)"
                [nzShowUploadList]="false"
        >
            <button  nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>批量导入</button>
        </nz-upload>
    </div>
    <nz-spin nzTip="批量导入中..." [nzSpinning]="isSpinning">
        <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="80px">门店名称</th>
                <th nzWidth="100px">门店电话</th>
                <th nzWidth="100px">创建时间</th>
                <th nzWidth="160px" nzRight="0px">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr *ngFor="let data of ajaxTable.data; let i = index">
                <td>{{i+1}}</td>
                <td>{{data.regionName}}</td>
                <td>{{data.storeKey}}</td>
                <td>{{data.storeName}}</td>
                <td>{{data.telephone}}</td>
                <td>{{data.createTime | 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)="getDetail(data.id)">详情</a>
                    <nz-divider nzType="vertical"></nz-divider>
                    <a *ngIf="'BTN_add_blance' | button"  (click)="getRecharge(data.id)">增加余额</a>
                    <nz-divider *ngIf="'BTN_add_blance' | button" nzType="vertical"></nz-divider>
                    <a (click)="getDelete(data.id)">删除</a>
                    <nz-divider nzType="vertical"></nz-divider>
                    <a [routerLink]="['/admin/device/list']" [queryParams]="{ merStoreId: data.id}">设备管理</a>
                </td>
            </tbody>
        </nz-table>
    </nz-spin>
</div>



<nz-modal [(nzVisible)]="errorStudentVisible" nzTitle="导入失败数据" (nzOnCancel)="handleCancelError()" nzWidth="900px" [nzFooter]="null">
    <nz-table #errorStudentTable [nzData]="importErrorStudentArray">
        <thead>
        <tr>
            <th nzWidth="80px">序号</th>
            <th nzWidth="150px">门店编号</th>
            <th nzWidth="150px">门店名称</th>
            <th nzWidth="150px">区域ID</th>
            <th nzWidth="300px">原因</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let data of errorStudentTable.data;let i = index">
            <td>{{ i + 1}}</td>
            <td>{{data.storeKey}}</td>
            <td>{{data.storeName}}</td>
            <td>{{data.regionId}}</td>
            <td>{{data.errorMessage}}</td>
        </tr>
        </tbody>
    </nz-table>
</nz-modal>

<nz-modal [(nzVisible)]="isVisibleAdd" nzTitle="新增预充值余额" (nzOnCancel)="isVisibleAdd = false" (nzOnOk)="handleOk()">
    <div nz-row>
        <div nz-col nzSpan="18">
            <nz-form-item>
                <nz-form-label [nzSpan]="6">充值金额</nz-form-label>
                <nz-form-control [nzSpan]="16">
                    <input nz-input placeholder="请输入充值金额..." [(ngModel)]="price" />
                </nz-form-control>
            </nz-form-item>
        </div>
    </div>
</nz-modal>
