<!--仓库管理-->
<template>
  <div class="container">
    <!-- 表格 -->
    <!-- <div class="top_form" v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.kan`">
      <div style='position:relative;' class="title">
        <span style="font-size:18px;font-weight: 600;margin-left:20px">今日储量明细</span><span style="color:#8890B1;font-size:16px">（{{dateTime}}）</span>
        <ws-button type="primary" v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.kan`" @click="handleall()" style="margin-left:20px;position:absolute;right:10px;top:50%;transform: translateY(-50%);">库存明细</ws-button>
        </div>
      <el-table :data="tableData" style="width: 100%;margin-top:20px">
      <el-table-column :prop="item" :label="item" show-overflow-tooltip v-for="(item, index) in tableHeader" :key="index"></el-table-column>
    </el-table>
    </div> -->
    <div class="flex">
      <div class="left" style="width:35%;">
        <el-form
          class="position"
          ref="deptBudgetList"
          :rules="rules"
          :model="deptBudgetList"
        >
          <div class="title"><span class="cangInfo">仓库信息</span></div>
          <!-- 仓储部负责人 -->
          <!-- <el-form-item label-width="120px" label="仓储部负责人" span="1" prop="acceptanceMethod">
             <el-input v-model="responsible" placeholder="暂无" maxlength="100" size="small" disabled/>
          </el-form-item> -->
          <!--仓库名称-->
          <el-form-item
            label-width="120px"
            label="仓库名"
            span="1"
            prop="warehouseName"
          >
            <el-select
              v-model="warehouseInfo.warehouseName"
              placeholder="请选择仓库名"
              filterable
              clearable
              @change="selectstaff"
              :filter-method="warehouseQuery"
            >
              <el-option
                v-for="item in warehouseXiaLa"
                :key="item.warehouseName"
                :label="item.warehouseName"
                :value="item.warehouseName"
              />
            </el-select>
          </el-form-item>
          <!--仓库所在地-->
          <el-form-item
            label-width="120px"
            label="仓库所在地"
            span="1"
            prop="acceptanceMethod"
          >
            <el-input
              v-model="warehouseInfo.warehouseLocation"
              placeholder="暂无"
              maxlength="100"
              size="small"
              disabled
            />
          </el-form-item>

          <!--详细地址-->
          <el-form-item
            label-width="120px"
            label="详细地址"
            span="1"
            prop="detailedAddress"
            class="readonly"
          >
            <el-input
              v-model="warehouseInfo.detailedAddress"
              placeholder="暂无"
              maxlength="100"
              size="small"
              disabled
            />
          </el-form-item>

          <!--总储量（吨）-->
          <el-form-item
            label-width="120px"
            label="最大容量（吨）"
            span="1"
            prop="settlementMethod"
            v-if="warehouseType == 1"
          >
            <el-input
              :readonly="true"
              v-model="warehouseInfo.maxReserves"
              maxlength="100"
              placeholder="暂无"
              size="small"
              disabled
            />
          </el-form-item>
          <!--负责人-->
          <el-form-item
            label-width="120px"
            label="负责人"
            span="1"
            prop="personCharge"
          >
            <el-input
              v-model="warehouseInfo.personCharge"
              placeholder="暂无"
              maxlength="100"
              size="small"
              disabled
            />
          </el-form-item>
          <!--其他负责人-->
          <el-form-item
            label-width="120px"
            label="其他驻库人员"
            span="1"
            prop="otherPersonCharge"
          >
            <!-- <el-select v-model="WarehouseInfo.otherPersonPhone" placeholder="暂无" @change="selectstaffOther" multiple filterable clearable collapse-tags disabled> -->
            <el-input
              v-model="warehouseInfo.otherPersonCharge"
              placeholder="暂无"
              maxlength="100"
              size="small"
              disabled
            />
          </el-form-item>
        </el-form>
      </div>
      <div class="right" style="width:70%">
        <div class="position">
          <div class="title"><span class="cangInfo">仓库储量</span></div>
          <div class="weight">
            <el-switch
              style="display: block"
              v-model="value"
              active-color="#13ce66"
              inactive-color="#409EFF"
              active-text="折算纯重"
              inactive-text="实际重量"
              active-value="1"
              inactive-value="0"
              @change="changeWeight"
            ></el-switch>
            <!-- <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.view` " @click="changeWeight(2)">实际重量</ws-button>
            <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.view` " @click="changeWeight(1)">折算纯重</ws-button> -->
          </div>
          <div class="color">
            <div v-for="(item, i) in totalReserves" :key="i" class="color_for">
              <div
                :style="{ background: lineColor[i] }"
                class="color_item"
              ></div>
              <div class="color_goodsName">{{ item.goodsName }}</div>
            </div>
          </div>
          <div
            v-for="(item, index) in totalReserves"
            :key="index"
            class="reservesInfo"
          >
            <div class="reservesInfo_item" v-if="warehouseType == '1'">
              <div class="reservesInfo_GoodsName">{{ item.goodsName }}</div>
              <span class="reservesInfo_Amount"
                >{{ item.stockNum == 0 ? '-' : item.stockNum }}(吨)</span
              ><br />
              <span
                v-if="item.stockNum && item.cost"
                class="reservesInfo_Amount"
                >{{ item.cost == 0 ? '-' : item.cost }}(元/吨)</span
              >
              <span v-else class="reservesInfo_Amount"
                >{{
                  item.conversionCost == 0 ? '-' : item.conversionCost
                }}(元/吨)</span
              ><br />
              <div style="display:grid">
                <span
                  v-if="item.cargoWeight && item.cargoWeight != 0"
                  class="reservesInfo_Amount"
                  >含转入:{{ item.cargoWeight }}(吨)</span
                >
                <span
                  v-if="item.redemptionWeight && item.redemptionWeight != 0"
                  class="reservesInfo_Amount"
                  >待赎回:{{ item.redemptionWeight }}(吨)</span
                >
              </div>
            </div>
            <div class="reservesInfo_item" v-if="warehouseType == '2'">
              <div class="reservesInfo_GoodsName">{{ item.goodsName }}(吨)</div>
              <span class="reservesInfo_Amount">{{
                item.surplus == 0 ? '-' : item.surplus
              }}</span>
            </div>
          </div>
          <div
            ref="myEchart7"
            style="height: 250px; width:96%;border-radius: 4px; border:1px solid #D8DCE6; padding: 10px;"
            class="column"
          ></div>
        </div>
      </div>
    </div>
    <div class="position">
      <div class="title">
        <span style="font-size:18px;font-weight: 600;margin-left:20px"
          >当期储量</span
        >
      </div>
      <ws-button
        type="primary"
        @click="handleAdd()"
        v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.add`"
        style="margin-left:20px"
        >添加</ws-button
      >
      <!-- <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.view` " @click="handleLook()">查看</ws-button> -->
      <ws-button
        v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.edit`"
        @click="handleEdit()"
        >编辑</ws-button
      >
      <!-- <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.delete`" @click="handleDelete()">删除</ws-button> -->
      <ws-button
        v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.view`"
        @click="record()"
        >记录</ws-button
      >
      <!-- <ws-button v-if="warehouseType == '1'" v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.view`" @click="loss()">盘库</ws-button> -->
      <!-- <ws-button v-if="warehouseInfo.clearStatusFlag == 1 && warehouseType == '2'" @click="clearance()">清库</ws-button> -->
      <!-- <ws-button v-if="warehouseInfo.clearStatusFlag == 3 && warehouseType == '2'" disabled> 已清库</ws-button> -->
      <!-- createType 1手动创建 2 自动创建 -->
      <!-- <ws-button v-if='warehouseInfo.createType==1' v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.delete`" @click="indialog = true">入库量</ws-button> -->
      <!-- <ws-button v-if='list.length>0' @click="handlTask()">任务</ws-button> -->
      <ws-button
        v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.add`"
        @click="outData(1)"
        >导出</ws-button
      >
      <ws-button @click="outData(2)">打印</ws-button>
      <!-- <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.kan`" @click="exportHistoricalData()">导出历史库存记录</ws-button> -->
      <ws-button
        @click="transformation()"
        v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.view`"
        >折转</ws-button
      >
      <!-- <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.kan`" @click="handleall()">全部仓库</ws-button> -->
      <!-- <ws-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.kan`" @click="handleMintor()">查看监控</ws-button> -->
      <ws-button @click="dryClick()">烘干入库</ws-button>
      <!-- <ws-button @click="materialInOut()">物料出入库</ws-button> -->
      <el-table
        ref="table"
        show-summary
        :summary-method="getSummaries"
        class="wenzi setUp_css"
        :data="warehouseList"
        style="width: 100%; margin-top: 20px"
        height="calc(100% - 45px)"
        v-if="warehouseType == '1'"
      >
        <el-table-column prop="warehouseName" label="仓库名"> </el-table-column>
        <el-table-column prop="binNumber" label="仓位编号"> </el-table-column>
        <el-table-column prop="capacity" label="容量（吨）">
          <template slot-scope="scope">
            <div
              v-if="scope.row.capacity != 'null' && scope.row.capacity != null"
            >
              {{ scope.row.capacity }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="货名">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.goodsName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="入库量（吨）">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.inNetWeight }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="出库量（吨）">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{
                item.outNetWeight == 0
                  ? '0'
                  : Number(item.outNetWeight).toFixed(3)
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="应余量（吨）">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.storage }}
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 临时库 -->
      <el-table
        class="wenzi"
        :data="warehouseList"
        style="width: 100%; margin-top: 20px"
        height="calc(100% - 45px)"
        v-if="warehouseType == '2'"
      >
        <el-table-column prop="warehouseName" label="仓库名"> </el-table-column>
        <el-table-column prop="binNumber" label="仓位编号"> </el-table-column>
        <el-table-column prop="capacity" label="容量（吨）">
          <template slot-scope="scope">
            <div
              v-if="scope.row.capacity != 'null' && scope.row.capacity != null"
            >
              {{ scope.row.capacity }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="货名">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.goodsName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="入库量（吨）">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.inNetWeight }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="出库量（吨）">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.outNetWeight }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="应余量（吨）">
          <template slot-scope="scope">
            <div
              style="height: 24px"
              v-for="(item, i) in scope.row.warehouseNumViewList"
              :key="i"
            >
              {{ item.surplus }}
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- <div class="map">
      <div class="title">
        <span style="font-size:18px;font-weight: 600;margin-left:20px">{{
          maptitle
        }}</span>
      </div>
      <div class="map_switch">
        <div :class="btnCss1" @click="mapChange(1)" v-if="warehouseType == '1'">
          监控
        </div>
        <div :class="btnCss2" @click="mapChange(2)">定位</div>
      </div>
      <div
        class="map-item"
        v-if="mapshow && warehousePositioning.lat && warehousePositioning.lng"
      >
        <map-drag
          @marker="marker"
          ref="childMap"
          :isShowaddress="true"
          v-on:addressListen="getAddress"
          v-on:pickedAddress="searchAddress"
          :warehousePositioning="warehousePositioning"
        ></map-drag>
      </div>
      <div v-if="!mapshow && warehouseType == '1'" class="monitor">
        <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> -->
    <el-dialog
      title="修改入库量"
      :visible.sync="indialog"
      width="30%"
      :before-close="handleClose"
      top="35vh"
    >
      <el-form>
        <el-form-item
          label-width="120px"
          label="入库量（吨）"
          span="1"
          prop="acceptanceMethod"
        >
          <el-input
            v-model="inWarehouse"
            placeholder="请输入入库量"
            maxlength="100"
            size="small"
            type="number"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
    <div class="mask" v-show="isShowPrintType"></div>
    <div class="print-type" v-show="isShowPrintType">
      <div class="print-type-content">
        <div class="print-type-title">{{ headerText }}</div>
        <div class="print-type-checkbox">
          <el-form ref="form" label-width="110px">
            <el-form-item label="类型">
              <el-radio-group v-model="parameter.radio">
                <el-radio :label="3">入库记录</el-radio>
                <el-radio :label="2">出库记录</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="起始日期">
              <el-date-picker
                type="datetime"
                @change="startDataChange"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择起始日期"
                v-model="parameter.printStartDate"
                default-time="00:00:00"
              ></el-date-picker>
              <!-- <el-date-picker v-model="value3" type="datetime" placeholder="选择日期时间" default-time="12:00:00"></el-date-picker> -->
            </el-form-item>
            <el-form-item label="截止日期">
              <el-date-picker
                type="datetime"
                @change="endDataChange"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择截止日期"
                v-model="parameter.printEndDate"
                default-time="00:00:00"
              >
              </el-date-picker>
            </el-form-item>
            <!-- <el-form-item label="截止日期1">
              <el-date-picker value-format="timestamp" type="date" placeholder="请选择截止日期" v-model="parameter.endDate1">
              </el-date-picker>
            </el-form-item> -->
            <!--仓库名称-->
            <el-form-item label="仓库名称" span="1" prop="warehouseName">
              <el-select
                @change="warehousechange"
                v-model="parameter.warehouseName"
                placeholder="请选择仓库名称"
                filterable
                clearable
              >
                <el-option
                  v-if="headerText != '打印记录'"
                  key=""
                  label="全部仓库"
                  value="全部仓库"
                />
                <el-option
                  v-for="item in warehouseAllXiaLa"
                  :key="item.warehouseName"
                  :label="item.warehouseName"
                  :value="item.warehouseName"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="仓位编号" span="1" prop="warehouseName">
              <el-select
                v-model="parameter.binNumber"
                placeholder="请选择仓位编号"
                filterable
                clearable
              >
                <el-option
                  v-for="item in typeList"
                  :key="item.id"
                  :label="item.binNumber"
                  :value="item.binNumber"
                />
              </el-select>
            </el-form-item>
            <el-form-item
              v-if="headerText != '导出记录'"
              label="货名"
              span="1"
              prop="warehouseName"
            >
              <el-select
                v-model="parameter.goodsName"
                placeholder="请选择货名"
                filterable
                clearable
              >
                <el-option
                  v-for="item in goodnameList"
                  :key="item.constKey"
                  :label="item.constValue"
                  :value="item.constValue"
                />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="增量比例（%）" v-if="headerText == '打印记录'">
              <el-input placeholder="请输入增量比例" v-model="parameter.proportion" clearable class="proportion_css">
              </el-input>
            </el-form-item> -->
          </el-form>
        </div>
      </div>
      <div class="bottom-btn">
        <el-button @click="submitClick()">确定</el-button>
        <el-button @click="removePrint">取消</el-button>
      </div>
    </div>
    <div class="mask" v-show="isShowPrintType1"></div>
    <div class="print-type" v-show="isShowPrintType1">
      <div class="print-type-content">
        <div class="print-type-title">{{ headerText1 }}</div>
        <div class="print-type-checkbox">
          <el-form ref="form" label-width="110px">
            <el-form-item label="起始日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="请选择起始日期"
                v-model="parameter.startDate"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item label="截止日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="请选择截止日期"
                v-model="parameter.endDate"
              >
              </el-date-picker>
            </el-form-item>
            <!--仓库名称-->
            <el-form-item label="仓库名称" span="1" prop="warehouseName">
              <el-select
                v-model="parameter.warehouseName"
                placeholder="请选择仓库名称"
                filterable
                clearable
              >
                <el-option key="" label="全部仓库" value="全部仓库" />
                <el-option
                  v-for="item in warehouseAllXiaLa"
                  :key="item.warehouseName"
                  :label="item.warehouseName"
                  :value="item.warehouseName"
                />
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div class="bottom-btn">
        <el-button @click="submitClick1()">确定</el-button>
        <el-button @click="removePrint1">取消</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import { packList } from '@/model/contarct/index'
