<!--
 * @Author: your name
 * @Date: 2021-12-03 11:10:14
 * @LastEditTime : 2022-03-25 16:31:01
 * @LastEditors  : Shiming
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\waybill-management\\components\\bulk\\bulk.component.html
-->
<!-- 搜索表单 -->
<page-header-wrapper [title]="''"> </page-header-wrapper>
<nz-card>
  <div nz-row nzGutter="8">
    <!-- 查询字段小于或等于3个时，不显示伸缩按钮 -->
    <div nz-col nzSpan="24" *ngIf="queryFieldCount <= 4">
      <sf
        #sf
        [schema]="schema"
        [ui]="ui"
        [mode]="'search'"
        [disabled]="!sf?.valid"
        [loading]="false"
        (formSubmit)="st?.load(1)"
        (formReset)="resetSF()"
      ></sf>
    </div>

    <!-- 查询字段大于3个时，根据展开状态调整布局 -->
    <ng-container *ngIf="queryFieldCount > 4">
      <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">
        <button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="search()"  acl  [acl-ability]="['WAYBILL-BULK-search']">查询</button>
        <button nz-button nzType="primary" [disabled]="false" acl  [acl-ability]="['WAYBILL-BULK-export']" (click)="exprot()">导出</button>
        <button nz-button [disabled]="false" (click)="resetSF()">重置</button>
        <button nz-button nzType="link" (click)="expandToggle()">
          {{ !_$expand ? '展开' : '收起' }}
          <i nz-icon [nzType]="!_$expand ? 'down' : 'up'"></i>
        </button>
      </div>
    </ng-container>
  </div>
</nz-card>

<nz-card>
  <nz-tabset (nzSelectedIndexChange)="selectChange($event)">
    <nz-tab [nzTitle]="'全部(' + tabs?.totalQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'待发车(' + tabs?.receivedQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'运输中(' + tabs?.cancelQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'待签收(' + tabs?.signQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'已完成(' + tabs?.compolatelQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'已取消(' + tabs?.deltQuantity + ')'"></nz-tab>
  </nz-tabset>
  <div style="margin-top: 15px">
    <st
      #st
      [bordered]="true"
      [scroll]="{ x: '2000px' }"
      [data]="service.$api_get_Bulkpage"
      [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, 30, 50, 100, 200, 300, 500, 1000] }"
      [loading]="false"
    >
    <ng-template st-row="createUserName" let-item let-index="index">
      <div> {{ item?.createUserName }}/{{ item?.createUserPhone }} </div>
    </ng-template>
      <ng-template st-row="driverName" let-item let-index="index">
        <div> {{ item?.driverName }}/{{ item?.driverTelephone }}/{{ item?.driverLicenseCarNo }} </div>
      </ng-template>
      <ng-template st-row="payeeName" let-item let-index="index">
        <div> {{ item?.payeeName }}/{{ item?.payeePhone }} </div>
      </ng-template>
      <ng-template st-row="wayBillCode" let-item let-index="index">
        <a [routerLink]="'bulk-detail/' + item?.id">{{ item?.wayBillCode }}</a>
        <div>
          <span>{{item?.wayBillStatusLabel}}</span>
        </div>
        <div>
          <span >{{item?.resourceTypeLabel}}{{item?.serviceTypeLabel}}</span>
        </div>
      </ng-template>
      <ng-template st-row="freightPrice" let-item let-index="index">
        {{ item?.freightPrice }}/吨
        <div>{{item?.settlementBasisLabel}}</div>
      </ng-template>
      <ng-template st-row="billExpenseDetails" let-item let-index="index">
        <div *ngIf="item?.billExpenseDetails?.length > 0">
          <p *ngFor="let data of item?.billExpenseDetails">
            {{ data.costName }}：{{ data.price | currency }}
            <span style="color: #f59a63">{{ data.paymentStatusLabel }}</span>
          </p>
        </div>
      </ng-template>
      <ng-template st-row="wayBill" let-item let-index="index">
        <a [routerLink]="'/waybill-management/bulk-detail/' + item?.id">{{ item?.wayBillCode }}</a>
      </ng-template>
      <ng-template st-row="goodsInfos" let-item let-index="index">
        <div>{{ item?.goodsInfos?.goodsName }}</div>
        <div>{{ item?.goodsInfos?.weight }}{{ item?.goodsInfos?.volume?  '/' +item?.goodsInfos?.volume : '' }}{{ item?.goodsInfos?.number ? '/' + item?.goodsInfos?.number : '' }}</div>
      </ng-template>
      <ng-template st-row="loadingTime" let-item let-index="index">
        <div *ngIf="item?.loadingTime">装 | {{ item?.loadingTime }}</div>
        <div *ngIf="item?.unloadingTime">卸 | {{ item?.unloadingTime }}</div>
      </ng-template>
    </st>
  </div>
</nz-card>
