<!--计量场景还原-->
<template>
  <div class="systemBase">
    <div>
      <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
        <el-form
          ref="searchData1"
          :inline="true"
          :model="search"
          :rules="ruleValidate"
        >
          <el-form-item label-width="70px" prop="carNo" label="车号">
            <el-input
              v-model="search.carNo"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="baseSpotNo" label="计量点">
            <el-select
              v-model="search.baseSpotNo"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in baseSpotNameItem"
                :key="index"
                :label="item.baseSpotName"
                :value="item.baseSpotNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="meterTypeName" label="业务类型">
            <el-select
              v-model="search.meterTypeName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in meterTypeNameItem"
                :key="index"
                :label="item.baseName"
                :value="item.baseName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="matterNo" label="物资名称">
            <el-select
              v-model="search.matterNo"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
              :filter-method="getMatterName"
            >
              <el-option
                v-for="(item, index) in matterNameItem"
                :key="index"
                :label="item.matterName"
                :value="item.matterNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="valueFlag" label="数据状态">
            <el-select
              v-model="search.valueFlag"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in valueFlagItem"
                :key="index"
                :label="item.valueFlag"
                :value="item.valueFlag"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="strDate" label="开始时间">
            <el-date-picker
              v-model="search.strDate"
              clearable
              type="datetime"
              style="width: 180px"
              placeholder="选择日期"
              size="small"
            ></el-date-picker>
          </el-form-item>
          <el-form-item prop="envDate" label="结束时间">
            <el-date-picker
              v-model="search.envDate"
              clearable
              type="datetime"
              style="width: 180px"
              placeholder="选择日期"
              size="small"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              icon="el-icon-search"
              type="primary"
              size="mini"
              @click="searchDatas"
              v-loading.fullscreen.lock="operateLoading"
              v-privilege="activeMenu + 'SEARCH'"
              >查询</el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <el-row>
        <el-col :span="16">
          <div style="border-right: 1px solid #d5d5d5">
            <div class="common-title-div">计量场景还原管理</div>
            <div class="common-table-div">
              <el-table
                v-loading="dataLoading"
                :row-class-name="tableRowClassName"
                ref="dataTable"
                highlight-current-row
                border
                :height="tableHeight"
                @row-click="getSubclassItem"
                :data="table.list"
                :exchangeFilterMap="{
                  valueFlag: { '0': '作废', '1': '有效', '2': '洁净' },
                  checkFlag: { '0': '未审', '1': '已审' },
                }"
                :icore-filter-flag="icoreFilterFlag"
              >
                <el-table-column
                  type="index"
                  label="序号"
                  fixed="left"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="actualFirstNo"
                  label="作业编号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="predictionNo"
                  label="预报编号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="carNo"
                  label="车号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="trailerNo"
                  label="挂号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="matterName"
                  label="物资名称"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="meterWeight"
                  label="重量"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.meterWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="meterNum"
                  label="数量"
                  align="right"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="addWeight"
                  label="附加重量"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.addWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="baseSpotName"
                  label="计量点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160"
                  prop="createTime"
                  label="计量时间"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="createManName"
                  label="计量员"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="meterClass"
                  label="班次"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="meterGroup"
                  label="班组"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="contractNo"
                  label="合同号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="batchNo"
                  label="批次号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="200"
                  prop="customerSupplierName"
                  label="供应商"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="200"
                  prop="forwardingUnitName"
                  label="发货单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="200"
                  prop="receivingUintName"
                  label="收货单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="materialName"
                  label="材质"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="specName"
                  label="规格"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="bindCardNo"
                  label="绑定卡号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="loadPointName"
                  label="卸货地点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="sampleNo"
                  label="取样编号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="sampleVoucher"
                  label="取样凭证"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="200"
                  prop="carrierUnitName"
                  label="承运单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="meterTypeName"
                  label="业务类型"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="valueFlag"
                  label="状态"
                  align="center"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.valueFlag == 0">作废</span>
                    <span v-else-if="scope.row.valueFlag == 1">有效</span>
                    <span v-else-if="scope.row.valueFlag == 2">结净</span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div class="common-foot-style">
              <el-pagination
                v-loading="dataLoading"
                @size-change="pageSizeChange"
                @current-change="pageCurrentChange"
                :current-page="page.pageNum"
                :page-sizes="[50, 100, 200, 400]"
                :page-size="page.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page.totalPage"
              >
              </el-pagination>
            </div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="common-title-div">附加重量</div>
          <div class="common-table-div">
            <el-table
              v-loading="dataLoading2"
              ref="dataTable2"
              highlight-current-row
              border
              :height="tableHeight"
              :data="table.list2"
              :icore-filter-flag="icoreFilterFlag"
            >
              <el-table-column
                type="index"
                label="序号"
                fixed="left"
                align="center"
              ></el-table-column>
              <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilNo"
                label="器具编号"
                min-width="110"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilName"
                label="器具名称"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilWeight"
                label="器具重量（KG）"
                min-width="120"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilUtensilName"
                label="器具属性"
                min-width="80"
                align="left"
              ></el-table-column>
            </el-table>
          </div>
          <div class="common-foot-style">
            <el-pagination
              v-loading="dataLoading2"
              @size-change="pageSizeChange2"
              @current-change="pageCurrentChange2"
              :current-page="page2.pageNum"
              :page-sizes="[50, 100, 200, 400]"
              :page-size="page2.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="page2.totalPage"
            >
            </el-pagination>
          </div>
        </el-col>
      </el-row>
      <el-row
        style="border-top: 1px solid #d5d5d5; border-bottom: 1px solid #d5d5d5; height：300px"
      >
        <el-col :span="8">
          <div class="common-title-div">计量数据截图区</div>
          <div id="getBigImage">
            <ul>
              <li v-for="(item, index) in urlImage" :key="index">
                <img :src="item.image" width="97%" @click="imageChange" />
              </li>
            </ul>
          </div>
          <!-- <el-row>
                 <el-col :span="8" v-for="(item,index) in urlImage" :key="index">
                  <img :src="item.image"/> 
                 </el-col>
               </el-row> -->
        </el-col>
        <el-col
          :span="8"
          style="
            border-left: 1px solid #d5d5d5;
            border-right: 1px solid #d5d5d5;
          "
        >
          <div class="common-title-div">
            计量数据重量曲线
            <el-button
              icon="el-icon-search"
              type="primary"
              size="mini"
              @click="searchData2"
              v-loading.fullscreen.lock="operateLoading"
              v-privilege="activeMenu + 'SEARCH2'"
              >查询</el-button
            >
          </div>
          <div
            id="main"
            style="width: 100%; height: 300px"
            @dblclick="chartZoomIn"
          ></div>
        </el-col>
        <el-col :span="8">
          <div class="common-title-div">计量数据操作日志</div>
          <div class="common-table-div">
            <el-table
              v-loading="dataLoading3"
              ref="dataTable3"
              highlight-current-row
              border
              :height="tableHeight"
              :data="table.list3"
              :icore-filter-flag="icoreFilterFlag"
            >
              <el-table-column
                type="index"
                label="序号"
                fixed="left"
                align="center"
              ></el-table-column>
              <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="noteNo"
                label="操作编号"
                min-width="110"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="baseSpotName"
                label="计量点"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="operationContent"
                label="操作内容"
                min-width="110"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="operationTime"
                label="操作时间"
                min-width="160"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="carNo"
                label="车号"
                min-width="100"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="meterManName"
                label="计量员"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="meterNoteSource"
                label="日志来源"
                min-width="90"
                align="left"
              >
                <template slot-scope="scope">
                  <span v-if="scope.row.meterNoteSource == 0"
                    >智能计量终端</span
                  >
                  <span v-else-if="scope.row.meterNoteSource == 1"
                    >自助取码终端</span
                  >
                  <span v-else-if="scope.row.meterNoteSource == 2"
                    >计量监控终端</span
                  >
                  <span v-else-if="scope.row.meterNoteSource == 3"
                    >微信小程序</span
                  >
                  <span v-else-if="scope.row.meterNoteSource == 4"
                    >远程计量终端</span
                  >
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div class="common-foot-style">
            <el-pagination
              v-loading="dataLoading3"
              @size-change="pageSizeChange3"
              @current-change="pageCurrentChange3"
              :current-page="page3.pageNum"
              :page-sizes="[50, 100, 200, 400]"
              :page-size="page3.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="page3.totalPage"
            >
            </el-pagination>
          </div>
        </el-col>
      </el-row>
    </div>
    <el-dialog
      title="计量数据重量曲线"
      :visible.sync="dialogVisible"
      width="90%"
    >
      <div
        id="chartMain"
        v-bind:style="{ width: EchartsWidth, height: EchartsHeight }"
      ></div>
    </el-dialog>
    <el-dialog
      title="计量数据重量曲线"
      :visible.sync="dialogVisibleSearch"
      width="90%"
    >
      <div style="border-top: 1px solid #d5d5d5">
        <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
          <el-form
            ref="searchData2"
            :inline="true"
            :model="search"
            :rules="ruleValidate2"
          >
            <el-form-item prop="baseSpotNo" label="计量点">
              <el-select
                v-model="search2.baseSpotNo"
                clearable
                filterable
                collapse-tags
                size="small"
                style="width: 120px"
              >
                <el-option
                  v-for="(item, index) in baseSpotNameItem"
                  :key="index"
                  :label="item.baseSpotName"
                  :value="item.baseSpotNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="strDate" label="开始时间">
              <el-date-picker
                v-model="search2.strDate"
                clearable
                type="datetime"
                style="width: 180px"
                placeholder="选择日期"
                size="small"
              ></el-date-picker>
            </el-form-item>
            <el-form-item prop="envDate" label="结束时间">
              <el-date-picker
                v-model="search2.envDate"
                clearable
                type="datetime"
                style="width: 180px"
                placeholder="选择日期"
                size="small"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label-width="20px">
              <el-button
                icon="el-icon-search"
                type="primary"
                size="mini"
                @click="searchDataEcharts"
                v-loading.fullscreen.lock="operateLoading"
                >生成图表</el-button
              >
            </el-form-item>
          </el-form>
        </div>
        <div
          id="chartMainSearch"
          v-bind:style="{ width: EchartsWidth, height: EchartsHeight }"
        ></div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import * as echarts from 'echarts';
