<!--静态轨道衡一次计量数据匹配-->
<template>
  <div class="systemBase">
    <div>
      <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
        <el-form
          ref="searchData1"
          :inline="true"
          :model="search"
          :rules="ruleValidateSearch"
        >
          <el-form-item label-width="70px" prop="railwayNo" label="车号">
            <el-input
              v-model="search.railwayNo"
              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="getMatterName2"
            >
              <el-option
                v-for="item in matterNameItem2"
                :key="item.matterNo"
                :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="searchData"
              v-loading.fullscreen.lock="operateLoading"
              v-privilege="activeMenu + 'SEARCH'"
              >查询</el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <el-row>
        <el-col :span="24">
          <div style="border-right: 1px solid #d5d5d5">
            <div class="common-title-div">
              一次计量数据<span style="color: red"
                >(只会查询出进行了审核的数据)</span
              >
              <div class="common-operation-button-div">
                <el-button
                  size="mini"
                  type="primary"
                  icon="el-icon-check"
                  @click="mateData"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'MATCH'"
                  >匹配</el-button
                >
                <el-button
                  size="mini"
                  type="danger"
                  plain
                  icon="el-icon-remove-outline"
                  @click="removeData"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'RELIEVE'"
                  >解除</el-button
                >
              </div>
            </div>
            <div class="common-table-div">
              <el-table
                v-loading="dataLoading"
                :row-class-name="tableRowClassName"
                ref="dataTable"
                highlight-current-row
                border
                :height="tableHeight"
                @current-change="handleCurrentChange2"
                :data="table.list"
                @cell-click="getDataList2"
                :exchangeFilterMap="{
                  weightType: {
                    '0': '毛重',
                    '1': '常规皮重',
                    '2': '期限皮重',
                    '3': '历史皮重',
                    '4': '标识皮重',
                    '5': '自重皮重',
                  },
                  meterMode: {
                    '1': '远程计量',
                    '2': '智能计量',
                    '3': '手工录入',
                    '4': '放行智能计量',
                    '5': '滞后匹配',
                  },
                  valueFlag: { '0': '作废', '1': '作废', '3': '作废' },
                }"
                :icore-filter-flag="icoreFilterFlag"
              >
                <el-table-column
                  type="index"
                  label="序号"
                  fixed="left"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="actualFirstNo"
                  label="作业编号"
                  min-width="110"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="predictionNo"
                  label="预报编号"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="railwayNo"
                  label="车号"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <!-- <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="railwayCarriageNo"
                  label="车厢序号"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="railwayWorkNo"
                  label="列车作业编号"
                  min-width="120"
                  align="left"
                ></el-table-column> -->
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="matterName"
                  label="物资名称"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterWeight"
                  label="计量重量"
                  min-width="100"
                  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"
                  prop="meterSortWeight"
                  label="分检重量"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.meterSortWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterBalanceWeight"
                  label="结算重量"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{
                      Math.floor((scope.row.meterBalanceWeight - 0) / 10) / 100
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="weightType"
                  label="重量类型"
                  min-width="100"
                  align="left"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.weightType == 0">毛重</span>
                    <span v-else-if="scope.row.weightType == 1">常规皮重</span>
                    <span v-else-if="scope.row.weightType == 2">期限皮重</span>
                    <span v-else-if="scope.row.weightType == 3">历史皮重</span>
                    <span v-else-if="scope.row.weightType == 4">标识皮重</span>
                    <span v-else-if="scope.row.weightType == 5">自重皮重</span>
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="shipmentNum"
                  label="数量"
                  min-width="100"
                  align="right"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="baseSpotName"
                  label="计量点"
                  min-width="160"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="createTime"
                  label="计量时间"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="createManName"
                  label="计量员"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterClass"
                  label="班次"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterGroup"
                  label="班组"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="contractNo"
                  label="合同号"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="batchNo"
                  label="批次号"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="customerSupplierName"
                  label="供应商"
                  min-width="200"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="memo"
                  min-width="120"
                  label="备注"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="station"
                  label="发站"
                  min-width="200"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="arrival"
                  label="到站"
                  min-width="200"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="forwardingUnitName"
                  label="发货单位"
                  min-width="200"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="receivingUintName"
                  label="收货单位"
                  min-width="200"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="materialName"
                  label="材质"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="specName"
                  label="规格"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="bindCardNo"
                  label="绑定卡号"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="loadPointName"
                  label="卸货地点"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="sampleNo"
                  label="取样编号"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="sampleVoucher"
                  label="取样凭证"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="carrierUnitName"
                  label="承运单位"
                  min-width="200"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterTypeName"
                  label="业务类型"
                  min-width="100"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterMode"
                  label="计量方式"
                  min-width="100"
                  align="left"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.meterMode == 1">远程计量</span>
                    <span v-else-if="scope.row.meterMode == 2">智能计量</span>
                    <span v-else-if="scope.row.meterMode == 3">手工录入</span>
                    <span v-else-if="scope.row.meterMode == 4"
                      >放行智能计量</span
                    >
                    <span v-else-if="scope.row.meterMode == 5">滞后匹配</span>
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="valueFlag"
                  label="状态"
                  min-width="100"
                  align="left"
                >
                  <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-row>
      <el-row>
        <el-col :span="24">
          <div
            style="
              margin-top: 10px;
              padding-top: 10px;
              border-bottom: 1px solid #d5d5d5;
              border-top: 1px solid #d5d5d5;
            "
          >
            <el-form ref="search2" :inline="true" :model="search2">
              <el-form-item
                label-width="80px"
                prop="predictionNo"
                label="预报编号"
              >
                <el-input
                  v-model="search2.predictionNo"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
              <el-form-item prop="railwayNo" label="车号">
                <el-input
                  v-model="search2.railwayNo"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
              <el-form-item prop="predictionType" label="预报类型">
                <el-select
                  v-model="search2.predictionType"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                >
                  <el-option
                    v-for="(item, index) in predictionTypeItem"
                    :key="index"
                    :label="item.predictionType"
                    :value="item.predictionType"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="meterTypeName" label="业务类型">
                <el-select
                  v-model="search2.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="search2.matterNo"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                  :filter-method="getMatterName"
                >
                  <el-option
                    v-for="item in matterNameItem"
                    :key="item.matterNo"
                    :label="item.matterName"
                    :value="item.matterNo"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label-width="20px">
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  size="mini"
                  @click="searchData2"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'SEARCH2'"
                  >查询</el-button
                >
              </el-form-item>
            </el-form>
          </div>
          <div class="common-title-div">计量预报</div>
          <div class="common-table-div">
            <el-table
              v-loading="dataLoading2"
              :row-class-name="tableRowClassName2"
              ref="dataTable2"
              highlight-current-row
              border
              :height="tableHeight"
              @current-change="handleCurrentChange"
              :data="table.list2"
              :exchangeFilterMap="{
                predictionType: {
                  '0': '批次预报',
                  '1': '单次预报',
                  '2': '联运预报',
                  '3': '分检预报',
                },
                valueFlag: {
                  '0': '未配车',
                  '1': '未使用',
                  '2': '已使用',
                  '3': '已作废',
                  '4': '正使用',
                },
              }"
              :icore-filter-flag="icoreFilterFlag"
            >
              <el-table-column
                type="index"
                label="序号"
                fixed="left"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="noticeNo"
                label="通知单号"
                min-width="110"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="predictionNo"
                label="预报编号"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="railwayNo"
                label="车号"
                min-width="110"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="matterName"
                label="物资名称"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="contractNo"
                label="合同号"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="batchNo"
                label="批次号"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="customerSupplierName"
                label="供应商"
                min-width="200"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="forwardingUnitName"
                label="发货单位"
                min-width="200"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="receivingUintName"
                label="收货单位"
                min-width="200"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="memo"
                min-width="120"
                label="备注"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="materialName"
                label="材质"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="specName"
                label="规格"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="shipmentGrossWeight"
                label="发运毛重"
                min-width="80"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="shipmentNetWeight"
                label="发运净重"
                min-width="80"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="shipmentNum"
                label="发运数量"
                min-width="80"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="bindCardNo"
                label="绑定卡号"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="loadPointName"
                label="卸货地点"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="sampleNo"
                label="取样编号"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="sampleVoucher"
                label="取样凭证"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="carrierUnitName"
                label="承运单位"
                min-width="200"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="predictionType"
                label="预报类型"
                min-width="80"
                align="left"
              >
                <template slot-scope="scope">
                  <span v-if="scope.row.predictionType == 0">批次预报</span>
                  <span v-else-if="scope.row.predictionType == 1"
                    >单次预报</span
                  >
                  <span v-else-if="scope.row.predictionType == 2"
                    >联运预报</span
                  >
                  <span v-else-if="scope.row.predictionType == 3"
                    >分检预报</span
                  >
                </template>
              </el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="predictionCombination"
                label="预报组合"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="meterTypeName"
                label="业务类型"
                min-width="80"
                align="left"
              ></el-table-column>
              <!-- <el-table-column sortable :show-overflow-tooltip="true" prop="" label="可用类型" width="80" align="left"></el-table-column> -->
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="effectiveStartTime"
                label="有效开始时间"
                min-width="160"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="effectiveEndTime"
                label="有效结束时间"
                min-width="160"
                align="left"
              ></el-table-column>
              <!-- <el-table-column sortable :show-overflow-tooltip="true" prop="" label="有效总量" width="80" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" prop="" label="有效次数" width="80" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" prop="" label="检斤重量" width="80" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" prop="" label="检斤次数" width="80" align="left"></el-table-column> -->
              <!-- <el-table-column sortable :show-overflow-tooltip="true" prop="" label="火车车号" width="80" align="left"></el-table-column> -->
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="valueFlag"
                label="状态"
                min-width="60"
                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>
                  <span v-else-if="scope.row.valueFlag == 3">已作废</span>
                  <span v-else-if="scope.row.valueFlag == 4">正使用</span>
                </template>
              </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>
    </div>
  </div>
