//钢材统计报表
<template>
  <div class="purchasFuelNewMonitor">
    <div class="tableTop">
      <el-form :inline="true">
        <el-form-item>
          <el-select
            v-model="screen"
            placeholder="请选择需筛选的内容"
            clearable
            @change="changeScreen"
            style="width:100px"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-input
            style="width:170px"
            v-model="input"
            placeholder="请输入查询条件"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="screen1"
            placeholder="请选择需筛选的内容"
            clearable
            style="width:100px"
          >
            <el-option
              v-for="item in options1"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-input
            style="width:170px"
            v-model="input1"
            placeholder="请输入查询条件"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="screen2"
            placeholder="请选择需筛选的内容"
            clearable
            style="width:120px"
          >
            <el-option
              v-for="item in options2"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-date-picker
            v-show="screen2 == '制单日期'"
            v-model="startTime"
            type="datetime"
            placeholder="选择日期"
            style="width:150px"
          >
          </el-date-picker>
          <el-date-picker
            v-show="screen2 == '订单日期'"
            v-model="startTime"
            type="date"
            placeholder="选择日期"
            style="width:150px"
          >
          </el-date-picker>
          <span>至</span>
          <el-date-picker
            v-show="screen2 == '制单日期'"
            v-model="endTime"
            type="datetime"
            placeholder="选择日期"
            style="width:150px"
          >
          </el-date-picker>
          <el-date-picker
            v-show="screen2 == '订单日期'"
            v-model="endTime"
            type="date"
            placeholder="选择日期"
            style="width:150px"
          >
          </el-date-picker>
          <el-button type="primary" class="btn" @click="onclick">
            <i class="el-icon-search"></i>
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="exportAllReportToExcel()"
            >下载Excel</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="refresh">
            <i class="el-icon-refresh"></i>
          </el-button>
        </el-form-item>
        <el-form-item v-if="isShowOperate">
          <el-button type="primary" @click="checkTrans()"
            ><i class="el-icon-truck"></i>轨迹</el-button
          >
          <!-- <el-button type="primary" @click="operation()"
            ><i class="el-icon-edit"></i>更改</el-button
          > -->
          <el-button type="primary" @click="updateDetailsOrderPrice">
            <i class="el-icon-edit"></i>修改计费详单
          </el-button>
          <!-- <el-button type="primary" @click="batchoperation()"
            ><i class="el-icon-edit"></i>批量更改</el-button
          > -->
          <!-- <el-button
            type="primary"
            @click="checkPoint()"
            v-if="!notRoutList.includes('checkPoint')"
            ><i class="el-icon-map-location"></i>实时路径</el-button
          > -->
        </el-form-item>
        <el-form-item v-show="activeName == 'first'">
          <el-button
            type="primary"
            @click="makeSurePrice"
            v-if="!notRoutList.includes('capacityNo')"
            ><i class="el-icon-circle-check"></i>确认执行价</el-button
          >
        </el-form-item>
        <el-form-item v-show="activeName == 'second'">
          <el-button
            type="primary"
            @click="cancelMakeSure"
            v-if="!notRoutList.includes('capacityNo')"
            ><i class="el-icon-circle-check"></i>取消确认</el-button
          >
        </el-form-item>
        <el-form-item v-show="activeName == 'second'">
          <el-button type="primary" @click="openStatement">
            <i class="el-icon-circle-check"></i>生成账单
          </el-button>
        </el-form-item>
        <el-form-item v-show="activeName == 'first'">
          <el-button
            type="primary"
            @click="openDetails"
            v-if="!notRoutList.includes('uploadDetails')"
          >
            <i class="el-icon-circle-check"></i>直接修改单价
          </el-button>
        </el-form-item>
        <el-form-item v-show="activeName == 'first'">
          <el-button
            type="primary"
            @click="openDetailsAdd"
            v-if="!notRoutList.includes('uploadDetails')"
          >
            <i class="el-icon-circle-check"></i>冲红
          </el-button>
        </el-form-item>
        <el-form-item v-show="activeName == 'first'">
          <el-button
            type="primary"
            @click="openConsigneeUpd"
            v-if="!notRoutList.includes('uploadDetails')"
          >
            <i class="el-icon-circle-check"></i>改客户
          </el-button>
        </el-form-item>
        <!-- <el-form-item v-if="isShowOperate">
          <el-button type="primary" @click="openReceive()">
            <i class="el-icon-document"></i>签收抵达</el-button
          >
        </el-form-item> -->
        <el-form-item v-show="activeName == 'first'">
          <label
            class="el-form-item__label"
            style="width: auto;font-size: 16px;line-height: auto;"
            >车数/磅重/金额 {{ totalCapacity }}车/{{ totalNetWeight }}吨/{{
              totalDetailsAmount
            }}元
          </label>
        </el-form-item>
        <el-form-item v-show="activeName == 'second'">
          <label
            class="el-form-item__label"
            style="width: auto;font-size: 16px;line-height: auto;"
            >车数/磅重/金额 {{ setteldTotalCapacity }}车/{{
              totalNetWeightSettled
            }}吨/{{ totalDetailsAmountSettled }}元
          </label>
        </el-form-item>
      </el-form>
    </div>
    <div class="table11">
      <el-tabs v-model="activeName" style="margin-left: 20px;">
        <el-tab-pane label="未结算" name="first">
          <div class="table" id="unSettledReports">
            <el-table
              :data="visibleList"
              :span-method="objectSpanMethod"
              ref="tableRef"
              class="untable"
              border
              style="width: 100%"
              :height="maxHeight"
              :row-class-name="tableRowClassName"
              @cell-mouse-enter="cellMouse1"
              @cell-mouse-leave="cellLeave1"
              @row-click="rowClick"
              @filter-change="filterChange"
              @select="selectOne"
              @selection-change="handleSelectionChange()"
              @select-all="unSetteleAllselect"
            >
              <el-table-column type="selection" width="30" label="选择">
              </el-table-column>
              <el-table-column
                width="40"
                label="序号"
                align="center"
                :resizable="false"
              >
                <template slot-scope="scope">{{
                  scope.row.group + 1
                }}</template>
              </el-table-column>
              <el-table-column
                prop="orderTime"
                column-key="orderTime"
                key="orderTime"
                label="订单日期"
                width="110px"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="saleMakeDate"
                column-key="saleMakeDate"
                key="saleMakeDate"
                label="制单日期"
                width="130px"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="newCapacityNo"
                column-key="newCapacityNo"
                key="newCapacityNo"
                label="车号"
                align="center"
                width="90px"
                show-overflow-tooltip
                :filters="filterCapacityList"
              >
              </el-table-column>
              <el-table-column
                prop="consigneeName"
                label="客户"
                width="160px"
                align="center"
                column-key="consigneeName"
                key="consigneeName"
                :filters="filterConsigneeList"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="materialName"
                column-key="materialNameList"
                key="materialNameList"
                label="物料名称"
                align="center"
                width="150px"
                :filters="filtermaterialNameList"
              >
              </el-table-column>
              <el-table-column
                prop="materialSpe"
                label="规格型号"
                column-key="materialSpe"
                key="materialSpe"
                align="center"
                :filters="filtermaterialSpe"
                width="120px"
              >
              </el-table-column>
              <el-table-column
                prop="materialPlanNumber"
                column-key="materialPlanNumber"
                key="materialPlanNumber"
                label="辅助数量"
                align="center"
                width="100px"
              >
              </el-table-column>
              <el-table-column
                prop="materialAcWeight"
                column-key="materialAcWeight"
                key="materialAcWeight"
                label="累计出库数量"
                align="center"
                width="100px"
              >
              </el-table-column>
              <el-table-column
                prop="materialNum"
                column-key="materialNum"
                key="materialNum"
                label="累计检斤通知单辅助数量"
                align="center"
                width="150px"
              >
              </el-table-column>
              <el-table-column
                prop="netWeight"
                label="磅重"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="saleRemark"
                column-key="saleRemark"
                key="saleRemark"
                label="摘要"
                width="150px"
                align="center"
                :filters="filterSaleRemark"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="carrierName"
                label="承运商"
                align="center"
                width="80px"
                column-key="carrierList"
                key="carrierList"
                show-overflow-tooltip
                :filters="filterCarrierList"
              >
              </el-table-column>
              <el-table-column
                prop="outBoundWarehouse"
                label="出库库房"
                align="center"
                width="80px"
                column-key="outBoundWarehouse"
                key="outBoundWarehouse"
                show-overflow-tooltip
                :filters="filterOutBoundWarehouse"
              >
              </el-table-column>
              <el-table-column
                prop="addressPlace"
                label="下货地点"
                width="300px"
                column-key="actualAddress"
                key="actualAddress"
              >
              </el-table-column>
              <el-table-column
                prop="priceValue"
                label="单价"
                width="100px"
                column-key="priceValue"
                key="priceValue"
              >
              </el-table-column>
              <el-table-column
                prop="detailsAmount"
                column-key="detailsAmount"
                key="detailsAmount"
                label="运费"
                width="100px"
              ></el-table-column>
              <el-table-column
                prop="closeEntryId"
                column-key="closeEntryId"
                key="closeEntryId"
                label="分录ID"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="actualCity"
                column-key="actualCity"
                key="actualCity"
                label="卸货城市"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="areaName"
                label="分区"
                width="150px"
                align="center"
                column-key="saleAreaList"
                key="saleAreaList"
                :filters="filterSaleAreaList"
              >
              </el-table-column>
              <el-table-column
                prop="unloadType"
                label="卸货类型"
                width="60px"
                column-key="unloadType"
                key="unloadType"
              >
              </el-table-column>
              <el-table-column
                prop="saleOrderReceiveCustomer"
                column-key="saleOrderReceiveCustomer"
                key="saleOrderReceiveCustomer"
                label="收款客户"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <!-- <el-table-column
                prop="addressPlace"
                label="收货地址"
                width="250px"
                sortable
                column-key="addressPlace"
                :filters="filteraddressPlace"
              >
              </el-table-column> -->
              <el-table-column
                prop="materialWeight"
                column-key="materialWeight"
                key="materialWeight"
                label="理重"
                show-overflow-tooltip
              >
              </el-table-column>

              <el-table-column
                prop="paymentCustomer"
                column-key="paymentCustomer"
                key="paymentCustomer"
                label="付款单位"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="consingneeSettlementMethod"
                column-key="consingneeSettlementMethod"
                key="consingneeSettlementMethod"
                label="结算方式"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>

              <el-table-column
                prop="recordUserName"
                column-key="recordUserName"
                key="recordUserName"
                label="操作人"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="detailsRemark"
                column-key="detailsRemark"
                key="detailsRemark"
                label="直接修改备注"
                width="120px"
                show-overflow-tooltip
              >
                <template slot-scope="scope">
                  <el-button
                    @click="showPhoto(scope.row)"
                    type="text"
                    size="small"
                  >
                    {{ scope.row.detailsRemark }}
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane label="已确认" name="second">
          <div class="table1">
            <el-table
              :data="visibleList1"
              :span-method="objectSpanMethod1"
              class="tabled"
              ref="tableRef1"
              border
              style="width: 100%"
              :height="maxHeight"
              @filter-change="filterChange"
              @select-all="setteldAllselect"
            >
              <el-table-column
                type="selection"
                key="selection"
                column-key="selection"
                align="center"
                width="30"
                label="选择"
              ></el-table-column>
              <el-table-column
                width="50"
                label="序号"
                type="index"
                key="index"
                column-key="index"
                align="center"
                :resizable="false"
              >
                <template slot-scope="scope">{{
                  scope.row.group + 1
                }}</template>
              </el-table-column>
              <el-table-column
                prop="orderTime"
                column-key="orderTime"
                key="orderTime"
                label="订单日期"
                width="110px"
                align="center"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="saleMakeDate"
                column-key="saleMakeDate"
                key="saleMakeDate"
                label="制单日期"
                width="130px"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="newCapacityNo"
                column-key="newCapacityNo"
                key="newCapacityNo"
                label="车号"
                align="center"
                width="90px"
                :filters="filterCapacityList"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="consigneeName"
                label="客户"
                width="160px"
                align="center"
                column-key="consigneeName"
                key="consigneeName"
                :filters="filterConsigneeList"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="materialName"
                column-key="materialNameList"
                key="materialNameList"
                label="物料名称"
                align="center"
                width="150px"
                :filters="filtermaterialNameList"
              >
              </el-table-column>
              <el-table-column
                prop="materialSpe"
                label="规格型号"
                column-key="materialSpe"
                key="materialSpe"
                align="center"
                :filters="filtermaterialSpe"
                width="120px"
              >
              </el-table-column>
              <el-table-column
                prop="materialPlanNumber"
                column-key="materialPlanNumber"
                key="materialPlanNumber"
                label="辅助数量"
                align="center"
                width="100px"
              >
              </el-table-column>
              <el-table-column
                prop="materialAcWeight"
                column-key="materialAcWeight"
                key="materialAcWeight"
                label="累计出库数量"
                align="center"
                width="100px"
              >
              </el-table-column>
              <el-table-column
                prop="materialNum"
                column-key="materialNum"
                key="materialNum"
                label="累计检斤通知单辅助数量"
                align="center"
                width="150px"
              >
              </el-table-column>
              <el-table-column
                prop="netWeight"
                column-key="netWeight"
                key="netWeight"
                label="磅重"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="saleRemark"
                column-key="saleRemark"
                key="saleRemark"
                label="摘要"
                width="150px"
                align="center"
                :filters="filterSaleRemark"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="carrierName"
                label="承运商"
                align="center"
                width="80px"
                column-key="carrierList"
                key="carrierList"
                show-overflow-tooltip
                :filters="filterCarrierList"
              >
              </el-table-column>
              <el-table-column
                prop="outBoundWarehouse"
                label="出库库房"
                align="center"
                width="80px"
                column-key="outBoundWarehouse"
                key="outBoundWarehouse"
                show-overflow-tooltip
                :filters="filterOutBoundWarehouse"
              >
              </el-table-column>
              <el-table-column
                prop="addressPlace"
                label="下货地点"
                width="300px"
                column-key="actualAddress"
                key="actualAddress"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="priceValue"
                label="单价"
                width="100px"
                column-key="priceValue"
                key="priceValue"
              >
              </el-table-column>
              <el-table-column
                prop="detailsAmount"
                column-key="detailsAmount"
                key="detailsAmount"
                label="运费"
                width="100px"
              ></el-table-column>
              <el-table-column
                prop="closeEntryId"
                column-key="closeEntryId"
                key="closeEntryId"
                label="分录ID"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="actualCity"
                column-key="actualCity"
                key="actualCity"
                label="卸货城市"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="areaName"
                label="分区"
                width="150px"
                align="center"
                column-key="saleAreaList"
                key="saleAreaList"
                :filters="filterSaleAreaList"
              >
              </el-table-column>
              <el-table-column
                prop="unloadType"
                label="卸货类型"
                width="60px"
                column-key="unloadType"
                key="unloadType"
              >
              </el-table-column>
              <el-table-column
                prop="saleOrderReceiveCustomer"
                column-key="saleOrderReceiveCustomer"
                key="saleOrderReceiveCustomer"
                label="收款客户"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <!-- <el-table-column
                prop="addressPlace"
                label="收货地址"
                width="250px"
                sortable
                column-key="addressPlace"
                :filters="filteraddressPlace"
              >
              </el-table-column> -->

              <el-table-column
                prop="materialWeight"
                column-key="materialWeight"
                key="materialWeight"
                label="理重"
                show-overflow-tooltip
              >
              </el-table-column>

              <el-table-column
                prop="paymentCustomer"
                column-key="paymentCustomer"
                key="paymentCustomer"
                label="付款单位"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="consingneeSettlementMethod"
                column-key="consingneeSettlementMethod"
                key="consingneeSettlementMethod"
                label="结算方式"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>

              <el-table-column
                prop="recordUserName"
                label="操作人"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                prop="detailsRemark"
                label="直接修改备注"
                width="120px"
                show-overflow-tooltip
                column-key="detailsRemark"
                key="detailsRemark"
              >
                <template slot-scope="scope">
                  <el-button
                    @click="showPhoto(scope.row)"
                    type="text"
                    size="small"
                  >
                    {{ scope.row.detailsRemark }}
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                prop="statementRemark"
                label="账单备注"
                width="120px"
                show-overflow-tooltip
              >
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div>
      <vxe-modal
        width="80%"
        height="80%"
        v-model="isShow3"
        show-footer
        show-zoom
        class="vxeModal"
      >
        <div class="demo-image__preview" v-for="(item, i) in srcList" :key="i">
          <span>{{ item.title }}</span>
          <el-image
            :src="item.src"
            fit="fill"
            @click.prevent.right="receiveClick(item.src, '抵达')"
          >
            <div slot="error" class="image-slot">
              <span>司机未上传图片</span>
            </div>
          </el-image>
        </div>
      </vxe-modal>
      <vxe-modal width="80%" height="80%" v-model="isShow4" show-zoom>
        <div class="demo-image__preview" v-for="(item, i) in srcList2" :key="i">
          <el-image
            :src="item.src"
            fit="fill"
            @click.prevent.right="receiveClick(item.src, '签收')"
          >
            <div slot="error" class="image-slot">
              <span>司机未上传图片</span>
            </div>
          </el-image>
        </div>
      </vxe-modal>
    </div>
    <div style="height: 100%">
      <vxe-modal
        width="1237"
        height="731"
        v-model="value7"
        show-zoom
        resize
        title="轨迹查询"
      >
        <template #default>
          <PathView v-bind.sync="pathOption"></PathView>
        </template>
      </vxe-modal>
    </div>
    <div style="height:100%">
      <vxe-modal
        width="1237"
        height="731"
        v-model="value8"
        show-zoom
        resize
        title="实时路径"
        ><currentLocation :carNumber="carNumber"></currentLocation
      ></vxe-modal>
    </div>
    <el-drawer
      title="修改详单地址"
      :visible.sync="dialogFormVisible"
      size="50%"
    >
      原详单地址
      <el-input
        style="width:250px;height: 30px"
        v-model="originalAddress"
        disabled
      ></el-input>
      <label>原单价</label>
      <el-input
        style="width:100px;height: 30px"
        v-model="originalPriceValue"
        disabled
      ></el-input>
      <el-input
        v-model="addresText"
        placeholder="请输入内容"
        style="margin-top: 10px; margin-left: 20px; width: 250px"
        @keyup.native.enter="selectAddresClick"
      ></el-input>
      <el-button type="primary" @click="selectAddresClick"
        ><i class="el-icon-search"></i>查询</el-button
      >
      <div>
        <!-- 查询所有的运输单价 -->
        <!-- <dilTable
          v-bind.sync="Address"
          @radio-change="currentRadioChange2"
          :drawer="aaadrawer"
          style="overflow-y:scroll"
        ></dilTable> -->
        <div>
          <!-- 查询所有的运输单价 -->
          <el-table
            :data="priceList"
            style="width:100%"
            max-height="400px"
            @row-click="currentRadioChange2"
            :border="true"
            ref="carrierNameTable"
          >
            <el-table-column label="选择项" width="55">
              <template slot-scope="scope">
                <el-radio v-model="tableRadio" :label="scope.row"
                  >&nbsp;</el-radio
                >
              </template>
            </el-table-column>
            <el-table-column type="index" label="序号"> </el-table-column>
            <el-table-column prop="addressProvince" label="省份" align="center">
            </el-table-column>
            <el-table-column
              prop="addressDistrict"
              label="市\区"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="addressTown" label="县镇" align="center">
            </el-table-column>
            <el-table-column
              prop="addressDeliveryAddress"
              label="卸货地点"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="priceValue" label="运价" align="center">
            </el-table-column>
            <el-table-column
              prop="haulDistance"
              label="参考运距（公里）"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="priceTonKilometer"
              label="吨公里（元/吨.km）"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="priceDate" label="执行日期" align="center">
            </el-table-column>
            <el-table-column prop="carrierName" label="承运商" align="center">
            </el-table-column>
          </el-table>
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            layout="total,prev,pager,next,sizes"
            :total="carrierNametotal"
            :page-sizes="[5, 10, 20, 50, 100]"
            :page-size="currentPageSize"
          >
          </el-pagination>
        </div>
      </div>
      <div class="opreation">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="makeSureAll"
          >修改下货地址和单价</el-button
        >
        <el-button type="primary" @click="makeSure">只修改单价</el-button>
      </div>
    </el-drawer>
    <el-dialog
      title="上传账单"
      :visible.sync="showStatementUpLoad"
      :before-close="closeUpload"
    >
      <el-form style="margin-left:20%">
        <el-form-item label="选中详单合计金额">
          <el-input
            v-model="selecteddetailsOrderAmount"
            style="width:200px"
            type="number"
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="发票金额">
          <el-input
            v-model="excludeTax"
            style="width:200px"
            type="number"
          ></el-input>
        </el-form-item>
        <el-form-item label="发票账期">
          <el-date-picker
            v-model="statementTime"
            type="date"
            placeholder="选择账单起始日期"
            style="width:200px"
          >
          </el-date-picker>
          <el-date-picker
            v-model="statementEndTime"
            type="date"
            placeholder="选择账单结束日期"
            style="width:200px"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="发票图片" style="">
          <el-upload
            ref="statementUpload"
            list-type="picture-card"
            action="noAction"
            :limit="10"
            :on-change="fileChange1"
            :on-preview="handlePictureCardPreview"
            :on-exceed="exceed"
            accept=".jpg,.jpeg,.png,.JPG,.JPEG"
            :auto-upload="false"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-form-item>
      </el-form>
      <el-button
        type="primary"
        @click="generateStatement"
        :loading="isLoading"
        style="margin-left:40%"
        >确定</el-button
      >
    </el-dialog>
    <el-dialog
      title="修改详单金额"
      :visible.sync="showDetailsUpLoad"
      :before-close="closeUpload2"
    >
      <el-form style="margin-left:20%">
        <el-form-item label="修改单价">
          <el-input
            v-model="detailAmount"
            style="width:200px"
            type="number"
          ></el-input>
        </el-form-item>
        <el-form-item label="修改备注">
          <el-input v-model="detailRemark" style="width:200px"></el-input>
        </el-form-item>
        <el-form-item label="凭证图片" style="">
          <el-upload
            ref="detailsUpload"
            action="noAction"
            list-type="picture-card"
            :limit="10"
            :on-change="fileChange2"
            :on-preview="handlePictureCardPreview"
            :on-exceed="exceed"
            accept=".jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP"
            :auto-upload="false"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-form-item>
      </el-form>
      <el-button
        type="primary"
        @click="updateTruckDetail"
        :loading="isLoading"
        style="margin-left:40%"
        >确定</el-button
      >
    </el-dialog>
    <el-dialog title="冲红" :visible.sync="showDetailsAdd">
      <el-form style="margin-left:20%">
        <el-form-item label="冲红金额">
          <el-input
            v-model="detailAmount"
            style="width:200px"
            type="number"
          ></el-input>
        </el-form-item>
        <el-form-item label="冲红备注">
          <el-input v-model="detailRemark" style="width:200px"></el-input>
        </el-form-item>
        <el-form-item label="凭证图片" style="">
          <el-upload
            ref="detailsUpload"
            action="noAction"
            list-type="picture-card"
            :limit="10"
            :on-change="fileChange2"
            :on-preview="handlePictureCardPreview"
            :on-exceed="exceed"
            accept=".jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP"
            :auto-upload="false"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-form-item>
      </el-form>
      <el-button
        type="primary"
        @click="addTruckDetail"
        :loading="isLoading"
        style="margin-left:40%"
        >确定</el-button
      >
    </el-dialog>
    <el-dialog title="改收货客户" :visible.sync="showConsigneeUpd">
      <el-table
        :data="consigneeUpdList"
        ref="consigneeUpdTableRef"
        class="untable"
        border
        style="width: 100%"
        height="200px"
        individual-panel
        highlight-current-row
        @current-change="consigneeUpdSelect"
      >
        <el-table-column
          width="40"
          label="序号"
          align="center"
          :resizable="false"
        >
          <template slot-scope="scope">{{ scope.row.group + 1 }}</template>
        </el-table-column>
        <el-table-column
          prop="orderTime"
          label="订单日期"
          width="110px"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="saleMakeDate"
          label="制单日期"
          width="130px"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="newCapacityNo"
          column-key="newCapacityNo"
          label="车号"
          align="center"
          width="90px"
          show-overflow-tooltip
          :filters="filterCapacityList"
        >
        </el-table-column>
        <el-table-column
          prop="consigneeName"
          label="客户"
          width="160px"
          align="center"
          column-key="consigneeName"
          :filters="filterConsigneeList"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="materialName"
          column-key="materialNameList"
          label="物料名称"
          align="center"
          width="150px"
          :filters="filtermaterialNameList"
        >
        </el-table-column>
        <el-table-column
          prop="materialSpe"
          label="规格型号"
          column-key="materialSpe"
          align="center"
          :filters="filtermaterialSpe"
          width="120px"
        >
        </el-table-column>
        <el-table-column
          prop="materialPlanNumber"
          label="辅助数量"
          align="center"
          width="100px"
        >
        </el-table-column>
        <el-table-column
          prop="materialAcWeight"
          label="累计出库数量"
          align="center"
          width="100px"
        >
        </el-table-column>
        <el-table-column
          prop="materialNum"
          label="累计检斤通知单辅助数量"
          align="center"
          width="150px"
        >
        </el-table-column>
        <el-table-column prop="netWeight" label="磅重" show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="saleRemark"
          column-key="saleRemark"
          label="摘要"
          width="150px"
          align="center"
          :filters="filterSaleRemark"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="carrierName"
          label="承运商"
          align="center"
          width="80px"
          column-key="carrierList"
          show-overflow-tooltip
          :filters="filterCarrierList"
        >
        </el-table-column>
        <el-table-column
          prop="addressPlace"
          label="下货地点"
          width="300px"
          column-key="actualAddress"
        >
        </el-table-column>
        <el-table-column prop="priceValue" label="单价" width="100px">
        </el-table-column>
        <el-table-column
          prop="detailsAmount"
          label="运费"
          width="100px"
        ></el-table-column>
        <el-table-column
          prop="closeEntryId"
          label="分录ID"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="actualCity"
          label="卸货城市"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="areaName"
          label="分区"
          width="150px"
          align="center"
          column-key="saleAreaList"
          :filters="filterSaleAreaList"
        >
        </el-table-column>
        <el-table-column prop="unloadType" label="卸货类型" width="60px">
        </el-table-column>
        <el-table-column
          prop="saleOrderReceiveCustomer"
          label="收款客户"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>
        <!-- <el-table-column
          prop="addressPlace"
          label="收货地址"
          width="250px"
          sortable
          column-key="addressPlace"
          :filters="filteraddressPlace"
        >
        </el-table-column> -->
        <el-table-column
          prop="materialWeight"
          label="理重"
          show-overflow-tooltip
        >
        </el-table-column>

        <el-table-column
          prop="paymentCustomer"
          label="付款单位"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="consingneeSettlementMethod"
          label="结算方式"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>

        <el-table-column
          prop="recordUserName"
          label="操作人"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="detailsRemark"
          label="直接修改备注"
          width="120px"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-button @click="showPhoto(scope.row)" type="text" size="small">
              {{ scope.row.detailsRemark }}
            </el-button>
          </template>
        </el-table-column>
        <el-table-column
          prop="statementRemark"
          label="账单备注"
          width="120px"
          show-overflow-tooltip
        >
        </el-table-column>
      </el-table>
      <el-form style="margin-left:20%">
        <el-form-item label="收货客户">
          <el-autocomplete
            class="inline-input"
            v-model="consigneeName"
            :fetch-suggestions="querySearchConsignee"
            placeholder="请输入收货客户名称"
            :trigger-on-focus="false"
            @select="handleSelectConsignee"
            style="width:300px"
          >
            <template slot-scope="{ item }">
              <div class="name">{{ item.consigneeCompanyName }}</div>
            </template>
          </el-autocomplete>
        </el-form-item>
      </el-form>
      <el-button
        type="primary"
        @click="updateConsignee"
        :loading="isLoading"
        style="margin-left:40%"
        >确定
      </el-button>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisible" width="80%">
      <img width="100%" :src="dialogImageUrl" alt="" />
    </el-dialog>
    <el-dialog
      title="查看凭证"
      :visible.sync="showPhotoPreview"
      :before-close="() => (showPhotoPreview = false)"
    >
      <img
        width="100%"
        v-for="(item, index) in previewList"
        :key="index"
        :src="item"
        alt=""
      />
    </el-dialog>
  </div>
