<!--
 * @Description  : 
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2022-01-12 10:52:50
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-02-28 17:00:48
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\insurance-management\\components\\list\\list.component.html
 * Copyright (C) 2022 huzhenhong. All rights reserved.
-->
<!-- 搜索表单 -->
<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]="_$expand">
        <button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="search()" acl  [acl-ability]="['INSURANCE-LIST-search']">查询</button>
        <button nz-button nzType="primary" [disabled]="false" acl  [acl-ability]="['INSURANCE-LIST-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)" [nzTabBarExtraContent]="extraTemplate">
    <nz-tab [nzTitle]="'全部(' + tabs?.totalCount + ')'"></nz-tab>
    <nz-tab [nzTitle]="'待投保(' + tabs?.receivedQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'已投保(' + tabs?.stayQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'投保失败(' + tabs?.GoingQuantity + ')'"></nz-tab>
    <nz-tab [nzTitle]="'已取消(' + tabs?.cancelQuantity + ')'"></nz-tab>
  </nz-tabset>
  <div style="margin-top: 15px">
    <st
      #st
      [bordered]="true"
      [scroll]="{ x: '2000px' }"
      [data]="service.$api_premiumInfo_list"
      [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="resourceCode" let-item let-index="index">
        {{ item.resourceCode | currency }}
      </ng-template>
      <ng-template st-row="practicalPremium" let-item let-index="index">
        {{ item.practicalPremium | currency }}
      </ng-template>
      <ng-template st-row="insureAmount" let-item let-index="index">
        {{ item.insureAmount | currency }}
      </ng-template>
      <ng-template st-row="premium" let-item let-index="index">
        {{ item.premium | currency }}
      </ng-template>
      <ng-template st-row="processMessage" let-item let-index="index">
        {{ item.processResult == '2' ? item.processMessage : '' }}
      </ng-template>
      <ng-template st-row="driverName" let-item let-index="index">
        <div> {{ item?.driverName }}/{{ item?.driverTelephone }}/{{ item?.carNo }} </div>
      </ng-template>
      <ng-template st-row="distance" let-item let-index="index">
        <div>
          {{ item?.distance ? ((item?.distance)/1000).toFixed(4) + '公里' : '' }}
        </div>
      </ng-template>
      <ng-template st-row="goodsNumber" let-item let-index="index">
        <div>
          {{ item?.billCode }}
        </div>
      </ng-template>
      <ng-template st-row="resourceCode" let-item let-index="index">
        <div>
          {{ item?.resourceCode }}
        </div>
        <div>
          {{ item?.resourceStatusLabel }}
        </div>
      </ng-template>
      <ng-template st-row="insureCode" let-item let-index="index">
        <div>{{ item.insureCode }}</div>
        <div>
          <span>{{ item?.insureStatusLabel }}</span>
        </div>
      </ng-template>
      <ng-template st-row="goodsName" let-item let-index="index">
        <div>{{ item?.goodsInfoName }}</div>
        <div>
          <span>{{ item?.weight ? item?.weight + '吨/' : '' }}</span>
          <span>{{ item?.volume ? item?.volume + '方' : '' }}</span>
          <span>{{ item?.number ? item?.number + '件' : '' }}</span>
        </div>
      </ng-template>
      <ng-template st-row="mybidDetailInfo" let-item let-index="index">
        <div *ngIf="item.mybidDetailInfo?.length > 0">
          <p *ngFor="let data of item.mybidDetailInfo">
            {{ data.expenseName }}：{{ data.price | currency }}
            <span *ngIf="data.paymentStatusLabel" style="color: #f59a63">{{ data.paymentStatusLabel }}</span>
          </p>
        </div>
      </ng-template>
    </st>
  </div>
</nz-card>

<ng-template #extraTemplate>
  <div>
    <button nz-button nzType="primary" (click)="changeOrder()" acl  [acl-ability]="['INSURANCE-LIST-insuranceConfig']"> 保险配置 </button>
  </div>
</ng-template>