import { formatDate } from '@/utils/util.js';
import Viewer from 'viewerjs'
import 'viewerjs/dist/viewer.css'
export default {
  data () {
    return {
      dataLoading: false,
      dataLoading2: false,
      dataLoading3: false,
      operateLoading: false,
      icoreFilterFlag: true,
      dialogVisible: false,
      dialogVisibleSearch: false,
      // EchartsWidth: (document.body.clientWidth*0.7)+'px',
      // EchartsHeight: (document.body.clientHeight - 240 )+'px',
      EchartsWidth: (document.body.clientWidth * 0.9) + 'px',
      EchartsHeight: (document.body.clientHeight - 240) + 'px',
      actualFirst: {},
      measurementData: '',
      baseSpotNameItem: [],
      meterTypeNameItem: [],
      matterNameItem: [],
      valueFlagItem: [
        { valueFlag: '有效' },
        { valueFlag: '作废' },
        { valueFlag: '结净' }
      ],
      page: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page3: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      table: {
        list: [],
        list2: [],
        list3: []
      },
      tableHeight: 0,
      ruleValidate: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify,
          trigger: 'blur'
        }]
      },
      ruleValidate2: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify2,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify2,
          trigger: 'blur'
        }]
      },
      search: {
        carNo: '',
        baseSpotNo: '',
        meterTypeName: '',
        matterNo: '',
        valueFlag: '',
        strDate: formatDate(new Date(), 'yyyy-MM-dd') + ' 00:00:00',
        envDate: formatDate(new Date(), 'yyyy-MM-dd') + ' 23:59:59'
      },
      search2: {
        baseSpotNo: '',
        strDate: '',
        envDate: '',
      },
      urlImage: [],
      option: {
        grid: {
          left: '4%',
          right: '5%',
          bottom: '2%',
          top: '15%',
          containLabel: true,
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        xAxis: {
          type: 'category',
          // name: '时间',
          data: [],
          axisTick: {
            alignWithLabel: true,
            // show:false,
          },
          axisLabel: {
            interval: 0,
            rotate: 20,//角度顺时针计算的
            // color: "#fff",//坐标值得具体的颜色
            interval: 5
          }
        },
        yAxis: {
          type: 'value',
          // name: '吨',
          // axisLabel: {
          //   formatter: '{value} t'
          // }
        },
        series: [{
          data: [],
          type: 'line',
          lineStyle: {
            normal: {
              color: 'rgb(64,158,255)', // 线条颜色
            },
          }
        }]
      },
      option2: {
        grid: {
          left: '4%',
          right: '5%',
          bottom: '2%',
          top: '15%',
          containLabel: true,
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        xAxis: {
          type: 'category',
          // name: '时间',
          data: [],
          axisTick: {
            alignWithLabel: true,
            // show:false,
          },
          axisLabel: {
            interval: 0,
            // rotate:20,//角度顺时针计算的
            // color: "#fff",//坐标值得具体的颜色
            interval: 5
          }
        },
        yAxis: {
          type: 'value',
          // name: '吨',
          // axisLabel: {
          //   formatter: '{value} t'
          // }
        },
        series: [{
          data: [],
          type: 'line',
          lineStyle: {
            normal: {
              color: 'rgb(64,158,255)', // 线条颜色
            },
          }
        }]
      },
      activeMenu: '',
      matList: []
    }
  },
  components: {
    Viewer
  },
  created () {
    this.tableHeight = (window.innerHeight - 220) / 2 > 200 ? (window.innerHeight - 220) / 2 : 200
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted () {
    // this.getDataList();
    this.searchDatas()
    this.getBaseSpotNameItem();
    this.getMatterNameItem();
    this.getMeterTypeNameItem()
    // this.getEchart()
  },
  methods: {
    getMatterName (val) {
      if (val) {
        this.matterNameItem = this.matList.filter(item => {
          if (item.matterName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.matterNameItem = [...this.matList].slice(0, 300)
      }
    },
    endTimeVerify (rule, value, callback) {
      if (this.search.strDate && !this.search.envDate) {
        callback(new Error('结束时间不能为空！'));
      } else if (this.search.envDate) {
        if (Date.parse(this.search.envDate) > Date.parse(this.search.strDate)) {
          callback();
        } else {
          callback(new Error('结束时间不得早于开始时间！'));
        }
      } else {
        callback();
      }
    },
    strTimeVerify (rule, value, callback) {
      if (this.search.envDate && !this.search.strDate) {
        callback(new Error('开始时间不能为空！'));
      } else {
        callback()
      }
    },
    endTimeVerify2 (rule, value, callback) {
      if (this.search2.strDate && !this.search2.envDate) {
        callback(new Error('结束时间不能为空！'));
      } else if (this.search2.envDate) {
        if (Date.parse(this.search2.envDate) > Date.parse(this.search2.strDate)) {
          callback();
        } else {
          callback(new Error('结束时间不得早于开始时间！'));
        }
      } else {
        callback();
      }
    },
    strTimeVerify2 (rule, value, callback) {
      if (this.search2.envDate && !this.search2.strDate) {
        callback(new Error('开始时间不能为空！'));
      } else {
        callback()
      }
    },
    searchData2 () {
      this.dialogVisibleSearch = true
    },
    searchDataEcharts () {
      this.$refs['searchData2'].validate((valid) => {
        if (valid) {
          if (isNaN(this.search2.strDate) && !isNaN(Date.parse(this.search2.strDate))) {
          } else {
            this.search2.strDate = formatDate(this.search2.strDate, 'yyyy-MM-dd HH:mm:ss')
          }
          if (isNaN(this.search2.envDate) && !isNaN(Date.parse(this.search2.envDate))) {
          } else {
            this.search2.envDate = formatDate(this.search2.envDate, 'yyyy-MM-dd HH:mm:ss')
          }
          this.option2.xAxis.data = [];
          this.option2.series[0].data = [];
          this.axios.get('pass/systemBase/v1/metermonitorweights/chartByTime' + '?baseSpotNo=' + this.search2.baseSpotNo + '&collectStartTime=' + this.search2.strDate + '&collectEndTime=' + this.search2.envDate)
            .then(res => {
              const echartList = res.data;
              let i = 0;
              echartList.forEach(item => {
                this.option2.xAxis.data[i] = item.timeSpot
                this.option2.series[0].data[i] = Number(item.weight)
                i++
              })
              this.chartZoomInSearch()
            })
        }
      })
    },
    getEchart () {
      var echarts = require('echarts');
      // 基于准备好的dom，初始化echarts实例
      const myChart = echarts.init(document.getElementById('main'));
      // 绘制图表
      myChart.setOption(this.option);
      window.onresize = function () {
        myChart.resize();
      }
    },
    chartZoomIn () {
      this.dialogVisible = true
      this.$nextTick(() => {
        var echarts = require('echarts');
        // 基于准备好的dom，初始化echarts实例
        const chartMain = document.getElementById('chartMain');
        const myChart2 = echarts.init(document.getElementById('chartMain'));
        // 绘制图表
        myChart2.setOption(this.option);
        window.onresize = function () {
          myChart2.resize();
        }
      })
    },
    chartZoomInSearch () {
      this.$nextTick(() => {
        var echarts = require('echarts');
        // 基于准备好的dom，初始化echarts实例
        const chartMainSearch = document.getElementById('chartMainSearch');
        const myChart3 = echarts.init(document.getElementById('chartMainSearch'));
        // 绘制图表
        myChart3.setOption(this.option2);
        window.onresize = function () {
          myChart3.resize();
        }
      })
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData()
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData()
    },
    pageSizeChange2 (size) {
      this.page2.pageSize = size;
      this.getDataList2(this.actualFirst);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.getDataList2(this.actualFirst);
    },
    pageSizeChange3 (size) {
      this.page3.pageSize = size;
      this.getDataList3(this.actualFirst);
    },
    pageCurrentChange3 (index) {
      this.page3.pageNum = index;
      this.getDataList3(this.actualFirst);
    },
    getSubclassItem (row) {
      this.actualFirst = row
      this.getDataList2(this.actualFirst)
      this.getImageList(this.actualFirst)
      this.getDataList3(this.actualFirst)
      this.getEchartList(this.actualFirst)
    },
    getDataList () {
      this.dataLoading = true;
      this.axios.get('pass/systemBase/v1/meterworkcaractualfirsts/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize)
        .then(res => {
          this.dataLoading = false;
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total;
          if (this.table.list.length > 0) {
            this.$refs.dataTable.setCurrentRow(this.table.list[0])
            this.getSubclassItem(this.table.list[0])
          }
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    getImageList (row) {
      this.urlImage = []
      if (row.actualFirstNo === null) {
        return
      }
      this.axios.get('pass/systemBase/v1/meterworkimages/getUrl' + '?actualFirstNo=C' + row.actualFirstNo)
        .then(res => {
          if (res.data !== null && res.data.length !== 0) {
            const imageList = res.data
            for (let i = 0; i < imageList.length; i++) {
              if (this.urlImage.length < res.data.length) {
                this.urlImage.push({ image: '' })
              }
              this.urlImage[i].image = '/weblib' + imageList[i]
            }
          }
        });
    },
    imageChange (e) {
      if (e.target.nodeName == 'IMG') {
        this.initImageTools();
      }
    },
    initImageTools () {
      const ViewerDom = document.getElementById('getBigImage');

      const viewer = new Viewer(ViewerDom, {
        url: 'src',  //设置大图片的 url
        show: function () {
          viewer.update();
        },
        hide: function () { //在图片消失的时候销毁viewer
          viewer.destroy()
        }
      });
    },
    getDataList2 (row) {
      this.table.list2 = []
      if (row.actualFirstNo === null) {
        return
      }
      this.dataLoading2 = true;
      this.axios.get('pass/systemBase/v1/meterworkaddweights/' + '?pageNum=' + this.page2.pageNum + '&pageSize=' + this.page2.pageSize + '&actualFirstNo=' + row.actualFirstNo)
        .then(res => {
          this.dataLoading2 = false;
          this.table.list2 = res.data.list;
          this.page2.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading2 = false;
        });
    },
    getDataList3 (row) {
      this.table.list3 = []
      if (row.actualFirstNo === null) {
        return
      }
      this.dataLoading3 = true;
      this.axios.get('pass/systemBase/v1/metermonitornotes/selectByTime' + '?pageNum=' + this.page3.pageNum + '&pageSize=' + this.page3.pageSize + '&baseSpotNo=' + row.baseSpotNo + '&operationTime=' + row.createTime + '&carNo=' + row.carNo)
        .then(res => {
          this.dataLoading3 = false;
          this.table.list3 = res.data.list;
          this.page3.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading3 = false;
        });
    },
    getEchartList (row) {
      this.option.xAxis.data = [];
      this.option.series[0].data = [];
      this.axios.get('pass/systemBase/v1/metermonitorweights/listByTime' + '?actualFirstNo=' + row.actualFirstNo)
        .then(res => {
          const echartList = res.data;
          let i = 0;
          echartList.forEach(item => {
            this.option.xAxis.data[i] = item.timeSpot
            this.option.series[0].data[i] = Number(item.weight)
            i++
          })
          this.getEchart()
        })
    },
    searchDatas () {
      this.page.pageNum = 1;
      this.searchData()
    },
    searchData () {
      this.$refs['searchData1'].validate((valid) => {
        if (valid) {
          this.dataLoading = true;
          this.search.valueFlag1 = this.search.valueFlag === '有效' ? 1 : this.search.valueFlag === '作废' ? 0 : this.search.valueFlag === '结净' ? 2 : ''
          if (isNaN(this.search.strDate) && !isNaN(Date.parse(this.search.strDate))) {
          } else {
            this.search.strDate = formatDate(this.search.strDate, 'yyyy-MM-dd HH:mm:ss')
          }
          if (isNaN(this.search.envDate) && !isNaN(Date.parse(this.search.envDate))) {
          } else {
            this.search.envDate = formatDate(this.search.envDate, 'yyyy-MM-dd HH:mm:ss')
          }
          this.urlImage = []
          this.table.list2 = []
          this.axios.get('pass/systemBase/v1/meterworkcaractualfirsts/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize + '&carNo=' + this.search.carNo
            + '&baseSpotNo=' + this.search.baseSpotNo + '&meterTypeName=' + this.search.meterTypeName + '&matterNo=' + this.search.matterNo + '&valueFlag=' + this.search.valueFlag1
            + '&createTime1=' + this.search.strDate + '&createTime2=' + this.search.envDate)
            .then(res => {
              this.dataLoading = false;
              this.table.list = res.data.list;
              this.page.totalPage = res.data.total;
              if (this.table.list.length > 0) {
                this.$refs.dataTable.setCurrentRow(this.table.list[0])
                this.getSubclassItem(this.table.list[0])
              }
            }).catch(e => {
              this.dataLoading = false;
            });
        }
      })
    },
    tableRowClassName ({
      row,
      rowIndex
    }) {
      if (row.valueFlag === '0') {
        return 'error-row2';
      }
      return '';
    },
    getBaseSpotNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasespotinfos/noPage' + '?validFlag=1')
        .then(res => {
          this.baseSpotNameItem = res.data;
        })
    },
    getMatterNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1')
        .then(res => {
          this.matList = res.data;
          this.matterNameItem = [...res.data].slice(0, 300);
        })
    },
    getMeterTypeNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001006' + '&validFlag=1')
        .then(res => {
          this.meterTypeNameItem = res.data;
        })
    },
  }
}
</script>

<style scoped>
</style>