</template>

<script>
import { sjTime, isVehicleNumber } from '@/utils/sharedJsFile'
import { getCookie } from '@/utils/util.js'
import PathView from './mapTest.vue'
import currentLocation from './currentLocation.vue'
import { downloadFile } from '@/utils/base64ToBlob.js'
import { get } from 'http'
import FileSaver from 'file-saver'
export default {
  components: {
    PathView,
    currentLocation
  },
  data() {
    return {
      statementTime: null,
      statementEndTime: null,
      saleOrderMaterialIds: [],
      batchAddressProvince: '',
      batchAddressDistrict: '',
      batchAddressTown: '',
      batchPlace: '',
      centerDialogVisibleBatch: false,
      reallyList: [],
      visibleList: [],
      visibleList1: [],
      itemHeight: 30,
      scrollTop: 0,
      totalHeight: 0,
      //单选框
      tableRadio: '',
      debounceS: false,
      debounceS1: false,
      carNumber: '',
      activeName: 'first',
      //弹出框
      centerDialogVisible: false,
      //
      steelMap: {},
      startTime: new Date(),
      endTime: new Date(),
      //钢材子表数据
      steelList: [],
      drawer: false,
      isShow3: false,
      isShow4: false,
      input: null,
      screen: '',
      screen1: '',
      screen2: '订单日期',
      //存储单价信息的列表（分页前）
      priceAllList: [],
      //存储单价信息的列表（分页后）
      priceList: [],
      options: [
        {
          value: '客户',
          lable: '客户'
        },
        {
          value: '承运商',
          lable: '承运商'
        },
        {
          value: '车号',
          lable: '车号'
        },
        {
          value: '分录ID',
          lable: '分录ID'
        },
        {
          value: '下货地址',
          lable: '下货地址'
        },
        {
          value: '收款客户',
          lable: '收款客户'
        }
      ],
      options1: [
        {
          value: '客户',
          lable: '客户'
        },
        {
          value: '承运商',
          lable: '承运商'
        },
        {
          value: '车号',
          lable: '车号'
        },
        {
          value: '下货地址',
          lable: '下货地址'
        },
        {
          value: '收款客户',
          lable: '收款客户'
        }
      ],
      options2: [
        {
          value: '订单日期',
          lable: '订单日期'
        },
        {
          value: '制单日期',
          lable: '制单日期'
        }
      ],
      //合计净重（磅重）
      totalNumber: 0,
      //合计车数
      totalCapacity: 0,
      //合计净重
      totalNetWeight: 0,
      //合计运费
      totalDetailsAmount: 0,
      setteldTotalNumber: 0,
      setteldTotalCapacity: 0,
      totalDetailsAmountSettled: 0,
      totalNetWeightSettled: 0,
      tableTitle: '销售统计报表',
      capacityList: [],
      carrierList: [],
      tableData: [],
      tableData1: [],
      //筛选条件1（客户）
      filters1: [],
      spanArr: [],
      spanArr1: [],
      spanArr2: [],
      spanArr3: [],
      pos: 0,
      pos1: 0,
      pos2: 0,
      pos3: 0,
      mergeListBatch: ['磅重', '运费'],
      //需要合并列的名称
      mergeList: [
        // '选择',
        '序号',
        '整车操作',
        '销售订单状态',
        '销售订单号',
        '发货单位',
        '司机电话',
        '运输订单号',
        '签收地址',
        '签收时间',
        '抵达地址',
        '抵达时间',
        '出厂时间',
        '进厂时间',
        '运单状态',
        '车号',
        '承运商',
        '收货地址',
        '下货地点',
        '业务员',
        '送货单打印',
        '收货客户电话',
        '是否自提',
        '订单日期',
        '短信发送',
        '销售片区',
        '抵达时间',
        '签收时间',
        '最终运价',
        '摘要'
      ],
      //需要合并列的名称(已结算)
      mergeList1: [
        // '选择',
        '序号',
        '整车操作',
        '销售订单状态',
        '销售订单号',
        '发货单位',
        '司机电话',
        '运输订单号',
        '签收地址',
        '签收时间',
        '抵达地址',
        '抵达时间',
        '出厂时间',
        '进厂时间',
        '运单状态',
        '车号',
        '承运商',
        '收货地址',
        '下货地点',
        '业务员',
        '送货单打印',
        '收货客户电话',
        '是否自提',
        '订单日期',
        '短信发送',
        '销售片区',
        '抵达时间',
        '签收时间',
        '最终运价'
      ],

      tableTitle: '销售钢材计费详单',
      //所有省
      provinceList: [],
      //选中的省
      province: '',
      //所有市
      cityList: [],
      //选中的市
      city: '',
      //所有的县(区)
      countyList: [],
      //选中的县
      county: '',
      //地址输入框的值
      addresText: '',
      //已选中省市县
      address: null,
      //具体地址
      place: null,
      //暂存具体地址
      place1: null,
      //省市县Id
      addressId: null,
      addressRow: {},
      srcList: [],
      src: '',
      isShow: false,
      srcList2: [],
      src2: '',
      isShow2: false,
      input1: '',
      maxHeight: 700,
      //轨迹窗口
      value7: false,
      //实时路径窗口
      value8: false,
      pathOption: {
        orderNumber: '',
        capacityNumber: '',
        startPointName: '',
        endPointName: ''
      },
      someOnePriceValueList: [],
      saleSteelKey: false,
      tableRowIndex: '',
      isRowClick: 0,
      orgCodeList: [
        'wuliuyunshubu',
        'dagangadmin',
        'shichangxinxibu',
        'zidonghuabu',
        'chengyunshang'
      ],
      isShowOperate: false,
      filterConsigneeList: [],
      filterCarrierList: [],
      filterOutBoundWarehouse: [
        {
          text: '厂内库',
          value: '厂内库'
        },
        {
          text: '欧冶鑫宏中心库',
          value: '欧冶鑫宏中心库'
        },
        {
          text: '欧冶巨昌中心库',
          value: '欧冶巨昌中心库'
        }
      ],
      filterCapacityList: [],
      filtermaterialNameList: [],
      filterSaleAreaList: [],
      filterorderStatus: [],
      filteraddressPlace: [],
      filtermaterialSpe: [],
      filterSaleRemark: [],
      filterSaleOrderStatus: [],
      filterMap: {},
      //权限控制
      notRoutList: [],
      location: null,
      orderNumber: null,
      capacityNumber: null,
      fileListArrival: [],
      fileListReceive: [],
      dialogImageUrl: '',
      dialogVisible: false,
      isLoading: false,
      batchList: [],
      Address: {
        requestUrl: '',
        selectionType: 'radio',
        maxHeight: 300
      },
      dialogFormVisible: false,
      addresText: null,
      originalPriceValue: null,
      originalAddress: null,
      aaadrawer: false,
      downloadCapacityNo: null,
      makeSurePriceOrderList: [],
      makeSurePriceId: null,
      makeSurePlaceId: null,
      //当前页数
      currentPage: 1,
      //当前共多少条
      carrierNametotal: 10,
      //当前尺寸
      currentPageSize: 10,
      detailsAmount: null,
      mapValuenew: {},
      //存放要执行的单价的位置Id，以及价格
      amsPriceList: [],
      placeIds: [],
      //用于赋予承运商的权限
      userId: '',
      ops: {
        vuescroll: {},
        scrollPanel: {},
        rail: {
          keepShow: true
        },
        bar: {
          hoverStyle: true,
          onlyShowBarOnScroll: false, //是否只有滚动的时候才显示滚动条
          background: '#5f9ea0', //滚动条颜色
          opacity: 0.8, //滚动条透明度
          'overflow-x': 'hidden'
        }
      },
      excludeTax: null,
      statementList: [],
      showStatementUpLoad: false,
      detailAmount: null,
      detailsList: [],
      consigneeUpdList: [],
      showDetailsUpLoad: false,
      showDetailsAdd: false,
      showConsigneeUpd: false,
      updateConsigneeRow: null,
      consigneeId: null,
      consigneeName: '',
      detailRemark: null,
      showPhotoPreview: false,
      previewList: [],
      selecteddetailsOrderAmount: 0,
      scrollLeft: 0,
      scrollLeft1: 0,
      scrollTop1: 0,
      scrollLeftFlag1: 0,
      scrollLeftFlag: 0,
      //全选事件
      setteldAllselectValue: 0,
      unSetteleAllselectValue: 0
    }
  },
  created() {
    this.userId = getCookie('userId')
    if (this.orgCodeList.includes(getCookie('orgCode'))) {
      this.isShowOperate = true
    }
    if (getCookie('orgCode') == 'chengyunshang') {
      this.notRoutList = [
        'checkPoint',
        'checkTrans',
        'carrierName',
        'consigeeTel',
        'province',
        'city',
        'country',
        'place',
        'addressClick',
        'closeOrder',
        'materialNum',
        'closeEntry',
        'capacityNo',
        'uploadDetails'
      ]
    }
    //只要涉及提交即必须设计防抖,在初始化时绑定防抖函数
    this.cellMouse1 = this.debounce((row, column, cell) => {
      this.cellMouse(row, column, cell)
    }, 100)
    this.cellLeave1 = this.debounce((row, column, cell) => {
      this.cellLeave(row, column, cell)
    }, 100)
    this.getSteelReport()
  },
  watch: {
    scrollLeft: {
      immediate: true,
      deep: true,
      handler(val) {
        this.scrollLeftFlag = 1
      }
    },
    scrollLeft1: {
      immediate: true,
      deep: true,
      handler(val) {
        this.scrollLeftFlag1 = 1
      }
    },
    tableData: {
      handler(oldVal, newVal) {
        this.$nextTick(() => {
          if (this.activeName == 'first') {
            this.filterListChange(newVal)
          }
        })
      },
      deep: true,
      immediate: false
    },
    tableData1: {
      handler(oldVal, newVal) {
        this.$nextTick(() => {
          if (this.activeName == 'second') {
            this.filterListChange(newVal)
          }
        })
      },
      deep: true,
      immediate: false
    },
    scrollTop: {
      immediate: true,
      deep: true,
      handler(val) {
        this.$nextTick(() => {
          if (
            val >=
            this.tableData.length * 30 -
              document.querySelector('.untable .el-table__body-wrapper')
                .offsetHeight -
              20
          ) {
            val =
              this.tableData.length * 30 -
              document.querySelector('.untable .el-table__body-wrapper')
                .offsetHeight
          }
          if (val <= 0) {
            val = 0
          }
          document.querySelector(
            '.untable .el-table__body-wrapper .el-table__body'
          ).style.transform = `translateY(${val}px)`
          const start = Math.floor(val / this.itemHeight)
          this.visibleList = this.tableData.slice(
            start,
            start + Math.floor(this.maxHeight / this.itemHeight) + 1
          )
          this.getSpanArr(this.visibleList)
          this.debounceS = false
        })
      }
    },
    scrollTop1: {
      immediate: true,
      deep: true,
      handler(val) {
        this.$nextTick(() => {
          if (
            val >=
            this.tableData1.length * 30 -
              document.querySelector('.tabled .el-table__body-wrapper')
                .offsetHeight -
              20
          ) {
            val =
              this.tableData1.length * 30 -
              document.querySelector('.tabled .el-table__body-wrapper')
                .offsetHeight
          }
          if (val <= 0) {
            val = 0
          }
          document.querySelector(
            '.tabled .el-table__body-wrapper .el-table__body'
          ).style.transform = `translateY(${val}px)`
          const start = Math.floor(val / this.itemHeight)
          this.visibleList1 = this.tableData1.slice(
            start,
            start + Math.floor(this.maxHeight / this.itemHeight) + 1
          )
          this.getSpanArr(this.visibleList1)
          this.debounceS1 = false
        })
      }
    },
    activeName: {
      immediate: true,
      handler(oldVal, newVal) {
        this.$nextTick(() => {
          if (newVal == 'first') {
            this.filterListChange(this.tableData)
          } else {
            this.filterListChange(this.tableData1)
          }
        })
      }
    }
  },
  computed: {},
  mounted() {
    let that = this
    this.$nextTick(() => {
      window.onresize = () => {
        return (() => {
          this.maxHeight =
            window.innerHeight -
            document.querySelector('.tableTop').offsetHeight -
            40
        })()
      }
    })
    this.$refs.tableRef.bodyWrapper.addEventListener('scroll', e => {
      if (this.scrollLeftFlag == 1 && this.debounceS == true) {
        this.debounceS = false
      }
      if (this.debounceS) return
      this.debounceS = true
      this.scrollTop = e.target.scrollTop
      this.scrollLeft = e.target.scrollLeft
      this.scrollUpdateSelectFlag = 1
    })
    this.$refs.tableRef1.bodyWrapper.addEventListener('scroll', e => {
      if (this.scrollLeftFlag1 == 1 && this.debounceS1 == true) {
        this.debounceS1 = false
      }
      if (this.debounceS1) return
      this.debounceS1 = true
      this.scrollTop1 = e.target.scrollTop
      this.scrollLeft1 = e.target.scrollLeft
      this.scrollUpdateSelectFlag1 = 1
    })
  },
  activated() {
    this.maxHeight =
      window.innerHeight - document.querySelector('.tableTop').offsetHeight - 40
  },
  computed: {},
  methods: {
    unSetteleAllselect() {
      console.log('监听全选事件')
      console.log(this.unSetteleAllselectValue, 'this.unSetteleAllselectValue')
      if (this.unSetteleAllselectValue === 0) {
        this.unSetteleAllselectValue = 1
      } else {
        this.unSetteleAllselectValue = 0
      }
    },
    setteldAllselect() {
      console.log('监听全选事件')
      if (this.setteldAllselectValue == 0) {
        this.setteldAllselectValue = 1
      } else {
        this.setteldAllselectValue = 0
      }
    },
    selectOne(selection, row) {
      console.log('selection:', row)
      this.rowClick(row)
    },
    handleSelectionChange() {
      this.amsPriceList = []
      this.makeSurePriceOrderList = []
      this.someOnePriceValueList = []
      let data = []
      if (this.unSetteleAllselectValue == 1) {
        data = this.tableData
      } else {
        data = this.$refs.tableRef.selection
      }
      let mapvalue = {
        placeId: '',
        priceValue: '',
        orderId: ''
      }
      let mapValue1 = {
        detailsAmount: ''
      }
      this.makeSurePriceOrderList = data.map(e => {
        //运价判断
        mapValue1.detailsAmount = e.detailsAmount
        this.someOnePriceValueList.push(mapValue1)
        mapvalue.placeId = e.placeId
        mapvalue.priceValue = e.priceValue
        mapvalue.orderId = e.orderId
        this.amsPriceList.push(mapvalue)
        return e.orderId
      })
      //车序号和订单ID
      this.saleOrderMaterialIds = this.$refs.tableRef.selection.map(e => {
        return {
          saleOrderMaterialId: e.saleOrderMaterialId,
          orderId: e.orderId
        }
      })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.currentPageSize = val
      //计算分页尺寸
      let startPageNum = (this.currentPage - 1) * this.currentPageSize
      let endPageNum = this.currentPage * this.currentPageSize
      this.priceList = this.priceAllList.slice(startPageNum, endPageNum)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.currentPage = val
      //计算分页尺寸
      let startPageNum = (this.currentPage - 1) * this.currentPageSize
      let endPageNum = this.currentPage * this.currentPageSize
      this.priceList = this.priceAllList.slice(startPageNum, endPageNum)
    },
    cancelMakeSure() {
      if (this.$refs.tableRef1.selection.length == 0) {
        this.$message({
          type: 'error',
          offset: '250',
          message: '请勾选'
        })
        return
      }
      let data = []
      if (this.setteldAllselectValue == 1) {
        data = this.tableData1
      } else {
        data = this.$refs.tableRef1.selection
      }
      let orderList = data.map(e => {
        return e.orderId
      })
      let detailsOrderList = data.map(e => {
        return e.detailsId
      })
      let map = {
        orderList: orderList,
        detailsOrderList: detailsOrderList,
        updateStatus: 1
      }
      this.$confirm('是否将勾选住的单据取消确认', '提示', {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        center: true
      })
        .then(() => {
          this.axios.post('/api/v1/bms/updateDetailsStatus', map).then(res => {
            if (res.data.code == '200') {
              this.$refs.tableRef.clearSelection()
              this.getSteelReport()
              this.makeSurePriceOrderList = []
              this.setteldAllselectValue = 0
              this.$message({
                type: 'success',
                message: '取消确认执行价成功',
                duration: 2000,
                offset: '250'
              })
            } else {
              this.$message({
                type: 'error',
                message: '修改失败,联系管理员',
                duration: 2000,
                offset: '250'
              })
            }
          })
        })
        .catch(e => {
          this.$message({
            type: 'error',
            message: '取消操作',
            duration: 2000,
            offset: '250'
          })
        })
    },
    makeSurePrice() {
      this.amsPriceList = []
      this.makeSurePriceOrderList = []
      this.someOnePriceValueList = []
      let data = []
      if (this.unSetteleAllselectValue == 1) {
        data = this.tableData
      } else {
        data = this.$refs.tableRef.selection
      }
      let mapvalue = {
        placeId: '',
        priceValue: '',
        orderId: ''
      }
      let mapValue1 = {
        detailsAmount: ''
      }
      this.makeSurePriceOrderList = data.map(e => {
        //运价判断
        mapValue1.detailsAmount = e.detailsAmount
        this.someOnePriceValueList.push(mapValue1)
        mapvalue.placeId = e.placeId
        mapvalue.priceValue = e.priceValue
        mapvalue.orderId = e.orderId
        this.amsPriceList.push(mapvalue)
        return e.orderId
      })
      let detailsOrderList = data.map(e => {
        return e.detailsId
      })
      let map = {
        orderList: this.makeSurePriceOrderList,
        detailsOrderList: detailsOrderList,
        amsPriceList: this.amsPriceList
      }
      // let flag = 0
      // this.someOnePriceValueList.forEach(e => {
      //   if (e.detailsAmount == null) {
      //     console.log('进入了flag++')
      //     flag++
      //   }
      // })
      // if (flag != 0) {
      //   this.$message({
      //     type: 'error',
      //     message: '没有最终运费',
      //     duration: 2000,
      //     offset: '250'
      //   })
      //   return
      // }
      console.log('确认执行价的顺序')
      console.log(this.makeSurePriceOrderList)
      console.log(map)
      this.axios
        .post('/api/v1/bms/updateDetailsStatus', map)
        .then(res => {
          if (res.data.code == '200') {
            this.$refs.tableRef.clearSelection()
            this.getSteelReport()
            this.makeSurePriceOrderList = []
            this.unSetteleAllselectValue = 0
            this.$message({
              type: 'success',
              message: '确认执行价成功',
              duration: 2000,
              offset: '250'
            })
          } else {
            this.$message({
              type: 'error',
              message: '修改失败,联系管理员',
              duration: 2000,
              offset: '250'
            })
          }
        })
        .catch(e => {
          this.$message({
            type: 'error',
            message: '修改失败,联系管理员',
            duration: 2000,
            offset: '250'
          })
        })
      this.amsPriceList = []
    },
    openStatement() {
      console.log(this.$refs.tableRef1.selection, 'selection')
      if (
        !this.$refs.tableRef1.selection ||
        this.$refs.tableRef1.selection.length <= 0
      ) {
        this.$message.warning('请选择需要上传发票的订单')
      } else {
        this.excludeTax = null
        this.statementList = []
        let data = []
        if (this.setteldAllselectValue == 1) {
          data = this.tableData1
        } else {
          let orderList = []
          this.$refs.tableRef1.selection.forEach(item => {
            orderList.push(item.orderId)
          })
          console.log('orderList', orderList)
          console.log('tableData1', this.tableData1)
          data = this.tableData1.filter(
            item => orderList.indexOf(item.orderId) >= 0
          )
        }
        console.log(data, 'data')
        let noWeightBatchIdList = []
        let weightBatchIdList = []
        let arrNetAmount = []
        let totalWeightList = []
        let hash = {}
        noWeightBatchIdList = data.reduce((prev, item) => {
          if (!item.weightBatchId) {
            prev.push(item)
          }
          return prev
        }, [])
        weightBatchIdList = data.reduce((prev, item) => {
          if (item.weightBatchId) {
            prev.push(item)
          }
          return prev
        }, [])
        arrNetAmount = weightBatchIdList.reduce(function(
          prev,
          item,
          index,
          arr
        ) {
          hash[item.weightBatchId]
            ? null
            : (hash[item.weightBatchId] = true && prev.push(item))
          return prev
        },
        [])
        totalWeightList = noWeightBatchIdList.concat(arrNetAmount)
        this.selecteddetailsOrderAmount =
          totalWeightList.reduce((prev, item) => {
            return item.detailsAmount * 1000 + prev
          }, 0) / 1000
        this.selecteddetailsOrderAmount = this.selecteddetailsOrderAmount.toFixed(
          2
        )
        this.showStatementUpLoad = true
      }
    },
    generateStatement() {
      this.isLoading = true
      if (!this.excludeTax || !this.statementTime || !this.statementEndTime) {
        this.$message.warning('请填写所有信息！')
        this.isLoading = false
      } else if (this.statementList.length < 1) {
        this.$message.warning('请上传发票')
        this.isLoading = false
      } else {
        let data = []
        if (this.setteldAllselectValue == 1) {
          data = this.tableData1
        } else {
          data = this.$refs.tableRef1.selection
        }
        let orderList = data.map(e => {
          return e.orderId
        })
        let detailsIdList = data.map(e => {
          return e.detailsId
        })
        console.log(orderList, 'orderList')
        let formData = new window.FormData()
        this.statementList.forEach((item, index) => {
          formData.append('file' + index, item.raw)
        })
        formData.append('orderList', orderList)
        formData.append('detailsIdList', detailsIdList)
        formData.append(
          'selecteddetailsOrderAmount',
          this.selecteddetailsOrderAmount
        )
        formData.append('excludeTax', this.excludeTax)
        formData.append('userId', getCookie('userId'))
        console.log('statementTime:', this.statementTime)
        formData.append('statementTime', this.statementTime.getTime())
        formData.append('statementEndTime', this.statementEndTime.getTime())
        let options = {
          url: '/api/v1/bms/addTruckStatement',
          data: formData,
          method: 'post',
          headers: {
            'Content-Type': 'multipart/form-data'
          }
        }
        this.axios(options).then(res => {
          console.log('uploadRes:', res)
          if (res.data.status == 'succeed') {
            this.$message.success('上传成功！')
            this.setteldAllselectValue = 0
            this.closeUpload()
          } else {
            this.$message.error(res.data.data)
            this.isLoading = false
          }
        })
      }
    },
    openDetails() {
      console.log(this.$refs.tableRef.selection, 'selection')
      if (
        !this.$refs.tableRef.selection ||
        this.$refs.tableRef.selection.length != 1
      ) {
        this.$message.warning('请选择需要上传凭证的订单,一次只允许修改一个')
        return
      } else {
        this.detailAmount = null
        this.detailRemark = null
        this.detailsList = []
        let data = []
        if (this.unSetteleAllselectValue == 1) {
          data = this.tableData
        } else {
          data = this.$refs.tableRef.selection
        }
        for (let i = 0; i < data.length; i++) {
          if (!data[i].orderId || !data[i].netWeight) {
            this.$message.warning('没有派发运单，或没有净重，无法修改此项')
            return
          }
        }
        this.showDetailsUpLoad = true
      }
    },
    updateTruckDetail() {
      this.isLoading = true
      if (
        this.detailAmount == null ||
        this.detailAmount == '' ||
        !this.detailRemark
      ) {
        this.$message.warning('请填写所有信息！')
        this.isLoading = false
      } else {
        let data = []
        if (this.unSetteleAllselectValue == 1) {
          data = this.tableData
        } else {
          data = this.$refs.tableRef.selection
        }
        let orderList = data.map(e => {
          return e.orderId
        })
        console.log(orderList, 'orderList')
        let formData = new window.FormData()
        if (this.detailsList) {
          this.detailsList.forEach((item, index) => {
            formData.append('file' + index, item.raw)
          })
        }
        formData.append('orderList', orderList)
        formData.append('userId', getCookie('userId'))
        formData.append('detailAmount', this.detailAmount)
        formData.append('detailRemark', this.detailRemark)
        let options = {
          url: '/api/v1/bms/updateTruckDetail',
          data: formData,
          method: 'post',
          headers: {
            'Content-Type': 'multipart/form-data'
          }
        }
        this.axios(options).then(res => {
          console.log('uploadRes:', res)
          if (res.data.status == 'succeed') {
            this.$message.success('修改成功！')
            this.setteldAllselectValue = 0
            this.onclick()
            this.closeUpload2()
          } else {
            this.$message.error(res.data.data)
            this.isLoading = false
          }
        })
      }
    },
    openDetailsAdd() {
      console.log(this.$refs.tableRef.selection, 'selection')
      if (
        !this.$refs.tableRef.selection ||
        this.$refs.tableRef.selection.length != 1
      ) {
        this.$message.warning('请选择需要冲红的订单,一次只允许修改一个')
        return
      } else {
        this.detailAmount = null
        this.detailRemark = null
        this.detailsList = []
        let data = []
        if (this.unSetteleAllselectValue == 1) {
          data = this.tableData
        } else {
          data = this.$refs.tableRef.selection
        }
        for (let i = 0; i < data.length; i++) {
          if (!data[i].orderId) {
            this.$message.warning('没有派发运单，无法修改此项')
            return
          }
        }
        this.showDetailsAdd = true
      }
    },
    addTruckDetail() {
      this.isLoading = true
      if (!this.detailAmount || !this.detailRemark) {
        this.$message.warning('请填写所有信息！')
        this.isLoading = false
      } else {
        let data = []
        if (this.unSetteleAllselectValue == 1) {
          data = this.tableData
        } else {
          data = this.$refs.tableRef.selection
        }
        let orderList = data.map(e => {
          return e.orderId
        })
        console.log(orderList, 'orderList')
        let map = {
          orderList: orderList,
          userId: getCookie('userId'),
          detailAmount: this.detailAmount,
          detailRemark: this.detailRemark
        }
        let _this = this
        new Promise((resolve, reject) => {
          if (_this.detailsList.length > 0) {
            //先上传备注图片
            let formData = new window.FormData()
            _this.detailsList.forEach((item, index) => {
              formData.append('file' + index, item.raw)
            })
            let options = {
              url: '/api/v1/uc/uploadPic',
              data: formData,
              method: 'post',
              headers: {
                'Content-Type': 'multipart/form-data'
              }
            }
            _this.axios(options).then(res => {
              map.urls = res.data
              _this.closeUpload2()
              resolve('OK')
            })
          } else {
            resolve('NoPIC')
          }
        }).then(result => {
          console.log(result)
          this.axios.post('/api/v1/bms/addTruckDetail', map).then(res => {
            if (res.data.status == 'succeed') {
              this.$message.success('修改成功！')
              this.setteldAllselectValue = 0
              this.onclick()
            } else {
              this.$message.error(res.data.data)
            }
            this.showDetailsAdd = false
            this.isLoading = false
          })
        })
      }
    },
    openConsigneeUpd() {
      if (
        !this.$refs.tableRef.selection ||
        this.$refs.tableRef.selection.length != 1
      ) {
        this.$message.warning('请选择需要修改的订单,一次只允许选中一个')
        return
      } else {
        this.consigneeUpdList = []
        let data = this.$refs.tableRef.selection
        if (!data[0].orderId || !data[0].detailsId) {
          this.$message.warning('没有派发运单或没有详单，无法修改此项')
          return
        }
        this.consigneeUpdList = this.visibleList.filter(item => {
          return item.orderId == data[0].orderId
        })
        this.showConsigneeUpd = true
        this.updateConsigneeRow = null
        this.consigneeId = null
        this.consigneeName = null
        this.isLoading = false
      }
    },
    consigneeUpdSelect(selection) {
      console.log(selection)
      this.updateConsigneeRow = selection
    },
    handleSelectConsignee(item) {
      this.consigneeName = item.consigneeCompanyName
      this.consigneeId = item.consigneeId
    },
    querySearchConsignee(queryString, cb) {
      this.axios
        .post('/api/v1/uc/getConsigneeByLike?index=' + queryString)
        .then(res => {
          if (res.data.code == '200') {
            var restaurantsConsignee = res.data.data
            var results = queryString
              ? restaurantsConsignee.filter(
                  this.createFilterConsignee(queryString)
                )
              : restaurantsConsignee
            // 调用 callback 返回建议列表的数据
            cb(results)
          }
        })
    },
    createFilterConsignee(queryString) {
      return restaurantsConsignee => {
        return (
          restaurantsConsignee.value
            .toLowerCase()
            .indexOf(queryString.toLowerCase()) > -1
        )
      }
    },
    updateConsignee() {
      this.isLoading = true
      if (!this.consigneeId || !this.updateConsigneeRow) {
        this.$message.warning('请点击物资并填写、选中收货客户！')
        this.isLoading = false
      } else {
        let map = {
          orderId: this.updateConsigneeRow.orderId,
          detailsId: this.updateConsigneeRow.detailsId,
          userId: getCookie('userId'),
          consigneeId: this.consigneeId
        }
        this.axios.post('/api/v1/bms/updateConsignee', map).then(res => {
          if (res.data.status == 'succeed') {
            this.$message.success('修改成功！')
            this.setteldAllselectValue = 0
            this.onclick()
          } else {
            this.$message.error(res.data.data)
          }
          this.showConsigneeUpd = false
          this.isLoading = false
        })
      }
    },
    receiveClick(src, title) {
      // this.dialogImageUrl = src
      downloadFile(src, `${this.downloadCapacityNo}${title}照片`, '.jpg')
      // this.dialogVisible = true
    },
    async selectAddresClick() {
      //计算分页尺寸
      let startPageNum = (this.currentPage - 1) * this.currentPageSize
      let endPageNum = this.currentPage * this.currentPageSize
      if (this.addresText) {
        if (!this.notRoutList.includes('capacityNo')) {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?con=' +
                this.addresText,
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        } else {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?con=' +
                this.addresText,
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        }
      } else {
        if (!this.notRoutList.includes('capacityNo')) {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?i=' +
                new Date(),
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        } else {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?i=' +
                new Date(),
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        }
      }
      this.priceList = this.priceAllList.slice(startPageNum, endPageNum)
    },
    async updateDetailsOrderPrice() {
      if (Object.values(this.steelMap).length == 0) {
        this.$message.error('请点击需要执行更改操作的行！')
        return
      }
      //计算分页尺寸
      let startPageNum = (this.currentPage - 1) * this.currentPageSize
      let endPageNum = this.currentPage * this.currentPageSize
      console.log(this.steelMap)
      if (this.steelMap.actualAddress == null) {
        this.originalAddress = this.steelMap.addressPlace
      } else {
        this.originalAddress = this.steelMap.actualAddress
      }
      this.originalPriceValue = this.steelMap.priceValue
      if (!this.notRoutList.includes('capacityNo')) {
        if (
          typeof this.steelMap.addressTown != 'undefined' &&
          this.steelMap.addressTown != null
        ) {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?i=' +
                new Date() +
                '&con=' +
                this.steelMap.addressTown,
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        } else {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?i=' +
                new Date(),
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        }
      } else {
        if (
          typeof this.steelMap.addressTown != 'undefined' &&
          this.steelMap.addressTown != null
        ) {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?i=' +
                new Date() +
                '&con=' +
                this.steelMap.addressTown,
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        } else {
          await this.axios
            .post(
              '/api/v1/ams/getAmsContractTransportPriceForDetail?i=' +
                new Date(),
              this.steelMap
            )
            .then(res => {
              if (res.data.code) {
                this.priceAllList = res.data.data
                this.carrierNametotal = this.priceAllList.length
              }
            })
        }
      }
      this.priceList = this.priceAllList.slice(startPageNum, endPageNum)
      // console.log("获取分页后的数据")
      // console.log(startPageNum)
      // console.log(endPageNum)
      // console.log(this.priceAllList)
      // console.log(this.priceList)
      this.dialogFormVisible = true
    },
    currentRadioChange2(val) {
      this.tableRadio = val
      console.log('进入了该方法')
      console.log(val)
      //若具体地址有值，清空值
      if (this.place != null) {
        this.place = null
      }
      this.steelMap.placeId = val.placeId
      this.steelMap.address = val.address
      this.steelMap.addressId = val.addressId
      this.steelMap.priceId = val.priceid
      this.makeSurePriceId = val.priceid
      this.makeSurePlaceId = val.placeId
      this.detailsAmount = val.detailsAmount
    },
    //只修改单价
    makeSure() {
      //若没有单价Id
      console.log('获取数据')
      console.log(this.userId)
      console.log(this.saleOrderMaterialIds)
      if (this.saleOrderMaterialIds.length == 0) {
        this.amsPriceList = []
        this.$message({
          type: 'success',
          message: '请先选择需要修改的单价',
          duration: 2000,
          offset: '250'
        })
        return
      }
      this.saleOrderMaterialIds.forEach(e => {
        e.priceId = this.makeSurePriceId
        e.placeId = this.makeSurePlaceId
      })
      let mapValue = {}
      mapValue.mapList = this.saleOrderMaterialIds
      mapValue.userId = this.userId
      // //是否确定修改详单地址!
      // this.$confirm('确定修改', '提示', {
      //   confirmButtonText: '仅修改单价',
      //   cancelButtonText: '修改下货地址和单价',
      //   distinguishCancelAndClose: true,
      //   type: 'warning',
      //   center: true
      // })
      //   .then(() => {
      //初始化修改详单地址对话框的信息
      this.axios
        .post('/api/v1/bms/updateBatchDetailsOrder', mapValue)
        .then(res => {
          if (res.data.code == '200') {
            this.$message.success('修改详单单价成功!')
            //this.$refs.tableRef.clearSelection()
            //重置未结算详单表单信息
            // this.operation(this.steelMap)
            this.loadNewData()
            this.dialogFormVisible = false
          } else {
            this.$message.error('修改失败:' + res.data.data)
            this.dialogFormVisible = false
          }
        })
      this.amsPriceList = []
    },
    //修改单价和收货地址
    makeSureAll() {
      console.log('获取数据')
      console.log(this.userId)
      if (this.saleOrderMaterialIds.length == 0) {
        this.amsPriceList = []
        this.$message({
          type: 'success',
          message: '请先选择需要修改的单价',
          duration: 2000,
          offset: '250'
        })
        return
      }
      let mapList = []
      this.saleOrderMaterialIds.forEach(e => {
        e.priceId = this.makeSurePriceId
        e.placeId = this.makeSurePlaceId
        e.updatePlace = 1
      })
      let mapValue = {}
      mapValue.mapList = this.saleOrderMaterialIds
      mapValue.updatePlace = 1
      mapValue.userId = this.userId
      console.log('要的数据')
      console.log(mapValue)
      this.axios
        .post('/api/v1/bms/updateBatchDetailsOrder', mapValue)
        .then(res => {
          if (res.data.code == '200') {
            //this.$refs.tableRef.clearSelection()
            this.$message.success('修改详单单价和地址成功!')
            // this.operation(this.steelMap)
            this.loadNewData()
            this.dialogFormVisible = false
          } else {
            this.$message.error('修改失败:' + res.data.data)
            this.dialogFormVisible = false
          }
        })
      this.amsPriceList = []
    },
    hanleScroll() {
      console.log('我滚动了')
    },
    // batchAddressClick() {
    //   const loading = this.$loading({
    //     lock: true,
    //     text: '正在修改收货地址',
    //     spinner: 'el-icon-loading',
    //     background: 'rgba(0, 0, 0, 0.7)'
    //   })
    //   this.batchList.forEach(e => {
    //     e.addressProvince = this.batchAddressProvince
    //     e.addressDistrict = this.batchAddressDistrict
    //     e.place = this.batchPlace
    //     e.isCloseEas = Number(1)
    //     e.isNewCar = Number(1)
    //     e.shipperAddressId = this.addressId
    //     this.axios
    //       .post('/api/v1/ams/updateCarAddress', e)
    //       .then(res => {
    //         if (res.data.code == '200') {
    //           this.$message.success('修改收货地址成功!')
    //           this.getSteelReport()
    //         } else {
    //           this.$message.error('修改失败,请联系管理员!')
    //           this.getSteelReport()
    //         }
    //       })
    //       .catch(() => {
    //         this.$message.error('修改失败,请联系管理员!')
    //         this.getSteelReport()
    //       })
    //   })
    // },
    // batchoperation() {
    //   if (this.batchList.length > 0) {
    //     console.log(this.batchList)
    //     this.getAllProvince()
    //     this.onchangeProvince()
    //     this.onchangeCity()
    //     this.centerDialogVisibleBatch = true
    //   } else {
    //     this.$message({
    //       type: 'info',
    //       offset: '250',
    //       message: '请先选择'
    //     })
    //   }
    // },
    // openReceive() {
    //   if (Object.values(this.steelMap).length == 0) {
    //     this.$message.warning('请选择需要补录的实绩')
    //     return
    //   }
    //   let row = this.steelMap
    //   if (!row.outGateTime) {
    //     this.$message.warning('该车未出厂，不允许签收')
    //     return
    //   }
    //   if (row.arrivalAddress) {
    //     this.location = row.arrivalAddress
    //   } else {
    //     this.location = row.addressPlace
    //   }
    //   this.orderNumber = row.orderNo
    //   this.capacityNumber = row.capacityNo
    //   this.arrivalReceiving = true
    // },
    fileChange1(file, fileList) {
      let arr = ['IMAGE/JPEG', 'IMAGE/PNG', 'IMAGE/JPG']
      if (!arr.includes(file.raw.type.toUpperCase())) {
        this.$message({
          message: '暂时仅支持jpg或jpeg或png格式的发票上传',
          duration: 2000,
          type: 'error',
          offset: '250'
        })
        fileList.pop()
        return false
      }
      this.statementList = fileList
    },
    fileChange2(file, fileList) {
      this.detailsList = fileList
    },
    showPhoto(row) {
      this.showPhotoPreview = true
      this.previewList = []
      this.axios
        .post('/api/v1/uc/getPicture', {
          urls: row.photo
        })
        .then(res => {
          console.log(res)
          this.previewList = res.data
        })
    },
    exceed() {
      this.$message.warning('超出上传数量!')
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    closeUpload() {
      this.showStatementUpLoad = false
      this.isLoading = false
      this.$refs.statementUpload.clearFiles()
      // this.$refs.receive.clearFiles()
    },
    closeUpload2() {
      this.showDetailsUpLoad = false
      this.isLoading = false
      this.$refs.detailsUpload.clearFiles()
    },
    //防抖函数--防止用户重复点击
    debounce(func, delay) {
      let timer = null
      return function(...args) {
        if (timer !== null) {
          clearTimeout(timer)
        }
        timer = setTimeout(function() {
          func.apply(this, args)
        }, delay)
      }
    },
    // handleSelectionChange(selection) {
    //   this.batchList = selection
    //   console.log(selection)
    // },
    //筛选
    filterChange(obj) {
      console.log('filterChangeParam', obj)
      //承运商筛选,后续有待优化
      if (typeof obj.carrierList != 'undefined' && obj.carrierList.length > 0) {
        this.filterMap.carrierList = obj.carrierList
      }
      if (
        typeof obj.carrierList != 'undefined' &&
        obj.carrierList.length == 0
      ) {
        delete this.filterMap.carrierList
      }
      //物资名称（物料名称）筛选,后续有待优化
      if (
        typeof obj.materialNameList != 'undefined' &&
        obj.materialNameList.length > 0
      ) {
        this.filterMap.materialNameList = obj.materialNameList
      }
      if (
        typeof obj.materialNameList != 'undefined' &&
        obj.materialNameList.length == 0
      ) {
        delete this.filterMap.materialNameList
      }
      //车号筛选,后续有待优化
      if (
        typeof obj.newCapacityNo != 'undefined' &&
        obj.newCapacityNo.length > 0
      ) {
        this.filterMap.capacityList = obj.newCapacityNo
      }
      if (
        typeof obj.newCapacityNo != 'undefined' &&
        obj.newCapacityNo.length == 0
      ) {
        delete this.filterMap.capacityList
      }
      if (typeof obj.capacityNo != 'undefined' && obj.capacityNo.length == 0) {
        delete this.filterMap.capacityList
      }
      //客户筛选,后续有待优化
      if (
        typeof obj.consigneeName != 'undefined' &&
        obj.consigneeName.length > 0
      ) {
        this.filterMap.consigneeNameList = obj.consigneeName
      }
      if (
        typeof obj.consigneeName != 'undefined' &&
        obj.consigneeName.length == 0
      ) {
        delete this.filterMap.consigneeNameList
      }
      //销售片区筛选,后续有待优化
      if (
        typeof obj.saleAreaList != 'undefined' &&
        obj.saleAreaList.length > 0
      ) {
        this.filterMap.saleAreaList = obj.saleAreaList
      }
      if (
        typeof obj.saleAreaList != 'undefined' &&
        obj.saleAreaList.length == 0
      ) {
        delete this.filterMap.saleAreaList
      }
      //物资规格（规格型号）筛选
      if (typeof obj.materialSpe != 'undefined' && obj.materialSpe.length > 0) {
        this.filterMap.materialSpeList = obj.materialSpe
      }
      if (
        typeof obj.materialSpe != 'undefined' &&
        obj.materialSpe.length == 0
      ) {
        delete this.filterMap.materialSpeList
      }
      //收货地址筛选
      if (
        typeof obj.addressPlace != 'undefined' &&
        obj.addressPlace.length > 0
      ) {
        this.filterMap.addressPlaceList = obj.addressPlace
      }
      if (
        typeof obj.addressPlace != 'undefined' &&
        obj.addressPlace.length == 0
      ) {
        delete this.filterMap.addressPlaceList
      }
      if (typeof obj.orderStatus != 'undefined' && obj.orderStatus.length > 0) {
        this.filterMap.orderStatusList = obj.orderStatus
      }
      if (
        typeof obj.orderStatus != 'undefined' &&
        obj.orderStatus.length == 0
      ) {
        delete this.filterMap.orderStatusList
      }
      if (
        typeof obj.saleOrderStatus != 'undefined' &&
        obj.saleOrderStatus.length > 0
      ) {
        this.filterMap.saleOrderStatusList = obj.saleOrderStatus
      }
      if (
        typeof obj.saleOrderStatus != 'undefined' &&
        obj.saleOrderStatus.length == 0
      ) {
        delete this.filterMap.saleOrderStatusList
      }
      if (typeof obj.saleRemark != 'undefined' && obj.saleRemark.length > 0) {
        this.filterMap.saleRemarkList = obj.saleRemark
      }
      if (typeof obj.saleRemark != 'undefined' && obj.saleRemark.length == 0) {
        delete this.filterMap.saleRemarkList
      }
      if (
        typeof obj.outBoundWarehouse != 'undefined' &&
        obj.outBoundWarehouse.length > 0
      ) {
        this.filterMap.outBoundWarehouseList = obj.outBoundWarehouse
      }
      if (
        typeof obj.outBoundWarehouse != 'undefined' &&
        obj.outBoundWarehouse.length == 0
      ) {
        delete this.filterMap.outBoundWarehouseList
      }
      // if (obj)
      this.onclick(this.filterMap)
    },
    //控制筛选数组变化
    filterListChange(data) {
      if (data.length == 0) {
        if (this.activeName == 'first') {
          data = this.tableData
        } else {
          data = this.tableData1
        }
      }
      //客户筛选数组
      let consigneeNameList = data.map(e => {
        return e.consigneeName
      })
      //承运商筛选数组
      let carrierNameList = data.map(e => {
        return e.carrierName
      })
      //车号筛选数组
      let capacityList = data.map(e => {
        return e.newCapacityNo
      })
      //物资筛选数组
      let materialNameList = data
        .map(e => {
          return e.materialName
        })
        .filter(e => {
          return e != null
        })
      //销售片区筛选数组
      let saleAreaList = data
        .map(e => {
          return e.areaName
        })
        .filter(e => {
          return e != null
        })
      let addressPlaceList = data
        .map(e => {
          return e.addressPlace
        })
        .filter(e => {
          return e != null
        })
      let orderStatusList = data
        .map(e => {
          return e.orderStatus
        })
        .filter(e => {
          return e != null
        })
      let materialSpeList = data
        .map(e => {
          return e.materialSpe
        })
        .filter(e => {
          return e != null
        })
      let saleOrderStatusList = data.map(e => {
        return e.saleOrderStatus
      })
      let saleRemarkList = data.map(e => {
        return e.saleRemark
      })
      this.filterConsigneeList = []
      this.filterCarrierList = []
      this.filterCapacityList = []
      this.filtermaterialNameList = []
      this.filterSaleAreaList = []
      this.filterorderStatus = []
      this.filteraddressPlace = []
      this.filtermaterialSpe = []
      this.filterSaleOrderStatus = []
      this.filterSaleRemark = []

      Array.from(new Set(consigneeNameList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterConsigneeList.push(map)
      })
      Array.from(new Set(carrierNameList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterCarrierList.push(map)
      })
      Array.from(new Set(capacityList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterCapacityList.push(map)
      })
      Array.from(new Set(materialNameList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filtermaterialNameList.push(map)
      })
      Array.from(new Set(saleAreaList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterSaleAreaList.push(map)
      })
      Array.from(new Set(addressPlaceList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filteraddressPlace.push(map)
      })
      Array.from(new Set(orderStatusList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterorderStatus.push(map)
      })
      Array.from(new Set(materialSpeList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filtermaterialSpe.push(map)
      })
      Array.from(new Set(saleOrderStatusList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterSaleOrderStatus.push(map)
      })
      Array.from(new Set(saleRemarkList)).forEach(e => {
        let map = {}
        map.text = e
        map.value = e
        this.filterSaleRemark.push(map)
      })
    },

    rowClick(row, column, event) {
      this.steelMap = {}
      this.tableRowIndex = row.group
      this.isRowClick = 1
      this.steelMap = row
    },
    tableRowClassName({ row, rowIndex }) {
      if (row.group == this.tableRowIndex && this.tableRowIndex !== '') {
        return 'warning-row'
      }
    },
    cellMouse(row, column, cell, event) {
      if (this.isRowClick == 0) {
        this.tableRowIndex = row.group
      }
    },
    cellLeave(row, column, cell, event) {
      if (this.isRowClick == 0) {
        this.tableRowIndex = ''
      }
    },
    reset() {
      var that = this
      that.$nextTick(() => {
        that.saleSteelKey = !that.saleSteelKey
      })
    },
    checkTrans(row) {
      this.isRowClick = 0
      if (Object.values(this.steelMap).length == 0) {
        this.$message.error('请点击需要查看轨迹的行！')
        return
      }
      if (typeof row === 'undefined') {
        row = this.steelMap
      }
      if (row.outGateTime == null) {
        this.$message.error('该车还未出厂,暂无轨迹')
        return
      }
      let that = this
      that.axios
        .post('/api/v1/otms/fullPath?orderNumber=' + row.orderNo)
        .then(res => {
          console.log(res.data)
          if (res.data.data == '-1') {
            this.$message.error('运输订单未关闭的自提车辆无权查看!')
          } else if (res.data.data.startAndEndRoutes != null) {
            that.pathOption.orderNumber = row.orderNo
            that.pathOption.capacityNumber = row.capacityNo
            that.pathOption.startPointName = '达钢集团小东门'
            that.pathOption.endPointName = row.arrivalAddress
            that.value7 = true
          } else {
            this.$message.error('车辆没有开启GPS')
          }
        })
    },

    //查看抵达图
    toPhotoClick(orderNo, num) {
      this.axios
        .post('/api/v1/otms/getArrivalPhoto?orderNumber=' + orderNo)
        .then(res => {
          this.srcList = []
          this.srcList.push({
            title: '车头照片',
            src: res.data[0]
          })
          this.srcList.push({
            title: '满货箱照片',
            src: res.data[1]
          })
          if (num == 1) {
            this.isShow3 = true
          } else {
            this.isShow = true
          }
        })
    },
    //查看实时路径
    checkPoint() {
      if (this.input || this.input1 || this.steelMap.capacityNo) {
        this.carNumber = this.input || this.input1 || this.steelMap.capacityNo
        this.value8 = true
      } else {
        this.$message.error('请输入或者点击有车牌号的行查询车牌号的实时路径')
      }
    },
    //查看签收图
    receipctPhotoClick(orderNo, num) {
      this.axios
        .post('/api/v1/otms/getReceivingPhotoByUrl?orderNumber=' + orderNo)
        .then(res => {
          console.log(res.data)
          if (num == 1) {
            this.isShow4 = true
          } else {
            this.isShow2 = true
          }
          this.srcList2 = []
          if (res.data && res.data.length > 0) {
            res.data.forEach(item => {
              this.srcList2.push({
                title: '',
                src: item
              })
            })
          }
        })
    },

    //销售钢材报表导出excel
    exportAllReportToExcel() {
      const loading = this.$loading({
        lock: true,
        text: '正在导出Excel',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      var title = this.tableTitle
      let tHeader = []
      let filterVal = []
      if (this.activeName === 'first') {
        console.log('进入了1')
        console.log(this.$refs.tableRef)
        this.$refs.tableRef.$children.forEach(item => {
          if (item.label != undefined && item.prop != undefined) {
            if (tHeader.indexOf(item.label) === -1) {
              tHeader.push(item.label)
            }
            if (filterVal.indexOf(item.prop) === -1) {
              filterVal.push(item.prop)
            }
          }
        })
        this.downloadLoading = true
        require.ensure([], () => {
          const {
            export_json_to_excel
          } = require('@/assets/excel/Export2Excel.js') //这里必须使用绝对路径，使用@/+存放export2Excel的路径
          let data = this.disposeDataToExcel(this.tableData).map(v =>
            filterVal.map(j => v[j])
          ) //3.formatJson格式转换
          export_json_to_excel(tHeader, data, title) // (title)导出的表格名称
        })
      } else if (this.activeName === 'second') {
        console.log(this.$refs.tableRef1)
        this.$refs.tableRef1.$children.forEach(item => {
          if (item.label != undefined && item.prop != undefined) {
            if (tHeader.indexOf(item.label) === -1) {
              tHeader.push(item.label)
            }
            if (filterVal.indexOf(item.prop) === -1) {
              filterVal.push(item.prop)
            }
          }
        })
        this.downloadLoading = true
        require.ensure([], () => {
          const {
            export_json_to_excel
          } = require('@/assets/excel/Export2Excel.js') //这里必须使用绝对路径，使用@/+存放export2Excel的路径
          let data = this.disposeDataToExcel(this.tableData1).map(v =>
            filterVal.map(j => v[j])
          ) //3.formatJson格式转换
          export_json_to_excel(tHeader, data, title) // (title)导出的表格名称
        })
      }
      loading.close()
    },
    disposeDataToExcel(data) {
      //如果批次相同,只允许一条磅重和运费置为0
      //首先找出批次相同的数组元素
      data.reduce((prev, item) => {
        if (item.weightBatchId) {
          //如果有批次则走这个方法
          if (prev.length > 0) {
            let hash = prev[prev.length - 1]
            //如果处理后的数组长度大于0,那么判断处理后的数组的最后一个元素里面的批次是否与当前批次相等，如果相等
            if (
              item.weightBatchId &&
              hash.weightBatchId &&
              item.weightBatchId == hash.weightBatchId
            ) {
              prev[prev.length - 1].netWeight = 0
              prev[prev.length - 1].detailsAmount = 0
            }
          }
          prev.push(item)
          return prev
        } else {
          prev.push(item)
          return prev
        }
      }, [])
      return data
    },
    changeScreen() {},
    //承运商弹出层
    handleSelectCarrier() {
      this.carrierList.forEach(item => {
        if (item.carrierName == this.steelMap.carrierName) {
          this.steelMap.newCarrierId = item.carrierId
          this.steelMap.carrierId = item.carrierId
        }
      })
    },
    //承运商边输边查
    querySearchCarrier(queryString, cb) {
      if (queryString != null && queryString != '' && queryString.length > 1) {
        this.axios
          .post('/api/v1/uc/getCarrierMesByLike?index=' + queryString)
          .then(res => {
            if (res.data.code == '200') {
              this.carrierList = []
              if (res.data.data.length == 0) {
                this.$message.info('承运商不存在,请前往注册')
                return
              }
              var restaurants = res.data.data
              this.carrierList = res.data.data
              var results = queryString
                ? restaurants.filter(this.createFilterCarrier(queryString))
                : restaurants
              cb(results)
            }
          })
      }
    },
    createFilterCarrier(queryString) {
      return restaurants => {
        return (
          restaurants.value1.toLowerCase().indexOf(queryString.toLowerCase()) >
          -1
        )
      }
    },
    //以下是车牌号边输边查搜索
    querySearch(queryString, cb) {
      console.log(queryString)
      if (
        (queryString != null && queryString != '' && queryString.length > 3) ||
        queryString == '取消' ||
        queryString == '待定'
      ) {
        this.axios
          .post('/api/v1/uc/getCapacityByLike?index=' + queryString)
          .then(res => {
            this.capacityList = []
            if (res.data.code == '200') {
              if (res.data.data.length == 0) {
                this.$message.info('车牌号不存在,请前往注册')
                return
              }
              var restaurants = res.data.data
              this.capacityList = res.data.data
              var results = queryString
                ? restaurants.filter(this.createFilter(queryString))
                : restaurants
              // 调用 callback 返回建议列表的数据
              cb(results)
            }
          })
      }
    },
    createFilter(queryString) {
      return restaurants => {
        return (
          restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >
          -1
        )
      }
    },
    //车牌号弹出层

    //修改司机电话号码
    //修改收货客户电话
    //获取所有省数据
    getAllProvince() {
      this.axios.post('/api/v1/uc/getAllProvince').then(res => {
        this.provinceList = res.data.data
      })
    },
    //省改变
    onchangeProvince() {
      this.axios
        .post(
          '/api/v1/uc/getDistrictByProvince?addressProvince=' +
            this.steelMap.addressProvince +
            '&i=' +
            new Date()
        )
        .then(res => {
          this.cityList = res.data.data
          // this.city = "";
          // this.county = "";
        })
    },
    //市改变
    onchangeCity() {
      this.axios
        .post(
          '/api/v1/uc/getTownByDistrict?addressDistrict=' +
            this.steelMap.addressDistrict +
            '&i=' +
            new Date()
        )
        .then(res => {
          this.countyList = res.data.data
        })
    },
    //县(区)改变
    onchangeCounty() {
      let mapValue = {
        addressProvince: this.steelMap.addressProvince,
        addressDistrict: this.steelMap.addressDistrict,
        addressTown: this.steelMap.addressTown
      }
      this.axios.post('/api/v1/uc/getPlaceByAllAddress', mapValue).then(res => {
        this.addressId = res.data.data[0].addressId
      })
    },
    //收货地址弹出层
    handleSelect1(item) {
      console.log('获取所有下拉值!')
    },
    //以下是收货地址边输边查搜索
    querySearch1(queryString, cb) {
      this.axios
        .post(
          '/api/v1/ams/getRealAddressByLike?addressId=' +
            this.addressId +
            '&index=' +
            queryString
        )
        .then(res => {
          if (res.data.code == '200') {
            var restaurants = res.data.data
            var results = queryString
              ? restaurants.filter(this.createFilter1(queryString))
              : restaurants
            // 调用 callback 返回建议列表的数据
            cb(results)
          }
        })
    },
    createFilter1(queryString) {
      return restaurants => {
        return (
          restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >
          -1
        )
      }
    },
    //记录每一行的合并数
    getSpanArr(data) {
      //每次调用方法初始化
      this.spanArr = []
      this.spanArr2 = []
      for (var i = 0; i < data.length; i++) {
        if (i === 0) {
          this.spanArr.push(1)
          this.spanArr2.push(1)
          this.pos = 0
          this.pos2 = 0
        } else {
          // 判断当前元素与上一个元素是否相同
          if (data[i].saleOrderMaterialId === data[i - 1].saleOrderMaterialId) {
            this.spanArr[this.pos] += 1
            this.spanArr.push(0)
            if (
              data[i].weightBatchId &&
              data[i].weightBatchId === data[i - 1].weightBatchId
            ) {
              //批次合并
              this.spanArr2[this.pos2] += 1
              this.spanArr2.push(0)
            } else {
              this.spanArr2.push(1)
              this.pos2 = i
            }
          } else {
            this.spanArr.push(1)
            this.pos = i

            this.spanArr2.push(1)
            this.pos2 = i
          }
        }
      }
    },
    getSpanArr1(data) {
      //每次调用方法初始化
      this.spanArr1 = []
      this.spanArr3 = []
      for (var i = 0; i < data.length; i++) {
        if (i === 0) {
          this.spanArr1.push(1)
          this.pos = 0

          this.spanArr3.push(1)
          this.pos3 = 0
        } else {
          // 判断当前元素与上一个元素是否相同
          if (data[i].saleOrderMaterialId === data[i - 1].saleOrderMaterialId) {
            this.spanArr1[this.pos] += 1
            this.spanArr1.push(0)

            if (
              data[i].weightBatchId &&
              data[i].weightBatchId === data[i - 1].weightBatchId
            ) {
              //批次合并
              this.spanArr3[this.pos3] += 1
              this.spanArr3.push(0)
            } else {
              this.spanArr3.push(1)
              this.pos3 = i
            }
          } else {
            this.spanArr1.push(1)
            this.pos = i

            this.spanArr3.push(1)
            this.pos3 = i
          }
        }
      }
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (this.mergeList.indexOf(column.label) != -1) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      } else if (this.mergeListBatch.indexOf(column.label) != -1) {
        const _row = this.spanArr2[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    },
    objectSpanMethod1({ row, column, rowIndex, columnIndex }) {
      if (this.mergeList1.indexOf(column.label) != -1) {
        const _row = this.spanArr1[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      } else if (this.mergeListBatch.indexOf(column.label) != -1) {
        const _row = this.spanArr2[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    },
    //计算总件数和总车数
    getTotalNum(data) {
      //通过车序号的个数来计算车数
      let arr = []
      let arrNetAmount = []
      let noWeightBatchIdList = []
      let weightBatchIdList = []
      let totalWeightList = []
      let hash = {}
      arr = data.map(e => {
        return e.saleOrderMaterialId
      })
      noWeightBatchIdList = data.reduce((prev, item) => {
        if (!item.weightBatchId) {
          prev.push(item)
        }
        return prev
      }, [])
      weightBatchIdList = data.reduce((prev, item) => {
        if (item.weightBatchId) {
          prev.push(item)
        }
        return prev
      }, [])
      arrNetAmount = weightBatchIdList.reduce(function(prev, item, index, arr) {
        hash[item.weightBatchId]
          ? null
          : (hash[item.weightBatchId] = true && prev.push(item))
        return prev
      }, [])
      totalWeightList = noWeightBatchIdList.concat(arrNetAmount)
      this.totalCapacity = Array.from(new Set(arr)).length
      this.totalNetWeight =
        totalWeightList.reduce(function(prev, item, index) {
          return prev + item.netWeight * 1000
        }, 0) / 1000
      this.totalDetailsAmount =
        totalWeightList.reduce((prev, item) => {
          return prev + item.detailsAmount * 1000
        }, 0) / 1000
    },
    //计算总件数和总车数
    getTotalNumSettled(data) {
      //通过车序号的个数来计算车数
      let arr = []
      let arrNetAmount = []
      let noWeightBatchIdList = []
      let weightBatchIdList = []
      let totalWeightList = []
      let hash = {}
      arr = data.map(e => {
        return e.saleOrderMaterialId
      })
      noWeightBatchIdList = data.reduce((prev, item) => {
        if (!item.weightBatchId) {
          prev.push(item)
        }
        return prev
      }, [])
      weightBatchIdList = data.reduce((prev, item) => {
        if (item.weightBatchId) {
          prev.push(item)
        }
        return prev
      }, [])
      arrNetAmount = weightBatchIdList.reduce(function(prev, item, index, arr) {
        if (item.weightBatchId) {
          hash[item.weightBatchId]
            ? ''
            : (hash[item.weightBatchId] = true && prev.push(item))
          return prev
        } else {
          return prev.push(item)
        }
      }, [])
      totalWeightList = noWeightBatchIdList.concat(arrNetAmount)
      this.setteldTotalCapacity = Array.from(new Set(arr)).length
      this.totalNetWeightSettled =
        totalWeightList.reduce(function(prev, item) {
          return prev + item.netWeight * 1000
        }, 0) / 1000
      this.totalDetailsAmountSettled =
        totalWeightList.reduce((prev, item) => {
          return prev + item.detailsAmount * 1000
        }, 0) / 1000
    },

    //查询，输入查询条件
    onclick(obj) {
      this.setteldAllselectValue = 0
      this.selecteddetailsOrderAmount = 0
      this.amsPriceList = []
      this.isRowClick = 0
      if (!obj) {
        obj = new Object()
      }
      if (this.screen2 == '制单日期') {
        obj.saleMakeDate = 1
      }
      if (this.activeName == 'first') {
        const loading = this.$loading({
          lock: true,
          text: '正在获取数据',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        let startTime = null
        let endTime = null
        let carrierSsoId = null
        let carrierName = null
        let consigneeName = null
        let capacityNo = null
        let remark = null
        let saler = null
        let easPrimaryId = null
        let consigneeLoginName = null
        if (this.startTime && this.endTime) {
          startTime = sjTime(this.startTime)
          endTime = sjTime(this.endTime)
        }
        if (getCookie('orgCode') == 'chengyunshang') {
          carrierSsoId = getCookie('userId')
        }
        if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
          saler = getCookie('loginName')
        }
        if (getCookie('orgCode') == 'shouhuokehu') {
          consigneeLoginName =
            JSON.parse(getCookie('userInfo')).userCode || getCookie('loginName')
          obj.consigneeLoginName = consigneeLoginName
        }
        if (this.screen == '收款客户' && this.screen1 == '收款客户') {
          obj.paymentCustomer = [this.input, this.input1]
        } else {
          if (this.screen == '收款客户') {
            obj.paymentCustomer = [this.input]
          }
          if (this.screen1 == '收款客户') {
            obj.paymentCustomer = [this.input1]
          }
        }
        if (this.screen == '客户') {
          consigneeName = this.input
        } else if (this.screen == '承运商') {
          carrierName = this.input
        } else if (this.screen == '车号') {
          capacityNo = this.input
        } else if (this.screen == '分录ID') {
          console.log('进入了分录')
          easPrimaryId = this.input
        } else if (this.screen != '收款客户' && this.input) {
          remark = this.input
        }
        if (
          this.screen1 == '客户' &&
          this.input1 != null &&
          this.input1 != ''
        ) {
          consigneeName = this.input1
        } else if (
          this.screen1 == '承运商' &&
          this.input1 != null &&
          this.input1 != ''
        ) {
          carrierName = this.input1
        } else if (
          this.screen1 == '车号' &&
          this.input1 != null &&
          this.input1 != ''
        ) {
          capacityNo = this.input1
        } else if (this.screen1 != '收款客户' && this.input1) {
          remark = this.input1
        }
        this.axios
          .post(
            '/api/v1/tms/getSaleSteelReportNew?startTime=' +
              startTime +
              '&endTime=' +
              endTime +
              '&carrierSsoId=' +
              carrierSsoId +
              '&i=' +
              new Date() +
              '&remark=' +
              remark +
              '&consigneeName=' +
              consigneeName +
              '&carrierName=' +
              carrierName +
              '&capacityNo=' +
              capacityNo +
              '&saler=' +
              saler +
              '&easPrimaryId=' +
              easPrimaryId,
            obj
          )
          .then(res => {
            this.tableData = res.data.data
            this.getNodeNum(this.tableData)
            this.maxHeight =
              window.innerHeight -
              document.querySelector('.tableTop').offsetHeight -
              40
            this.visibleList = []
            this.visibleList = this.tableData.slice(
              0,
              Math.floor(this.maxHeight / this.itemHeight) + 1
            )
            this.getSpanArr(this.visibleList)
            this.getTotalNum(this.tableData)
            this.filterListChange(this.tableData)
            loading.close()
          })
          .catch(() => {
            loading.close()
          })
      } else {
        console.log('执行')
        const loading = this.$loading({
          lock: true,
          text: '正在获取数据',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        let startTime = null
        let endTime = null
        let carrierSsoId = null
        let carrierName = null
        let consigneeName = null
        let capacityNo = null
        let remark = null
        let saler = null
        let easPrimaryId = null
        let consigneeLoginName = null
        if (this.startTime && this.endTime) {
          startTime = sjTime(this.startTime)
          endTime = sjTime(this.endTime)
        }
        if (getCookie('orgCode') == 'chengyunshang') {
          carrierSsoId = getCookie('userId')
        }
        if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
          saler = getCookie('loginName')
        }
        if (getCookie('orgCode') == 'shouhuokehu') {
          consigneeLoginName =
            JSON.parse(getCookie('userInfo')).userCode || getCookie('loginName')
          obj.consigneeLoginName = consigneeLoginName
        }
        console.log(this.screen1, this.input1, 'here')
        if (this.screen == '收款客户' && this.screen1 == '收款客户') {
          obj.paymentCustomer = [this.input, this.input1]
        } else {
          if (this.screen == '收款客户') {
            obj.paymentCustomer = [this.input]
          }
          if (this.screen1 == '收款客户') {
            obj.paymentCustomer = [this.input1]
          }
        }
        if (this.screen == '客户') {
          consigneeName = this.input
        } else if (this.screen == '承运商') {
          carrierName = this.input
        } else if (this.screen == '车号') {
          capacityNo = this.input
        } else if (this.screen == '分录ID') {
          console.log('进入了分录')
          easPrimaryId = this.input
        } else if (!this.screen && this.input) {
          remark = this.input
        }
        if (
          this.screen1 == '客户' &&
          this.input1 != null &&
          this.input1 != ''
        ) {
          consigneeName = this.input1
        } else if (
          this.screen1 == '承运商' &&
          this.input1 != null &&
          this.input1 != ''
        ) {
          carrierName = this.input1
        } else if (
          this.screen1 == '车号' &&
          this.input1 != null &&
          this.input1 != ''
        ) {
          capacityNo = this.input1
        } else if (!this.screen1 && this.input1) {
          remark = this.input1
        }
        this.axios
          .post(
            '/api/v1/tms/getSettledSaleSteelReportNew?startTime=' +
              startTime +
              '&endTime=' +
              endTime +
              '&carrierSsoId=' +
              carrierSsoId +
              '&i=' +
              new Date() +
              '&remark=' +
              remark +
              '&consigneeName=' +
              consigneeName +
              '&carrierName=' +
              carrierName +
              '&capacityNo=' +
              capacityNo +
              '&saler=' +
              saler +
              '&easPrimaryId=' +
              easPrimaryId,
            obj
          )
          .then(res => {
            this.tableData1 = res.data.data
            this.getNodeNum(this.tableData1)
            this.maxHeight =
              window.innerHeight -
              document.querySelector('.tableTop').offsetHeight -
              40
            this.visibleList1 = []
            this.visibleList1 = this.tableData1.slice(
              0,
              Math.floor(this.maxHeight / this.itemHeight) + 1
            )
            console.log(this.visibleList1, 'this.visibleList1')
            this.getSpanArr1(this.visibleList1)
            this.getTotalNumSettled(this.tableData1)
            this.filterListChange(this.tableData1)
            loading.close()
          })
          .catch(() => {
            loading.close()
          })
      }
    },
    //重新获取表格数据
    refresh() {
      this.getSteelReport()
    },
    //仅仅更新变更数据
    loadNewData() {
      const loading = this.$loading({
        lock: true,
        text: '正在更新数据,请稍候',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      let startTime = null
      let endTime = null
      if (this.startTime && this.endTime) {
        startTime = sjTime(this.startTime)
        endTime = sjTime(this.endTime)
      }
      let map = {
        saleMaterialIds: this.visibleList.map(e => {
          return e.saleMaterialId
        })
      }
      console.log('map:', map)
      this.axios
        .post(
          '/api/v1/tms/getSaleSteelReportNew?startTime=' +
            startTime +
            '&endTime=' +
            endTime,
          map
        )
        .then(res => {
          //遍历旧数组
          this.visibleList.forEach(e1 => {
            //遍历新数组
            let temp = res.data.data.find(e2 => {
              return e1.saleMaterialId == e2.saleMaterialId
            })
            //赋值
            e1.priceValue = temp.priceValue
            e1.detailsAmount = temp.detailsAmount
            e1.actualAddress = temp.actualAddress
          })
          loading.close()
        })
        .catch(() => {
          loading.close()
        })
    },
    //将序号确定下来
    getNodeNum(data) {
      for (var i = 0; i < data.length; i++) {
        if (i === 0) {
          data[i].group = i
          data[i].rowKey = i
        } else {
          // 判断当前元素与上一个元素是否相同
          if (data[i].saleOrderMaterialId === data[i - 1].saleOrderMaterialId) {
            data[i].group = data[i - 1].group
            data[i].rowKey = i
          } else {
            data[i].group = data[i - 1].group + 1
            data[i].rowKey = i
          }
        }
      }
    },
    //获取钢材统计报表
    getSteelReport() {
      this.selecteddetailsOrderAmount = 0
      this.setteldAllselectValue = 0
      this.amsPriceList = []
      const loading = this.$loading({
        lock: true,
        text: '正在获取数据,请稍候',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      if (this.screen2 == '制单日期') {
        this.filterMap.saleMakeDate = 1
      }
      this.isRowClick = 0
      let startTime = null
      let endTime = null
      let carrierSsoId = null
      let carrierName = null
      let consigneeName = null
      let consigneeLoginName = null
      let capacityNo = null
      let remark = null
      let saler = null
      let easPrimaryId = null
      if (this.startTime && this.endTime) {
        startTime = sjTime(this.startTime)
        endTime = sjTime(this.endTime)
      }
      if (getCookie('orgCode') == 'chengyunshang') {
        carrierSsoId = getCookie('userId')
      }
      if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
        saler = getCookie('loginName')
      }
      if (getCookie('orgCode') == 'shouhuokehu') {
        consigneeLoginName =
          JSON.parse(getCookie('userInfo')).userCode || getCookie('loginName')
        this.filterMap.consigneeLoginName = consigneeLoginName
      }
      if (this.screen == '客户') {
        consigneeName = this.input
      } else if (this.screen == '承运商') {
        carrierName = this.input
      } else if (this.screen == '车号') {
        capacityNo = this.input
      } else if (this.screen == '分录ID') {
        easPrimaryId = this.input
      } else {
        remark = this.input
      }
      if (this.screen1 == '下单客户') {
        consigneeName = this.input1
      } else if (this.screen1 == '承运商') {
        carrierName = this.input1
      } else if (this.screen1 == '车号') {
        capacityNo = this.input1
      }
      if (getCookie('orgCode') == 'chengyunshang') {
        carrierSsoId = getCookie('userId')
      }
      if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
        saler = getCookie('loginName')
      }
      this.axios
        .post(
          '/api/v1/tms/getSaleSteelReportNew?startTime=' +
            startTime +
            '&endTime=' +
            endTime +
            '&carrierSsoId=' +
            carrierSsoId +
            '&saler=' +
            saler +
            '&i=' +
            new Date() +
            '&remark=' +
            remark +
            '&consigneeName=' +
            consigneeName +
            '&carrierName=' +
            carrierName +
            '&capacityNo=' +
            capacityNo +
            '&easPrimaryId=' +
            easPrimaryId,
          this.filterMap
        )
        .then(res => {
          this.tableData = res.data.data
          this.getNodeNum(this.tableData)
          this.maxHeight =
            window.innerHeight -
            document.querySelector('.tableTop').offsetHeight -
            40
          this.visibleList = []
          this.visibleList = this.tableData.slice(
            0,
            Math.floor(this.maxHeight / this.itemHeight) + 1
          )
          console.log(this.visibleList)
          this.getSpanArr(this.visibleList)
          this.getTotalNum(this.tableData)
          if (this.activeName == 'first') {
            this.filterListChange(this.tableData)
          } else {
            this.filterListChange(this.tableData1)
          }
          loading.close()
        })
        .catch(() => {
          loading.close()
        })

      this.axios
        .post(
          '/api/v1/tms/getSettledSaleSteelReportNew?startTime=' +
            startTime +
            '&endTime=' +
            endTime +
            '&carrierSsoId=' +
            carrierSsoId +
            '&saler=' +
            saler +
            '&i=' +
            new Date() +
            '&remark=' +
            remark +
            '&consigneeName=' +
            consigneeName +
            '&carrierName=' +
            carrierName +
            '&capacityNo=' +
            capacityNo +
            '&easPrimaryId=' +
            easPrimaryId,
          this.filterMap
        )
        .then(res => {
          loading.close()
          this.tableData1 = res.data.data
          this.getNodeNum(this.tableData1)
          this.maxHeight =
            window.innerHeight -
            document.querySelector('.tableTop').offsetHeight -
            40
          this.visibleList1 = []
          this.visibleList1 = this.tableData1.slice(
            0,
            Math.floor(this.maxHeight / this.itemHeight) + 1
          )
          console.log(this.visibleList1)
          this.getSpanArr1(this.visibleList1)
          this.getTotalNumSettled(this.tableData1)
          if (this.activeName == 'first') {
            this.filterListChange(this.tableData)
          } else {
            this.filterListChange(this.tableData1)
          }
        })
        .catch(() => {
          loading.close()
        })
    }
  }
}
</script>

<style lang="scss" scoped>
.purchasFuelNewMonitor {
  .tableTop {
    margin-left: 20px;
    margin-top: 20px;
  }
  .table {
    .el-tooltip {
      width: auto !important;
    }
    /deep/ .el-table__body {
      overflow-y: auto;
      position: absolute !important;
      tr:hover > td {
        background-color: #fff;
      }
    }

    ::-webkit-scrollbar {
      height: 20px;
      width: 10px;
      background-color: transparent;
    }
  }

  .dialog {
    .steelMapClass {
      .steelMapClass1 {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;
        .steelMapClass12 {
          margin-left: 50px;
          margin-right: 10px;
        }
      }
      .steelMapClass2 {
        margin-top: 20px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;
        .steelMapClass22 {
          margin-left: 50px;
          margin-right: 10px;
          .el-select {
            .el-input .el-input--suffix {
              .el-input__inner {
                border: 0px solid !important;
              }
            }
          }
        }
      }
      .steelMapClass3 {
        margin-top: 20px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;
        .steelMapClass33 {
          margin-left: 50px;
          // margin-right: 10px;
        }
      }
      .steelMapClass4 {
        margin-top: 20px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;

        .steelMapClass42 {
          margin-left: 50px;
          margin-right: 10px;
        }
        .steelMapClass43 {
          margin-left: 50px;
          margin-right: 10px;
        }
        .steelMapClass44 {
          margin-left: 50px;
          margin-right: 10px;
        }
      }
      .steelMapClass5 {
        margin-top: 20px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;

        .steelMapClass52 {
          margin-left: 50px;
          margin-right: 10px;
          .steelMapClass521 {
            margin-left: 20px;
          }
        }
      }
      .steelMapClass6 {
        margin-top: 20px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;
        .steelMapClass62 {
          margin-left: 50px;
          margin-right: 10px;
        }
      }

      .steelMapClass7 {
        margin-top: 20px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 16px;
        .steelMapClass72 {
          margin-left: 50px;
          margin-right: 10px;
        }
      }
    }
    .table1 {
      margin-left: 20px;
      margin-top: 20px;
      .el-tooltip {
        width: auto !important;
      }
    }
  }
  .address {
    .button-box {
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>
<!-- <style lang="scss">
.el-table__body-wrapper {
  overflow-y: auto;
  .el-table__body {
    position: absolute;
  }
}
</style> -->
