<page-header-wrapper [title]="''"></page-header-wrapper>

<nz-card>
  <!-- 搜索表单 -->
  <div nz-row nzGutter="8">
    <div nz-col [nzSpan]="_$expand ? 24 : 18">
      <sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'"></sf>
    </div>
    <div nz-col [nzSpan]="_$expand ? 24 : 6" [class.text-right]="_$expand">
      <button nz-button nzType="primary" [disabled]="!sf.valid" [nzLoading]="isLoading && st.loading" (click)="search()"
        acl [acl-ability]="['FUND-REPORTING-search']">查询</button>
      <button nz-button (click)="resetSF()">重置</button>
      <button nz-button (click)="export()" acl [acl-ability]="['FUND-REPORTING-export']">导出</button>
      <button nz-button nzType="link" (click)="expandToggle()">
        {{ !_$expand ? '展开' : '收起' }}
        <i nz-icon [nzType]="!_$expand ? 'down' : 'up'"></i>
      </button>
    </div>
  </div>
</nz-card>
<nz-card>
  <nz-tabset [nzTabBarExtraContent]="extraTemplate" *ngIf="tabs.length>0">

    <nz-tab *ngFor="let tab of tabs" [nzTitle]="tab.name" (nzSelect)="selectChange(tab)">
    </nz-tab>
  </nz-tabset>
  <!-- 数据列表 -->
  <st #st [scroll]="{x:'1200px'}" [data]="service.$api_get_fund_reporting_page" [columns]="columns"
    [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
    [res]="{ reName: { list: 'data.records', total: 'data.total' } }"
    [page]="{ show: true, showSize: true, pageSizes: [10,20, 50, 100] }" (change)="changeSt($event)">
    <ng-template st-row="uploadStatus" let-item>
      <span [ngClass]="{'text-red-dark':item?.uploadStatus === '4'}">{{item?.uploadStatusLabel}}</span>
    </ng-template>
    <ng-template st-row="verifyStatus" let-item>
      <a (click)="viewResult(item)" acl [acl-ability]="['FUND-REPORTING-view-verify-data']"
        *ngIf="item?.verifyStatus === '2'">{{item?.verifyStatusLabel}}</a>
      <span *ngIf="item?.verifyStatus !== '2'">{{item?.verifyStatusLabel}}</span>
    </ng-template>
    <ng-template st-row="orderCode" let-item>
      <a (click)="routeToOrder(item)">{{item?.orderCode}}</a>
    </ng-template>
    <ng-template st-row="wayBillCode" let-item>
      <a (click)="routeTowaybill(item)">{{item?.wayBillCode}}</a>
    </ng-template>
    <ng-template st-row="tolalAmount" let-item let-index="index">
      <div class="text-right">{{item?.tolalAmount | currency }}</div>
    </ng-template>
    <ng-template st-row="payAmount" let-item let-index="index">
      <div class="text-right">{{item?.payAmount | currency }}</div>
    </ng-template>
  </st>
</nz-card>
<ng-template #extraTemplate>
  <div class="d-flex align-items-center">
    <div class="mr-md">
      已选择
      <strong class="text-red">{{ selectedRows.length }}</strong> 条数据
    </div>
    <button nz-button nzType="primary" (click)="upload()" acl [acl-ability]="['FUND-REPORTING-upload']">上传</button>
    <button nz-button nzType="primary" (click)="recall()" acl [acl-ability]="['FUND-REPORTING-recall']">撤回</button>
    <button nz-button nzType="primary" (click)="updateData()" acl
      [acl-ability]="['FUND-REPORTING-upload-data']">更新数据</button>
  </div>
</ng-template>
