<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->

<div class="inner-content">
  <form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)">
    <div nz-row>
      <div nz-col nzSpan="8">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">商户号</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input formControlName="merNo" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col nzSpan="8">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">商户名称</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input formControlName="merName" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col nzSpan="8">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">商户类型</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-select nzAllowClear formControlName="merType">
              <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]="8">开户人</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input formControlName="regName" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col nzSpan="8">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">开户人手机号</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input formControlName="regPhone" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col nzSpan="8">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">状态</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-select nzAllowClear formControlName="merStatus">
              <nz-option nzLabel="正常" nzValue="1"></nz-option>
              <nz-option nzLabel="编辑中" nzValue="2"></nz-option>
              <nz-option nzLabel="审核中" nzValue="3"></nz-option>
              <nz-option nzLabel="审核失败" nzValue="4"></nz-option>
              <nz-option nzLabel="违规" nzValue="5"></nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col nzSpan="8">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">业务员</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-select nzAllowClear formControlName="salesmanId">
              <nz-option *ngFor="let item of salesmanArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></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>共计 {{dataObject.total?dataObject.total:0}} 条数据</span>
  <div class="operating-button">
    <button nz-button nzType="primary" class="right-btn" (click)="merMigrateSalesmanModal = true">移交业务员</button>
  </div>

  <!--数组表格 -->
  <nz-table #basicTable
            [nzData]="dataObject.list"
            [nzTotal]="dataObject.total"
            [nzFrontPagination]="false"
            [nzLoading]="tableLoading"
            [nzPageIndex]="whereObject.pageNum"
            (nzPageIndexChange)="requestData($event)"
            [nzScroll]="{ x: '1150px'}">
    <thead>
    <tr>
      <th nzWidth="50px" [(nzChecked)]="allChecked" [nzShowCheckbox]="true" (nzCheckedChange)="onAllChecked($event)"></th>
      <th nzWidth="60px">序号</th>
      <th nzWidth="100px">商户类型</th>
      <th nzWidth="180px">商户号</th>
      <th nzWidth="250px">商户名称</th>
      <th nzWidth="200px">商户简称</th>
      <th nzWidth="100px">法人名称</th>
      <th nzWidth="100px">开户人</th>
      <th nzWidth="140px">开户人手机</th>
      <th nzWidth="100px">状态</th>
      <th nzWidth="130px">资料填写情况</th>
      <th nzWidth="160px">创建时间</th>
      <th nzWidth="100px">业务员</th>
      <th nzWidth="120px" nzRight="0px">操作</th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of basicTable.data;let i = index">
      <td
        [nzShowCheckbox]="true"
        [nzChecked]="data.checked"
        [nzDisabled]="data.disabled"
        (nzCheckedChange)="checkedChange(data, $event)"
      ></td>
      <td>{{i + 1}}</td>
      <td>{{data.merType | merType}}</td>
      <td>{{data.merNo}}</td>
      <td>{{data.merName?data.merName:'未填写'}}</td>
      <td>{{data.merAbbreviate?data.merAbbreviate:'未填写'}}</td>
      <td>{{data.larName?data.larName:'未填写'}}</td>
      <td>{{data.regName?data.regName:'未填写'}}</td>
      <td>{{data.regPhone?data.regPhone:'未填写'}}</td>
      <td>{{data.merStatus | merStatus}}</td>
      <td>{{data.completeStatus | completeStatus}}</td>
      <td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
      <td>{{data.salesmanName}}</td>
      <td nzRight="0px" 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 [routerLink]="['/admin/store/store-list']" [queryParams]="{merId: data.id}" nz-menu-item>门店列表</li>
            <li *ngIf="data.merStatus != 2" [routerLink]="['/admin/mer/detail']" [queryParams]="{merId: data.id}" nz-menu-item>商户详情</li>
            <li *ngIf="roleType == 1 && data.merStatus == 1" (click)="showPlatformConfig(data.id)" nz-menu-item>平台配置</li>
            <li *ngIf="data.merStatus == 4" (click)="auditFail(data.id)" nz-menu-item>失败原因</li>
          </ul>
        </nz-dropdown-menu>
      </td>
    </tr>
    </tbody>
  </nz-table>
