<!--
 * @Author: your name
 * @Date: 2021-12-03 15:31:52
 * @LastEditTime : 2022-04-14 20:06:41
 * @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-detail\\bulk-detail.component.html
-->

<page-header-wrapper [title]="'大宗运单详情'" [logo]="logo">
  <ng-template #logo>
    <button nz-button nz-tooltip nzTooltipTitle="返回上一页" (click)="goBack()">
      <i nz-icon nzType="left" nzTheme="outline"></i>
    </button>
  </ng-template>
  <ng-template #headerContent>
    <div>
      <nz-tabset style="margin-top: 15px;">
        <nz-tab nzTitle="装卸货信息" (nzClick)="goDistance(distannce1)">
        </nz-tab>
        <nz-tab nzTitle="基本信息" (nzClick)="goDistance(distannce1)">
        </nz-tab>
        <nz-tab nzTitle="运费信息" (nzClick)="goDistance(distannce3)">
        </nz-tab>
        <nz-tab nzTitle="附件信息" (nzClick)="goDistance(distannce4)">
        </nz-tab>
        <nz-tab nzTitle="轨迹信息" (nzClick)="goDistance(distannce5)">
        </nz-tab>
      </nz-tabset>
    </div>
  </ng-template>
</page-header-wrapper>
<nz-card [nzBorderless]="true" class="mb0" #distannce1>
  <div class=" common-order-header" nz-row>
    <div>
      <button nz-button nzType="primary" nzSize="small" nzDanger>{{i?.wayBillStatusLabel}}</button>
      <b class="ml-md text-md">运单号: {{ i?.wayBillCode }}</b>
    </div>
    <div>
      <button nz-button *ngIf="i?.wayBillStatus == '2'" (click)="sureDepart(i)" acl
        [acl-ability]="['WAYBILL-BULK-DETAIL-insertBulkStartCarInfo']">确认发车</button>
      <button nz-button nzType="primary" *ngIf="i?.wayBillStatus == '3'" (click)="sureArrive(i)" nzGhost acl
        [acl-ability]="['WAYBILL-BULK-DETAIL-insertBulkUnloadCarInfo']">确认到车</button>
    </div>
  </div>
  <nz-divider class="mt-sm mb-sm"></nz-divider>
  <div class="mb-lg">
    <div sv-container>
      <sv label="网络货运人">{{ i?.enterpriseInfoName }} </sv>
      <sv label="货主">{{ i?.shippername }} </sv>
      <sv label="所属项目">{{i?.enterpriseProjectName}}</sv>
      <sv label="服务类型">{{i?.serviceTypeLabel}}</sv>
      <sv label="调度员">{{i?.dispatchName}} /{{i?.dispatchPhone}}</sv>
      <sv label="外部订单号">{{ i?.externalBillCode }}</sv>
      <sv label="货源编号">{{ i?.resourceCode }} </sv>
      <sv label="承诺付款天数">{{ i?.paymentDays }}</sv>
    </div>
  </div>
  <div class="approval-status">
    <div class="step-row">
      <nz-steps [nzCurrent]="i?.scheduleVOList?.length + 1" nzLabelPlacement="vertical">
        <nz-step *ngFor="let item of i?.scheduleVOList" [nzTitle]="item.state" [nzSubtitle]="item.stateTime"
          [nzStatus]="item.displayStatus === 'SHOW' ? 'finish' : 'wait'"></nz-step>
      </nz-steps>
    </div>
  </div>
