<!--
 * @Description  : 
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2021-12-24 16:58:02
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-01-20 20:32:44
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\order-management\\components\\bulk-detail-change\\bulk-detail-change.component.html
 * Copyright (C) 2022 huzhenhong. All rights reserved.
-->

<page-header-wrapper [title]="''" [logo]="logo" [content]="headerContent">
  <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 class="mb-xs" nz-row>
      <button nz-button nzType="primary" nzSize="small" nzDanger>{{i?.billStatusLabel}}</button>
      <h4 class="ml-md" style="font-size: 18px;">订单号: {{ i?.billCode }}</h4>
    </div>
    <div nz-row style="display: flex; justify-content: end;">
      <div nz-col nzSpan="10">
        <button nz-button (click)="cancelChange()">取消修改</button>
        <button nz-button nzType="primary" (click)="save()" nzGhost>保存修改</button>
      </div>
    </div>
    <nz-divider></nz-divider>
   <div>
      <div sv-container>
        <sv label="网络货运人">{{ i?.goodsResource?.enterpriseInfoName }} </sv>
        <sv label="货主">{{ i?.goodsResource?.shipperAppUserName }} </sv>
        <sv label="所属项目">{{i?.goodsResource?.enterpriseProjectName}}</sv>
        <sv label="服务类型">{{i?.goodsResource?.serviceTypeLabel}}</sv>
        <sv label="录单员">{{i?.goodsResource?.createUserName}} /{{i?.goodsResource?.createUserPhone}} </sv>
        <sv label="调度员">{{i?.goodsResource?.dispatchName}}/{{i?.goodsResource?.dispatchPhone}} </sv>
     </div>
     <nz-tabset style="margin-top: 15px;">
      <nz-tab nzTitle="装卸货信息" (nzClick)="goDistance(distannce1)">
      </nz-tab>
      <nz-tab nzTitle="基本信息" (nzClick)="goDistance(distannce2)">
      </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 nzTitle="运单进度"  #distannce1>
  <div class="approval-status">
    <div style="width: 60%; margin: 0 auto">
        <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>
  <div class="card-title"
    >装卸货信息<span class="tip-font">预计公里数：{{ totalDistance }}km，预计行程耗时：{{ totalTime }}小时</span></div
  >

  <form nz-form [formGroup]="validateForm1" role="form">
    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="10">
        <div *ngFor="let data1 of startInfo; let idx = index">
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>装货地</nz-form-label>
            <nz-form-control [nzErrorTip]="'请输入装货地'">
              <div class="align-center">
                <nz-input-group [nzSuffix]="endInconTemp1">
                  <input
                    nz-input
                    [(ngModel)]="data1.detailedAddress"
                    (click)="openMap('start', idx)"
                    formControlName="loadAddress{{ idx }}"
                    placeholder="请输入装货地"
                  />
                </nz-input-group>
              </div>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
            <div style="display: flex;">
              <nz-form-control [nzErrorTip]="'请输入联系人姓名'">
                <input
                  nz-input
                  [(ngModel)]="data1.appUserName"
                  formControlName="loadName{{ idx }}"
                  name="loadName{{ idx }}"
                  maxlength="30"
                  placeholder="请输入联系人姓名"
                />
              </nz-form-control>
              <nz-form-control [nzErrorTip]="'请输入联系人电话'">
                <input
                  style="margin-left: 12px"
                  nz-input
                  [(ngModel)]="data1.contractTelephone"
                  maxlength="11"
                  formControlName="loadPhone{{ idx }}"
                  name="loadPhone{{ idx }}"
                  placeholder="请输入联系人电话"
                />
              </nz-form-control>
            </div>
          </nz-form-item>
        </div>
      </div>
      <div nz-col [nzSpan]="4">
        <div style="display: flex; justify-content: center">
          <span style="padding: 24 px; font-size: 30px; color: #7d7d7d"><i nz-icon nzType="swap" nzTheme="outline"></i></span>
        </div>
      </div>
      <div nz-col [nzSpan]="10">
        <div *ngFor="let data2 of endInfo; let idx = index">
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>卸货地</nz-form-label>
            <nz-form-control [nzErrorTip]="'请输入卸货地'">
              <div class="align-center">
                <nz-input-group [nzSuffix]="endInconTemp1">
                  <input
                    nz-input
                    [(ngModel)]="data2.detailedAddress"
                    (click)="openMap('end', idx)"
                    formControlName="unloadAddress{{ idx }}"
                    placeholder="请输入卸货地"
                    name="unloadAddress{{ idx }}"
                  />
                </nz-input-group>
              </div>
            </nz-form-control>
          </nz-form-item>
          <nz-form-item>
            <nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
            <div style="display: flex;">
              <nz-form-control [nzErrorTip]="'请输入联系人姓名'">
                <input
                  nz-input
                  [(ngModel)]="data2.appUserName"
                  maxlength="30"
                  formControlName="unloadName{{ idx }}"
                  name="unloadAddress{{ idx }}"
                  placeholder="请输入联系人姓名"
                />
              </nz-form-control>
              <nz-form-control [nzErrorTip]="'请输入联系人电话'">
                <input
                  style="margin-left: 12px"
                  nz-input
                  [(ngModel)]="data2.contractTelephone"
                  formControlName="unloadPhone{{ idx }}"
                  name="unloadAddress{{ idx }}"
                  maxlength="11"
                  placeholder="请输入联系人电话"
                />
              </nz-form-control>
            </div>
          </nz-form-item>
        </div>
      </div>
    </div>
    <div nz-row [nzGutter]="24" style="margin-top: 24px">
      <div nz-col [nzSpan]="10">
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>装货时间</nz-form-label>
          <nz-form-control [nzErrorTip]="'请输入装货时间'">
            <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="loadingTime" name="loadingTime"></nz-date-picker>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="4"></div>
      <div nz-col [nzSpan]="10">
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>卸货时间</nz-form-label>
          <nz-form-control [nzErrorTip]="'请输入卸货时间'">
            <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="unloadingTime" name="unloadingTime"></nz-date-picker>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>
    <ng-template #endInconTemp1><i nz-icon nzType="environment" nzTheme="outline"></i></ng-template>
  </form>