</div>

<nz-modal [nzVisible]="platformConfigModal" nzTitle="平台配置" [nzBodyStyle]="{padding: '10px 0px 20px 10px'}" [nzFooter]="null" (nzOnCancel)="closePlatformConfig()">
  <ng-container *nzModalContent>
    <nz-tabset>
      <nz-tab nzTitle="建设银行">
        <form nz-form [formGroup]="ccbConfigForm">
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>商户号</nz-form-label>
            <nz-form-control [nzSm]="14">
              <input nz-input formControlName="platformNo" placeholder="请输入商户号"  />
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>柜台号</nz-form-label>
            <nz-form-control [nzSm]="14">
              <input nz-input formControlName="posId" placeholder="请输入柜台号" />
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>分行号</nz-form-label>
            <nz-form-control [nzSm]="14">
              <input nz-input formControlName="branchId" placeholder="请输入分行号" />
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>商户公钥</nz-form-label>
            <nz-form-control [nzSm]="14">
              <textarea rows="4" nz-input formControlName="merPublicKey" placeholder="请输入商户公钥"></textarea>
            </nz-form-control>
          </nz-form-item>

          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>人员编号</nz-form-label>
            <nz-form-control [nzSm]="14">
              <input nz-input formControlName="platformOperatorId" placeholder="请输入建行操作人员编号"  />
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>人员密码</nz-form-label>
            <nz-form-control [nzSm]="14">
              <input nz-input type="password" formControlName="platformOperatorPwd" placeholder="请输入建行操作人员密码" />
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>
            <span>证书文件
              <i nz-icon nz-tooltip nzTooltipTitle="建行操作人员证书文件，注意：证书文件是pfx格式" nzType="question-circle" nzTheme="outline"></i>
            </span>
            </nz-form-label>
            <nz-form-control [nzSm]="14">
              <nz-upload
                nzAction="{{BASE_URL + 'merPlatformNo/uploadfile?platformType=3'}}"
                [nzFileList]="ccbFileArray"
                (nzChange)="ccbFileCandleChange($event)"
                [nzAccept]="'.pfx'"
              >
                <button nz-button ><i nz-icon nzType="upload"></i>
                  {{ccbFileArray.length == 0?'上传文件':'重新上传'}}
                </button>
              </nz-upload>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSm]="6" nzRequired>证书秘钥</nz-form-label>
            <nz-form-control [nzSm]="14">
              <input nz-input type="password" formControlName="refundCertPwd" placeholder="请输入证书秘钥"/>
            </nz-form-control>
          </nz-form-item>

          <div style="text-align: center">
            <button nz-button nzType="primary" style="width: 200px;" (click)="saveCCBConfig()">保存</button>
          </div>
        </form>
      </nz-tab>
    </nz-tabset>
  </ng-container>
</nz-modal>


<nz-modal [(nzVisible)]="merMigrateSalesmanModal" nzTitle="移交业务员" (nzOnCancel)="merMigrateSalesmanModal = false" nzWidth="500px" [nzFooter]="null">
  <ng-container *nzModalContent>
    <form nz-form [formGroup]="merMigrateSalesmanForm">
      <nz-form-item>
        <nz-form-label [nzSpan]="6">业务员</nz-form-label>
        <nz-form-control [nzSpan]="14">
          <nz-select nzAllowClear formControlName="salesmanId">
            <nz-option *ngFor="let item of salesmanArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option>
          </nz-select>
        </nz-form-control>
      </nz-form-item>
      <div style="text-align: center;">
        <button nz-button nzType="primary" style="width: 150px;" (click)="submitMigrateSalesman()">确定</button>
      </div>
    </form>
  </ng-container>
</nz-modal>
