<template>
  <div class="center">
    <BaseHeaderLayout :leftSpan="12">
      <template slot="left">
      </template>
      <template slot="right">
        <el-select style="width:400px;" v-model="warehouseName" filterable placeholder="" @change="warehouseNameChange" :value="searchType">
          <el-option v-for="item in warehouseList" :key="item.value" :label="item.value" :value="item.value"
            style="color: #8890b1" />
        </el-select>
      </template>
    </BaseHeaderLayout>
    <div style="display: flex;">
      <div style="background: #f6f7fc; padding: 10px" class="grid-content bg-purple size_css">
        <BalanceAlert v-if="isShowBalance" ref="weightChild" :deptBudgetList="deptBudgetList" :information="information"
          v-on:balanceListen="setVal" class="zujian">
        </BalanceAlert>
        <div class="top">
          <div class="confirmWeight">
            <div class="titleWeight">确认重量</div>
            <div v-if="index == 0" class="weight">
              {{ weighingList.tare }} <span class="kg-style">kg</span>
            </div>
            <div v-else class="weight">
              {{ weighingList.grossWeight }} <span class="kg-style">kg</span>
            </div>
          </div>
          <div class="confirmInfo">
            <div class="car-type">车牌号</div>
            <div class="car-no">{{ weighingList.carNumber }}</div>
          </div>
          <!-- <el-button @click="weightweight" type="success" plain>确定</el-button> -->
        </div>
        <div class="bg-left titleup">
          <span class="word_css">实时监控</span>
        </div>
        <div class="bottom">
          <div v-if="!monitorUrl1" class="video1">
            <img src="../../../public/img/quesheng@2x.png" alt="" class="img1" />
            <div>监控视频未连接</div>
          </div>
          <div v-else class="video1">
            <iframe :src="monitorUrl1" width="440" height="360" allowfullscreen="true" webkitallowfullscreen="true"
              mozallowfullscreen="true" allow="autoplay; fullscreen; microphone;"></iframe>
          </div>
          <div v-if="!monitorUrl2" class="video1">
            <img src="../../../public/img/quesheng@2x.png" alt="" class="img1" />
            <div>监控视频未连接</div>
          </div>
          <div v-else class="video2">
            <iframe :src="monitorUrl2" width="440" height="360" allowfullscreen="true" webkitallowfullscreen="true"
              mozallowfullscreen="true" allow="autoplay; fullscreen; microphone;"></iframe>
          </div>
        </div>
      </div>
      <div>
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <div class="tab weigh_btn">
                <el-button :type="tpyeNo == 1 ? 'primary' : ''">
                  <!-- <el-badge :value="mListTop.length" class="badge_item"> -->
                  <div @click="tabClick(0)">称皮重</div>
                </el-button>
                <!-- </el-badge> -->
                <el-button :type="tpyeNo == 2 ? 'primary' : ''">
                  <!-- <el-badge :value="pListTop.length" class="badge_item"> -->
                  <div @click="tabClick(1)">称毛重</div>
                  <!-- </el-badge> -->
                </el-button>
              </div>
              <ws-form class="right-content">
                <div class="left1">
                  <div class="weightInfo">
                    <ws-info-table>
                      <ws-form-item label="任务编号" span="1" prop="inOutTaskNo">
                        <el-select v-if="tpyeNo == 1" :disabled="recheck" filterable clearable
                          v-model="weighingList.inOutTaskNo" placeholder="请选择任务编号" class="typeselect"
                          @change="contractNoChange">
                          <el-option v-for="item in taskNolist" :key="item.id" :label="item.inOutTaskNo"
                            :value="item.inOutTaskNo" />
                        </el-select>
                        <ws-input v-else v-model="weighingList.inOutTaskNo" placeholder="自动获取，不可编辑" maxlength="100"
                          disabled size="small" />
                      </ws-form-item>
                      <!-- <ws-form-item label="业务编号" span="1" prop="number">
                        <ws-input v-model="weighingList.number" placeholder="自动获取，不可编辑" maxlength="100" disabled
                          size="small" />
                      </ws-form-item> -->
                      <ws-form-item label="合同编号" span="1" prop="contractNo" v-show="inWarehouseType == 1"
                        v-if="weighingList.contractNo && tpyeNo == 1">
                        <ws-input v-model="weighingList.contractNo" placeholder="自动获取，不可编辑" maxlength="100" disabled
                          size="small" />
                      </ws-form-item>
                      
                      <ws-form-item label="移库编号" span="1" prop="moveTaskNo" v-show="inWarehouseType == 1"
                        v-if="!weighingList.contractNo && tpyeNo == 1">
                        <ws-input v-model="weighingList.moveTaskNo" placeholder="自动获取，不可编辑" maxlength="100" size="small"
                          disabled />
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 1" label="已完成量（吨）" span="1" prop="tips">
                        <ws-input v-model="weighingList.donecount" placeholder="自动获取，不可编辑" maxlength="100" disabled
                          size="small" />
                          <!-- {{}} -->
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 1" label="提示" span="1" prop="tips">
                        <ws-input v-model="weighingList.tips" placeholder="自动获取，不可编辑" maxlength="100" disabled
                          size="small" />
                      </ws-form-item>
                      <ws-form-item label="货名" span="1" prop="goodsName">
                        <ws-input v-model="weighingList.goodsName" placeholder="自动获取，不可编辑" maxlength="100" disabled
                          size="small" />
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 1 && warehouseType == 1" label="仓位号" span="1" prop="inOutTaskNo">
                        <el-select @change="binNumberchange" :disabled="recheck" filterable clearable
                          v-model="weighingList.binNumber" placeholder="请选择仓位号" class="typeselect">
                          <el-option v-for="item in positionInfos" :key="item.id" :label="item.binNumber"
                            :value="item.binNumber" />
                        </el-select>
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 1 && warehouseType == 1" label="囤位号" span="1" prop="storageNumber">
                        <ws-input :disabled="recheck" v-model="weighingList.storageNumber" placeholder="选填，1-10个字符"
                          maxlength="10" size="small" />
                      </ws-form-item>
                      <ws-form-item label="价格" span="1" prop="contractPrice">
                        <ws-input :disabled="priceedit" v-model="weighingList.contractPrice" placeholder="请输入价格(元/吨)"
                          maxlength="10" size="small" />
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 2" label="备注" span="1" prop="customer">
                        <ws-input :disabled="recheck" v-model="weighingList.customer" placeholder="请输入备注"
                          maxlength="10" size="small" />
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 1" label="出库类型" span="1">

                        <ws-input v-model="weighingList.inOutType" class="right-bottom" disabled
                          placeholder="自动获取，不可编辑" />
                          <!-- :disabled="isSelectType" -->
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 1" label="出库日期" span="1" prop="inOutDate" class="deliverydate">
                        <ws-date-picker v-model="weighingList.inOutDate" type="date" placeholder="请选择出库日期"
                          value-format="yyyy-MM-dd" />
                      </ws-form-item>
                      <ws-form-item label="运输方式" span="1" prop="outType">
                        <el-select @change="outTypechange" v-model="weighingList.outType" placeholder="请选择运输方式" :disabled="recheck1">
                          <el-option v-for="item in multiSelector" :key="item.value" :label="item.name"
                            :value="item.name"  />
                        </el-select>
                      </ws-form-item>
                      <ws-form-item v-if="fleetNameList.length > 0 && tpyeNo == 1&&weighingList.outType == '汽运'" label="车队" span="1" prop="fleetName">
                        <el-select @change="fleetNameChange" :disabled="recheck" v-model="weighingList.fleet" placeholder="非车队车辆">
                          <el-option  key="" label="非车队"
                            value="非车队" />
                          <el-option v-for="item in fleetNameList" :key="item.value" :label="item.fleetName"
                            :value="item.fleetName" />
                        </el-select>
                      </ws-form-item>
                      <ws-form-item label="车牌号" span="1" prop="carNo" v-if="
                      weighingList.outType == '散船' ||
                      weighingList.outType == '汽运' ||
                      weighingList.outType == '集装箱船'
                    ">
                        <el-input :maxlength="'7'" v-if="carjudge" v-model="weighingList.carNo" placeholder="请输入车牌号"
                           size="small" :disabled="recheck1"/>
                        <el-select v-else filterable clearable v-model="weighingList.carNo" placeholder="请选择车牌号"
                          class="typeselect" @change="carChange" :disabled="recheck1">
                          <el-option v-for="item in options2" :key="item.constKey"
                            :label="item.carNo + '(' + item.tranCarNo + ')'" :value="item.carNo" />
                        </el-select>
                        <el-button type="primary" @click="carNoTypeChange" v-if="carstatus">{{ carChange1 }}</el-button>
                      </ws-form-item>
                      <ws-form-item label="箱号-1" span="1" prop="boxNo" v-if="
                      weighingList.outType == '汽运' ||
                      weighingList.outType == '集装箱船'
                    ">
                        <ws-input v-model="weighingList.boxNo" placeholder="请输入箱号" maxlength="20" size="small" :disabled="recheck1"/>
                      </ws-form-item>
                      <ws-form-item label="封号-1" span="1" prop="titleNo" v-if="
                      weighingList.outType == '汽运' ||
                      weighingList.outType == '集装箱船'
                    ">
                        <ws-input v-model="weighingList.titleNo" placeholder="请输入封号" maxlength="20" size="small" :disabled="recheck1"/>
                      </ws-form-item>
                      <ws-form-item label="箱号-2" span="1" prop="boxNoOther" v-if="
                      weighingList.outType == '汽运' ||
                      weighingList.outType == '集装箱船'
                    ">
                        <ws-input v-model="weighingList.boxNoOther" placeholder="请输入箱号" maxlength="20" size="small" :disabled="recheck1"/>
                      </ws-form-item>

                      <ws-form-item label="封号-2" span="1" prop="titleNoOther" v-if="
                      weighingList.outType == '汽运' ||
                      weighingList.outType == '集装箱船'
                    ">
                        <ws-input v-model="weighingList.titleNoOther" placeholder="请输入封号" maxlength="20" size="small" :disabled="recheck1"/>
                      </ws-form-item>
                      <ws-form-item label="车厢号-1" span="1" prop="wingNumber" v-if="weighingList.outType == '火运'">
                        <ws-input v-model="weighingList.wingNumber" placeholder="请输入车厢号" maxlength="20" size="small" />
                      </ws-form-item>
                      <ws-form-item label="车厢号-2" span="1" prop="wingNumberOther" v-if="weighingList.outType == '火运'">
                        <ws-input v-model="weighingList.wingNumberOther" placeholder="请输入车厢号" maxlength="20"
                          size="small" />
                      </ws-form-item>
                      <ws-form-item label="船名" span="1" prop="shipName" v-if="weighingList.outType == '散船'||weighingList.outType == '集装箱船'">
                        <!-- <ws-input v-model="weighingList.shipName" placeholder="请输入船名" maxlength="20" size="small" /> -->
                        <el-select :disabled="tpyeNo == 2" filterable clearable v-model="weighingList.shipName"
                          placeholder="请选择船名" class="typeselect" @change="shipInfoChange($event)">
                          <el-option v-for="item in shipInfoList" :key="item.id" :label="item.shipName"
                            :value="item.shipName" />
                        </el-select>
                      </ws-form-item>
                      <ws-form-item label="航次" span="1" prop="shipNumber" v-if="weighingList.outType == '散船'||weighingList.outType == '集装箱船'">
                        <ws-input disabled v-model="weighingList.shipNumber" placeholder="请输入航次" maxlength="20" size="small" />
                      </ws-form-item>
                      <ws-form-item v-if="tpyeNo == 2" label="毛重(KG)" span="1" prop="grossWeight">
                        <ws-input type="number" @mousewheel.native.prevent v-if="tpyeNo == 2"
                          v-model="weighingList.grossWeight" @input="calculation" placeholder="未获取到毛重" maxlength="100"
                          size="small" :disabled="disabled" />
                        <el-button v-if="tpyeNo == 2 && warehouseType == 1" @click="openPort">重新获取</el-button>
                        <!-- <el-button v-if="tpyeNo == 2 && warehouseType == 2" @click="disabled = false">编辑</el-button> -->
                      </ws-form-item>
                      <ws-form-item label="皮重(KG)" span="1" prop="tare" v-if="information == '毛重'">
                        <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.tare"
                          @input="calculation" placeholder="未获取到皮重" maxlength="100" size="small" disabled />
                      </ws-form-item>
                      <ws-form-item label="皮重(KG)" span="1" prop="tare" v-if="information == '皮重'">
                        <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.tare"
                          @input="calculation" placeholder="未获取到皮重" maxlength="100" size="small" :disabled="disabled" />
                        <el-button v-if="tpyeNo == 1 && warehouseType == 1" @click="openPort">重新获取</el-button>
                        <!-- <el-button v-if="tpyeNo == 1 && warehouseType == 2" @click="disabled = false">编辑</el-button> -->
                      </ws-form-item>
                      <div class="formItem">
                        <!-- <ws-form-item label="扣重(KG)" span="1" prop="buckleMiscellaneous" v-if="
                        information == '毛重' &&
                        (paramType == '2' || inWarehouseType == 1)
                      ">
                      <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.buckleMiscellaneous"
                        @input="calculation" placeholder="请输入扣重" maxlength="100" size="small" />
                    </ws-form-item> -->
                        <ws-form-item label="净重(KG)" span="1" prop="netWeight" v-if="information == '毛重'">
                          <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.netWeight"
                            placeholder="自动计算，不可编辑" maxlength="100" size="small" disabled />
                        </ws-form-item>
                        <!-- <ws-form-item label="应收卸车过磅费（元）" span="1" prop="receivableWeighingFee" v-if="index == 1">
										<ws-input type="number" v-model="weighingList.receivableWeighingFee" placeholder="未获取到卸车过磅费金额"
											maxlength="100" size="small" disabled />
										</ws-form-item>
										<ws-form-item label="实收卸车过磅费（元）" span="1" prop="actualWeighingFee" v-if="index == 1">
										<ws-input type="number" v-model="weighingList.actualWeighingFee" placeholder="输入卸车过磅费" maxlength="100"
											size="small" />
										</ws-form-item> -->
                      </div>
                    </ws-info-table>
                    <div class="but">
                      <!-- <el-button @click="print" type="primary" :disabled="submitAllow">提交</el-button> -->
                      <el-button @click="print" v-if="information == '毛重'" type="primary">提交</el-button>
                      <el-button @click="print" v-if="information == '皮重'" type="primary" :disabled="submitAllow">提交
                      </el-button>
                    </div>
                    <!-- <div>
                      <div>粮源</div>
                      <div class='stocks' v-for='(item,index) in stocks'>
                        <el-select v-model="item.warehouseName" filterable placeholder="选择所属仓库" @change="warehouseNameChange" :value="searchType">
                          <el-option v-for="item in warehouseList" :key="item.value" :label="item.value" :value="item.value"
                            style="color: #8890b1" />
                        </el-select>
                        <el-select v-model="item.warehouseName" filterable placeholder="选择货名" @change="warehouseNameChange" :value="searchType">
                          <el-option v-for="item in warehouseList" :key="item.value" :label="item.value" :value="item.value"
                            style="color: #8890b1" />
                        </el-select>
                          <ws-input v-model="item.cost" placeholder="输入重量" maxlength="100"
                          size="small" />
                          <img class='add' @click='addstocks(index)' style='width:20px;height:20px;' src="../../../public/img/add.png" alt="">
                          <img class='del' @click='delstocks(index)' style='width:20px;height:20px;' src="../../../public/img/del.png" alt="">
                      </div>
                    </div> -->
                    <!-- </div> -->
                  </div>
                </div>
              </ws-form>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="list-info">
              <div style="justify-content: space-between;" class="flex">
                <div style="min-width:146px;">
                  <el-button v-if="tpyeNo == 1" @click="add" type="primary">新增</el-button>
                  <el-button v-if="tpyeNo == 1" @click="deletelist" type="danger">删除</el-button>
                  <el-button v-if="tpyeNo == 2" @click="statustypechangelist(3)"
                    :type="statusType == 3 ? 'primary' : ''">未称毛重
                  </el-button>
                  <!-- <el-button v-if="tpyeNo == 2" @click="statustypechangelist(2)"
                    :type="statusType == 2 ? 'primary' : ''">已称毛重
                  </el-button> -->
                </div>
                <div style="display: flex;">
                  <el-button @click='refreshClick(1)' type="primary">刷新</el-button>
                  <el-button @click='refreshClick' type="primary">{{timer?refresh:'自动刷新'}}</el-button>
                  <el-button @click="record" type="primary">记录</el-button>
                </div>
              </div>

              <el-table @cell-click="listclick" :data="deliveryList" style="width: 100%; margin-top: 20px"
                ref="deliveryList" border>
                <el-table-column prop="number" width="120" label="业务编号"></el-table-column>
                <el-table-column prop="carNumber" label="车牌号"></el-table-column>
                <el-table-column prop="status" label="状态"></el-table-column>
              </el-table>
              <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="currentPage" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                :total="deptBudgetTotal">
              </el-pagination>
            </div>

          </el-col>
        </el-row>
      </div>
    </div>
    <div class="mask" v-show="isShowPrintType"></div>
    <div class="print-type" v-show="isShowPrintType">
      <div class="print-type-content">
        <div class="print-type-title">请选择打印类型</div>
         <div class="ew-print" v-if="checked||(!ddchecked&&!checked)">
          <div class="row">
           <div>我司发货单位：</div>
            <el-select v-model="companyName" placeholder="请选择" style="width: 75%;">
              <el-option v-for="item in companyNameOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="row">
           <div>我司收货单位：</div>
            <el-select v-model="myCompanyCustomer" disabled style="width: 75%;">
             
            </el-select>
          </div>
        </div>
        <div v-if="warehouseName=='鲅鱼圈金信库'||warehouseName=='白城内陆港'||warehouseName=='哈尔滨依兰库'||warehouseName=='山东园丰库'">
          <div class="print-type-ew">
            <el-checkbox v-model="checked" @change="changeEw">打印额外票据</el-checkbox>
            <el-checkbox v-model="ddchecked" @change="changeEwDD">单独打印额外票据</el-checkbox>
          </div>
          <div class="ew-print" v-if="printSeparately">
            <div class="row">
              <div>额外发货单位：</div>
              <!-- <div>{{companyName}}</div> -->
              <el-select v-model="ewCustomer" placeholder="请选择" style="width: 75%;">
                <el-option v-for="item in ewCustomerOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div class="row">
              <div>额外收货单位：</div>
              <!-- <div>{{companyNameEW}}</div> -->
              <el-select v-model="companyNameEW" placeholder="请选择" style="width: 75%;">
                <el-option v-for="item in companyNameEWOptions" :key="item.value" :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
          </div>
        </div>
      </div>
      <div class="bottom-btn">
        <el-button @click="typePrintClick">确定</el-button>
        <el-button @click="typePrintCannelClick">取消</el-button>
      </div>
    </div>
    <!-- @opened="opendBtn" -->
    <el-dialog width="70%" class="title_css" center :visible.sync="isShowPrint" title="出库检斤单" @close="closeDialog"
      :close-on-click-modal="false">
      <weightCheckPrint :tableData="inspect" ref="saveImg"></weightCheckPrint>
      <div style="text-align: center">
        <el-button type="primary" @click="closePrint">关闭</el-button>
        <el-button type="primary" @click="printSmall">打印小票</el-button>
        <el-button type="primary" @click="printBig">打印单据</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import {
    grossWeight,
    getbinNumber,
    contractListWeighing,
    tareAdd,
    tareEdit,
    getweighing,
    getweighingList,
    selectWarehouseSelf,
    delelteWeighing,
    newSubmit,
    getInfo,
    gettask,
    getweight
  } from '@/model/outboundManagement/index'
  import {
    pullDown,
    addstorageputList,
    xialaNo,
    getstaff,
    getReceiptTaskNo,
  } from '@/model/warehouse/index'
  
  import axios from 'axios'
  import weightCheckPrint from './component/weightCheckPrint.vue'
  import inspectInfoPrint from './component/inspectInfoPrint.vue'
  import html2canvas from 'html2canvas'
  import WsUpload from '@/components/WsUpload'
  import BalanceAlert from '@/components/balanceAlert'
  import {
    EventBus
  } from 'base-core-lib'
  export default {
    components: {
      WsUpload,
      inspectInfoPrint,
      weightCheckPrint,
      BalanceAlert
    },
    data() {
      return {
        timer: '',
        refresh: 60,
        isShowBalance: false,
        isShowPrint: false,
        warehouseName: '',
        warehouseList: [],
        warehouseList1: [],
        currentPage: 1,
        pageSize: 50,
        shipInfoList:[],
        priceedit:false,
        submitAllow: false,
        deliveryList: [],
        inOutTypeList:[],
        positionInfos: [],
        searchKeyWord: '',
        paramType: '',
        deptBudgetTotal: 0,
        monitorUrl1: '',
        monitorUrl2: '',
        index: 0,
        inspect: {},
        stocks: [{
          warehouseName: '',
          weight: '',
          cost: ''
        }],
        id: 0,
        options2: [],
        isSelectType: false,
        recheck: false,
        recheck1:false,
        recheckPrice:false,
        disabled: true,
        pListTop: [],
        tpyeNo: 1,
        types: null,
        information: '皮重',
        carChange1: '手动填写',
        inWarehouseType: 1, //入库类型
        outContractNo: [],
        mListTop: [],
        searchType: '',
        taskNolist: [],
        storageType: [],
        fleetNameList: [],
        carstatus: false,
        carjudge: false,
        warehouseCount: '',
        warehouseCount1: 0,
        warehouseNo: '',
        statusType: '3',
        warehouseType: 1,
        weighingList: {
          grossWeight: '',
          tare: '',
          selfLoading: 0,
          buckleMiscellaneous: 0,
          netWeight: 0,
          weight: '',
          tips: '',
          carNo:'1231321',
          // contractNo:'',
          // inOutTaskNo:'',
          receivableWeighingFee: '',
          warehouseInOutDetail: {
            grade: '',
            imperfectGrain: '',
            impurity: '',
            jiaorenli: '',
            bulkDensity: '',
            mildewGrain: '',
          },
          qualityInspectionManagement: {
            boxNo: '暂无',
            boxNoOther: '暂无',
            titleNo: '暂无',
            titleNoOther: '暂无',
          },
          inOutDate: ''
        },
        carWeightInfo: {
          carNumber: '',
          type: '',
          weight: '',
        },
        ddchecked:false,
        checked:false,
        dialogDataList:[],
        ewCustomerOptions: [ {
          value: '天津建源供应链管理有限公司',
          label: '天津建源供应链管理有限公司'
        },{
          value: '厦门建发物产有限公司',
          label: '厦门建发物产有限公司'
        },{
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        }, {
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        }],
       companyNameOptions: [
         {
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        }],
        
        companyName: '黑龙江中天昊元贸易有限公司',
        companyNameEW: '黑龙江利润元粮食贸易有限公司',
        companyNameEWOptions: [{
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '厦门建发物产有限公司',
          label: '厦门建发物产有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        }],
        idPrint: '',
        
        myCompanyCustomer:'',
        ewCustomer: '厦门建发物产有限公司',
        ewradio: '',
        printSeparately: false,
        isShowPrintType:false,
        deptBudgetList: {},
        multiSelector: [{
            name: '汽运',
            value: '0',
          },
          {
            name: '火运',
            value: '1',
          },
          {
            name: '集装箱船',
            value: '2',
          },
          {
            name: '散船',
            value: '3',
          },
        ],
        jjSelectPrintList: [],
      }
    },
    beforeDestroy() {
      if (this.timer) { //如果定时器还在运行 或者直接关闭，不用判断
        clearInterval(this.timer); //关闭
      }
    },
    mounted() {
      this.getNowTime()
      this.selectWarehouse()
      this.showType = this.isShow
      this.isShowBalance = true
      this.openPort()
      if (localStorage.getItem('houseSelfCollect_house1')) {
        if (localStorage.getItem('houseSelfCollect_house1').allowEdit == 1) {
          this.disabled = false
        } else {
          this.disabled = true
        }
      }

    },
    activated() {},
    methods: {
      shipInfoChange(e){
        for (let i = 0; i < this.shipInfoList.length; i++) {
          if(this.shipInfoList[i].shipName==this.weighingList.shipName){
            this.weighingList.shipNumber=this.shipInfoList[i].shipNo
          } 
        }
      },
      async typePrintClick(type) {
        getweighing({
            id: this.idPrint
          })
          .toPromise()
          .then((response) => {
            this.dialogDataList = [] //点击确认时先清空要打印的数组
              this.dialogData = response
              if (response.compName == '黑龙江秋收有限公司') {
                this.dialogData.compName = '黑龙江中天昊元贸易有限公司'
              }
              if (this.checked) {
                if(this.dialogData&&!this.dialogData.customer&&this.dialogData.contractManagement){
                  this.dialogData.customer = this.dialogData.contractManagement.seller
                }
                this.dialogDataList.push(this.dialogData)
                var _datas = JSON.stringify(this.dialogData)
                _datas = JSON.parse(_datas)
                _datas.compName =this.ewCustomer
                _datas.customer =  this.companyNameEW
                this.dialogDataList.push(_datas)
                this.printBig('', this.radio)
              } else if (this.ddchecked) {
                _datas = this.dialogData
                _datas.compName = this.companyNameEW;
                _datas.customer = this.ewCustomer
                this.dialogDataList.push(_datas)
                this.printBig(1, this.radio)
              } else {
                this.dialogData.companyName = this.companyName
                if(this.dialogData&&!this.dialogData.customer&&this.dialogData.contractManagement){
                  this.dialogData.customer = this.dialogData.contractManagement.buyer
                }
                this.dialogDataList.push(this.dialogData)
                this.printBig('', this.radio)
              }
          })
          .catch((response) => {})
      },
      outTypechange(e){
        console.log(e)
        if(e=='汽运'){
          if(this.carChange1 == '手动填写'){
            this.weighingList.selfLoading = '0'
            this.carjudge=false
          }else{
            this.weighingList.selfLoading = '1'
            this.carjudge=true
          }
        }else if(e=='散船'){
          this.carjudge=true
          this.weighingList.selfLoading = '0'
        }else if(e=='集装箱船'){
          this.carjudge=true
          this.weighingList.selfLoading = '0'
        }
      },
      typePrintCannelClick() {
        this.ddchecked = false,
          this.checked = false,
          this.dialogDataList = [] //打个打印取消时数组至空
        this.isShowPrintType = false
      },
      changeEw(e) {
        this.ddchecked = false
        if (e) {
          this.printSeparately = true
        } else {
          this.printSeparately = false
        }
      },
      changeEwDD(e) {
        this.checked = false
        if (e) {
          this.printSeparately = true
        } else {
          this.printSeparately = false
        }
      },
      addstocks(index) {
        this.stocks.push({
          warehouseName: '',
          cost: ''
        })
      },
      delstocks(index) {
        this.stocks.splice(index, 1)
      },
      refreshClick(type) {
        let that = this
        if (type == 1) {
          getweighingList({
              compId: localStorage.getItem('ws-pf_compId'),
              currentPage: that.currentPage,
              pageSize: that.pageSize,
              searchKeyWord: that.searchKeyWord,
              warehouseName: that.warehouseName,
              managementType: 3,
              statusType: that.statusType,
              // loadingstatus: 1,
            })
            .toPromise()
            .then((response) => {
              that.deliveryList = response.records
              that.deptBudgetTotal = response.total
              for (var i = 0; i < response.records.length; i++) {
                if (response.records[i].addressUrl != null) {
                  if (response.records[i].addressUrl) {
                    response.records[i].addressUrlArray =
                      response.records[i].addressUrl.split(',')
                  }
                } else {
                  response.records[i].addressUrlArray = []
                }
              }
              for (var i = 0; i < response.records.length; i++) {
                var arr = new Array()
                that.addressUrls[i] = new Array()
                if (that.weighingList.records[i].addressUrl != null) {
                  arr = that.weighingList.records[i].addressUrl.split(',')
                  that.addressUrls[i] = arr
                }
              }
            })
            .catch((response) => {})
        } else {
          clearInterval(that.timer)
          that.refresh = 60
          that.timer = setInterval(function() {
            console.log(that.refresh)
            if (that.refresh == 0) {
              that.refresh = 60
              getweighingList({
                  compId: localStorage.getItem('ws-pf_compId'),
                  currentPage: that.currentPage,
                  pageSize: that.pageSize,
                  searchKeyWord: that.searchKeyWord,
                  warehouseName: that.warehouseName,
                  managementType: 3,
                  statusType: that.statusType,
                  loadingstatus: 1,
                })
                .toPromise()
                .then((response) => {
                  that.deliveryList = response.records
                  that.deptBudgetTotal = response.total
                  for (var i = 0; i < response.records.length; i++) {
                    if (response.records[i].addressUrl != null) {
                      if (response.records[i].addressUrl) {
                        response.records[i].addressUrlArray =
                          response.records[i].addressUrl.split(',')
                      }
                    } else {
                      response.records[i].addressUrlArray = []
                    }
                  }
                  for (var i = 0; i < response.records.length; i++) {
                    var arr = new Array()
                    that.addressUrls[i] = new Array()
                    if (that.weighingList.records[i].addressUrl != null) {
                      arr = that.weighingList.records[i].addressUrl.split(',')
                      that.addressUrls[i] = arr
                    }
                  }
                })
                .catch((response) => {})
            }
            that.refresh--

          }, 1000);
        }

      },
      statustypechangelist(status) {
        this.statusType = status
        this.getList()
      },
      getNowTime() {
        var now = new Date()
        var year = now.getFullYear() //得到年份
        var month = now.getMonth() //得到月份
        var date = now.getDate() //得到日期
        month = month + 1
        month = month.toString().padStart(2, '0')
        date = date.toString().padStart(2, '0')
        var defaultDate = `${year}-${month}-${date}`
        this.$set(this.weighingList, 'inOutDate', defaultDate)
      },
      record() {
        this.$router.push({
          path: 'weighingManagementrecord',
          query: {
            warehouseName: this.warehouseName
          },
        })
      },
      closePrint() {
        this.isShowPrint = false
      },
      printSmall() {
        // localStorage.setItem('inspect', JSON.stringify(this.inspect))
        // window.open('../../../static/weightChecknew.html?type=1')
        localStorage.setItem('ck_bd_printData1', JSON.stringify(this.inspect))
        window.open('../../../../static/outWeightPrint.html?type=1&other="true"')
      },
      printBig(type, radioType) {
          //  localStorage.setItem('ck_bd_printData1',JSON.stringify(this.inspect))
          //  window.open('../../../../static/outWeightPrint.html?type=2')
          // 打印额外
           localStorage.removeItem('print_out_data')
          localStorage.removeItem('selectPrint_EWjjSelectPrintList')
          localStorage.removeItem('selectPrint_jjSelectPrintList')
          if (this.checked || this.ddchecked) {
            this.makeEWjjSelectPrintList()
            //  this.selectEW = true;
          }
         
          if (type == 1) {
            localStorage.setItem('selectPrint_jjSelectPrintList', JSON.stringify(this.dialogDataList))
            window.open('../../../../static/weightCheckOutNew.html?type=2&radioType=' + radioType + '&selectEW=' + this
              .checked + '&selectEWDD=' + this.ddchecked)
          } else if (type == 2) {
            localStorage.setItem('selectPrint_jjSelectPrintList', JSON.stringify(this.excelPrintData))
            window.open('../../../../static/weightCheckOutNew.html?type=2&radioType=' + radioType)
          } else {
            console.log(this.dialogDataList)
            localStorage.setItem('print_out_data',JSON.stringify(this.dialogDataList).replace(/%/g, 'baifenhao'))
            window.open('../../../../static/weightCheckOutNew.html?type=2' )
          }
      },
    
      makeEWjjSelectPrintList() {
        let _selectPrint_EWjjSelectPrintList = JSON.parse(JSON.stringify(this.dialogDataList));
        for (let i = 0; i < _selectPrint_EWjjSelectPrintList.length; i++) {
          let _data = _selectPrint_EWjjSelectPrintList[i];
          _data.compName = this.companyNameEW;
          _data.customer = this.ewCustomer
        }
        localStorage.setItem('selectPrint_EWjjSelectPrintList', JSON.stringify(_selectPrint_EWjjSelectPrintList))
      },
      opendBtn() {
        html2canvas(this.$refs.saveImg.$el).then((canvas) => {
          let dataURL = canvas.toDataURL('image/png')
          this.imgUrl = dataURL
          if (this.imgUrl !== '') {
            let b = this.dataURLtoFile(this.imgUrl, 'printImg')
            let formdata = new FormData()
            formdata.append('file', b)
            axios({
              method: 'post',
              url:this.global.uploadPath,
              data: formdata,
            }).then((response) => {
              //编辑接口
              this.weighingList.pictureAddress = response.data.url
              console.log(this.types)
              if (this.types == 3) {
                this.weighingList.flag = 0
              } else if (this.types == 4) {
                this.weighingList.flag = 1
              }
              if (this.tpyeNo == 1) {
                tareEdit(this.weighingList)
                  .toPromise()
                  .then((response) => {
                    this.types = ''
                    this.weighingList = {
                      grossWeight: '',
                      tare: '',
                      tips: '',
                      // contractNo:'',
                      // inOutTaskNo:'',
                      buckleMiscellaneous: 0,
                      netWeight: 0,
                      receivableWeighingFee: '',
                      warehouseInOutDetail: {
                        grade: '',
                        imperfectGrain: '',
                        impurity: '',
                        jiaorenli: '',
                        bulkDensity: '',
                        mildewGrain: '',
                      },
                      qualityInspectionManagement: {
                        boxNo: '暂无',
                        boxNoOther: '暂无',
                        titleNo: '暂无',
                        titleNoOther: '暂无',
                      },
                    }
                    // this.inspect = []
                  })
              } else {
                grossWeight(this.weighingList)
                  .toPromise()
                  .then((response) => {
                    this.types = ''
                    this.weighingList = {
                      grossWeight: '',
                      tare: '',
                      tips: '',
                      // contractNo:'',
                      // inOutTaskNo:'',
                      buckleMiscellaneous: 0,
                      netWeight: 0,
                      receivableWeighingFee: '',
                      warehouseInOutDetail: {
                        grade: '',
                        imperfectGrain: '',
                        impurity: '',
                        jiaorenli: '',
                        bulkDensity: '',
                        mildewGrain: '',
                      },
                      qualityInspectionManagement: {
                        boxNo: '暂无',
                        boxNoOther: '暂无',
                        titleNo: '暂无',
                        titleNoOther: '暂无',
                      },
                    }
                    // this.inspect = []
                  })

              }

            })
          }
        })
      },
      closeDialog() {
        html2canvas(this.$refs.saveImg.$el).then((canvas) => {
          let dataURL = canvas.toDataURL('image/png')
          this.imgUrl = dataURL
          if (this.imgUrl !== '') {
            let b = this.dataURLtoFile(this.imgUrl, 'printImg')
            let formdata = new FormData()
            formdata.append('file', b)
            axios({
              method: 'post',
              url:this.global.uploadPath,
              data: formdata,
            }).then((response) => {
              //编辑接口
              this.weighingList.pictureAddress = response.data.url
              console.log(this.types)
              if (this.types == 3) {
                this.weighingList.flag = 0
              } else if (this.types == 4) {
                this.weighingList.flag = 1
              }
              if (this.tpyeNo == 1) {
                tareEdit(this.weighingList)
                  .toPromise()
                  .then((response) => {
                    this.types = ''
                    this.weighingList = {
                      grossWeight: '',
                      tare: '',
                      tips: '',
                      // contractNo:'',
                      // inOutTaskNo:'',
                      buckleMiscellaneous: 0,
                      netWeight: 0,
                      receivableWeighingFee: '',
                      warehouseInOutDetail: {
                        grade: '',
                        imperfectGrain: '',
                        impurity: '',
                        jiaorenli: '',
                        bulkDensity: '',
                        mildewGrain: '',
                      },
                      qualityInspectionManagement: {
                        boxNo: '暂无',
                        boxNoOther: '暂无',
                        titleNo: '暂无',
                        titleNoOther: '暂无',
                      },
                    }
                    // this.inspect = []
                  })
              } else {
                grossWeight(this.weighingList)
                  .toPromise()
                  .then((response) => {
                    this.types = ''
                    this.weighingList = {
                      grossWeight: '',
                      tare: '',
                      tips: '',
                      // contractNo:'',
                      // inOutTaskNo:'',
                      buckleMiscellaneous: 0,
                      netWeight: 0,
                      receivableWeighingFee: '',
                      warehouseInOutDetail: {
                        grade: '',
                        imperfectGrain: '',
                        impurity: '',
                        jiaorenli: '',
                        bulkDensity: '',
                        mildewGrain: '',
                      },
                      qualityInspectionManagement: {
                        boxNo: '暂无',
                        boxNoOther: '暂无',
                        titleNo: '暂无',
                        titleNoOther: '暂无',
                      },
                    }
                    // this.inspect = []
                  })

              }
            })
            this.dialogTableVisible = true
          }
        })
      },
      weightweight() {
        if (this.tpyeNo == 1) {
          this.weighingList.grossWeight = this.weighingList.weight
        } else {
          this.weighingList.tare = this.weighingList.weight
        }
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      },
      setVal(data) {
        if (this.information == '毛重') {
          this.weighingList.grossWeight = data
          this.weighingList.netWeight = Number(this.weighingList.grossWeight) - Number(this.weighingList.tare)
        } else {
          this.weighingList.tare = data
        }
      },
      openPort() {
        this.$refs.weightChild.openPort()
      },

      listclick(row) {
        this.id = row.id
        getweighing({
            id: row.id,
          })
          .toPromise()
          .then((response) => {
            this.weighingList = response
            if(response.inOutType == '移库出库' && this.warehouseType == '1'){
              this.recheckPrice = true
            }else{
              this.recheckPrice = false
            }

            // this.weighingList.carNo =
              // response.qualityInspectionManagement.carNumber
        this.$set(this.weighingList,'carNo', response.qualityInspectionManagement.carNumber)
            this.weighingList.boxNo = response.boxNo
            this.weighingList.boxNoOther = response.boxNoOther
            this.weighingList.titleNo = response.titleNo
            this.weighingList.titleNoOther = response.titleNoOther
            this.weighingList.wingNumber =
              response.qualityInspectionManagement.wingNumber
            this.weighingList.wingNumberOther =
              response.qualityInspectionManagement.wingNumberOther
            this.weighingList.warehouseInOutDetail = {
              grade: '',
              imperfectGrain: '',
              impurity: '',
              jiaorenli: '',
              bulkDensity: '',
              mildewGrain: '',
            }
          })
        // if(){

        // }
        // this.deptBudgetList=row
        // console.log(row)
      },
      add() {
        this.information = '皮重'
        this.weighingList = {
          grossWeight: 0,
          tare: 0,
          tips: '',
          // contractNo:'',
          // inOutTaskNo:'',
          buckleMiscellaneous: 0,
          netWeight: 0,
          receivableWeighingFee: '',
          warehouseInOutDetail: {
            grade: '',
            imperfectGrain: '',
            impurity: '',
            jiaorenli: '',
            bulkDensity: '',
            mildewGrain: '',
          },
          qualityInspectionManagement: {
            boxNo: '暂无',
            boxNoOther: '暂无',
            titleNo: '暂无',
            titleNoOther: '暂无',
          },
        }
      },
      deletelist() {
        if (this.id) {
          delelteWeighing({
              id: this.id,
            })
            .toPromise()
            .then((response) => {
              this.$message({
                message: '删除成功!',
                type: 'success',
              })
              this.id = ''
              this.weighingList = {
                grossWeight: '',
                tare: '',
                tips: '',
                // contractNo:'',
                // inOutTaskNo:'',
                buckleMiscellaneous: 0,
                netWeight: 0,
                receivableWeighingFee: '',
                warehouseInOutDetail: {
                  grade: '',
                  imperfectGrain: '',
                  impurity: '',
                  jiaorenli: '',
                  bulkDensity: '',
                  mildewGrain: '',
                },
                qualityInspectionManagement: {
                  boxNo: '暂无',
                  boxNoOther: '暂无',
                  titleNo: '暂无',
                  titleNoOther: '暂无',
                },
              }
              this.getList()
            })
        }
      },
      binNumberchange(e) {
        for (let i = 0; i < this.positionInfos.length; i++) {
          if (this.positionInfos[i].binNumber == e) {
            this.weighingList.positionId = this.positionInfos[i].id
          }
        }
      },
      check(name, type) {
        if (type == 1) {
          for (var _tmp = 0; _tmp < this.ewCustomerOptions.length; _tmp++) {
            if (this.ewCustomerOptions[_tmp].label == name) {
              return false
            }
          }
          return true
        } else if (type == 2) {
          for (var _tmp = 0; _tmp < this.companyNameEWOptions.length; _tmp++) {
            if (this.companyNameEWOptions[_tmp].label == name) {
              return false
            }
          }
          return true

        }

      },
      print() {
        this.weighingList.warehouseType = this.warehouseType
        console.log(this.weighingList,this.weighingList.binNumbe ,this.weighingList.warehouseType)
        this.carjudge=false
        this.carChange1 = '手动填写'
        // if(this.tpyeNo==2){
        //   if(this.weighingList.qualityInspectionManagement.status != '已质检'){
        //     this.$message.error("该条信息未质检！")
        //     return
        //   }
        // }
        // for (var i = 0; i < this.outContractNo.length; i++) {
        //   if (this.outContractNo[i].contractNo == this.weighingList.contractNo){
        //       this.$set(this.weighingList,'customer',this.outContractNo[i].buyer)
        //   }
        // }debugger
        // console.log(this.weighingList.customer)
        this.weighingList.carNumber = this.weighingList.carNo
        if (this.tpyeNo == 1 || this.tpyeNo == 2) {
          if (!this.weighingList.contractNo) {
            this.$message({
              message: '合同编号不能为空',
              type: 'warning',
            })
            return
          }
          if (!this.weighingList.binNumber && this.weighingList.warehouseType == 1) {
            this.$message({
              message: '仓位号不能为空',
              type: 'warning',
            })
            return
          }
          // if (!this.weighingList.storageNumber) {
          //   this.$message({
          //     message: '囤位号不能为空',
          //     type: 'warning',
          //   })
          //   return
          // }
          if (!this.weighingList.contractPrice && this.weighingList.inOutType != '移库出库'
          ||this.weighingList.inOutType == '移库出库'&&this.weighingList.priceType=='随行就市'&&this.weighingList.warehouseType==2) {
            this.$message({
              message: '价格不能为空',
              type: 'warning',
            })
            return
          }
          if (
            this.weighingList.storageNumber&&this.weighingList.storageNumber.length < 1 ||
            this.weighingList.storageNumber&&this.weighingList.storageNumber.length > 10
          ) {
            this.$message({
              message: '囤位号不超过10个字符！',
              type: 'warning',
            })
            return
          }
          if (!this.weighingList.carNumber) {
            this.$message({
              message: '车牌号不能为空',
              type: 'warning',
            })
            return
          }
          if (this.weighingList.carNumber.length != 7) {
            this.$message({
              message: '车牌号输入错误',
              type: 'warning',
            })
            return
          }
          if (!this.weighingList.inOutType) {
            this.$message({
              message: '出库类型不能为空',
              type: 'warning',
            })
            return
          }
        }
        if (!this.weighingList.binNumber&& this.weighingList.warehouseType == 1) {
          this.$message({
            message: '仓位号不能为空',
            type: 'warning',
          })
          return
        }
        if (this.tpyeNo == 1) {
          if (!this.weighingList.inOutType) {
            this.$message({
              message: '出库类型不能为空',
              type: 'warning',
            })
            return
          }
          if (!this.weighingList.tare) {
            this.$message({
              message: '皮重不能为空',
              type: 'warning',
            })
            return
          }
          if (
            isNaN(this.weighingList.tare) ||
            (String(this.weighingList.tare).indexOf('.') != -1 &&
              String(this.weighingList.tare).length -
              (String(this.weighingList.tare).indexOf('.') + 1) >
              1) ||
            this.weighingList.tare < 1 ||
            this.weighingList.tare > 100000
          ) {
            this.$message({
              message: '皮重输入错误！',
              type: 'warning',
            })
            return
          }
        }
        if (this.tpyeNo == 2) {
          if (!this.weighingList.grossWeight) {
            this.$message({
              message: '毛重不能为空',
              type: 'warning',
            })
            return
          }
          if (
            isNaN(this.weighingList.grossWeight) ||
            (String(this.weighingList.grossWeight).indexOf('.') != -1 &&
              String(this.weighingList.grossWeight).length -
              (String(this.weighingList.grossWeight).indexOf('.') + 1) >
              1) ||
            this.weighingList.grossWeight < 1 ||
            this.weighingList.grossWeight > 120000
          ) {3
            this.$message({
              message: '毛重输入错误！',
              type: 'warning',
            })
            return
          }
          if (this.weighingList.netWeight < 0) {
            this.$message({
              message: '净重不能为负',
              type: 'warning',
            })
            return
          }
        }
        this.weighingList.compId = localStorage.getItem('ws-pf_compId')
        this.weighingList.warehouseName = this.warehouseName
        
        this.$confirm('确定保存检斤信息？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
          .then(() => {
            this.weighingList.inOutFlag = 1
            this.weighingList.statusFlag = 3
            // if (this.weighingList.grossWeight) {
            //   this.weighingList.grossWeight = this.weighingList.grossWeight / 1000
            // }
            // if (this.weighingList.netWeight) {
            //   this.weighingList.netWeight = this.weighingList.netWeight / 1000
            // }
            // this.weighingList.tare = this.weighingList.tare / 1000
            // if (this.weighingList.buckleMiscellaneous) {
            //   this.weighingList.buckleMiscellaneous = this.weighingList.buckleMiscellaneous / 1000
            // }
            if (this.tpyeNo == 1) {
              this.deptBudgetList.skinInspector =
                localStorage.getItem('ws-pf_staffName')
              //  this.weighingList.serviceManagementType=2
              this.weighingList.statusFlag = 1
              this.weighingList.relationId = this.relationId
              this.weighingList.warehouseId = this.warehouseId
              this.weighingList.baseId = this.warehouseId
              this.weighingList.skinInspector =
                localStorage.getItem('ws-pf_staffName')
              if (this.weighingList.id) { //修改皮重
                var weighingList1 = JSON.parse(JSON.stringify(this.weighingList)) //为了解除双向绑定问题，不影响this.weighingList的数据
                weighingList1.id = this.weighingList.warehouseInOutId
                weighingList1.warehouseInOutDetail.id = this.weighingList.inOutDetailId
                weighingList1.weighingManagement = this.weighingList
                if (weighingList1.tare) {//为了解决出入库与检斤单位不一致（出入库单位吨，检斤公斤）
                  weighingList1.tare = weighingList1.tare / 1000
                }
                if (weighingList1.netWeight) {
                  weighingList1.netWeight = weighingList1.netWeight / 1000
                }
                newSubmit(weighingList1)
                  .toPromise()
                  .then((response) => {
                    getweighing({
                        id: this.weighingList.id
                      })
                      .toPromise().then((response) => {
                        if (this.reader) {
                          this.reader.cancel()
                        }
                        this.$notify({
                          title: '成功',
                          message: '提交成功',
                          type: 'success',
                        })
                        this.getList()
                        
                        this.weighingList = response
                        // this.warehouseCount = Number(this.warehouseCount) + 1
                        // this.warehouseCount1 = Number(this.warehouseCount1) + 1
                        this.inspect = JSON.parse(
                          JSON.stringify(this.weighingList)
                        )
                        // this.isShowPrint = true
                        this.isShowPrintType = true
                        this.weighingList = {
                          grossWeight: 0,
                          tare: 0,
                          tips: '',
                          // contractNo:'',
                          // inOutTaskNo:'',
                          buckleMiscellaneous: 0,
                          netWeight: 0,
                          receivableWeighingFee: '',
                          warehouseInOutDetail: {
                            grade: '',
                            imperfectGrain: '',
                            impurity: '',
                            jiaorenli: '',
                            bulkDensity: '',
                            mildewGrain: '',
                          },
                          qualityInspectionManagement: {
                            boxNo: '暂无',
                            boxNoOther: '暂无',
                            titleNo: '暂无',
                            titleNoOther: '暂无',
                          },
                        }
                      })
                  })
              } else { //新增皮检信息
                this.weighingList.relationId = this.relationId
                this.weighingList.warehouseId = this.warehouseId
                this.weighingList.baseId = this.warehouseId
                this.weighingList.warehouseNo = this.warehouseNo
                var weighingList1 = JSON.parse(JSON.stringify(this.weighingList)) //为了解除双向绑定问题，不影响this.weighingList的数据
                weighingList1.id = this.weighingList.warehouseInOutId
                weighingList1.warehouseInOutDetail.id = this.weighingList.inOutDetailId
                weighingList1.weighingManagement = this.weighingList
                if (weighingList1.tare) {//为了解决出入库与检斤单位不一致（出入库单位吨，检斤公斤）
                  weighingList1.tare = weighingList1.tare / 1000
                }
                if (weighingList1.netWeight) {
                  weighingList1.netWeight = weighingList1.netWeight / 1000
                }
                newSubmit(weighingList1)
                  .toPromise()
                  .then((response) => {
                    this.idPrint=response
                    getweighing({
                        id: response
                      })
                      .toPromise().then((response) => {
                        if (this.reader) {
                          this.reader.cancel()
                        }
                        this.$notify({
                          title: '成功',
                          message: '提交成功',
                          type: 'success',
                        })
                        this.getList()
                        this.weighingList = response
                        // this.warehouseCount = Number(this.warehouseCount) + 1
                        // this.warehouseCount1 = Number(this.warehouseCount1) + 1
                        this.inspect = JSON.parse(
                          JSON.stringify(this.weighingList)
                        )
                        if(this.warehouseName == '鲅鱼圈金信库' ||
                        this
                        .warehouseName == '哈尔滨依兰库' || this
                        .warehouseName == '白城内陆港'|| this
                        .warehouseName == '山东园丰库'){
                          if(this.weighingList.contractManagement){
                            let cang = {}
                            cang.value = this.weighingList.contractManagement.seller
                            cang.label = this.weighingList.contractManagement.seller
                            if (this.check(this.weighingList.contractManagement.seller, 1)) {
                              this.ewCustomerOptions.push(cang)
                              }
                              let cang1 = {}
                              cang1.value = this.weighingList.contractManagement.buyer
                              cang1.label = this.weighingList.contractManagement.buyer
                              if (this.check(this.weighingList.contractManagement.buyer, 2)) {
                                this.companyNameEWOptions.push(cang1)
                              }
                              this.myCompanyCustomer = this.weighingList.contractManagement.buyer
                          }
                          this.isShowPrintType = true
                        }else{
                          this.isShowPrintType = true
                        }
                        this.weighingList = {
                          grossWeight: 0,
                          tare: 0,
                          tips: '',
                          // contractNo:'',
                          // inOutTaskNo:'',
                          buckleMiscellaneous: 0,
                          netWeight: 0,
                          receivableWeighingFee: '',
                          warehouseInOutDetail: {
                            grade: '',
                            imperfectGrain: '',
                            impurity: '',
                            jiaorenli: '',
                            bulkDensity: '',
                            mildewGrain: '',
                          },
                          qualityInspectionManagement: {
                            boxNo: '暂无',
                            boxNoOther: '暂无',
                            titleNo: '暂无',
                            titleNoOther: '暂无',
                          },
                        }
                      })
                  })
              }
            } else if (this.tpyeNo == 2) {
              this.weighingList.secretaryWeigher =
                localStorage.getItem('ws-pf_staffName')
              this.weighingList.warehouseId = this.warehouseId
              this.weighingList.baseId = this.warehouseId
              var weighingList1 = JSON.parse(JSON.stringify(this.weighingList)) //为了解除双向绑定问题，不影响this.weighingList的数据
              weighingList1.id = this.weighingList.warehouseInOutId
              weighingList1.warehouseInOutDetail.id = this.weighingList.inOutDetailId
              console.log(this.weighingList)
              if(this.weighingList.inOutType=='移库出库'){
                this.weighingList.customer=this.weighingList.tips
              }
              weighingList1.weighingManagement = this.weighingList
              if (weighingList1.grossWeight) {//为了解决出入库与检斤单位不一致（出入库单位吨，检斤公斤）
                weighingList1.grossWeight = weighingList1.grossWeight / 1000
              }
              if (weighingList1.netWeight) {
                weighingList1.netWeight = weighingList1.netWeight / 1000
              }
              if (weighingList1.tare) {
                weighingList1.tare = weighingList1.tare / 1000
              }
              newSubmit(weighingList1)
                .toPromise()
                .then((response) => {
                  this.idPrint=response
                  getweighing({
                      id: response
                    })
                    .toPromise().then((response) => {
                      
                       if(this.warehouseName == '鲅鱼圈金信库' ||
                        this
                        .warehouseName == '哈尔滨依兰库' || this
                        .warehouseName == '白城内陆港'|| this
                        .warehouseName == '山东园丰库'){
                          this.weighingList = response
                      this.inspect = JSON.parse(
                        JSON.stringify(this.weighingList)
                      )
                          if(this.weighingList.contractManagement){
                            let cang = {}
                            cang.value = this.weighingList.contractManagement.seller
                            cang.label = this.weighingList.contractManagement.seller
                            if (this.check(this.weighingList.contractManagement.seller, 1)) {
                              this.ewCustomerOptions.push(cang)
                              }
                              let cang1 = {}
                              cang1.value = this.weighingList.contractManagement.buyer
                              cang1.label = this.weighingList.contractManagement.buyer
                              if (this.check(this.weighingList.contractManagement.buyer, 2)) {
                                this.companyNameEWOptions.push(cang1)
                              }
                              this.myCompanyCustomer = this.weighingList.contractManagement.buyer
                          }
                          
                          this.isShowPrintType = true
                        }else{
                          this.isShowPrintType = true
                        }
                      
                    })
                  if (this.reader) {
                    this.reader.cancel()
                  }
                  // 	this.$notify.success({
                  // 	title: '成功',
                  // 	message: '提交成功',
                  // })
                  this.$notify({
                    title: '成功',
                    message: '提交成功',
                    type: 'success',
                  })
                  this.inspect = JSON.parse(JSON.stringify(this.weighingList))

                  // this.isShowPrint = true
                  this.weighingList = {
                    grossWeight: 0,
                    selfLoading: 0,
                    tare: 0,
                    tips: '',
                    // contractNo:'',
                    // inOutTaskNo:'',
                    buckleMiscellaneous: 0,
                    netWeight: 0,
                    receivableWeighingFee: '',
                    warehouseInOutDetail: {
                      grade: '',
                      imperfectGrain: '',
                      impurity: '',
                      jiaorenli: '',
                      bulkDensity: '',
                      mildewGrain: '',
                    },
                    qualityInspectionManagement: {
                      boxNo: '暂无',
                      boxNoOther: '暂无',
                      titleNo: '暂无',
                      titleNoOther: '暂无',
                    },
                  }
                  this.getList()
                })
              // addstorageputList(weighingList1)
              //   .toPromise()
              //   .then((response) => {
              //     this.weighingList.grossWeight =
              //       this.weighingList.grossWeight * 1000
              //     this.weighingList.tare = this.weighingList.tare * 1000
              //     this.weighingList.netWeight =
              //       this.weighingList.netWeight * 1000
              //     this.weighingList.buckleMiscellaneous =
              //       this.weighingList.buckleMiscellaneous * 1000
              //     this.weighingList.warehouseInOutId = response
              //     grossWeight(this.weighingList)
              //       .toPromise()
              //       .then((response) => {
              //         getweighing({
              //             id: response
              //           })
              //           .toPromise()
              //           .then((response) => {
              //             this.weighingList = response
              //             this.inspect = JSON.parse(
              //               JSON.stringify(this.weighingList)
              //             )
              //             this.isShowPrint = true
              //           })
              //         if (this.reader) {
              //           this.reader.cancel()
              //         }
              //         // 	this.$notify.success({
              //         // 	title: '成功',
              //         // 	message: '提交成功',
              //         // })
              //         this.$notify({
              //           title: '成功',
              //           message: '提交成功',
              //           type: 'success',
              //         })
              //         this.inspect = JSON.parse(JSON.stringify(this.weighingList))

              //         this.isShowPrint = true
              //         this.weighingList = {
              //           grossWeight: 0,
              //           selfLoading: 0,
              //           tare: 0,
              //           tips: '',
              //           // contractNo:'',
              //           // inOutTaskNo:'',
              //           buckleMiscellaneous: 0,
              //           netWeight: 0,
              //           receivableWeighingFee: '',
              //           warehouseInOutDetail: {
              //             grade: '',
              //             imperfectGrain: '',
              //             impurity: '',
              //             jiaorenli: '',
              //             bulkDensity: '',
              //             mildewGrain: '',
              //           },
              //           qualityInspectionManagement: {
              //             boxNo: '暂无',
              //             boxNoOther: '暂无',
              //             titleNo: '暂无',
              //             titleNoOther: '暂无',
              //           },
              //         }
              //         this.getList()
              //       })
              //   })
              //   .catch((response) => {})
            }
          })
          .catch(() => {
            return false
          })
      },
      carNoTypeChange() {
        this.carjudge = !this.carjudge
        if (this.carjudge) {
          this.weighingList.selfLoading = '1'
          this.carChange1 = '识别下拉'
        } else {
          this.weighingList.selfLoading = '0'
          this.carChange1 = '手动填写'
        }
      },
      tabClick(val) {
        this.weighingList = {
          grossWeight: '',
          tare: '',
          tips: '',
          buckleMiscellaneous: 0,
          netWeight: 0,
          receivableWeighingFee: '',
          warehouseInOutDetail: {
            grade: '',
            imperfectGrain: '',
            impurity: '',
            jiaorenli: '',
            bulkDensity: '',
            mildewGrain: '',
          },
          qualityInspectionManagement: {
            boxNo: '暂无',
            boxNoOther: '暂无',
            titleNo: '暂无',
            titleNoOther: '暂无',
          },
        }
        this.index = val
        // this.disabled=true
        if (val == 0) {
          this.statusType = '3'
          this.information = '皮重'
          this.tpyeNo = '1'
          this.recheck1 = false
        } else {
          this.statusType = 3
          this.tpyeNo = '2'
          this.information = '毛重'
          this.recheck1 = true
        }
        this.getList()
      },
      warehouseNameChange(e) {
        for (let i = 0; i < this.warehouseList.length; i++) {
          if (this.warehouseList[i].value == e) {
            this.warehouseId = this.warehouseList[i].warehouseId
            // this.warehouseCount = this.warehouseList[i].ouCount
          }
        }
        for (let i = 0; i < this.warehouseList1.length; i++) {
          if (this.warehouseList1[i].warehouseName == e) {
            localStorage.setItem(
              'houseSelfCollect_house1',
              JSON.stringify({
                No: this.warehouseList1[i].commonWarehouseNo,
                allowEdit: this.warehouseList1[i].allowEdit,
                value: this.warehouseList1[i].warehouseName,
                count: this.warehouseList1[i].count,
                warehouseId: this.warehouseList1[i].id,
              })
            )
            if (this.warehouseList1[i].allowEdit == 1) {
              this.disabled = false
            } else {
              this.disabled = true
            }
            this.positionInfos = this.warehouseList1[i].positionInfos
            this.warehouseCount = this.warehouseList1[i].outCount
            this.warehouseNo = this.warehouseList1[i].commonWarehouseNo
            this.warehouseType = this.warehouseList1[i].warehouseType
          }
        }
        this.getList()
        this.weighingList = {
          grossWeight: 0,
          selfLoading: 0,
          tare: 0,
          tips: '',
          // contractNo:'',
          // inOutTaskNo:'',
          buckleMiscellaneous: 0,
          netWeight: 0,
          receivableWeighingFee: '',
          warehouseInOutDetail: {
            grade: '',
            imperfectGrain: '',
            impurity: '',
            jiaorenli: '',
            bulkDensity: '',
            mildewGrain: '',
          },
          qualityInspectionManagement: {
            boxNo: '暂无',
            boxNoOther: '暂无',
            titleNo: '暂无',
            titleNoOther: '暂无',
          },
        }
      },
      // async openPort() {
      // console.log('openPort', navigator)
      // if ('serial' in navigator) {
      //   //   if (!this.$store.state.app.reader) {
      //   // The Web Serial API is supported.
      //   console.log('the Web Serial API is supported.')
      //   console.log(this.param)
      //   const port = await navigator.serial.requestPort()
      //   await port.open({
      //     baudRate: this.param,
      //   }) // set baud rate
      //   this.reader = port.readable.getReader()
      //   console.log('beforeReader', port)
      //   console.log('beforeReader', this.reader)
      //   this.$store.dispatch('app/setReader', this.reader)
      //   //   } else {
      //   //     console.log('afterport', this.$store.state.app.reader)
      //   //     this.reader = this.$store.state.app.reader
      //   //   }
      //   // 监听来自串行设备的数据
      //   while (true) {
      //     const {
      //       value,
      //       done
      //     } = await this.reader.read()
      //     // console.log("value",value);
      //     if (done) {
      //       // 允许稍后关闭串口。
      //       this.reader.releaseLock()
      //       break
      //     }
      //     var result = ''
      //     //2。获取16进制字符串
      //     // var receData = HexConvert.ByteToString(value);
      //     // console.log("receData",receData);
      //     var flag = false
      //     // for(var i=0;i<value.length;i++){
      //     // 	var tmp = String.fromCharCode(value[i])
      //     // 	if(tmp == '+'){
      //     // 	flag = true
      //     // 	}
      //     // 	if(flag && result.length <6 && tmp != '+'){
      //     // 	result += tmp
      //     // 	}
      //     // }
      //     // if(this.tpyeNo != 2){
      //     // 	this.weighingList.grossWeight = parseInt(result)
      //     // }
      //     // else{
      //     // 	this.weighingList.tare = parseInt(result)
      //     // }
      //     if (
      //       (this.warehouseName &&
      //         (this.warehouseName == '山东诸城迈饶库' ||
      //           this.warehouseName == '克东千红库')) ||
      //       this.warehouseName == '鲅鱼圈祥腾库' ||
      //       this.warehouseName == '哈尔滨依兰库' ||
      //       this.warehouseName == '龙江金信库'
      //     ) {
      //       for (var i = 0; i < value.length; i++) {
      //         var tmp = String.fromCharCode(value[i])
      //         if (tmp == '+') {
      //           flag = true
      //         }
      //         if (flag && result.length < 6 && tmp != '+') {
      //           result += tmp
      //         }
      //       }
      //       if (this.tpyeNo != 2) {
      //         if (parseInt(result) || parseInt(result) == 0) {
      //           this.weighingList.weight = parseInt(result)
      //         }
      //       } else {
      //         if (parseInt(result) || parseInt(result) == 0) {
      //           this.weighingList.weight = parseInt(result)
      //         }
      //       }
      //     } else if (
      //       this.warehouseName &&
      //       (this.warehouseName == '顺诚粮库' ||
      //         this.warehouseName == '鲅鱼圈金信库')
      //     ) {
      //       for (var i = value.length - 1; i >= 0; i--) {
      //         var tmp = String.fromCharCode(value[i])
      //         console.log(tmp)
      //         if (String.fromCharCode(value[0]) == '.') {
      //           flag = true
      //         }
      //         if (flag && result.length < 9 && tmp != '=' && tmp != '.') {
      //           result += tmp
      //         }
      //       }
      //       if (this.tpyeNo != 2) {
      //         if (parseInt(result) || parseInt(result) == 0) {
      //           this.weighingList.weight = parseInt(result)
      //         }
      //       } else {
      //         if (parseInt(result) || parseInt(result) == 0) {
      //           this.weighingList.weight = parseInt(result)
      //         }
      //       }
      //     } else {
      //       for (var i = 0; i < value.length; i++) {
      //         var tmp = String.fromCharCode(value[i])
      //         if (value[0] != 49 && value[0] != 2) {
      //           break
      //         }
      //         if (tmp == String.fromCharCode(32)) {
      //           flag = true
      //         }
      //         if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
      //           // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
      //           // 	continue
      //           // }
      //           // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
      //           // 	continue
      //           // }
      //           result += tmp
      //         }
      //       }
      //       if (this.tpyeNo != 2) {
      //         if (parseInt(result) || parseInt(result) == 0) {
      //           this.weighingList.weight = parseInt(result) * 100
      //         }
      //       } else {
      //         if (parseInt(result) || parseInt(result) == 0) {
      //           this.weighingList.weight = parseInt(result) * 100
      //         }
      //       }
      //     }
      //     // setTimeout(1000)
      //     // value 是一个 Uint8Array
      //   }
      //   await port.close()
      // } else {
      //   console.log('the Web Serial API is not supported.', navigator)
      // }
      // },
      find() {
        this.getList()
      },
      calculation() {
        if (this.weighingList.grossWeight && this.weighingList.tare) {
          let count = 0
          this.weighingList.netWeight =
            this.weighingList.grossWeight -
            this.weighingList.tare -
            Number(
              this.weighingList.buckleMiscellaneous ?
              this.weighingList.buckleMiscellaneous :
              0
            )
        }
      },
      carChange(e) {
        for (let i = 0; i < this.tranCarInfoList.length; i++) {
          if (this.tranCarInfoList[i].carNo == this.weighingList.carNo) {
            this.weighingList.carNumber = this.tranCarInfoList[i].carNo
            this.weighingList.tranCarNo = this.tranCarInfoList[i].tranCarNo
            this.weighingList.freight = this.tranCarInfoList[i].tranPrice
            this.weighingList.carId = this.tranCarInfoList[i].id
          }
        }
      },
      fleetNameChange(e){
        console.log(e,this.fleetNameList)
        if(e=='非车队'){
          this.carjudge=false
          this.weighingList.selfLoading = '0'
          this.carChange1 = '手动填写'
        }else{
          for (let i = 0; i < this.fleetNameList.length; i++) {
            if (this.fleetNameList[i].carNo == this.weighingList.fleetName) {
              this.weighingList.freight = this.fleetNameList[i].tranPrice
              this.carjudge=true
              if (this.carjudge) {
                this.weighingList.selfLoading = '1'
                this.carChange1 = '识别下拉'
              } else {
                this.weighingList.selfLoading = '0'
                this.carChange1 = '手动填写'
              }
              this.$forceUpdate()
            }
          }
        }
        
      },
      // 获取当前年月日
      getTime() {
        var date = new Date()
        var mouth = date.getMonth() + 1
        var day = date.getDate()
        if (mouth < 10) {
          mouth = '0' + mouth
        }
        if (day < 10) {
          day = '0' + day
        }
        return date.getFullYear() + mouth + day
      },
      contractNoChange(e) {
        
        this.weighingList={
          grossWeight: '',
          tare: '',
          buckleMiscellaneous: 0,
          netWeight: 0,
          weight: '',
          tips: '',
          carNo:'',
          // contractNo:'',
          // inOutTaskNo:'',
          receivableWeighingFee: '',
          warehouseInOutDetail: {
            grade: '',
            imperfectGrain: '',
            impurity: '',
            jiaorenli: '',
            bulkDensity: '',
            mildewGrain: '',
          },
          qualityInspectionManagement: {
            boxNo: '暂无',
            boxNoOther: '暂无',
            titleNo: '暂无',
            titleNoOther: '暂无',
          },
          inOutDate: ''
        }
        this.getNowTime()
        this.weighingList.inOutTaskNo=e
        this.warehouseCount = this.warehouseCount1
        var data = null
       
        for (let i = 0; i < this.taskNolist.length; i++) {
          if (this.taskNolist[i].inOutTaskNo == e) {
            this.weighingList.donecount=this.taskNolist[i].completedQuantity+'/'+this.taskNolist[i].weight
            //  this.weighingList.number = this.taskNolist[i].inOutTaskNo
            // this.warehouseCount = '000' + (Number(this.warehouseCount) + 1)
            this.weighingList.numberLetter = 'XSCK'
            this.weighingList.goodsName = this.taskNolist[i].goodsName
            this.weighingList.tips = this.taskNolist[i].businessDescribe
            data = this.taskNolist[i]
            console.log(data,11111111111)
            if(this.taskNolist[i].inOutType=='移库出库'){ 
              
              this.weighingList.contractNo = this.taskNolist[i].moveTaskNo
              gettask({contractNo:this.taskNolist[i].moveTaskNo,compId:localStorage.getItem('ws-pf_compId')}).toPromise().then((response) => {
                // console.log(response)
                if(!response){
                  this.$message({
                      message: '联系内勤创建运输任务',
                      type: 'warning',
                      
                    });
                }
              })
              this.carjudge=false
              
              if(this.warehouseType == '1'){
                this.recheckPrice = true
              }else{
                this.recheckPrice = false
              }
              if (this.carjudge) {
                this.weighingList.selfLoading = '1'
                this.carChange1 = '识别下拉'
              } else {
                this.weighingList.selfLoading = '0'
                this.carChange1 = '手动填写'
              }
            }else{
              this.carjudge=true
              if (this.taskNolist[i].contractNo) {
                // console.log(this.taskNolist[i])
                this.weighingList.contractNo = this.taskNolist[i].contractNo
              } else {
                this.weighingList.contractNo = this.taskNolist[i].moveTaskNo
              }
              this.recheckPrice = false
            }
            if (this.carjudge) {
                this.weighingList.selfLoading = '1'
                this.carChange1 = '识别下拉'
              } else {
                this.weighingList.selfLoading = '0'
                this.carChange1 = '手动填写'
              }
          }
        }
        // if (!data) return
        for (var i = 0; i < this.outContractNo.length; i++) {
          if (this.outContractNo[i].contractNo == this.weighingList.contractNo) {
            this.shipInfoList=this.outContractNo[i].shipInfoList
            this.weighingList.goodsName = this.outContractNo[i].goodsName
            if (this.weighingList.goodsName == '玉米（潮粮）') {
              this.weighingList.type = '潮粮'
            } else {
              this.weighingList.type = '干粮'
            }
            console.log(this.outContractNo[i],12222)
            // this.weighingList.contractPrice = this.outContractNo[i].unitContractPrice
            this.$set(this.weighingList,'contractPrice',this.outContractNo[i].unitContractPrice)
            this.$set(this.weighingList,'customer',this.outContractNo[i].buyer)
            this.weighingList.goodsNameKey = this.outContractNo[i].goodsNameKey
            this.weighingList.grade = this.outContractNo[i].grade
            this.weighingList.inOutType = this.outContractNo[i].inOutType
            if (this.outContractNo[i].inOutType == '销售出库') {
              if(this.outContractNo[i].deliverType==1){
                gettask({contractNo:this.outContractNo[i].contractNo,compId:localStorage.getItem('ws-pf_compId')}).toPromise().then((response) => {
                  // console.log(response)
                  if(!response){
                    this.$message({
                        message: '联系内勤创建运输任务',
                        type: 'warning',
                        
                      });
                  }
                })
              }
              
              if(this.outContractNo[i].priceType=='随行就市'){
                this.priceedit=false
              }else if(this.outContractNo[i].priceType=='定价销售'){
                this.priceedit=false
              }{

              }
              this.warehouseCount = '000' + (Number(this.warehouseCount) + 1)
              this.weighingList.numberLetter = 'XSCK'
              this.weighingList.buyer = this.outContractNo[i].buyer
              this.weighingList.seller = localStorage.getItem('ws-pf_compName')
              if (!this.outContractNo[i].unitContractPrice) {
                this.weighingList.tips = '买方' + this.outContractNo[i].buyer
              } else {
                this.weighingList.tips =
                  '买方' +
                  this.outContractNo[i].buyer +
                  '（ ' +
                  this.outContractNo[i].unitContractPrice +
                  '元/吨）'
              }
              this.weighingList.inOutTypeKey = 1
            } else if (this.outContractNo[i].inOutType == '移库出库') {
              for (let q = 0; q < this.warehouseList1.length; q++) {
                if (this.warehouseList1[q].warehouseName == this.warehouseName) {
                  if(this.warehouseList1[q].warehouseType==2&&this.warehouseList1[q].createType==1&&this.outContractNo[i].priceType=='定价采购'){
                    // console.log(this.outContractNo[i].contractPrice,11111111111)
                    this.priceedit=true
                    this.weighingList.contractPrice=this.outContractNo[i].contractPrice
                  }
                  if(this.warehouseList1[q].warehouseType==2&&this.warehouseList1[q].createType==1&&this.outContractNo[i].priceType=='随行就市'){
                    this.priceedit=false
                  }
                   if(this.warehouseList1[q].warehouseType==1){
                     this.priceedit=true
                   }
                }
              }
              this.weighingList.priceType=this.outContractNo[i].priceType
              this.warehouseCount = '000' + (Number(this.warehouseCount) + 1)
              this.weighingList.numberLetter = 'YKCK'

              this.weighingList.buyer = this.outContractNo[i].receiveWarehouse
              this.weighingList.seller = this.outContractNo[i].sendWarehouse
              this.weighingList.goodsName = data == null?'玉米':data.goodsName
              this.weighingList.goodsNameKey = data == null?'1':data.goodsNameKey
              this.weighingList.grade = data == null?'二等品':data.grade
              if (this.outContractNo[i].unitContractPrice) {
                this.weighingList.tips =
                  '入货库' +
                  data == null?'':data.receiveWarehouse +
                  '（ ' +
                  this.outContractNo[i].unitContractPrice +
                  '元/吨）'
              } else {
                this.weighingList.tips = '入货库' + data == null?'':data.receiveWarehouse
              }
              this.weighingList.inOutTypeKey = 3
            } else if (this.outContractNo[i].inOutType == '暂存入库') {
              this.weighingList.inOutTypeKey = 4
            } else if (this.outContractNo[i].inOutType == '贸易服务出库') {
              this.weighingList.inOutTypeKey = 5
            } else if (this.outContractNo[i].inOutType == '采购出库') {
              this.weighingList.inOutTypeKey = 6
            }
            if (this.outContractNo[i].deliverType == '1') {
              this.carjudge = false
              
            } else {
              this.carjudge = true
            }
            if (this.outContractNo[i].tranCarInfoList) {
              this.options2 = this.outContractNo[i].tranCarInfoList
              this.tranCarInfoList = this.outContractNo[i].tranCarInfoList
              this.carjudge = false

            }else{
              this.options2 = []
              this.tranCarInfoList = []
            }
            if (this.outContractNo[i].tranCarInfoList1) {
              this.fleetNameList = this.outContractNo[i].tranCarInfoList1
            }else{
              this.fleetNameList = []
            }
            if (this.carjudge) {
                this.weighingList.selfLoading = '1'
                this.carChange1 = '识别下拉'
              } else {
                this.weighingList.selfLoading = '0'
                this.carChange1 = '手动填写'
              }
          }
        }
        
      },
      selectWarehouse() {
        selectWarehouseSelf({
            compId: localStorage.getItem('ws-pf_compId'),
          })
          .toPromise()
          .then((response) => {
            this.warehouseList = []
            for (let i = 0; i < response.length; i++) {
              this.warehouseList.push({
                value: response[i].warehouseName,
                warehouseId: response[i].id,
              })
            }
            let _wareHouse = localStorage.getItem('houseSelfCollect_house1')
            _wareHouse = JSON.parse(_wareHouse)
            for (let i = 0; i < response.length; i++) {
              if (_wareHouse && response[i].warehouseName == _wareHouse.value) {
                this.warehouseName = response[i].warehouseName
                this.warehouseId = response[i].id
                this.positionInfos = response[i].positionInfos
                this.warehouseCount = response[i].outCount
                this.warehouseCount1 = response[i].outCount
                this.warehouseNo = response[i].commonWarehouseNo
                this.warehouseType = response[i].warehouseType
                if (response[i].allowEdit == 1) {
                  this.disabled = false
                } else {
                  this.disabled = true
                }
              }
              if (!_wareHouse) {
                this.warehouseName = this.warehouseList[0].value
                this.warehouseId = this.warehouseList[0].warehouseId
                this.positionInfos = response[0].positionInfos
                this.warehouseCount = response[0].outCount
                this.warehouseCount1 = response[0].outCount
                this.warehouseNo = response[0].commonWarehouseNo
                this.warehouseType = response[0].warehouseType
                if (response[0].allowEdit == 1) {
                  this.disabled = false
                } else {
                  this.disabled = true
                }
                console.log()
              }
            }
            this.warehouseList1 = response

            this.deptBudgetList.warehouseName = this.warehouseName
            this.getList()
          })
      },
      getList() {
        pullDown({
        	constId: 'CON6',
        })
        .toPromise()
        .then((response) => {
        	this.storageType = response
        })
        getReceiptTaskNo({
            flag: 1,
            warehouseName: this.warehouseName,
            agentKey: localStorage.getItem('ws-pf_userId'),
          })
          .toPromise()
          .then((response) => {
            this.taskNolist = response
          })
        //合同编号
        xialaNo({
            compId: localStorage.getItem('ws-pf_compId'),
            loadingstatus: 1,
            flag: 5,
          })
          .toPromise()
          .then((response) => {
            this.outContractNo = response
          })
        // this.refreshClick(1)
        getweighingList({
            compId: localStorage.getItem('ws-pf_compId'),
            currentPage: this.currentPage,
            pageSize: this.pageSize,
            searchKeyWord: this.searchKeyWord,
            warehouseName: this.warehouseName,
            managementType: 3,
            statusType: this.statusType,
          })
          .toPromise()
          .then((response) => {
            this.deliveryList = response.records
            this.deptBudgetTotal = response.total
            for (var i = 0; i < response.records.length; i++) {
              if (response.records[i].addressUrl != null) {
                if (response.records[i].addressUrl) {
                  response.records[i].addressUrlArray =
                    response.records[i].addressUrl.split(',')
                }
              } else {
                response.records[i].addressUrlArray = []
              }
            }
            for (var i = 0; i < response.records.length; i++) {
              var arr = new Array()
              this.addressUrls[i] = new Array()
              if (this.weighingList.records[i].addressUrl != null) {
                arr = this.weighingList.records[i].addressUrl.split(',')
                this.addressUrls[i] = arr
              }
            }
          })
          .catch((response) => {})
      },
    },
  }
</script>
<style lang="scss" scoped>
  .center {
    background: #fff;
  }

  .size_css {
    width: 540px;
    min-width: 540px;
    overflow-x: scroll;
    position: relative;
  }

  .ws-info-table {
    border: none;
  }

  .base_header_layout {
    padding: 10px;
    margin-bottom: 10px;
  }

  .ws-info-table .el-form-item {
    width: 50%;
    border: none;
  }

  .formItem {
    width: 100%;
    display: inline;
  }

  .ws-info-table {
    border: none;
  }

  .ws-info-table .el-form-item {
    width: 100%;
    border: none;
  }

  /deep/.ws-info-table .el-form-item .el-form-item__label {
    width: 30%;
    text-align: center;
    background: #ffffff;
    color: #8890b1;
  }

  /deep/.ws-info-table .el-form-item .el-form-item__content {
    border: none;
  }

  /deep/.el-textarea__inner {
    width: 92%;
  }

  /deep/.ws-info-table .el-form-item.rememo .el-form-item__content {
    height: 76px;
  }

  .title {
    font-size: 16px;
    font-weight: 600;
    margin: 10px;
  }

  .titleup {
    position: relative;
  }

  .title::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 15px;
    background: #8890b1;
    margin-right: 5px;
  }

  .substance {
    background: #ffffff;
    width: 100%;
    border-radius: 4px;
    margin: 0 auto;
    padding-top: 20px;
  }

  /deep/.el-table .el-table__header .cell,
  .el-table .el-table__body .cell {
    text-align: center;
  }

  /deep/.el-table--enable-row-transition .el-table__body td {
    text-align: center;
  }

  .bg-left {
    padding-left: 30px;
  }

  .bg-right {
    padding-right: 10px;
    text-align: right;
  }

  .bg-bottom {
    margin: 15px 0px;
  }

  .titleup {
    position: relative;
  }

  /deep/ .substance .bangdan {
    width: 100%;
    padding-top: 6%;
    padding-bottom: 6%;
  }

  // // .photo2{
  // //   margin-top: 10px;
  // // }
  .el-upload--picture-card {
    background-color: #fbfdff;
    border: 1px dashed #c0ccda;
    border-radius: 6px;
    box-sizing: border-box;
    width: 148px;
    height: 148px;
    line-height: 146px;
    vertical-align: top;
    margin-left: -289px;
  }

  // .titleup::before {
  // 	content: '';
  // 	display: inline-block;
  // 	width: 5px;
  // 	height: 30px;
  // 	background: #5473e8;
  // 	position: absolute;
  // 	left: 0;
  // }

  .but {
    text-align: center;
    margin: 20px auto;
  }

  .stocks {
    position: relative;

    /deep/.el-select>.el-input {
      display: inline-block;
    }

    /deep/>.el-input {
      width: 33.3333%;
    }

    .add,
    .del {
      position: absolute;
      right: -16px;
      transform: translateY(20%);
    }

    .del {
      right: -40px;
    }
  }

  .butCss {
    opacity: 0;
    color: #000;
  }

  .center {
    overflow-y: scroll;
  }

  .el-button--success.is-plain {
    border: 1px solid #2aff7c;
    background: black;
    color: #2aff7c;
    width: 50%;
  }

  .call-show {
    width: 540px;
  }

  .top {
    background: black;
    color: #2aff7c;
    font-size: 32px;
    text-align: right;
    padding: 0 10px 0 20px;
    border-radius: 10px;
    margin: 0 20px 20px 21px;
    position: absolute;
    top: 140px;
    width: 465px;

    .zujian {
      position: relative;
    }

    .kg-style {
      font-size: 30px;
      color: red;
    }

    .confirmInfo {
      display: flex;
      // line-height: 90px;

      .car-type {
        text-align: left;
        width: 50%;
        min-width: 200px;
      }

      .car-no {
        width: 50%;
        text-align: right;
      }
    }

    .confirmWeight {
      display: flex;
      align-items: center;

      .titleWeight {
        width: 35%;
        min-width: 200px;
        text-align: left;
        line-height: 90px;
        color: red;
      }

      .weight {
        width: 65%;
        text-align: right;
        color: red;
      }
    }
  }

  .bottom {
    // text-align: center;
    background: white;
    margin: 20px 20px 0 20px;
    // border-radius: 10px;
    padding-bottom: 20px;
    .img1,
    .img2 {
      width: 200px;
      padding: 20px;
    }

    .video-content {
      width: 100%;
    }

    .video1 {
      text-align: center;
    }
  }

  /deep/.title_css .el-dialog__header {
    text-align: center !important;
  }
   .mask {
    background: black;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    z-index: 99;
    opacity: 0.3;
  }

  .print-type-title {
    text-align: center;
    font-size: 18px;
    margin: 20px;
  }

  .bottom-btn {
    display: flex;
    margin-top: 20px;
    justify-content: space-around;
  }

  .print-type-checkbox {
    // padding-left: 20px;
  }

  .print-type {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    width: 440px;
    height: 320px;
    background: white;
    border-radius: 10px;
    z-index: 100;
  }

  /deep/.el-radio-group {
    width: 100%;
    display: flex;
  }

  /deep/.el-radio__label {
    font-size: 20px;
  }

  /deep/.el-radio__inner {
    // background: red;
    height: 20px;
    width: 20px;
  }

  .label-width {
    width: 100%;
    text-align: center;
    font-size: 20px;
  }

  .show-excel {
    opacity: 0;
  }

  /deep/.base_header_layout .find.el-button--primary {
    width: 30px;
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
  }

  /deep/.base_header_layout .findinput input {
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px;
  }

  .ew-print {
    padding: 0 20px;
    margin-top: 10px;
    margin-bottom: 15px;

    // display: flex;
    // justify-content: space-between;
    // align-content: center;
    .row {
      display: flex;
      margin-top: 10px;
      align-items: center;
    }
  }

  .sh-address {
    display: flex;
  }

  .print-type-ew {
    display: flex;
    justify-content: space-between;
    padding: 0 20px;

    /deep/.el-radio__label {
      font-size: 14px;
    }

    margin-top: 10px;
  }

  /deep/.el-table .cell {
    text-align: center;
  }

  .shdw-style {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    margin-top: 20px;
  }

 

  // /deep/.el-table__body .current-row td:first-child {
  //   border-left: 4px solid #2aff7c;
  //   // border-bottom: 1px solid #2aff7c ;
  // }

  // /deep/.el-table__body .current-row td:last-child {
  //   border-right: 4px solid #2aff7c;
  //   // border-bottom: 1px solid #2aff7c ;
  // }
</style>