</template>
<script>
import { formatDate } from '@/utils/util.js';
import { getCookie } from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js';

export default {
  data () {
    return {
      dataLoading: false,
      dataLoading2: false,
      operateLoading: false,
      icoreFilterFlag: true,
      baseSpotNameItem: [],//计量点
      actualFirst: {},
      meterTypeNameItem: [],
      matterNameItem: [],
      matterNameItem2: [],
      valueFlagItem: [
        { valueFlag: '有效' },
        { valueFlag: '作废' },
        { valueFlag: '结净' }
      ],
      predictionTypeItem: [
        { predictionType: '批次预报' },
        { predictionType: '单次预报' },
        { predictionType: '联运预报' },
        { predictionType: '分检预报' }
      ],
      page: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      table: {
        list: [],
        list2: []
      },
      multipleSelection: {},
      singleCurrent: {},
      tableHeight: 0,
      search: {
        railwayNo: '',
        baseSpotName: '',
        baseSpotNo: '',
        meterTypeName: '',
        matterNo: '',
        valueFlag: '',
        strDate: '',
        envDate: '',
      },
      search2: {
        predictionNo: '',
        railwayNo: '',
        predictionType: '',
        meterTypeName: '',
        matterNo: ''
      },
      ruleValidateSearch: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify,
          trigger: 'blur'
        }]
      },
      activeMenu: '',
      userNo: '',
      userName: ''
    }
  },
  created () {
    this.userNo = getCookie(cookieUserId);
    this.userName = getCookie(cookieUserName);
    this.tableHeight = (window.innerHeight - 320) / 2 > 200 ? (window.innerHeight - 320) / 2 : 200
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted () {
    this.getDataList();
    // this.getMatterNameItem();
    this.getBaseSpotNameItem();
    this.getMeterTypeNameItem();
  },
  methods: {
    getMatterName (val) {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterName=' + val)
        .then(res => {
          this.matterNameItem = res.data;
        })
    },
    getMatterName2 (val) {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterName=' + val)
        .then(res => {
          this.matterNameItem2 = res.data;
        })
    },
    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()
      }
    },
    mateData () {
      if (JSON.stringify(this.multipleSelection) == "{}") {
        return this.$message.warning('请选择一条计量数据！');
      }
      if (JSON.stringify(this.singleCurrent) == "{}") {
        return this.$message.warning('请选择一条计量预报数据！');
      }
      let obj = {}
      const param = {
        createManNo: this.userNo,
        createManName: this.userName,
        operationPage: '静轨-结净计量数据匹配',
        operationFunction: "匹配",
        operationId: this.multipleSelection.actualNo,
        operationPredictionNo: this.singleCurrent.predictionNo,
        operationCarnNo: this.multipleSelection.railwayNo,
        operationBeforeFix: '', // 毛重编号
        operationAfterFix: '' // 皮重编号
      }
      //  let obj = Object.assign(this.multipleSelection[0], this.singleCurrent);
      obj.actualFirstNo = this.multipleSelection.actualFirstNo
      obj.predictionNo = this.singleCurrent.predictionNo
      this.axios.post('pass/systemBase/v1/meterworkrailwayactfirsts/match', obj, { individualType: 'json' }).then(async res => {
        if (res.succeed) {
          const res1 = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
          if (!res1.succeed) {
            this.$message.error('匹配日志保存失败')
          }
          this.$message.success('匹配成功');
          // this.getDataListUpdate()
          this.searchData()
          this.getDataList2(this.actualFirst);
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    removeData () {
      if (JSON.stringify(this.multipleSelection) == "{}") {
        return this.$message.warning('请选择计量数据！');
      }
      const param = {
        createManNo: this.userNo,
        createManName: this.userName,
        operationPage: '静轨-结净计量数据匹配',
        operationFunction: "解除",
        operationId: this.multipleSelection.actualNo,
        operationPredictionNo: this.multipleSelection.predictionNo,
        operationCarnNo: this.multipleSelection.railwayNo,
        operationBeforeFix: '', // 毛重编号
        operationAfterFix: '' // 皮重编号
      }
      this.axios.post('pass/systemBase/v1/meterworkrailwayactfirsts/remove', this.multipleSelection, { individualType: 'json' }).then(async res => {
        if (res.succeed) {
          const res1 = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
          if (!res1.succeed) {
            this.$message.error('解除日志保存失败')
          }
          this.$message.success('解除成功');
          // this.getDataListUpdate()
          this.searchData()
          this.getDataList2(this.actualFirst);
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    handleCurrentChange2 (val) {
      this.multipleSelection = val;
      this.getDataList2(val)
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData()
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData(2)
    },
    pageSizeChange2 (size) {
      this.page2.pageSize = size;
      this.getDataList2(this.actualFirst);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.getDataList2(this.actualFirst);
    },
    handleCurrentChange (val) {
      this.singleCurrent = val
    },
    getDataList () {
      this.dataLoading = true;
      this.axios.get('pass/systemBase/v1/meterworkrailwayactfirsts/selectSta' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize + '&valueFlag=1')
        .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.getDataList2(this.table.list[0])
          }
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    getDataListUpdate () {
      this.dataLoading = true;
      this.axios.get('pass/systemBase/v1/meterworkrailwayactfirsts/selectSta' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize + '&valueFlag=1')
        .then(res => {
          this.dataLoading = false;
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    getDataList2 (row) {
      this.actualFirst = row
      this.dataLoading2 = true;
      this.$refs.dataTable.setCurrentRow(row)
      this.axios.get('pass/systemBase/v1/prerailwayscales/select' + '?pageNum=' + this.page2.pageNum + '&pageSize=' + this.page2.pageSize + '&railwayNo=' + row.railwayNo)
        .then(res => {
          this.dataLoading2 = false;
          this.table.list2 = res.data.list;
          this.page2.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading2 = false;
        });
    },
    searchData (flag = 1) {
      if (flag === 1) {
        this.page.pageNum = 1
      }
      this.$refs['searchData1'].validate((valid) => {
        if (valid) {
          this.dataLoading = true;
          this.page.pageNum = 1;
          // this.search.valueFlag1 = this.search.valueFlag === '有效' ? 1 : this.search.valueFlag === '作废' ? 0 : this.search.valueFlag === '结净' ? 2 : ''
          this.search.strDate = formatDate(this.search.strDate, 'yyyy-MM-dd HH:mm:ss')
          this.search.envDate = formatDate(this.search.envDate, 'yyyy-MM-dd HH:mm:ss')
          this.axios.get('pass/systemBase/v1/meterworkrailwayactfirsts/selectSta' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize + '&railwayNo=' + this.search.railwayNo
            + '&baseSpotNo=' + this.search.baseSpotNo + '&meterTypeName=' + this.search.meterTypeName + '&matterNo=' + this.search.matterNo + '&valueFlag=1'
            + '&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.getDataList2(this.table.list[0])
              }
            }).catch(e => {
              this.dataLoading = false;
            });
        }
      })
    },
    searchData2 () {
      this.dataLoading2 = true;
      this.page2.pageNum = 1;
      this.search2.predictionType1 = this.search2.predictionType === '批次预报' ? 0 : this.search2.predictionType === '单次预报' ? 1 : this.search2.predictionType === '联运预报' ? 2 : this.search2.predictionType === '分检预报' ? 3 : ''
      this.axios.get('pass/systemBase/v1/prerailwayscales/' + '?pageNum=' + this.page2.pageNum + '&pageSize=' + this.page2.pageSize + '&railwayNo=' + this.search2.railwayNo
        + '&predictionNo=' + this.search2.predictionNo + '&meterTypeName=' + this.search2.meterTypeName + '&matterNo=' + this.search2.matterNo + '&predictionType=' + this.search2.predictionType1)
        .then(res => {
          this.dataLoading2 = false;
          this.table.list2 = res.data.list;
          this.page2.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading2 = false;
        });
    },
    getMatterNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1')
        .then(res => {
          this.matterNameItem = res.data;
        })
    },
    getBaseSpotNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasespotinfos/noPage' + '?validFlag=1' + '&spotTypeNo=001002002&spotTypeName=轨道衡')
        .then(res => {
          this.baseSpotNameItem = res.data;
        })
    },
    getMeterTypeNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001006' + '&validFlag=1')
        .then(res => {
          this.meterTypeNameItem = res.data;
        })
    },
    tableRowClassName ({
      row,
      rowIndex
    }) {
      if (row.valueFlag === '0') {
        return 'error-row2';
      }
      return '';
    },
    tableRowClassName2 ({
      row,
      rowIndex
    }) { }
  }
}
</script>

<style scoped>
</style>