</nz-card>
<nz-card [nzBorderless]="true" class="mb0">
  <div class="font-weight-blod text-md detail-title">
    <a class="sign"></a>
    <span>装货卸货信息</span>
    <span class="ml-sm text-sm">(
      <label>{{i?.loadingNumber || '一'}}装</label>
      <label>{{i?.dischargeNumber || '一'}}卸</label>
      )
    </span>
  </div>
  <div nz-row [nzGutter]="24">
    <div class="handling-col" nz-col [nzSpan]="12">
      <div class="handling-info p-md">
        <div class="flex" *ngFor="let item of i?.loadingPlace">
          <div *ngIf="item.type === '1'" class="loading-row">
            <div class="handling-info-icon loading-bg">装</div>
            <div class="info">
              <h4>装货地：{{item?.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}</h4>
              <p class="mb0">联系人：{{item.appUserName}}/{{item.contractTelephone}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="handling-col" nz-col [nzSpan]="12">
      <div class="handling-info p-md">
        <div class="flex" *ngFor="let item of i?.dischargePlace">
          <div *ngIf="item.type === '2'" class="loading-row">
            <div class="handling-info-icon unloaing-bg">卸</div>
            <div class="info">
              <h4>卸货地：{{item?.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}</h4>
              <p class="mb0">联系人：{{item.appUserName}}/{{item.contractTelephone}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</nz-card>

<nz-card [nzBorderless]="true" class="mb0" #distannce1>
  <div class="font-weight-blod text-md detail-title">
    <a class="sign"></a>
    <span>基本信息</span>
  </div>
  <sv-container col="3">
    <sv label="货物名称">
      {{i?.goodsInfos?.[0]?.goodsName}}
    </sv>
    <sv label="货物数量">
      {{i?.goodsInfos?.[0]?.weight}}吨,{{i?.goodsInfos?.[0]?.volume}}方,{{i?.goodsInfos?.[0]?.number}}件
    </sv>
    <sv label="用车需求">
      {{i?.goodsInfos?.[0]?.carModelLabel}}{{ i?.goodsInfos?.[0]?.carLength ? '/' + i?.goodsInfos?.[0]?.carLength + '米':
      ''}}
    </sv>
    <sv label="承运司机">
      {{i?.driver?.name}}/{{i?.driver?.phone}}
    </sv>
    <sv label="车型车长载重">
      {{i?.car?.carModelLabel}},{{i?.car?.carLengthLabel}}米,{{i?.car?.carLoad ? i?.car?.carLoad +'吨': ''}}
    </sv>
    <!-- <sv label="计划装货时间">
      {{i?.loadPlanTime}}
    </sv>
    <sv label="计划卸货时间">
      {{i?.unloadPlanTime}}
    </sv> -->
    <sv label="接单数量">
      {{ i?.acceptWeight }}吨,{{ i?.acceptVolume }}方
    </sv>
    <sv *ngIf="i?.wayBillStatus =='3' || i?.wayBillStatus =='4' || i?.wayBillStatus =='5'" label="装货数量">
      {{ i?.loadWeight }}吨，{{ i?.loadVolume }}方
    </sv>
    <sv *ngIf="i?.wayBillStatus =='4' || i?.wayBillStatus =='5'" label="卸货数量">
      {{ i?.settlementWeight }}吨,{{ i?.settlementVolume }}方
    </sv>
  </sv-container>

</nz-card>
<!-- <nz-card  [nzTitle]="'运费信息' +'（到货后'+i?.paymentDays+'天内支付运费）'"  #distannce3>
  <h2>{{i?.freightPrice}}{{i?.goodsInfos?.[0]?.freightTypeLabel}}（{{ i?.goodsInfos?.[0]?.settlementBasisLabel ? i?.goodsInfos?.[0]?.settlementBasisLabel + '，' :' ' }}{{i?.goodsInfos?.[0]?.ruleLabel}}）</h2>
  <st #st [data]="billExpenses" [columns]="logColumns" [ps]="0" [page]="{ show: false, showSize: false }">
    <ng-template st-row="PriceType" let-item let-index="index"> 到付 </ng-template>
    <ng-template st-row="price" let-item let-index="index">
      {{ item.price | currency }}
    </ng-template>
    <ng-template st-row="prices" let-item let-index="index">
      {{ item.price + item.surcharge | currency }}
    </ng-template>
    <ng-template st-row="surcharge" let-item let-index="index">
      {{ item.surcharge | currency }}
    </ng-template>
  </st>
  <div>
    <div>
      总计：<span style="color: #da001b; font-size: 18px">{{ i?.totalAmount | currency }}</span> （运费{{ i?.totalFreight | currency }}，
      附加费{{ i?.totalSurcharge | currency }}，附加费率{{ (i?.totalRate * 100).toFixed(2)}}%）
    </div>
  </div>
  <div *ngIf=" i?.payee?.name !== i?.driver?.name">车队长：{{ i?.payee?.name }}{{ i?.payee?.phone ? "/" +
    i?.payee?.phone : ''}}/{{ i?.payee?.idNo }}</div>
</nz-card> -->
<!--
结算依据为1时，卸货时间不为空，显示运费信息，否则隐藏
结算依据为2时，装货时间不为空，显示运费信息，否则隐藏
 -->
<nz-card #distannce3
  [hidden]="!(i?.settlementBasis ==='1' && i?.unloadTime) && !(i?.settlementBasis ==='2' && i?.loadTime)"
  [nzBorderless]="true" class="mb0">
  <div class="font-weight-blod text-md detail-title">
    <a class="sign"></a>
    <span>运费信息</span>
    <span class="pl-sm text-warning">到货后{{i?.goodsResource?.paymentDays}}天内支付运费</span>
  </div>


  <div style="margin-bottom: 18px">
    <span style="color: #da001b; font-size: 18px"> {{ i?.freightPrice }}{{ i?.freightTypeLabel }} </span>（{{
    i?.settlementBasisLabel }}，{{
    i?.ruleLabel
    }}）
  </div>
  <st size="small" #st [data]="billExpenses" [columns]="logColumns" [ps]="0" [page]="{ show: false, showSize: false }">
    <ng-template st-row="prices" let-item let-index="index">
      {{ item.price + item.surcharge | currency }}
    </ng-template>
    <ng-template st-row="PriceType" let-item let-index="index"> 到付 </ng-template>
    <ng-template st-row="price" let-item let-index="index"> {{item.price | currency}} </ng-template>
    <ng-template st-row="surcharge" let-item let-index="index"> {{item.surcharge | currency}} </ng-template>
  </st>
  <div>
    总计：<span style="color: #da001b; font-size: 18px">{{ i?.totalAmount | currency }}</span> （运费{{ i?.totalFreight |
    currency }}，
    附加费{{ i?.totalSurcharge | currency }}，附加费率{{ i?.totalRate * 100 | number: '0.2-2' }}%）
  </div>
  <div *ngIf=" i?.payeeId !== i?.driverId" class="mt-xs">车队长：{{ i?.payeeName }}/{{ i?.payeePhone }}</div>
</nz-card>
<div nz-row>
  <div nz-col nzSpan="12">
    <nz-card [nzBorderless]="true" class="mb0 attch-card" #distannce4>
      <div class="font-weight-blod text-md detail-title">
        <a class="sign"></a>
        <span>附件信息</span>
      </div>
      <div class="attachment-info">
        <sv-container col="1">
          <sv label="协议附件" col="1">
            <a *ngIf="i?.contractContent?.contractContent" (click)="agreement('1')">查看附件</a> &nbsp;&nbsp;&nbsp;&nbsp;
            <a *ngIf="i?.supplementContent?.contractContent" (click)="agreement('2')">补充协议</a>
          </sv>
        </sv-container>
        <sv-container col="2" layout="vertical" class="mt-md">
          <sv label="装货凭证">
            <app-imagelist *ngIf="i?.loadingCertificate && i?.loadingCertificate.length >0"
              [imgList]="i?.loadingCertificate" [style]="'width:120px;height:120px;'">
            </app-imagelist>
          </sv>
          <sv label="卸货凭证">
            <app-imagelist *ngIf="i?.unLoadingCertificate && i?.unLoadingCertificate.length >0"
              [imgList]="i?.unLoadingCertificate" [style]="'width:120px;height:120px;'">
            </app-imagelist>
          </sv>
        </sv-container>
      </div>
    </nz-card>
  </div>
  <div nz-col nzSpan="12">
    <nz-card [nzBorderless]="true" class="mb0 attch-card">
      <div class="font-weight-blod text-md detail-title">
        <a class="sign"></a>
        <span>补充信息</span>
      </div>
      <div class="attachment-info">
        <sv-container col="1">
          <sv label="是否回单">
            {{i?.receiptType == 1 ?'是':'否'}}
          </sv>
          <sv label="回单类型" *ngIf="i?.receiptType == '1'">
            {{i?.receiptTypeLabel}}
          </sv>

          <sv label="联系人" *ngIf="i?.receiptType == '2'">
            {{i?.receiptUser}} / {{i?.receiptUserPhone}}
          </sv>
          <sv label="所在地区" *ngIf="i?.receiptType == '2'">
            {{i?.receiptPlace}}
          </sv>
          <sv label="详细地址" *ngIf="i?.receiptType == '2'">
            {{i?.receiptAddress}}
          </sv>
          <sv label="备注">
            {{i?.goodsResource?.remarks}}
          </sv>
          <sv col="1" label="回单凭证" *ngIf="i?.receiptType == '1'">
            <app-imagelist [imgList]="[i?.receiptFilePath]" [style]="'width:120px;height:120px;'"></app-imagelist>
          </sv>
        </sv-container>
      </div>
    </nz-card>
  </div>
</div>

<nz-card class="mb0" [nzBorderless]="true">
  <p class="detail_title" #distannce5><span>|</span> 轨迹信息</p>
  <div nz-row>
    <div nz-col [nzSpan]="24">
      <amap-path-simplifier [mapWidth]="'100%'" [mapHeight]="'600px'" [mapList]="mapList">
      </amap-path-simplifier>
      <st [scroll]="{ y: '350px' }" #st [data]="addressItems" [columns]="logColumns2" [ps]="0"
        [page]="{ show: false, showSize: false }" size="small" class="map_st">
      </st>
      <nz-radio-group [(ngModel)]="trajectory" (ngModelChange)="trajectoryChange($event)" class="map_radio">
        <label nz-radio-button nzValue="car">车辆轨迹</label>
        <label nz-radio-button nzValue="driver">司机轨迹</label>
      </nz-radio-group>
    </div>
  </div>
</nz-card>

<nz-modal [(nzVisible)]="isVisible" nzWidth="1000px" [nzFooter]="nzModalFooter" [nzTitle]="modalTitle"
  (nzOnOk)="handleOK()" (nzOnCancel)="handleCancel()">
  <ng-container *nzModalContent>
    <div *ngIf="!modalcontent">暂无附件信息</div>
    <div [innerHTML]="modalcontent"></div>
  </ng-container>
  <ng-template #nzModalFooter>
    <button nz-button nzType="primary" (click)="handleOK()" [disabled]="">取消</button>
    <button nz-button nzType="default" (click)="handleCancel()">确定 </button>
  </ng-template>
</nz-modal>