</nz-card>
<nz-card nzTitle="基本信息" #distannce2>
  <div nz-row>
    <div nz-col nzSpan="12">
      <sf #sf3 [schema]="schema3" [formData]="sf3data" [button]="'none'" [ui]="ui3"></sf>
      <sf #sf4 [schema]="schema4" [formData]="sf4data" [button]="'none'" [ui]="ui4">
        <ng-template sf-template="weight" let-item let-ui="ui">
          <nz-input-group [nzAddOnAfter]="'吨'">
            <input
              nz-input
              type="number"
              [ngModel]="item.value"
              min="0"
              [max]="999999"
              step="0.01"
              (ngModelChange)="item.setValue($event)"
              placeholder="总重量，必填"
            />
          </nz-input-group>
        </ng-template>
        <ng-template sf-template="volume" let-item let-ui="ui">
          <nz-input-group [nzAddOnAfter]="'方'">
            <input
              nz-input
              type="number"
              [ngModel]="item.value"
              min="0"
              [max]="999999"
              step="0.01"
              (ngModelChange)="item.setValue($event)"
              placeholder="总体积"
            />
          </nz-input-group>
        </ng-template>
 
        <ng-template sf-template="number" let-item let-ui="ui">
          <nz-input-group [nzAddOnAfter]="'车'">
            <input
              nz-input
              type="number"
              [ngModel]="item.value"
              min="0"
              [max]="999999"
              step="0.01"
              (ngModelChange)="item.setValue($event)"
              placeholder="总车次"
            />
          </nz-input-group>
        </ng-template>

        <ng-template sf-template="carmand" let-item let-ui="ui">
          {{ i?.carModel }}/{{ i?.carLength }}
        </ng-template>
        <ng-template sf-template="drivers" let-item let-ui="ui">
          {{i?.driverName}}/{{i?.driverPhone}}/{{i?.carNo}}
        </ng-template>
        <ng-template sf-template="weightModel" let-item let-ui="ui">
          {{ i?.driverCarModelLabel }},{{ i?.driverCarLengthLabel }}米,{{ i?.driverCarWeight }}吨 
        </ng-template>

      <ng-template sf-template="loadTime" let-item let-ui="ui">
               <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss"  [(ngModel)]="loadTime"></nz-date-picker>
        </ng-template>
      <ng-template sf-template="unloadTime" let-item let-ui="ui">
        <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss"  [(ngModel)]="unloadTime"></nz-date-picker>
        </ng-template>

      </sf>
    </div>
  </div>

