<!--一次计量数据维护-->
<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="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="getMatterName1"
            >
              <el-option
                v-for="(item, index) in matterNameItem1"
                :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="18">
          <div style="border-right: 1px solid #d5d5d5">
            <div
              style="
                display: flex;
                padding-left: 10px;
                padding-top: 10px;
                margin-bottom: 10px;
                border-bottom: 1px solid #d5d5d5;
                height: 45px;
              "
            >
              一次计量数据 （
              <div
                style="
                  width: 12px;
                  height: 12px;
                  background-color: #000000;
                  color: #000000;
                  margin-top: 5px;
                "
              ></div>
              洁净
              <div
                style="
                  width: 12px;
                  height: 12px;
                  background-color: rgb(0, 116, 10);
                  color: rgb(0, 116, 10);
                  margin-left: 5px;
                  margin-top: 5px;
                "
              ></div>
              有效
              <div
                style="
                  width: 12px;
                  height: 12px;
                  background-color: red;
                  color: red;
                  margin-left: 5px;
                  margin-top: 5px;
                "
              ></div>
              作废）
              <div>
                <el-button
                  icon="el-icon-circle-plus-outline"
                  type="primary"
                  size="mini"
                  @click="addData"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'ADD'"
                  >新增</el-button
                >
                <el-button
                  icon="el-icon-edit"
                  type="primary"
                  size="mini"
                  @click="modifyData"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'UPDATE'"
                  >修改</el-button
                >
                <el-button
                  size="mini"
                  type="primary"
                  icon="el-icon-check"
                  @click="enableData"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'RECOVERY'"
                  >启用</el-button
                >
                <el-button
                  size="mini"
                  type="danger"
                  plain
                  icon="el-icon-remove-outline"
                  @click="discardData"
                  v-loading.fullscreen.lock="operateLoading"
                  v-privilege="activeMenu + 'ABOLISH'"
                  >废除</el-button
                >
                <el-button
                  type="primary"
                  size="mini"
                  @click="showBatchDialog"
                  v-privilege="activeMenu + 'BATCHEDIT'"
                  >批量修改</el-button
                >
              </div>
            </div>
            <div class="common-table-div">
              <el-table
                v-loading="dataLoading"
                @row-click="rowChange"
                :row-class-name="tableRowClassName"
                ref="dataTable"
                highlight-current-row
                border
                :height="tableHeight"
                @selection-change="handleSelectionChange"
                :data="table.list"
                @cell-click="getDataList2"
                :exchangeFilterMap="{
                  valueFlag: { '0': '作废', '1': '有效', '2': '洁净' },
                  weightType: {
                    '0': '毛重',
                    '1': '常规皮重',
                    '2': '期限皮重',
                    '3': '历史皮重',
                    '4': '标识皮重',
                    '5': '自重皮重',
                  },
                }"
                :icore-filter-flag="icoreFilterFlag"
              >
                <el-table-column
                  type="index"
                  label="序号"
                  fixed="left"
                  align="center"
                ></el-table-column>
                <el-table-column
                  type="selection"
                  width="55"
                  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"
                  fixed="left"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="carNo"
                  label="车号"
                  min-width="80"
                  fixed="left"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="trailerNo"
                  label="挂号"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="matterName"
                  label="物资名称"
                  min-width="120"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="contractNo"
                  min-width="100"
                  label="合同号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="batchNo"
                  min-width="100"
                  label="批次号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="customerSupplierName"
                  min-width="200"
                  label="供应商"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="forwardingUnitName"
                  min-width="200"
                  label="发货单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="receivingUintName"
                  min-width="200"
                  label="收货单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterWeight"
                  label="重量/t"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.round((scope.row.meterWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterNum"
                  min-width="110"
                  label="数量"
                  align="right"
                >
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="baseSpotName"
                  min-width="100"
                  label="计量点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="createTime"
                  min-width="160"
                  label="计量时间"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="shipmentGrossWeight"
                  min-width="110"
                  label="发运毛重"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{
                      Math.round((scope.row.shipmentGrossWeight - 0) / 10) / 100
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="shipmentNetWeight"
                  min-width="110"
                  label="发运净重"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{
                      Math.round((scope.row.shipmentNetWeight - 0) / 10) / 100
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="shipmentNum"
                  min-width="110"
                  label="发运数量"
                  align="right"
                >
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="addWeight"
                  min-width="100"
                  label="附加重量/t"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.round((scope.row.addWeight - 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="createManName"
                  min-width="100"
                  label="计量员"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterClass"
                  min-width="100"
                  label="班次"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterGroup"
                  min-width="100"
                  label="班组"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="materialName"
                  min-width="100"
                  label="材质"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="specName"
                  min-width="100"
                  label="规格"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="bindCardNo"
                  min-width="100"
                  label="绑定卡号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="loadPointName"
                  min-width="100"
                  label="卸货地点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="sampleNo"
                  min-width="100"
                  label="取样编号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="sampleVoucher"
                  min-width="100"
                  label="取样凭证"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="carrierUnitName"
                  min-width="200"
                  label="承运单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterTypeName"
                  min-width="100"
                  label="业务类型"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="valueFlag"
                  label="状态"
                  width="60"
                  min-width="100"
                  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
              ref="editTitle"
              class="common-title-div"
              style="margin-top: 20px; border-top: 1px solid #d5d5d5"
            >
              一次计量数据编辑区
            </div>
            <div ref="editDiv" class="commom-edit-div">
              <el-form
                ref="baseData"
                label-width="80px"
                :inline="true"
                :rules="ruleValidateTable1"
                :model="baseData"
              >
                <el-form-item prop="predictionNo" label="预报编号">
                  <el-input
                    v-model="baseData.predictionNo"
                    clearable
                    size="small"
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="meterTypeName" label="业务类型">
                  <el-select
                    v-model="baseData.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="addWeight" label="附加重量">
                  <el-input
                    v-model="baseData.addWeight"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="contractNo" label="合 同  号">
                  <el-input
                    v-model="baseData.contractNo"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="materialName" label="材       质">
                  <el-select
                    v-model="baseData.materialName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in materialNameItem"
                      :key="index"
                      :label="item.baseName"
                      :value="item.baseName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="forwardingUnitName" label="发货单位">
                  <el-select
                    v-model="baseData.forwardingUnitName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in forwardingUnitNameItem"
                      :key="index"
                      :label="item.companyName"
                      :value="item.companyName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="railwayNo" label="火车车号">
                  <el-input
                    v-model="baseData.railwayNo"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="meterMode" label="计量方式">
                  <el-select
                    v-model="baseData.meterMode"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in meterModeItem"
                      :key="index"
                      :label="item.meterMode"
                      :value="item.meterMode"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="carNo" label="车      号">
                  <el-input
                    v-model="baseData.carNo"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="meterWeight" label="计量重量/T">
                  <el-input
                    v-model="baseData.meterWeight"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="meterGroup" label="班     组">
                  <el-select
                    v-model="baseData.meterGroup"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in meterGroupItem"
                      :key="index"
                      :label="item.meterGroup"
                      :value="item.meterGroup"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="batchNo" label="批 次  号">
                  <el-input
                    v-model="baseData.batchNo"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="specName" label="规       格">
                  <el-select
                    v-model="baseData.specName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in specNameItem"
                      :key="index"
                      :label="item.baseName"
                      :value="item.baseName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="receivingUintName" label="收货单位">
                  <el-select
                    v-model="baseData.receivingUintName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in receivingUintNameItem"
                      :key="index"
                      :label="item.companyName"
                      :value="item.companyName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="weightType" label="重量类型">
                  <el-select
                    v-model="baseData.weightType"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in weightTypeItem"
                      :key="index"
                      :label="item.weightType"
                      :value="item.weightType"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="baseSpotName" label="计量点">
                  <el-select
                    v-model="baseData.baseSpotName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in baseSpotNameItem"
                      :key="index"
                      :label="item.baseSpotName"
                      :value="item.baseSpotName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="matterName" label="物资名称">
                  <el-select
                    v-model="baseData.matterName"
                    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.matterName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="meterNum" label="计量数量">
                  <el-input
                    v-model="baseData.meterNum"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="meterClass" label="班     次">
                  <el-select
                    v-model="baseData.meterClass"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in meterClassItem"
                      :key="index"
                      :label="item.meterClass"
                      :value="item.meterClass"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="loadPointName" label="卸货地点">
                  <el-select
                    v-model="baseData.loadPointName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in loadPointNameItem"
                      :key="index"
                      :label="item.loadPointName"
                      :value="item.loadPointName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="carrierUnitName" label="承运单位">
                  <el-select
                    v-model="baseData.carrierUnitName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in carrierUnitNameItem"
                      :key="index"
                      :label="item.carrierUnitName"
                      :value="item.carrierUnitName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="customerSupplierName" label="供应商">
                  <el-select
                    v-model="baseData.customerSupplierName"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in customerSupplierNameItem"
                      :key="index"
                      :label="item.customerSupplierName"
                      :value="item.customerSupplierName"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="trailerNo" label="挂号">
                  <el-input
                    v-model="baseData.trailerNo"
                    size="small"
                    clearable
                    style="width: 120px"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="createTime" label="计量时间">
                  <el-date-picker
                    v-model="baseData.createTime"
                    clearable
                    type="datetime"
                    placeholder="选择日期"
                    size="small"
                  ></el-date-picker>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="common-title-div">
            附加重量
            <div class="common-operation-button-div">
              <el-button
                icon="el-icon-circle-plus-outline"
                type="primary"
                size="mini"
                @click="addData2"
                v-loading.fullscreen.lock="operateLoading"
                v-privilege="activeMenu + 'ADD2'"
                >新增</el-button
              >
              <el-button
                size="mini"
                type="danger"
                plain
                icon="el-icon-remove-outline"
                @click="discardData2"
                v-loading.fullscreen.lock="operateLoading"
                v-privilege="activeMenu + 'DELETE2'"
                >删除</el-button
              >
            </div>
          </div>
          <div class="common-table-div">
            <el-table
              v-loading="dataLoading2"
              :row-class-name="tableRowClassName"
              ref="dataTable2"
              highlight-current-row
              border
              :height="tableHeight"
              @selection-change="handleSelectionChange2"
              :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"
                fixed="left"
                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="器具重量（T）"
                min-width="120"
                align="right"
              >
                <template slot-scope="scope">
                  {{ Math.round((scope.row.utensilWeight - 0) / 10) / 100 }}
                </template>
              </el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilUtensilName"
                label="器具属性"
                min-width="80"
                align="left"
              ></el-table-column>
              <!-- <el-table-column sortable :show-overflow-tooltip="true" prop="memo" label="备注" min-width="200" 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>
          <div
            ref="editTitle"
            class="common-title-div"
            style="margin-top: 20px; border-top: 1px solid #d5d5d5"
          >
            附加重量编辑区
          </div>
          <div ref="editDiv2" class="commom-edit-div">
            <el-form
              ref="baseData2"
              label-width="80px"
              :inline="true"
              :rules="ruleValidateTable2"
              :model="baseData2"
            >
              <el-form-item prop="utensilNo" label="器具编号">
                <el-input
                  v-model="baseData2.utensilNo"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                  @blur="getUtensil(baseData2.utensilName)"
                ></el-input>
              </el-form-item>
              <el-form-item prop="utensilName" label="器具名称">
                <el-select
                  v-model="baseData2.utensilName"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                  @change="getUtensil(baseData2.utensilName)"
                >
                  <el-option
                    v-for="(item, index) in utensilNameItem"
                    :key="index"
                    :label="item.baseName"
                    :value="item.baseName"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="utensilUtensilName" label="器具属性">
                <el-select
                  v-model="baseData2.utensilUtensilName"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                  readonly
                  disabled
                >
                  <el-option
                    v-for="(item, index) in utensilUtensilNameItem"
                    :key="index"
                    :label="item.baseName"
                    :value="item.baseName"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="utensilWeight" label="器具重量">
                <el-input
                  v-model="baseData2.utensilWeight"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                  readonly
                  disabled
                ></el-input>
              </el-form-item>
              <!-- <el-form-item prop="memo" label="备注">
                         <el-input v-model="baseData2.memo" size="small" placeholder="请输入" style="width:220px" type="textarea" :rows="3"></el-input>
                       </el-form-item> -->
            </el-form>
          </div>
        </el-col>
      </el-row>
    </div>
    <!-- 批量编辑弹窗 -->
    <batch-edit-dialog
      type="first"
      :showFlag="editDialogVisible"
      :baseData="batchEditData"
      :dataList="batchEditList"
      @close="closeDialog"
    >
    </batch-edit-dialog>
  </div>
</template>
<script>
import { formatDate, getCookie } from '@/utils/util.js';
import { cookieUserId, cookieUserName } from '@/config/config.js';
import { recordChange } from '../../../../utils/utils'
import { MessageBox } from 'element-ui'
import batchEditDialog from './common/batchEditDialog';

export default {
  data () {
    return {
      dataLoading: false,
      dataLoading2: false,
      operateLoading: false,
      actualFirst: {},
      baseSpotNameItem: [],//计量点
      meterTypeNameItem: [],
      matterNameItem1: [],
      matterNameItem2: [],
      valueFlagItem: [
        { valueFlag: '有效' },
        { valueFlag: '作废' },
        { valueFlag: '结净' }
      ],
      materialNameItem: [],//材质
      forwardingUnitNameItem: [],//发货单位
      icoreFilterFlag: true,
      meterModeItem: [
        { id: '1', meterMode: '远程计量' },
        { id: '2', meterMode: '智能计量' },
        { id: '3', meterMode: '手工录入' },
        { id: '4', meterMode: '放行智能计量' },
        { id: '5', meterMode: '滞后匹配' }
      ],//计量方式
      meterGroupItem: [
        { meterGroup: '甲' },
        { meterGroup: '乙' },
        { meterGroup: '丙' },
        { meterGroup: '丁' }
      ],//班组
      specNameItem: [],//规格
      receivingUintNameItem: [],//收货单位
      weightTypeItem: [
        { id: '0', weightType: '毛重' },
        { id: '1', weightType: '常规皮重' },
        { id: '2', weightType: '期限皮重' },
        { id: '3', weightType: '历史皮重' },
        { id: '4', weightType: '标识皮重' },
        { id: '5', weightType: '自重皮重' }
      ],//重量类型
      meterClassItem: [
        { meterClass: '白班' },
        { meterClass: '中班' },
        { meterClass: '晚班' },
        { meterClass: '常白班' }
      ],//班次
      loadPointNameItem: [],//卸货地点
      carrierUnitNameItem: [],//承运单位
      customerSupplierNameItem: [],//供应商
      utensilNameItem: [],//器具名称
      utensilUtensilNameItem: [],//器具属性
      page: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      table: {
        list: [],
        list2: []
      },
      baseData: {
        predictionNo: '',
        meterTypeName: '',
        addWeight: '',
        contractNo: '',
        materialName: '',
        forwardingUnitName: '',
        railwayNo: '',
        meterMode: '远程计量',
        carNo: '',
        meterWeight: '',
        meterGroup: '甲',
        batchNo: '',
        specName: '',
        receivingUintName: '',
        contractNo: '',
        weightType: '毛重',
        baseSpotName: '',
        matterName: '',
        meterNum: '',
        meterClass: '白班',
        createTime: '',
        loadPointName: '',
        carrierUnitName: '',
        customerSupplierName: '',
        trailerNo: '',
      },
      baseData2: {
        utensilName: '',
        utensilWeight: '',
        utensilUtensilName: '',
        utensilNo: ''
      },
      multipleSelection: [],
      tableHeight: 0,
      search: {
        carNo: '',
        baseSpotNo: '',
        meterTypeName: '',
        matterNo: '',
        valueFlag: '',
        strDate: formatDate(new Date()).slice(0, 10) + ' 00:00:00',
        envDate: formatDate(new Date()).slice(0, 10) + ' 23:59:59',
      },
      ruleValidateSearch: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify,
          trigger: 'blur'
        }]
      },
      ruleValidateTable1: {
        carNo: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        createTime: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        meterTypeName: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        baseSpotName: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        meterWeight: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }]
      },
      ruleValidateTable2: {
        utensilWeight: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        utensilNo: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        utensilUtensilName: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        utensilName: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
      },
      activeMenu: '',
      oldObj: {},
      newObj: {},
      userNo: '',
      userName: '',
      matList: [],
      groupList: [20, 2],
      ctrlFlag: false,
      editDialogVisible: false,
      batchEditData: {},
      batchEditList: []
    }
  },
  created () {
    this.tableHeight = (window.innerHeight - 220) / 2 > 300 ? (window.innerHeight - 220) / 2 : 300
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
    this.userNo = getCookie(cookieUserId)
    this.userName = getCookie(cookieUserName)
  },
  mounted () {
    let _this = this
    // this.getDataList();
    this.searchDatas();
    this.getBaseSpotNameItem();
    this.getMatterNameItem();
    this.getCarrierUnitNameItem();
    this.getUtensilNameItem();
    this.getLoadPointNameItem();
    this.getCustomerSupplierNameItem();
    this.getMeterTypeNameItem();
    this.getUtensilUtensilNameItem();
    this.getMaterialNameItem();//材质
    this.getSpecNameItem();//规格
    this.getForwardingUnitNameItem();//发货单位
    this.getReceivingUintNameItem();//收货单位
    // // 监听页面的按键事件
    // document.onkeydown = function (event) {
    //   // 判断 Ctrl
    //   if (event.ctrlKey) {
    //     if (!_this.ctrlFlag) {
    //       _this.ctrlFlag = true
    //       event.preventDefault();//取消默认行为
    //       console.log('下');
    //     }
    //   }
    // }
    // document.onkeyup = function (e) {
    //   if (e.ctrlKey) {
    //     _this.ctrlFlag = false;
    //     e.preventDefault();//取消默认行为
    //   }
    // }
  },
  methods: {
    getCode (code, arr, codeKey, nameKey) {
      if (!code) {
        return '';
      }
      let targetRow = arr.find(item => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : '';
    },
    getMatterName1 (val) {
      if (val) {
        this.matterNameItem1 = this.matList.filter(item => {
          if (item.matterName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.matterNameItem1 = [...this.matList].slice(0, 300)
      }
    },
    getMatterName2 (val) {
      if (val) {
        this.matterNameItem2 = this.matList.filter(item => {
          if (item.matterName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.matterNameItem2 = [...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()
      }
    },
    // 显示批量修改弹窗
    showBatchDialog () {
      try {
        this.multipleSelection.forEach(item => {
          if (item.valueFlag - 0 !== 0) {
            if (item.valueFlag - 0 === 0) {
              throw new Error(`选中数据中存在已作废的数据，不能进行批量修改`)
            } else if (item.valueFlag - 0 === 2) {
              throw new Error(`选中数据中存在已洁净的数据，请到洁净计量数据维护页面进行修改`)
            }
          }
        })
      } catch (e) {
        return this.$message.error(e.message)
      }
      if (this.multipleSelection.length === 0) {
        return this.$message.error('请选择要进行批量修改的数据')
      }
      this.batchEditList = [...this.multipleSelection]
      this.editDialogVisible = true;
    },
    getUtensil (val) {
      if (this.baseData2.utensilNo !== '' && val !== '') {
        this.axios.get('pass/systemBase/v1/meterbaseaddweights/' + '?utensilNo=' + this.baseData2.utensilNo + '&utensilName=' + val)
          .then(res => {
            if (res.data.list.length !== 0) {
              this.baseData2.utensilWeight = res.data.list[0].utensilWeight
              this.baseData2.utensilUtensilName = res.data.list[0].utensilUtensilName
            } else {
              this.baseData2.utensilWeight = '',
                this.baseData2.utensilUtensilName = ''
            }
          })
      } else {
        this.baseData2.utensilWeight = '',
          this.baseData2.utensilUtensilName = ''
      }
    },
    refresh () {
      this.baseData = {
        predictionNo: '',
        meterTypeName: '',
        addWeight: '',
        contractNo: '',
        materialName: '',
        forwardingUnitName: '',
        railwayNo: '',
        meterMode: '远程计量',
        carNo: '',
        meterWeight: '',
        meterGroup: '甲',
        batchNo: '',
        specName: '',
        receivingUintName: '',
        contractNo: '',
        weightType: '毛重',
        baseSpotName: '',
        matterName: '',
        meterNum: '',
        meterClass: '白班',
        createTime: '',
        loadPointName: '',
        carrierUnitName: '',
        customerSupplierName: '',
        trailerNo: '',
      }
      // this.baseData.matterName = this.matterNameItem[0].matterName
      // this.baseData.carrierUnitName = this.carrierUnitNameItem[0].carrierUnitName
      // this.baseData.loadPointName = this.loadPointNameItem[0].loadPointName
      // this.baseData.customerSupplierName = this.customerSupplierNameItem[0].customerSupplierName
      // this.baseData.meterTypeName = this.meterTypeNameItem[0].baseName
      // this.baseData.materialName = this.materialNameItem[0].baseName
      // this.baseData.specName = this.specNameItem[0].baseName
      // this.baseData.receivingUintName = this.receivingUintNameItem[0].companyName
      // this.baseData.forwardingUnitName = this.forwardingUnitNameItem[0].companyName
      this.$refs['baseData'].resetFields();
    },
    refresh2 () {
      this.baseData2 = {
        utensilName: '',
        utensilWeight: '',
        utensilUtensilName: '',
        utensilNo: ''
      },
        this.baseData2.utensilName = this.utensilNameItem[0].baseName;
      this.baseData2.utensilUtensilName = this.utensilUtensilNameItem[0].baseName;
      this.$refs['baseData2'].resetFields();
    },
    addData () {
      this.$refs['baseData'].validate((valid) => {
        console.log(valid)
        if (valid) {
          let baseDataAdd = {}
          baseDataAdd.predictionNo = this.baseData.predictionNo
          baseDataAdd.meterTypeName = this.baseData.meterTypeName
          baseDataAdd.addWeight = this.baseData.addWeight
          baseDataAdd.materialName = this.baseData.materialName
          baseDataAdd.forwardingUnitName = this.baseData.forwardingUnitName
          baseDataAdd.railwayNo = this.baseData.railwayNo
          baseDataAdd.carNo = this.baseData.carNo
          baseDataAdd.meterWeight = this.baseData.meterWeight
          baseDataAdd.meterGroup = this.baseData.meterGroup
          baseDataAdd.batchNo = this.baseData.batchNo
          baseDataAdd.specName = this.baseData.specName
          baseDataAdd.receivingUintName = this.baseData.receivingUintName
          baseDataAdd.contractNo = this.baseData.contractNo
          baseDataAdd.baseSpotName = this.baseData.baseSpotName
          baseDataAdd.matterName = this.baseData.matterName
          baseDataAdd.meterNum = this.baseData.meterNum
          baseDataAdd.meterClass = this.baseData.meterClass
          baseDataAdd.createTime = this.baseData.createTime
          baseDataAdd.loadPointName = this.baseData.loadPointName
          baseDataAdd.carrierUnitName = this.baseData.carrierUnitName
          baseDataAdd.customerSupplierName = this.baseData.customerSupplierName
          baseDataAdd.trailerNo = this.baseData.trailerNo
          baseDataAdd.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'meterMode', 'id')
          baseDataAdd.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'weightType', 'id')
          baseDataAdd.baseSpotNo = this.getCode(this.baseData.baseSpotName, this.baseSpotNameItem, 'baseSpotName', 'baseSpotNo')
          baseDataAdd.meterTypeNo = this.getCode(this.baseData.meterTypeName, this.meterTypeNameItem, 'baseName', 'baseCode')
          baseDataAdd.matterNo = this.getCode(this.baseData.matterName, this.matList, 'matterName', 'matterNo')
          baseDataAdd.loadPointNo = this.getCode(this.baseData.loadPointName, this.loadPointNameItem, 'loadPointName', 'loadPointNo') ? this.getCode(this.baseData.loadPointName, this.loadPointNameItem, 'loadPointName', 'loadPointNo') : ''
          baseDataAdd.carrierUnitNo = this.getCode(this.baseData.carrierUnitName, this.carrierUnitNameItem, 'carrierUnitName', 'carrierUnitNo')
          baseDataAdd.customerSupplierNo = this.getCode(this.baseData.customerSupplierName, this.customerSupplierNameItem, 'customerSupplierName', 'customerSupplierNo')
          baseDataAdd.materialNo = this.getCode(this.baseData.materialName, this.materialNameItem, 'baseName', 'baseCode')
          baseDataAdd.specNo = this.getCode(this.baseData.specName, this.specNameItem, 'baseName', 'baseCode')
          baseDataAdd.forwardingUnitNo = this.getCode(this.baseData.forwardingUnitName, this.forwardingUnitNameItem, 'companyName', 'companyNo')
          baseDataAdd.receivingUintNo = this.getCode(this.baseData.receivingUintName, this.receivingUintNameItem, 'companyName', 'companyNo')
          // 检验下计量重量是否大于200，如果大于则进行提示
          if (this.baseData.meterWeight - 0 > 200) {
            this.$confirm('当前填写的计量重量大于200吨，确定此车计量重量大于200吨吗？', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              // 将重量转换为吨以后显示
              let meterWeight = this.baseData.meterWeight * 1000
              const param = {
                createManNo: this.userNo,
                createManName: this.userName,
                operationPage: '一次计量数据维护页面',
                operationFunction: "新增",
                operationId: this.baseData.id,
                operationPredictionNo: this.baseData.predictionNo,
                operationCarnNo: this.baseData.carNo,
                operationBeforeFix: '',
                operationAfterFix: ''
              }

              this.axios.post('pass/systemBase/v1/meterworkcaractualfirsts/add', { ...baseDataAdd, meterWeight }, { individualType: 'json' }).then(async res => {
                if (res.succeed) {
                  const log = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
                  if (!log.succeed) {
                    this.$message.error('新增日志保存失败');
                  }
                  this.$message.success('新增成功');
                  // this.getDataList();
                  this.searchDatas();
                  this.refresh();
                } else {
                  this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
                  this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
                  this.$message.error(res.message)
                }
              }).catch(e => {
                this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
                this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
                this.$message.error(e.message)
              })
            }).catch(() => {
            });
          } else {
            let meterWeight = this.baseData.meterWeight * 1000
            const param = {
              createManNo: this.userNo,
              createManName: this.userName,
              operationPage: '一次计量数据维护页面',
              operationFunction: "新增",
              operationId: this.baseData.id,
              operationPredictionNo: this.baseData.predictionNo,
              operationCarnNo: this.baseData.carNo,
              operationBeforeFix: '',
              operationAfterFix: ''
            }

            this.axios.post('pass/systemBase/v1/meterworkcaractualfirsts/add', { ...baseDataAdd, meterWeight }, { individualType: 'json' }).then(async res => {
              if (res.succeed) {
                const log = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
                if (!log.succeed) {
                  this.$message.error('新增日志保存失败');
                }
                this.$message.success('新增成功');
                // this.getDataList();
                this.searchDatas();
                this.refresh();
              } else {
                this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
                this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
                this.$message.error(res.message)
              }
            }).catch(e => {
              this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
              this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
              this.$message.error(e.message)
            })
          }
        }
      })
    },
    async modifyData () {
      if (this.baseData.meterWeight - 0 === 0) {
        return this.$message.error('计量重量需要大于0')
      }
      if (this.baseData.meterWeight - 0 < 400) {
        // 将计量重量，附加重量由吨转换为千克
        this.baseData.meterWeight = (this.baseData.meterWeight - 0) * 1000
      }
      if (this.baseData.addWeight - 0 < 400) {
        this.baseData.addWeight = (this.baseData.addWeight - 0) * 1000
      }
      // 校验当前数据是否结净
      if (this.baseData.valueFlag - 0 !== 1) {
        let msg = ''
        console.log(1)
        switch (this.baseData.valueFlag - 0) {
          case 0: msg = '当前修改数据已作废'; break;
          case 2: msg = '当前修改数据已结净，不允许进行修改'; break;
        }
        return this.$message.error(msg)
      }
      this.$refs['baseData'].validate((valid) => {
        if (valid) {
          this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'meterMode', 'id')
          this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'weightType', 'id')
          this.baseData.baseSpotNo = this.getCode(this.baseData.baseSpotName, this.baseSpotNameItem, 'baseSpotName', 'baseSpotNo')
          this.baseData.meterTypeNo = this.getCode(this.baseData.meterTypeName, this.meterTypeNameItem, 'baseName', 'baseCode')
          this.baseData.matterNo = this.getCode(this.baseData.matterName, this.matList, 'matterName', 'matterNo')
          this.baseData.loadPointNo = this.getCode(this.baseData.loadPointName, this.loadPointNameItem, 'loadPointName', 'loadPointNo') ? this.getCode(this.baseData.loadPointName, this.loadPointNameItem, 'loadPointName', 'loadPointNo') : ''
          this.baseData.carrierUnitNo = this.getCode(this.baseData.carrierUnitName, this.carrierUnitNameItem, 'carrierUnitName', 'carrierUnitNo')
          this.baseData.customerSupplierNo = this.getCode(this.baseData.customerSupplierName, this.customerSupplierNameItem, 'customerSupplierName', 'customerSupplierNo')
          this.baseData.materialNo = this.getCode(this.baseData.materialName, this.materialNameItem, 'baseName', 'baseCode')
          this.baseData.specNo = this.getCode(this.baseData.specName, this.specNameItem, 'baseName', 'baseCode')
          this.baseData.forwardingUnitNo = this.getCode(this.baseData.forwardingUnitName, this.forwardingUnitNameItem, 'companyName', 'companyNo')
          this.baseData.receivingUintNo = this.getCode(this.baseData.receivingUintName, this.receivingUintNameItem, 'companyName', 'companyNo')

          // 记录修改的内容
          const { oldStr, newStr } = recordChange(this.oldObj, this.baseData)

          const param = {
            createManNo: this.userNo,
            createManName: this.userName,
            operationPage: '一次计量数据维护页面',
            operationFunction: "修改",
            operationId: this.baseData.id,
            operationPredictionNo: this.baseData.predictionNo,
            operationCarnNo: this.baseData.carNo,
            operationBeforeFix: oldStr,
            operationAfterFix: newStr
          }

          this.axios.post('pass/systemBase/v1/meterworkcaractualfirsts/update', this.baseData, { individualType: 'json' }).then(async res => {
            if (res.succeed) {
              const log = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
              if (!log.succeed) {
                this.$message.error('修改日志保存失败');
              }
              this.$message.success('修改成功');
              this.oldObj = {}
              // this.getDataList();
              this.searchDatas();
              this.refresh();
            } else {
              this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
              this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
              this.$message.error(res.message)
            }
          }).catch(e => {
            this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
            this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
            this.$message.error(e.message)
          })
        }
      })
    },
    enableData () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请选择您要启用的数据！');
        return;
      }
      let flag = false;
      let ParamList = []
      this.multipleSelection.forEach(item => {
        if (item.valueFlag === '1') {
          flag = true;
        }
        let param = {
          createManNo: this.userNo,
          createManName: this.userName,
          operationPage: '一次计量数据维护页面',
          operationFunction: "启用",
          operationId: item.id,
          operationPredictionNo: item.predictionNo,
          operationCarnNo: item.carNo,
          operationBeforeFix: '',
          operationAfterFix: ''
        }
        ParamList.push(param)
      })
      if (flag) {
        this.$message.warning('请选择状态为无效的数据！');
        return false;
      }

      this.axios.post('pass/systemBase/v1/meterworkcaractualfirsts/recover', this.multipleSelection, { individualType: 'json' }).then(async res => {
        if (res.succeed) {
          // 添加日志
          const res = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', ParamList, { individualType: 'json' })
          if (!res.succeed) {
            this.$message.error('记录启用日志失败');
          }
          this.$message.success('启用成功');
          this.$nextTick(() => {
            this.searchData();
          })
          //  this.refresh();
          //  this.refresh2();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    discardData () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请选择您要停用的数据！');
        return;
      }
      let flag = false;
      let ParamList = []
      this.multipleSelection.forEach(item => {
        if (item.valueFlag === '0') {
          flag = true;
        }
        let param = {
          createManNo: this.userNo,
          createManName: this.userName,
          operationPage: '一次计量数据维护页面',
          operationFunction: "作废",
          operationId: item.id,
          operationPredictionNo: item.predictionNo,
          operationCarnNo: item.carNo,
          operationBeforeFix: '',
          operationAfterFix: ''
        }
        ParamList.push(param)
      })
      if (flag) {
        this.$message.warning('请选择状态为有效的数据！');
        return false;
      }
      this.axios.post('pass/systemBase/v1/meterworkcaractualfirsts/abolish', this.multipleSelection, { individualType: 'json' }).then(async res => {
        if (res.succeed) {
          const res = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', ParamList, { individualType: 'json' })
          if (!res.succeed) {
            this.$message.error('记录作废日志失败');
          }
          this.$message.success('作废成功');
          this.searchData();
          //  this.refresh();
          //  this.refresh2();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    addData2 () {
      this.$refs['baseData2'].validate((valid) => {
        if (valid) {
          if (this.multipleSelection.length !== 1) {
            return this.$message.warning('请选择一条计量数据！');
          }
          let baseDataAdd = {}
          baseDataAdd.utensilName = this.baseData2.utensilName
          baseDataAdd.utensilWeight = this.baseData2.utensilWeight
          baseDataAdd.utensilUtensilName = this.baseData2.utensilUtensilName
          baseDataAdd.utensilNo = this.baseData2.utensilNo
          baseDataAdd.actualFirstNo = this.multipleSelection[0].actualFirstNo
          baseDataAdd.utensilTypeNo = this.getCode(this.baseData2.utensilUtensilName, this.utensilUtensilNameItem, 'baseName', 'baseCode')
          baseDataAdd.utensilNameNo = this.getCode(this.baseData2.utensilName, this.utensilNameItem, 'baseName', 'baseCode')
          this.axios.post('pass/systemBase/v1/meterworkaddweights/add', baseDataAdd, { individualType: 'json' }).then(res => {
            if (res.succeed) {
              this.$message.success('新增成功');
              // this.getDataList(1)
              this.searchDatas();
              this.getDataList2(this.actualFirst);
              this.refresh2();
            } else {
              this.$message.error(res.message)
            }
          }).catch(e => {
            this.$message.error(e.message)
          })
        }
      })
    },
    discardData2 () {
      if (this.multipleSelection2.length < 1) {
        this.$message.warning('请选择您要删除的数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/meterworkaddweights/delete', this.multipleSelection2, { individualType: 'json' }).then(res => {
        if (res.code === '0' || res.code === '200') {
          this.$message.success('删除成功');
          // this.getDataList(1)
          this.searchDatas();
          this.getDataList2(this.actualFirst);
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })

    },
    rowChange (row, column, event) {
      // 将重量由千克转换为吨后显示
      // 计量重量，附加重量
      // 记录当前编辑的实体
      this.oldObj = { ...row }
      this.baseData = Object.assign({}, row);
      // 计量重量
      this.baseData.meterWeight = Math.round((row.meterWeight - 0) / 10) / 100
      // 附加重量
      this.baseData.addWeight = Math.round((row.addWeight - 0) / 10) / 100
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterNo=' + this.baseData.matterNo)
        .then(res => {
          this.matterNameItem2 = [...res.data].slice(0, 300);
        })
      this.baseData.meterMode = this.getCode(this.baseData.meterMode, this.meterModeItem, 'id', 'meterMode')
      this.baseData.weightType = this.getCode(this.baseData.weightType, this.weightTypeItem, 'id', 'weightType')
    },
    handleSelectionChange (val) {
      // let list = []
      // if (this.ctrlFlag) {
      //   this.ctrlFlag = false
      //   val.forEach(item => {
      //     let index = this.table.list.findIndex(iItem => iItem.actualFirstNo === item.actualFirstNo)
      //     if (index >= 0) {
      //       list.push(index)
      //     }
      //   })
      //   console.log(list)
      //   // 数据起始index
      //   let list1 = this.table.list.slice(list[0], list[list.length - 1] + 1)
      //   console.log(list1)
      //   list1.forEach(item => {
      //     this.$refs.dataTable.toggleRowSelection(item, true)
      //   })
      // }
      this.multipleSelection = val;
      if (val.length > 0) {
        this.$refs.dataTable.setCurrentRow(this.multipleSelection[val.length - 1])
        this.getDataList2(this.multipleSelection[val.length - 1])
        this.rowChange(this.multipleSelection[val.length - 1])
        this.batchEditData = { ...val[0] }
        this.$refs.dataTable.setCurrentRow(val[val.length - 1])
      }
    },
    // 关闭批量修改弹窗
    closeDialog () {
      this.editDialogVisible = false
      this.multipleSelection = []
      this.batchEditList = []
      this.$refs.dataTable.clearSelection();
      this.searchDatas()
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData();
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData();
    },
    handleSelectionChange2 (val) {
      this.multipleSelection2 = val;
    },
    pageSizeChange2 (size) {
      this.page2.pageSize = size;
      this.getDataList2(this.actualFirst);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.getDataList2(this.actualFirst);
    },
    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 : ''
          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/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;
              if (res.data.list.length < 64) {
                this.groupList = [20]
              } else {
                this.groupList = [20, 2]
              }
              this.page.totalPage = res.data.total;
              if (res.data.list.length > 0) {
                let firstRow = res.data.list[0]
                this.$refs.dataTable.setCurrentRow(firstRow)
                this.getDataList2(firstRow)
              }
            }).catch(e => {
              this.dataLoading = false;
            });
        }
      })
    },
    getDataList (val) {
      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 (!val) {
            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;
        });
    },
    getDataList2 (row) {
      this.actualFirst = row
      if (row === undefined || row === null) {
        this.table.list2 = []
        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;
        });
    },
    tableRowClassName ({
      row,
      rowIndex
    }) {
      if (row.valueFlag === '0') {
        return 'error-row2';
      } else if (row.valueFlag === '1') {
        return 'wait-row'
      }
      return '';
    },
    getBaseSpotNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasespotinfos/noPage' + '?validFlag=1')
        .then(res => {
          this.baseSpotNameItem = res.data;
          // this.baseData.baseSpotName = res.data[0].baseSpotName;
        })
    },
    getMatterNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage')
        .then(res => {
          this.matList = [...res.data]
          this.matterNameItem1 = [...res.data].slice(0, 300);
          this.matterNameItem2 = [...res.data].slice(0, 300);
          // this.baseData.matterName = res.data[0].matterName;
        })
    },
    getCarrierUnitNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasecarrierunits/noPage' + '?validFlag=1')
        .then(res => {
          this.carrierUnitNameItem = res.data;
          // this.baseData.carrierUnitName = res.data[0].carrierUnitName;
        })
    },
    getUtensilNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001010' + '&validFlag=1')
        .then(res => {
          this.utensilNameItem = res.data;
          // this.baseData2.utensilName = res.data[0].baseName;
        })
    },
    getUtensilUtensilNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001009' + '&validFlag=1')
        .then(res => {
          this.utensilUtensilNameItem = res.data;
          // this.baseData2.utensilUtensilName = res.data[0].baseName;
        })
    },
    getLoadPointNameItem () {
      this.axios.get('pass/systemBase/v1/meterbaseloadpoints/noPage' + '?validFlag=1')
        .then(res => {
          this.loadPointNameItem = res.data;
          // this.baseData.loadPointName = res.data.length > 0 ? res.data[0].loadPointName : '';
        })
    },
    getCustomerSupplierNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/noPage' + '?validFlag=1')
        .then(res => {
          this.customerSupplierNameItem = res.data;
          // this.baseData.customerSupplierName = res.data[0].customerSupplierName;
        })
    },
    getMeterTypeNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001006' + '&validFlag=1')
        .then(res => {
          this.meterTypeNameItem = res.data;
          // this.baseData.meterTypeName = res.data[0].baseName;
        })
    },
    getMaterialNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001017' + '&validFlag=1')
        .then(res => {
          this.materialNameItem = res.data;
          // this.baseData.materialName = res.data.length > 0 ? res.data[0].baseName : '';
        })
    },
    getSpecNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001018' + '&validFlag=1')
        .then(res => {
          this.specNameItem = res.data;
          // this.baseData.specName = res.data.length > 0 ? res.data[0].baseName : '';
        })
    },
    getForwardingUnitNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/selectOut')
        .then(res => {
          this.forwardingUnitNameItem = res.data;
          // this.baseData.forwardingUnitName = res.data.length > 0 ? res.data[0].companyName : '';
        })
    },
    getReceivingUintNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/selectIn')
        .then(res => {
          this.receivingUintNameItem = res.data;
          // this.baseData.receivingUintName = res.data.length > 0 ? res.data[0].companyName : '';
        })
    }
  },
  components: {
    batchEditDialog
  }
}
</script>
<style scoped>
</style>