<!-- 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" *ngIf="userObjectType === 0">
        <nz-form-item>
          <nz-form-label [nzSpan]="8">分公司</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-select nzAllowClear formControlName="companyId">
              <nz-option *ngFor="let item of companyArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></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="name" />
          </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="contactPerson" />
          </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="contactPersonPhone" />
          </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="status">
              <nz-option nzLabel="正常" nzValue="1"></nz-option>
              <nz-option nzLabel="停用" nzValue="2"></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" [routerLink]="'/admin/agent/add'"><i nz-icon nzType="plus" nzTheme="outline"></i>添加</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="100px">序号</th>
      <th nzWidth="200px" *ngIf="userObjectType === 0">分公司</th>
      <th nzWidth="200px">代理商名称</th>
      <th nzWidth="150px">联系人</th>
      <th nzWidth="150px">联系电话</th>
      <th nzWidth="200px">详细地址</th>
      <th nzWidth="100px">状态</th>
      <th nzWidth="160px">创建时间</th>
      <th nzWidth="120px" nzRight="0px">操作</th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of basicTable.data;let i = index">
      <td>{{i + 1}}</td>
      <td *ngIf="userObjectType === 0">{{data.companyName}}</td>
      <td>{{data.name}}</td>
      <td>{{data.contactPerson}}</td>
      <td>{{data.contactPersonPhone}}</td>
      <td>{{data.address}}</td>
      <td>{{data.status | agentStatus}}</td>
      <td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</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 nz-menu-item><a [routerLink]="['/admin/agent/update']" [queryParams]="{agentId: data.id}">修改</a></li>
            <li nz-menu-item><a *ngIf="data.status === 1" (click)="showDisableAgentConfirm(data.id, true)">停用</a></li>
            <li nz-menu-item><a *ngIf="data.status === 2" (click)="showDisableAgentConfirm(data.id, false)">启用</a></li>
            <li nz-menu-item><a (click)="showDeleteConfirm(data.id)">删除</a></li>
            <li nz-menu-item><a (click)="showTradeTakeConfigMadel(data.id)">交易分账配置</a></li>
          </ul>
        </nz-dropdown-menu>
        <!--<a [routerLink]="['/admin/agent/detail']" [queryParams]="{agentId: data.id}">详情</a>-->
      </td>
    </tr>
    </tbody>
  </nz-table>
</div>


<nz-modal [(nzVisible)]="tradeTakeConfigMadel" nzTitle="交易分账配置" (nzOnCancel)="closeTradeTakeConfigMadel()" [nzFooter]="null">

  <form nz-form [formGroup]="tradeTakeConfigForm">
    <div nz-row>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>平台类型</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-select formControlName="platformType" (ngModelChange)="platformTypeChange($event)">
              <nz-option *ngFor="let data of platformTypeArray" nzLabel="{{data.codeName}}" nzValue="{{data.codeValue}}"></nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div class="title">公司入账配置</div>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>入账商户名称</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input type="text" formControlName="receiverName" placeholder="请填写平台的商户名称" />
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>平台入账商户号</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input type="text" formControlName="receiverAccount"  placeholder="请填写平台的商户号" />
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>分账比例（%）</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-input-number formControlName="receiverRatio" [nzPrecision]="4" [nzMax]="100" [nzMin]="0" nzPlaceHolder="分账比例" (ngModelChange)="compute($event)"></nz-input-number>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div class="title">代理商入账配置</div>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>入账商户名称</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input type="text" formControlName="subReceiverName" placeholder="请填写平台的商户名称" />
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>平台入账商户号</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <input nz-input type="text" formControlName="subReceiverAccount"  placeholder="请填写平台的商户号" />
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-label [nzSpan]="6" nzRequired>分账比例（%）</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <nz-input-number formControlName="subReceiverRatio" nzDisabled [nzPrecision]="4" [nzMax]="100" [nzMin]="0" nzPlaceHolder="分账比例"></nz-input-number>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="24">
        <nz-form-item>
          <nz-form-control [nzOffset]="7" [nzSpan]="12">
            <button nz-button (click)="submitTradeTakeConfig()" nzType="primary" >确定</button>
            <button nz-button (click)="closeTradeTakeConfigMadel()">取消</button>
          </nz-form-control>
        </nz-form-item>
      </div>

    </div>
  </form>

</nz-modal>