</nz-card>

<nz-card nzTitle="运费信息" #distannce3>
  <h2>{{i?.goodsInfoList?.[0]?.freightPrice}}{{i?.goodsInfoList?.[0]?.freightTypeLabel}}（以发货为准，保留小数）</h2>
  <st #st [data]="i?.billExpenseDetails" [columns]="logColumns" [ps]="0" [page]="{ show: false, showSize: false }">

  </st>
  <div>
    <div>
      总计：<span style="color: #da001b; font-size: 18px">{{ totalObj?.price  | currency }}</span> （运费￥{{
        totalObj?.price - attObj?.price  | currency}}，附加费￥{{ attObj?.price  | currency }}，附加费率{{i?.attPercent }}%）
    </div>
  </div>
  <div>收款人：{{ i?.payeeName }}/{{ i?.payeePhone }}</div>
</nz-card>


<nz-card nzTitle="附件信息" #distannce4>
  <sv-container>
    <sv label="协议附件">
      <!-- {{i?.supplementaryInformationVO?.stateReceipt?'是':'否'}} -->
      <a href="javascript:;" (click)="agreement('1')">查看附件</a>&nbsp;&nbsp;&nbsp;&nbsp;
      <a href="javascript:;" (click)="agreement('2')">补充协议</a>
    </sv>
  </sv-container>
  <sv-container col="2" class="mt-md">
    <sf #sf mode="edit" [schema]="schema" [ui]="ui" [formData]="formData" button="none"></sf>
  </sv-container>
</nz-card>
<nz-card nzTitle="补充信息">
  <sv-container>
    <sv label="是否回单">
      {{ i?.supplementaryInformationVO?.stateReceipt ? '是' : '否' }}
    </sv>
    <sv label="回单类型">
      {{ i?.supplementaryInformationVO?.receiptType === '1' ? '电子回单' : '纸质回单' }}
    </sv>
    <sv label="联系人"> {{ i?.supplementaryInformationVO?.receiptUserName }} / {{ i?.supplementaryInformationVO?.phon }} </sv>
    <sv label="所在地区">
      {{ i?.supplementaryInformationVO?.area }}
    </sv>
    <sv label="详细地址">
      {{ i?.supplementaryInformationVO?.address }}
    </sv>
  
  </sv-container>
  <sv-container col="1" class="mt-md">
    <sv label="回单凭证">
      <nz-upload
      class="avatar-uploader"
      [nzAction]="service.$api_upload_url"
      [nzName]="'multipartFile'"
      nzListType="picture-card"
      [(nzFileList)]="listImagUrls"
      [nzShowButton]="listImagUrls.length < 5"
      [nzPreview]="handlePreview1"
      [nzBeforeUpload]="beforeUpload"
      (nzChange)="handleChange1($event)"
    >
      <div>
        <i nz-icon nzType="plus"></i>
        <div style="margin-top: 8px">请上传图片</div>
      </div>
    </nz-upload>
    <nz-modal [nzVisible]="previewVisible1" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible1 = false">
      <ng-template #modalContent>
        <img [src]="previewImage1" [ngStyle]="{ width: '100%' }" />
      </ng-template>
    </nz-modal>
    </sv>
    <sv label="备注">
      {{i?.goodsResource?.remarks}}
    </sv>
  </sv-container>
</nz-card>

<nz-card>
  <div nz-row>
    <nz-card nzTitle="轨迹信息" style="width: 100%;" #distannce5>
      <div nz-row > 
        <div nz-col [nzSpan]='12'>
    <!-- <st #st [data]="i?.auditRecordList" [columns]="logColumns" [ps]="0" [page]="{ show: false, showSize: false }">
    </st> -->
  </div>
  <div nz-col [nzSpan]='12'>
     <amap-path-simplifier></amap-path-simplifier>
   </div>
   </div>
    </nz-card>
  </div>
</nz-card>
<nz-modal [(nzVisible)]="isVisible"   [nzFooter]="nzModalFooter" nzTitle="附件信息" (nzOnOk)="handleOK()" (nzOnCancel)="handleCancel()">
  <ng-container *nzModalContent>
    <app-imagelist [imgList]="imges"></app-imagelist>
  </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>