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

<nz-card>
  <!-- 搜索表单 -->
  <div nz-row nzGutter="8">
    <div nz-col [nzSpan]=" 24 ">
      <sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'"></sf>
    </div>
  </div>
  <div [class.text-right]="true">
    <button nz-button nzType="primary" [disabled]="!sf.valid" [nzLoading]="isLoading && st.loading" (click)="search()"
      acl [acl-ability]="['ORDER-REPORTING-search']">查询</button>
    <button nz-button (click)="resetSF()">重置</button>
    <button nz-button (click)="export()" acl [acl-ability]="['ORDER-REPORTING-export']">导出</button>
    <button nz-button nzType="link" (click)="expandToggle()">
      {{ !_$expand ? '展开' : '收起' }}
      <i nz-icon [nzType]="!_$expand ? 'down' : 'up'"></i>
    </button>
  </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_order_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] }" [loading]="service.http.loading"
    (change)="changeSt($event)">
    <ng-template st-row="billPutStatus" let-item let-index="index">
      <a *ngIf="item?.billPutStatus === '2'" (click)="viewAuditResult(item)">{{filterStatus(item?.billPutStatus)}}</a>
      <span *ngIf="item?.billPutStatus !== '2'">{{filterStatus(item?.billPutStatus)}}</span>
    </ng-template>
    <ng-template st-row="driverPutStatus" let-item let-index="index">
      <a (click)="viewAuditResult(item)"
        *ngIf="item?.driverPutStatus === '2'">{{filterStatus(item?.driverPutStatus)}}</a>
      <span *ngIf="item?.driverPutStatus !== '2'">{{filterStatus(item?.driverPutStatus)}}</span>
    </ng-template>
    <ng-template st-row="carPutStatus" let-item let-index="index">
      <a (click)="viewAuditResult(item)" *ngIf="item?.carPutStatus === '2'">{{filterStatus(item?.carPutStatus)}}</a>
      <span *ngIf="item?.carPutStatus !== '2'">{{filterStatus(item?.carPutStatus)}}</span>
    </ng-template>

    <ng-template st-row="checkStatus" let-item let-index="index">
      <a *ngIf="item?.checkStatus === '2'" acl [acl-ability]="['ORDER-REPORTING-view-upload-data']"
        (click)="viewResult(item)">{{filterCheckStatus(item?.checkStatus)}}</a>
      <span *ngIf="item?.checkStatus !== '2'">{{filterCheckStatus(item?.checkStatus)}}</span>
    </ng-template>

    <ng-template st-row="billCode" let-item>
      <a class="text-red-dark" (click)="routeToOrder(item)">{{item?.billCode}}</a>
    </ng-template>
    <ng-template st-row="wayBillCode" let-item>
      <a class="text-red-dark" (click)="routeTowaybill(item)">{{item?.wayBillCode}}</a>
    </ng-template>

    <ng-template st-row="freightAmount" let-item let-index="index">
      <div class="text-right">{{item?.freightAmount | currency }}</div>
    </ng-template>
    <ng-template st-row="goodsInfoList" let-item let-index="index">
      <div *ngFor="let _item of item?.goodsInfoList">
        {{_item?.goodsTypeName}}/{{_item?.goodsName}}/{{_item?.weight}}吨/{{_item?.volume}}m³
      </div>
    </ng-template>

    <ng-template st-row="car" let-item let-index="index">
      <a (click)="viewTrack(item,'car')">查看轨迹</a>
    </ng-template>
    <ng-template st-row="driver" let-item let-index="index">
      <a (click)="viewTrack(item,'driver')">查看轨迹</a>
    </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]="['ORDER-REPORTING-upload']">上传</button>
    <button nz-button nzType="primary" (click)="recall()" acl [acl-ability]="['ORDER-REPORTING-recall']">撤回</button>
    <button nz-button nzType="primary" (click)="updateData()" acl
      [acl-ability]="['ORDER-REPORTING-update-data']">更新数据</button>
    <button nz-button nzType="primary" (click)="uploadSetting()" acl
      [acl-ability]="['ORDER-REPORTING-search']">上传设置</button>
  </div>
</ng-template>