import {
  getList,
  getsponsible,
  clearancee,
  xiala,
  getQualityZhe,
  getQualityReal,
  exportHistoricalInventory,
  postExport,
  addselectinfoList,
  printAdd,
  postExportOut,
  getreserves,
  getResponsible,
  deletewarehouse,
  postInWeight,
  getwarehousNameNew,
  getbintype,
  postExportjynin,
  postExportjynout
} from '@/model/warehouse/index'
import mapDrag from '@/components/mapdrag/warehouseMap'
import { downloadFile } from '@/utils/batchDown'
import { dayjs, EventBus } from 'base-core-lib'
import Pagination from '@/components/Pagination'
import WsUpload from '@/components/WsUpload'

import axios from 'axios'
export default {
  name: 'viewSpareMoney',
  components: {
    WsUpload,
    Pagination,
    mapDrag,
    axios
  },
  watch: {
    vesselId(val) {
      this.getList()
    },
    isShow(val) {
      this.showType = val
    }
  },
  data() {
    return {
      value: '0',
      compName: localStorage.getItem('ws-pf_compName'),
      rules: {},
      options: [],
      StartDate: '',
      compId: localStorage.getItem('ws-pf_compId'),
      deptBudgetList: {},
      dateTime: '',
      list: [],
      warehouseList: [],
      warehouseType: '1',
      totalStorage: 0,
      radio: 0,
      tableHeader: [],
      tableData: [],
      totalReserves: [],
      warehouseXiaLa: [],
      warehouseInfo: {
        warehouseName: ''
      },
      lineColor: [
        '#5878E8',
        '#50CAD4',
        '#FF9F24',
        '#E87C25',
        '#27727B',
        '#FE8463',
        '#9BCA63',
        '#FAD860',
        '#F3A43B',
        '#60C0DD',
        '#D7504B',
        '#C6E579',
        '#F4E001',
        '#F0805A',
        '#26C0C0'
      ],
      warehouseXiaLaCopy: [],
      warehouseAllXiaLa: [],
      responsible: '',
      maptitle: '库点监控',
      btnCss1: 'btn1',
      btnCss2: 'btn',
      mapshow: false,
      indialog: false,
      inWarehouse: '',
      parameter: {
        startDate: '',
        endDate: ''
      },
      EndDate: '',
      isShowPrintType: false, //打印
      headerText: '',
      typeList: [],
      isShowPrintType1: false,
      headerText1: '导出历史库存记录',
      date: {
        year: dayjs().format('YYYY'),
        month: dayjs().format('MM')
      },
      warehousePositioning: {},
      monitorUrl1: '',
      monitorUrl2: '',
      goodnameList: []
    }
  },
  activated() {
    this.tableData = []
    this.getList()
    //  this.$refs.childMap.clearVal()
    this.showType = this.isShow
  },
  methods: {
    startDataChange(e) {
      var d = new Date(e)
      let year = d.getFullYear()
      let month = d.getMonth() + 1
      month = month < 10 ? '0' + month : month
      let date = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
      let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
      let minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
      let seconds = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
      this.parameter.printStartDate =
        year +
        '-' +
        month +
        '-' +
        date +
        ' ' +
        hours +
        ':' +
        minutes +
        ':' +
        seconds
    },
    endDataChange(e) {
      var d = new Date(e)
      let year = d.getFullYear()
      let month = d.getMonth() + 1
      month = month < 10 ? '0' + month : month
      let date = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
      let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
      let minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
      let seconds = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
      this.parameter.printEndDate =
        year +
        '-' +
        month +
        '-' +
        date +
        ' ' +
        hours +
        ':' +
        minutes +
        ':' +
        seconds
    },
    warehousechange(e) {
      for (let i = 0; i < this.warehouseAllXiaLa.length; i++) {
        if (this.warehouseAllXiaLa[i].warehouseName == e) {
          getbintype({ baseId: this.warehouseAllXiaLa[i].id })
            .toPromise()
            .then(response => {
              console.log(response)
              this.typeList = response
            })
        }
      }
    },
    downloadFile(url, fileName) {
      //fileurl文件地址（一般是接口返回） filename文件下载后的名字
      const x = new XMLHttpRequest()
      x.open('GET', url, true)
      x.responseType = 'blob'
      x.onload = function() {
        const url = window.URL.createObjectURL(x.response)
        const a = document.createElement('a')
        a.href = url
        a.download = fileName
        a.click()
        document.body.removeChild(a)
        // 然后移除
      }
      x.send()
    },
    //导出、打印EndDate
    outData(index) {
      if (index == 1) {
        this.headerText = '导出记录'
      } else if (index == 2) {
        this.headerText = '打印记录'
        let now = new Date()
        let tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000)
        var year = tomorrow.getFullYear()
        var month = tomorrow.getMonth() + 1
        var strDate = tomorrow.getDate()
        if (strDate < 10) {
          strDate = '0' + strDate
        }
        var pastdate = new Date()
        this.StartDate =
          pastdate.getFullYear() +
          '-' +
          (pastdate.getMonth() + 1) +
          '-' +
          (pastdate.getDate() >= 10
            ? pastdate.getDate()
            : '0' + pastdate.getDate()) +
          ' 00:00:00'
        // this.StartDate = new Date(pastdate.getFullYear() + '-' + (pastdate.getMonth() + 1) + '-' + (pastdate.getDate()>10?pastdate.getDate():'0'+pastdate.getDate())+' 00:00:00')
        this.$set(this.parameter, 'printStartDate', this.StartDate)
        // parameter.printStartDate
        this.EndDate = '' + year + '-' + month + '-' + strDate + ' 00:00:00'
        this.$set(this.parameter, 'printEndDate', this.EndDate)
      }
      this.$forceUpdate()
      this.isShowPrintType = true
    },
    removePrint() {
      this.parameter.warehouseName = ''
      this.parameter.proportion = ''
      this.isShowPrintType = false
    },
    async submitClick() {
      if (!this.parameter.radio && this.headerText == '打印记录') {
        this.$message.error('请选择打印的类型')
        return
      }
      if (!this.parameter.printStartDate) {
        this.$message.error('请选择打印的起始日期')
        return
      }
      if (!this.parameter.printEndDate) {
        this.$message.error('请选择打印的截止日期')
        return
      }
      if (!this.parameter.warehouseName) {
        this.$message.error('请选择所要打印的仓库')
        return
      }
      if (this.parameter.warehouseName == '全部仓库') {
        this.parameter.warehouseName = ''
      }
      if (this.parameter.binNumber == '全部仓位') {
        this.parameter.binNumber = ''
      }
      // let enddate = new Date(this.parameter.endDate).toLocaleString()//将截止时间的时间戳转为时间
      // this.parameter.endDate = enddate.split(' ')[0].replace('/' ,'-').replace('/','-')
      this.parameter.warehouseName = this.parameter.warehouseName.replace(
        '（临）',
        ''
      )
      this.isShowPrintType = false
      if (this.headerText == '导出记录') {
        if (this.parameter.radio == 3) {
          if (this.compName == '辽宁佳屹农商贸有限公司') {
            const data = await postExportjynin({
              compId: localStorage.getItem('ws-pf_compId'),
              startDate: this.parameter.printStartDate,
              endDate: this.parameter.printEndDate,
              warehouseName: this.parameter.warehouseName
            }).toPromise()
            console.log(data)
            // window.open(data.data.data)
            this.downloadFile(
              data.data.data,
              `${this.date.year +
                (this.date.month ? `-${this.date.month}` : '')}导出出库记录`
            )
          } else {
            const { data } = await postExport(
              {
                startDate: this.parameter.printStartDate,
                endDate: this.parameter.printEndDate,
                warehouseName: this.parameter.warehouseName
              },
              {},
              {
                responseType: 'blob'
              }
            ).toPromise()
            downloadFile({
              res: data,
              fileName: `${this.date.year +
                (this.date.month ? `-${this.date.month}` : '')}导出入库记录`,
              type: 'xls'
            })
          }
        } else if (this.parameter.radio == 2) {
          if (this.compName == '辽宁佳屹农商贸有限公司') {
            const data = await postExportjynout({
              compId: localStorage.getItem('ws-pf_compId'),
              startDate: this.parameter.printStartDate,
              endDate: this.parameter.printEndDate,
              warehouseName: this.parameter.warehouseName
            }).toPromise()
            console.log(data)
            this.downloadFile(
              data.data.data,
              `${this.date.year +
                (this.date.month ? `-${this.date.month}` : '')}导出出库记录`
            )
          } else {
            const { data } = await postExportOut(
              {
                startDate: this.parameter.printStartDate,
                endDate: this.parameter.printEndDate,
                warehouseName: this.parameter.warehouseName
              },
              {},
              {
                responseType: 'blob'
              }
            ).toPromise()
            downloadFile({
              res: data,
              fileName: `${this.date.year +
                (this.date.month ? `-${this.date.month}` : '')}导出出库记录`,
              type: 'xls'
            })
          }
        }
      } else if (this.headerText == '打印记录') {
        if (this.parameter.binNumber == '全部仓位') {
          this.parameter.binNumber = ''
        }
        addselectinfoList({
          compId: localStorage.getItem('ws-pf_compId'),
          printStartDate: this.parameter.printStartDate,
          printEndDate: this.parameter.printEndDate,
          warehouseName: this.parameter.warehouseName,
          binNumber: this.parameter.binNumber,
          goodsName: this.parameter.goodsName,
          searchType: this.parameter.radio,
          printFlag: '1',
          currentPage: 1,
          pageSize: 999,
          statusFlag: 3
        })
          .toPromise()
          .then(response => {
            if (response.records.length == 0) {
              this.$message.warning('暂未查到所要打印的出入库信息')
            } else {
              var warehousePrint = response.records
              if (this.parameter.proportion) {
                var countWeight = 0
                for (let i = 0; i < warehousePrint.length; i++) {
                  countWeight += Number(warehousePrint[i].netWeight)
                }
                var increment = (
                  countWeight *
                  (Number(this.parameter.proportion) / 100)
                ).toFixed(2) //所要增加的量
                printAdd()
                  .toPromise()
                  .then(response1 => {
                    //  setTimeout(function(){
                    for (let i = 0; i < response1.length; i++) {
                      increment = Number(increment)
                      if (increment > 0) {
                        let index = Math.abs(
                          Math.round(Math.random() * response1.length - 1)
                        )
                        let pro = response1[index] //取出假数据并设定值
                        pro.netWeight = Number(
                          (Math.random() * (70 - 10 + 1) + 10).toFixed(2)
                        )
                        pro.tare = Number(
                          (Math.random() * (20 - 10 + 1) + 10).toFixed(2)
                        )
                        // pro.grossWeight = Number((pro.tare + pro.netWeight).toFixed(2))
                        if (pro.netWeight < increment) {
                          //随机净重 小于 所要增量
                          increment = (increment - pro.netWeight).toFixed(2) //所要增的量
                          if (increment < 10 && pro.netWeight <= 60) {
                            pro.netWeight += Number(increment)
                            pro.grossWeight = Number(
                              (pro.tare + pro.netWeight).toFixed(2)
                            )
                            increment = 0
                            warehousePrint.push(pro)
                          } else {
                            increment -= pro.netWeight
                            pro.grossWeight = Number(
                              (pro.tare + pro.netWeight).toFixed(2)
                            )
                            warehousePrint.push(pro)
                          }
                        } else {
                          //随机净重 大于 所要增量
                          pro.netWeight = Number(increment.toFixed(2))
                          pro.grossWeight = Number(
                            (pro.tare + pro.netWeight).toFixed(2)
                          )
                          increment = 0
                          warehousePrint.push(pro)
                        }
                        response1.splice(index, 1) //删除已添加过得假数据车牌号
                        if (response1.length == 0) {
                          sessionStorage.setItem(
                            'inOutWarehouse_Print',
                            JSON.stringify(warehousePrint)
                          )
                          let _canshu = ''
                          _canshu =
                            this.parameter.radio +
                            '&warehouseName=' +
                            this.parameter.warehouseName +
                            '&startDate=' +
                            this.parameter.printStartDate +
                            '&endDate=' +
                            this.parameter.printEndDate
                          window.open(
                            '../../../../../static/warehousePrint.html?type=' +
                              _canshu
                          )
                        }
                      } else {
                        //增量为0时
                        break
                      }
                    }
                    //跳转
                    sessionStorage.setItem(
                      'inOutWarehouse_Print',
                      JSON.stringify(warehousePrint)
                    )
                    let _canshu = ''
                    _canshu =
                      this.parameter.radio +
                      '&warehouseName=' +
                      this.parameter.warehouseName +
                      '&startDate=' +
                      this.parameter.printStartDate +
                      '&endDate=' +
                      this.parameter.printEndDate
                    window.open(
                      '../../../../../static/warehousePrint.html?type=' +
                        _canshu
                    )
                  })
              } else {
                //没有增量比例的直接打印
                sessionStorage.setItem(
                  'inOutWarehouse_Print',
                  JSON.stringify(response.records)
                )
                let _canshu1 = ''
                _canshu1 =
                  this.parameter.radio +
                  '&warehouseName=' +
                  this.parameter.warehouseName +
                  '&startDate=' +
                  this.parameter.printStartDate +
                  '&endDate=' +
                  this.parameter.printEndDate
                window.open(
                  '../../../../../static/warehousePrint.html?type=' + _canshu1
                )
              }
            }
          })
      }
    },
    //导出历史库存记录
    exportHistoricalData() {
      let date = new Date()
      var year = date.getFullYear()
      var month = date.getMonth() + 1
      var strDate = date.getDate()
      var pastdate = new Date(date.getTime() - 24 * 60 * 60 * 1000)
      this.parameter.startDate =
        pastdate.getFullYear() +
        '-' +
        (pastdate.getMonth() + 1) +
        '-' +
        pastdate.getDate()
      this.parameter.endDate = '' + year + '-' + month + '-' + strDate
      this.$forceUpdate()
      this.isShowPrintType1 = true
    },
    removePrint1() {
      this.parameter.warehouseName = ''
      this.parameter.proportion = ''
      this.isShowPrintType1 = false
    },
    async submitClick1() {
      if (!this.parameter.startDate) {
        this.$message.error('请选择打印的起始日期')
        return
      }
      if (!this.parameter.endDate) {
        this.$message.error('请选择打印的截止日期')
        return
      }
      if (
        new Date(this.parameter.endDate).getTime() <
        new Date(this.parameter.startDate).getTime()
      ) {
        this.$message.error('截止日期输入错误')
        return
      }
      if (this.parameter.warehouseName == '全部仓库') {
        this.parameter.warehouseName = ''
      }
      if (this.parameter.binNumber == '全部仓位') {
        this.parameter.binNumber = ''
      }
      const { data } = await exportHistoricalInventory(
        {
          startDate: this.parameter.startDate,
          endDate: this.parameter.endDate,
          warehouseName: this.parameter.warehouseName
        },
        {},
        {
          responseType: 'blob'
        }
      ).toPromise()
      downloadFile({
        res: data,
        fileName: `${this.date.year +
          (this.date.month ? `-${this.date.month}` : '')}导出历史库存记录`,
        type: 'xls'
      })
    },
    handleClose() {
      this.indialog = false
    },
    submit() {
      if (!this.inWarehouse) {
        this.$message.error('请输入入库量')
        return
      }
      if (
        Number(this.warehouseInfo.warehouseNumViewList[0].outNetWeight) >
        Number(this.inWarehouse)
      ) {
        this.$message.error('入库量不可小于已出库量')
        return
      }
      if (
        String(this.inWarehouse).indexOf('.') != -1 &&
        String(this.inWarehouse).length -
          (String(this.inWarehouse).indexOf('.') + 1) >
          3
      ) {
        this.$message.error('入库量输入错误')
        return
      }
      if (Number(this.warehouseInfo.maxInStorage) < Number(this.inWarehouse)) {
        this.$message.error('入库量不可超过合同上限')
        return
      }
      let InnetWeight = {
        baseId: this.warehouseInfo.warehouseId,
        netWeight: this.inWarehouse
      }
      postInWeight(InnetWeight)
        .toPromise()
        .then(response => {
          this.$notify.success({
            title: '成功',
            message: '修改成功'
          })
          ;(this.indialog = false), (this.inWarehouse = ''), this.getList1()
        })
        .catch(response => {
          // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
        })
    },
    initCharts() {
      let _x = []
      let _y = []
      for (var i = 0; i < this.totalReserves.length; i++) {
        if (this.warehouseType == '1') {
          _x.push(this.totalReserves[i].goodsName)
          _y.push(this.totalReserves[i].stockNum)
        } else {
          _x.push(this.totalReserves[i].goodsName)
          _y.push(this.totalReserves[i].surplus)
        }
      }
      // 柱状图
      let myChart7 = this.$echarts.init(this.$refs.myEchart7)
      var zoption = {
        grid: {
          left: '0',
          right: '0',
          bottom: '0',
          top: '30',
          containLabel: true
        },
        // ---  提示框 ----
        tooltip: {
          show: true, // 是否显示提示框，默认为true
          trigger: 'item', // 数据项图形触发
          axisPointer: {
            // 指示样式
            type: 'shadow',
            axis: 'auto'
          },
          padding: 5,
          textStyle: {
            // 提示框内容的样式
            color: '#fff'
          }
        },
        //  ------  X轴 ------
        xAxis: {
          axisLabel: {
            // 坐标轴标签
            show: true, // 是否显示
            inside: false, // 是否朝内
            rotate: 0, // 旋转角度
            margin: 10, // 刻度标签与轴线之间的距离
            color: '#929AB8', // 默认取轴线的颜色
            interval: 0
          },
          splitArea: {
            // 网格区域
            show: false // 是否显示，默认为false
          },
          data: _x
        },
        //   ------   y轴  ----------
        yAxis: {
          axisLine: {
            // 坐标轴 轴线
            show: false // 是否显示
          },
          axisLabel: {
            // 坐标轴的标签
            show: true, // 是否显示
            inside: false, // 是否朝内
            rotate: 0, // 旋转角度
            margin: 8, // 刻度标签与轴线之间的距离
            color: '#929AB8' // 默认轴线的颜色
          },
          splitLine: {
            // gird 区域中的分割线
            show: true, // 是否显示
            lineStyle: {
              color: '#D9DDE7',
              width: 1,
              type: 'dashed'
            }
          }
        },
        //  -------   内容数据 -------
        series: [
          {
            name: '储量', // 序列名称
            type: 'bar', // 类型
            legendHoverLink: true, // 是否启用图列 hover 时的联动高亮
            // label: {   // 图形上的文本标签
            //   show: false,
            //   position: 'insideTop', // 相对位置
            //   rotate: 0,  // 旋转角度
            //   color: '#eee'
            // },
            itemStyle: {
              // 图形的形状
              // color: lineColor[index++]
              // barBorderRadius: [18, 18, 0 ,0]
              color: function(params) {
                var colorList = [
                  '#5878E8',
                  '#50CAD4',
                  '#FF9F24',
                  '#E87C25',
                  '#27727B',
                  '#FE8463',
                  '#9BCA63',
                  '#FAD860',
                  '#F3A43B',
                  '#60C0DD',
                  '#D7504B',
                  '#C6E579',
                  '#F4E001',
                  '#F0805A',
                  '#26C0C0'
                ]
                return colorList[params.dataIndex]
              }
            },
            barWidth: 20, // 柱形的宽度
            barCategoryGap: '20%', // 柱形的间距
            label: {
              show: true,
              position: 'top',
              color: '#000000'
            },
            data: _y
          }
        ]
      }
      myChart7.setOption(zoption)
    },
    mapChange(num) {
      if (num == 1) {
        this.mapshow = false
        this.btnCss1 = 'btn1'
        this.btnCss2 = 'btn'
        this.maptitle = '库点监控'
      } else if (num == 2) {
        this.mapshow = true
        this.btnCss1 = 'btn'
        this.btnCss2 = 'btn1'
        this.maptitle = '定位'
      }
    },
    getAddress(data) {
      this.deptBudgetList.warehousePrivate = data[0]
      this.deptBudgetList.warehouseCity = data[1]
      this.deptBudgetList.warehouseArea = data[2]
    },
    searchAddress(e) {
      this.deptBudgetList.warehousePositioning = e.lat + ',' + e.lng
    },
    marker: function(item) {
      this.deptBudgetList.warehousePositioning =
        item.lnglat.lat + ',' + item.lnglat.lng
    },
    handleMintor() {
      this.$router.push({
        path: 'warehouseManagementMintor'
      })
    },
    dryClick() {
      this.$router.push({
        path: 'dryWarehousing'
      })
    },
    materialInOut() {
      this.$router.push({
        path: 'materialInOutWarehouse'
      })
    },
    handleall() {
      this.$router.push({
        path: 'warehouseManagement'
      })
    },
    selectstaff(e) {
      this.warehouseInfo.warehouseName = e
      for (var tmp = 0; tmp < this.warehouseAllXiaLa.length; tmp++) {
        if (this.warehouseAllXiaLa[tmp].warehouseName == e) {
          this.warehouseType = this.warehouseAllXiaLa[tmp].warehouseType
          this.monitorUrl1 = this.warehouseAllXiaLa[tmp].monitorUrl1
          this.monitorUrl2 = this.warehouseAllXiaLa[tmp].monitorUrl2
          if (this.warehouseType == '2') {
            this.maptitle = '定位'
            this.btnCss2 = 'btn1'
            this.mapshow = true
          } else {
            this.maptitle = '库点监控'
            this.btnCss1 = 'btn1'
            this.btnCss2 = 'btn'
            this.mapshow = false
          }
          break
        }
      }
      this.warehouseXiaLa = this.warehouseXiaLaCopy
      if (this.warehouseInfo.warehouseName.indexOf('（临）') != -1) {
        this.warehouseInfo.warehouseName = this.warehouseInfo.warehouseName.replace(
          ' （临）',
          ''
        )
      }
      this.getList1()
    },
    warehouseQuery(query) {
      if (query) {
        this.warehouseXiaLa = this.warehouseAllXiaLa
        this.warehouseXiaLa = this.warehouseAllXiaLa.filter(
          item => item.warehouseName.indexOf(query) > -1
        )
      } else {
        this.warehouseXiaLa = this.warehouseXiaLaCopy
      }
    },
    getCurrentDate(format) {
      var now = new Date()
      var year = now.getFullYear() //得到年份
      var month = now.getMonth() //得到月份
      var date = now.getDate() //得到日期
      var day = now.getDay() //得到周几
      var hour = now.getHours() //得到小时
      var minu = now.getMinutes() //得到分钟
      var sec = now.getSeconds() //得到秒
      month = month + 1
      if (month < 10) month = '0' + month
      if (date < 10) date = '0' + date
      if (hour < 10) hour = '0' + hour
      if (minu < 10) minu = '0' + minu
      if (sec < 10) sec = '0' + sec
      var time = ''
      //精确到天
      if (format == 1) {
        time = year + '-' + month + '-' + date
      }
      //精确到分
      else if (format == 2) {
        time =
          year + '-' + month + '-' + date + ' ' + hour + ':' + minu + ':' + sec
      }
      return time
    },
    //添加
    handleAdd() {
      this.$router.push({
        path: 'warehouseNewManagementAdd'
      })
    },
    //编辑
    handleEdit() {
      this.$router.push({
        path: 'warehouseNewManagementEdit'
      })
    },
    //查看
    handleLook() {
      this.$router.push({
        name: 'warehouseManagementLookNew'
      })
    },
    //删除仓库
    handleDelete() {
      for (var num = 0; num < this.warehouseList.length; num++) {
        //删除仓库前应当判断是否有库存
        for (
          var num_item = 0;
          num_item < this.warehouseList[num].warehouseNumViewList.length;
          num_item++
        ) {
          if (this.warehouseType == 2) {
            if (
              Number(
                this.warehouseList[num].warehouseNumViewList[num_item].surplus
              ) > 0
            ) {
              this.$message.error('删除前应清空库存!')
              return
            }
          } else if (this.warehouseType == 1) {
            if (
              Number(
                this.warehouseList[num].warehouseNumViewList[num_item].storage
              ) > 0
            ) {
              this.$message.error('删除前应清空库存!')
              return
            }
          }
        }
      }
      this.$confirm(`确认删除` + this.warehouseInfo.warehouseName + `?`, {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning'
      })
        .then(() => {
          deletewarehouse({ id: this.warehouseInfo.warehouseId })
            .toPromise()
            .then(response => {
              this.$notify.success({
                title: '成功',
                message: '删除成功'
              })
              this.getList1()
            })
            .catch(response => {
              // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
            })
        })
        .catch(() => {
          return false
        })
    },
    //记录
    record() {
      this.$router.push({
        path: 'warehouseNewManagementRecord',
        query: {
          baseId: this.warehouseInfo.warehouseId,
          positionId: this.warehouseInfo.binNumberId,
          warehouseName: this.warehouseInfo.warehouseName,
          remark: this.warehouseInfo.remark,
          binNumber: this.warehouseInfo.binNumber,
          capacity: this.warehouseInfo.capacity,
          warehouseType: this.warehouseType
        }
      })
    },
    //盘损
    loss() {
      this.$router.push({
        path: 'warehouseNewManagementIoss',
        query: {
          baseId: this.warehouseInfo.warehouseId,
          positionId: this.warehouseInfo.binNumberId,
          warehouseName: this.warehouseInfo.warehouseName,
          binNumber: this.warehouseInfo.binNumber
        }
      })
    },
    //清仓
    clearance() {
      if (this.warehouseInfo.outNumber > 0) {
        this.$confirm(`你还有未完善的出库记录，请完善提交后再进行操作`, {
          cancelButtonText: '关闭'
        })
          .then(() => {})
          .catch(() => {
            return false
          })
      } else {
        this.$confirm(
          `清库操作代表库存已清零，清库后不可进行出库操作，是否确定清库`,
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }
        )
          .then(() => {
            clearancee({
              id: this.warehouseInfo.warehouseId
            })
              .toPromise()
              .then(response => {
                this.$notify.success({
                  title: '成功',
                  message: '状态清库成功'
                })
                this.getList1()
              })
              .catch(response => {})
          })
          .catch(() => {
            return false
          })
      }
    },
    //任务
    handlTask() {
      var arr = []
      for (let i = 0; i < this.list.length; i++) {
        arr.push(this.list[i].warehouseName)
      }
      this.$router.push({
        path: 'tranManagementWarehouseInOutTask',
        query: {
          // stringList: arr,
          // warehouseBaseInfoList: JSON.stringify(this.list)
        }
      })
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计'
        } else if (index === 4 || index === 5 || index === 6) {
          const values = data.map(item => {
            var val = item.warehouseNumViewList.map(items => {
              if (column.label == '入库量（吨）') {
                return items.inNetWeight
              } else if (column.label == '出库量（吨）') {
                return items.outNetWeight
              } else if (column.label == '应余量（吨）') {
                return items.storage
              } else if (column.label == '应余量（吨）') {
                return items.storage
              }
            })
            return val
          })
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              if (curr.length > 1) {
                var num = 0
                for (let i = 0; i < curr.length; i++) {
                  num += Number(curr[i])
                }
                return Number(prev) + num
              } else {
                const value = Number(curr)
                if (!isNaN(value)) {
                  return Number(prev) + Number(curr)
                } else {
                  return Number(prev)
                }
              }
            }, 0)
          } else {
            sums[index] = '--'
          }
        } else {
          sums[index] = '--'
        }
      })
      if (typeof sums[4] == 'number') {
        sums[4] = sums[4].toFixed(3)
      }
      if (typeof sums[5] == 'number') {
        sums[5] = sums[5].toFixed(3)
      }
      if (typeof sums[6] == 'number') {
        sums[6] = sums[6].toFixed(3)
      }
      return sums
    },
    // 折转
    transformation() {
      this.$router.push({
        path: 'transformation',
        query: {
          warehouseId: this.warehouseInfo.warehouseId,
          warehouseName: this.warehouseInfo.warehouseName,
          binNumberId: this.warehouseInfo.binNumberId,
          warehouseType: this.warehouseType
        } //warehouseType 1常用 2临时
      })
    },
    getList() {
      getreserves({ compId: localStorage.getItem('ws-pf_compId') })
        .toPromise()
        .then(response => {
          var obj = { 类型: '库内储量' },
            obj1 = { 类型: '移库在途' },
            obj2 = { 类型: '采购在途' },
            obj3 = { 类型: '销售在途' },
            obj4 = { 类型: '合计' },
            obj5 = { 类型: '货值' }
          var arr = response.map(item => {
            obj[item.goodsName] = item.stockNum
            obj1[item.goodsName] = item.moveNum
            obj2[item.goodsName] = item.purchaseNum
            obj3[item.goodsName] = item.saleNum
            return item.goodsName
          })
          arr.unshift('类型')
          for (const i in obj) {
            if (i != '类型') {
              var num = obj[i] + obj1[i] + obj2[i] + obj3[i]
              obj4[i] = num.toFixed(3)
            }
          }
          this.tableData.push(obj)
          this.tableData.push(obj1)
          this.tableData.push(obj2)
          this.tableData.push(obj3)
          this.tableData.push(obj4)
          this.tableHeader = arr
        })
      this.dateTime = this.getCurrentDate(1)

      // 仓储部负责人
      getResponsible({
        compId: localStorage.getItem('ws-pf_compId')
      })
        .toPromise()
        .then(response => {
          this.responsible = response[0].staffName
        })
      // 仓库名称
      getwarehousNameNew({
        compId: localStorage.getItem('ws-pf_compId')
      })
        .toPromise()
        .then(response => {
          this.warehouseXiaLa = response
          this.warehouseXiaLaCopy = response
          this.warehouseInfo.warehouseName = this.warehouseXiaLa[0].warehouseName
          this.monitorUrl1 = this.warehouseXiaLa[0].monitorUrl1
          this.monitorUrl2 = this.warehouseXiaLa[0].monitorUrl2
          for (var tmp = 0; tmp < response.length; tmp++) {
            if (response[tmp].warehouseType == '2') {
              response[tmp].warehouseName =
                response[tmp].warehouseName + ' （临）'
            }
          }
          this.warehouseAllXiaLa = response
          this.getList1()
        })
      getsponsible({
        compId: localStorage.getItem('ws-pf_compId')
      })
        .toPromise()
        .then(response => {
          this.list = response
        })
      packList({
        constId: 'CON2'
      })
        .toPromise()
        .then(response => {
          this.goodnameList = response
        })
    },
    changeWeight(e) {
      //实际重量
      if (e == '0') {
        if (this.warehouseType == '1') {
          getQualityReal({
            compId: localStorage.getItem('ws-pf_compId'),
            warehouseName: this.warehouseInfo.warehouseName
          })
            .toPromise()
            .then(response => {
              this.totalReserves = response.warehouseNumViewList
              this.initCharts()
            })
        } else {
          this.getList1()
        }
      } else {
        getQualityZhe({
          compId: localStorage.getItem('ws-pf_compId'),
          baseId: this.warehouseInfo.warehouseId
        })
          .toPromise()
          .then(response => {
            console.log(this.totalReserves)
            this.totalMoney1 = 0
            this.totalMoney2 = 0
            if (this.warehouseType == '1') {
              for (let j = 0; j < this.totalReserves.length; j++) {
                if (
                  this.totalReserves[j].cost &&
                  this.totalReserves[j].stockNum
                ) {
                  if (this.totalReserves[j].goodsName.indexOf('玉米') != -1) {
                    this.totalReserves[j].totalMoney1 = (
                      Number(this.totalReserves[j].cost) *
                      Number(this.totalReserves[j].stockNum)
                    ).toFixed(3)
                    this.totalMoney1 = (
                      Number(this.totalMoney1) +
                      Number(this.totalReserves[j].totalMoney1)
                    ).toFixed(3)
                  } else if (
                    this.totalReserves[j].goodsName.indexOf('高粱') != -1
                  ) {
                    this.totalReserves[j].totalMoney2 = (
                      Number(this.totalReserves[j].cost) *
                      Number(this.totalReserves[j].stockNum)
                    ).toFixed(3)
                    this.totalMoney2 = (
                      Number(this.totalMoney2) +
                      Number(this.totalReserves[j].totalMoney2)
                    ).toFixed(3)
                  }
                }
              }
              console.log(this.totalReserves)
              if (response.warehouseNumViewList.length != 0) {
                var result = []

                for (let i = 0; i < response.warehouseNumViewList.length; i++) {
                  let param = {}
                  for (let num = 0; num < this.totalReserves.length; num++) {
                    if (
                      response.warehouseNumViewList[i].goodsName ==
                        this.totalReserves[num].goodsName &&
                      response.warehouseNumViewList[i].goodsName != '玉米' &&
                      response.warehouseNumViewList[i].goodsName != '高粱'
                    ) {
                      param.cost = this.totalReserves[num].cost
                    }
                  }
                  if (response.warehouseNumViewList[i].pureWeight) {
                    param.goodsName = response.warehouseNumViewList[i].goodsName
                    param.stockNum = Number(
                      response.warehouseNumViewList[i].pureWeight
                    ).toFixed(3)
                    if (param.goodsName == '玉米') {
                      param.conversionCost = (
                        Number(this.totalMoney1) / Number(param.stockNum)
                      ).toFixed(3)
                    } else if (param.goodsName == '高粱') {
                      param.conversionCost = (
                        Number(this.totalMoney2) / Number(param.stockNum)
                      ).toFixed(3)
                    }
                    result.push(param)
                  }
                }
                console.log(result)
                this.totalReserves = result
                this.initCharts()
              } else {
                // this.$message.error('当前仓库无潮粮库存,无需折算!')
                // this.value = '0'
                // return
              }
            } else {
              //临时库
              if (response.warehouseNumViewList.length != 0) {
                var result1 = []
                for (let i = 0; i < response.warehouseNumViewList.length; i++) {
                  let param = {}
                  if (response.warehouseNumViewList[i].pureWeight) {
                    param.goodsName = response.warehouseNumViewList[i].goodsName
                    param.surplus = Number(
                      response.warehouseNumViewList[i].pureWeight
                    ).toFixed(3)
                    result1.push(param)
                  }
                }
                this.totalReserves = result1
                this.initCharts()
              }
            }
          })
      }
    },
    getList1() {
      getList({
        compId: localStorage.getItem('ws-pf_compId'),
        warehouseName: this.warehouseInfo.warehouseName,
        warehouseType: this.warehouseType
      })
        .toPromise()
        .then(response => {
          for (let q = 0; q < response.warehouseViewList.length; q++) {
            if (response.warehouseViewList[q].warehouseNumViewList.length > 0) {
              for (
                let i = 0;
                i < response.warehouseViewList[q].warehouseNumViewList.length;
                i++
              ) {
                if (
                  response.warehouseViewList[q].warehouseNumViewList[i]
                    .inNetWeight
                ) {
                  response.warehouseViewList[q].warehouseNumViewList[
                    i
                  ].inNetWeight = Number(
                    response.warehouseViewList[q].warehouseNumViewList[i]
                      .inNetWeight
                  ).toFixed(3)
                }
                if (
                  response.warehouseViewList[q].warehouseNumViewList[i]
                    .outNetWeight
                ) {
                  response.warehouseViewList[q].warehouseNumViewList[
                    i
                  ].outNetWeight = Number(
                    response.warehouseViewList[q].warehouseNumViewList[i]
                      .outNetWeight
                  ).toFixed(3)
                }
                if (
                  response.warehouseViewList[q].warehouseNumViewList[i].storage
                ) {
                  response.warehouseViewList[q].warehouseNumViewList[
                    i
                  ].storage = Number(
                    response.warehouseViewList[q].warehouseNumViewList[i]
                      .storage
                  ).toFixed(3)
                }
                if (
                  response.warehouseViewList[q].warehouseNumViewList[i]
                    .inNetWeight &&
                  response.warehouseViewList[q].warehouseNumViewList[i]
                    .outNetWeight
                ) {
                  response.warehouseViewList[q].warehouseNumViewList[
                    i
                  ].surplus = (
                    response.warehouseViewList[q].warehouseNumViewList[i]
                      .inNetWeight -
                    response.warehouseViewList[q].warehouseNumViewList[i]
                      .outNetWeight
                  ).toFixed(3)
                } else if (
                  response.warehouseViewList[q].warehouseNumViewList[i]
                    .inNetWeight
                ) {
                  response.warehouseViewList[q].warehouseNumViewList[
                    i
                  ].surplus =
                    response.warehouseViewList[q].warehouseNumViewList[
                      i
                    ].inNetWeight
                }
              }
            }
          }
          if (this.warehouseType == '1') {
            this.totalReserves = response.warehouseNumViewList
          } else {
            this.totalReserves =
              response.warehouseViewList[0].warehouseNumViewList
          }
          // this.totalMoney = Number(this.totalReserves[0].stockNum * this.totalReserves[0].cost).toFixed(3)
          this.value = '0'
          this.initCharts()
          this.warehouseList = response.warehouseViewList
          if (this.warehouseList.length > 0) {
            this.warehouseInfo = this.warehouseList[0]
            this.warehouseInfo.warehouseLocation =
              this.warehouseList[0].warehousePrivate +
              this.warehouseList[0].warehouseCity +
              this.warehouseList[0].warehouseArea
            // this.warehouseInfo.maxReserves = 0
            //经纬度
            this.warehousePositioning.lat = this.warehouseInfo.warehousePositioning.split(
              ','
            )[1]
            this.warehousePositioning.lng = this.warehouseInfo.warehousePositioning.split(
              ','
            )[0]
            for (let j = 0; j < this.warehouseXiaLa.length; j++) {
              if (
                this.warehouseInfo.warehouseName ==
                this.warehouseXiaLa[j].warehouseName
              ) {
                this.warehouseInfo.maxReserves = this.warehouseXiaLa[
                  j
                ].totalStorage
              }
            }
          }
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.container {
  background: #e8ecf6;
}
.top_form {
  background: #ffffff;
  /deep/.el-table .el-table__body .cell,
  /deep/.el-table .cell {
    text-align: center;
  }
}
.title {
  position: relative;
  background: #f6f7fc;
  height: 60px;
  line-height: 60px;
}
.title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 30px;
  background: #5473e8;
  position: absolute;
  left: 0;
  top: 12px;
}
.position {
  border-radius: 4px;
  background: #ffffff;
  margin: 20px 10px;
  padding-bottom: 10px;
  height: 550px;
  /deep/.el-table .el-table__body .cell,
  /deep/.el-table .cell {
    text-align: center;
  }
  /deep/.setUp_css .cell {
    display: contents !important;
  }
  .title {
    position: relative;
    background: #f6f7fc;
    height: 60px;
    line-height: 60px;
    margin-bottom: 14px;
  }

  .title::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 30px;
    background: #5473e8;
    position: absolute;
    left: 0;
    top: 12px;
  }
  .cangInfo {
    font-size: 18px;
    font-weight: 600;
    margin-left: 14px;
    line-height: 30px;
  }
  .el-input {
    width: 95%;
  }
  .el-select {
    width: 95%;
  }
}
.right {
  .title {
    position: relative;
    background: #f6f7fc;
    height: 60px;
    line-height: 60px;
    margin-bottom: 14px;
  }
  .title::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 30px;
    background: #5473e8;
    position: absolute;
    left: 0;
    top: 12px;
  }
  .cangInfo {
    font-size: 18px;
    font-weight: 600;
    margin-left: 14px;
    line-height: 30px;
  }
}
.reservesInfo {
  display: inline-flex;
  .reservesInfo_item {
    width: 140px;
    background: #f5f7fa;
    // height: 54px;
    text-align: center;
    line-height: 25px;
    margin: 0 10px;
    border-radius: 4px;
    padding: 10px 0;
    .reservesInfo_GoodsName {
      font-size: 12px;
      color: #8890b1;
    }
    .reservesInfo_Amount {
      color: #323233;
      font-size: 14px;
      font-weight: 600;
    }
  }
}
.weight {
  display: inline-flex;
  margin-left: 11px;
}
.color {
  display: inline-flex;
  width: 100%;
  height: 40px;
  line-height: 40px;
  justify-content: flex-end;
  .color_for {
    margin: 0 10px;
    display: flex;
  }
  .color_for .color_goodsName {
    margin-left: 10px;
    margin-top: -13px;
  }
  .color_item {
    width: 15px;
    height: 15px;
  }
}
.column {
  margin: 10px;
}
.map {
  background: #ffffff;
  width: 99%;
  margin: 100px auto 50px;
  height: 560px;
  border-radius: 4px;
  .map_switch {
    display: flex;
    border-bottom: 1px solid #d8dce6;
    .btn,
    .btn1 {
      padding: 7px 20px;
      border-radius: 4px;
      margin: 10px 0 10px 10px;
      font-size: 14px;
      cursor: pointer;
    }
    .btn1 {
      background: #f0f6ff;
      color: #5878e8;
    }
  }
  .map-item {
    width: 96%;
    margin: auto;
  }
  .monitor {
    margin-top: 30px;
    display: flex;
    .video1 {
      width: 440px;
      height: 360px;
      text-align: center;
      .img1 {
        width: 440px;
        height: 235px;
        padding: 20px;
      }
    }
  }
}
//打印弹窗
.mask {
  background: black;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  z-index: 99;
  opacity: 0.3;
}

.count {
  text-align: center;
  margin-bottom: 10px;
}

.print-type {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  width: 340px;
  height: 456px;
  background: white;
  border-radius: 10px;
  z-index: 999;

  .bottom-btn {
    text-align: center;
  }
}

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

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

  .el-date-editor.el-input {
    width: 85% !important;
  }

  .proportion_css {
    width: 85%;
  }
}
/deep/.el-table td,
/deep/.el-table th {
  text-align: center;
}
</style>
