<!--一次计量数据查询-->
<template>
  <div class="systemBase">
    <div>
      <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
        <el-form
          ref="searchData1"
          :inline="true"
          :model="search"
          :rules="ruleValidate"
        >
          <el-form-item label-width="70px" prop="carNo" label="车号">
            <el-input
              v-model="search.carNo"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="baseSpotNo" label="计量点">
            <el-select
              v-model="search.baseSpotNo"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in baseSpotNameItem"
                :key="index"
                :label="item.baseSpotName"
                :value="item.baseSpotNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="meterTypeName" label="业务类型">
            <el-select
              v-model="search.meterTypeName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in meterTypeNameItem"
                :key="index"
                :label="item.baseName"
                :value="item.baseName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="matterNo" label="物资名称">
            <el-select
              v-model="search.matterNo"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
              :filter-method="filterMatName"
            >
              <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 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-item label-width="20px">
            <el-button
              icon="el-icon-printer"
              type="primary"
              size="mini"
              @click="printQRCode"
              v-privilege="activeMenu + 'PRINT'"
              >打印检斤小票</el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <el-row>
        <el-col :span="18">
          <div style="border-right: 1px solid #d5d5d5">
            <div class="common-title-div" style="display: flex">
              一次计量数据查询 （
              <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>
            <div class="common-table-div">
              <el-table
                v-loading="dataLoading"
                :row-class-name="tableRowClassName"
                ref="dataTable"
                highlight-current-row
                border
                :height="tableHeight"
                :summary-method="getSummaries"
                show-summary
                :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" 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="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="carNo"
                  label="车号"
                  min-width="80"
                  align="center"
                  fixed="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="trailerNo"
                  label="挂号"
                  min-width="80"
                  align="center"
                ></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.floor((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="addWeight"
                  min-width="100"
                  label="附加重量/t"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.addWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  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="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="shipmentGrossWeight"
                  min-width="110"
                  label="发运毛重"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{
                      Math.floor((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.floor((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="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="center"
                ></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>
        </el-col>
        <el-col :span="6">
          <div class="common-title-div">附加重量</div>
          <div class="common-table-div">
            <el-table
              v-loading="dataLoading2"
              :row-class-name="tableRowClassName"
              ref="dataTable2"
              highlight-current-row
              border
              :height="tableHeight"
              :summary-method="getSummaries2"
              show-summary
              :data="table.list2"
              :icore-filter-flag="icoreFilterFlag"
            >
              <el-table-column
                type="index"
                label="序号"
                fixed="left"
                align="center"
              ></el-table-column>
              <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilNo"
                label="器具编号"
                min-width="110"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilName"
                label="器具名称"
                min-width="80"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="utensilWeight"
                label="器具重量（T）"
                min-width="120"
                align="right"
              >
                <template slot-scope="scope">
                  {{ Math.floor((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>
        </el-col>
      </el-row>
    </div>
    <div id="qrcode2" v-show="false" ref="qrcode2">
      <div id="printContent" style="box-sizeing: border-box">
        <div
          style="
            text-align: center;
            width: 280px;
            -webkit-transform-origin-x: 0;
            -webkit-transition: scale(0.77);
          "
        >
          <strong
            style="
              font-size: 6px;
              -webkit-transform-origin-x: 0;
              -webkit-transition: scale(0.5);
            "
            >金川集团股份有限公司</strong
          ><br />
          <strong
            style="
              font-size: 6px;
              -webkit-transform-origin-x: 0;
              -webkit-transition: scale(0.5);
            "
            >检斤小票</strong
          ><br />
        </div>
        <table
          style="
            border-collapse: collapse;
            text-align: center;
            font-size: '宋体';
          "
        >
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 'Arial';
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              流水号
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ actualFirstNo1 }}
            </td>
            <td
              style="width: 130px; height: 20px; border: 1px solid rgb(0, 0, 0)"
              rowspan="8"
            >
              <div
                style="
                  text-align: center;
                  width: 130px;
                  height: 160px;
                  padding-top: 1px;
                  padding-left: 1px;
                "
                id="XQ2"
              ></div>
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              预报编号
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ predictionNo1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              车号
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ carNo1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              检斤类型
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ meterTypeName1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              毛重(t)
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ meterWeight1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              皮重(t)
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ meterWeight2 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              净重(t)
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            ></td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              附加重量
            </td>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ addWeight1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              物质名称
            </td>
            <td
              colspan="2"
              style="
                width: 130px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ matterName1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              来源
            </td>
            <td
              colspan="2"
              style="
                width: 130px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ forwardingUnitName1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              去向
            </td>
            <td
              colspan="2"
              style="
                width: 130px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ receivingUintName1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              计量时间
            </td>
            <td
              colspan="2"
              style="
                width: 130px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ createTime1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              规格
            </td>
            <td
              colspan="2"
              style="
                width: 130px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
            >
              {{ specName1 }}
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 103px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                text-align: left;
                padding-left: 10px;
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
              colspan="3"
            >
              注：本小票不作为结算凭证，请注意保管！
            </td>
          </tr>
          <tr>
            <td
              style="
                width: 103px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                text-align: left;
                padding-left: 10px;
                font-size: 7px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.58);
              "
              colspan="3"
            >
              打票时间:{{ nowTime }}
            </td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</template>
<script>
import { formatDate } from '@/utils/util.js';
export default {
  data () {
    return {
      dataLoading: false,
      dataLoading2: false,
      operateLoading: false,
      icoreFilterFlag: true,
      // qrCode: '',
      weightType1: '',
      nowTime: '',
      actualFirstNo1: '',
      predictionNo1: '',
      carNo1: '',
      matterName1: '',
      meterTypeName1: '',
      forwardingUnitName1: '',
      receivingUintName1: '',
      createTime1: '',
      addWeight1: '',
      specName1: '',
      meterWeight1: '',
      meterWeight2: '',
      actualFirst: {},
      baseSpotNameItem: [],
      meterTypeNameItem: [
        // {meterTypeName:'采购进厂'},
        // {meterTypeName:'销售出厂'},
        // {meterTypeName:'内部倒运'}
      ],
      matterNameItem: [],
      valueFlagItem: [
        { valueFlag: '有效' },
        { valueFlag: '作废' },
        { valueFlag: '结净' }
      ],
      page: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      table: {
        list: [],
        list2: [],
      },
      tableHeight: 0,
      ruleValidate: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify,
          trigger: 'blur'
        }]
      },
      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',
      },
      activeMenu: '',
      matList: []
    }
  },
  created () {
    this.tableHeight = (window.innerHeight - 200) > 400 ? window.innerHeight - 200 : 400
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
    // this.search.envDate = new Date ()
    // this.search.strDate = new Date(new Date ().setMonth(new Date().getMonth() - 1))
  },
  mounted () {
    // this.getDataList();
    this.searchDatas();
    this.getBaseSpotNameItem();
    this.getMatterNameItem();
    this.getMeterTypeNameItem()
  },
  methods: {
    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()
      }
    },
    getSummaries (param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "总计";
        }
        if (index === 1) {
          sums[index] = data.length;
        } else if (column.property === "meterWeight") {
          let val = 0;
          for (let i in data) {
            val = this.floatComputed(
              data[i].meterWeight ? Math.floor((data[i].meterWeight - 0) / 10) / 100 : 0,
              val,
              "+"
            );
          }
          sums[index] = val;
        } else if (column.property === "meterNum") {
          let val = 0;
          for (let i in data) {
            val = this.floatComputed(
              data[i].meterNum ? data[i].meterNum - 0 : 0,
              val,
              "+"
            );
          }
          sums[index] = val;
        }
      });
      return sums;
    },
    getSummaries2 (param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "总计";
        }
        if (index === 1) {
          sums[index] = data.length;
        } else if (column.property === "utensilWeight") {
          let val = 0;
          for (let i in data) {
            val = this.floatComputed(
              data[i].utensilWeight ? Math.floor((data[i].utensilWeight - 0) / 10) / 100 : 0,
              val,
              "+"
            );
          }
          sums[index] = val;
        }
      });
      return sums;
    },
    filterMatName (val) {
      if (val) {
        this.matterNameItem = this.matList.filter(item => {
          if (item.matterName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.matterNameItem = [...this.matList].slice(0, 300)
      }
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData()
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData()
    },
    pageSizeChange2 (size) {
      this.page2.pageSize = size;
      this.getDataList2(this.actualFirst);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.getDataList2(this.actualFirst);
    },
    getDataList () {
      this.dataLoading = true;
      this.axios.get('pass/systemBase/v1/meterworkcaractualfirsts/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize)
        .then(res => {
          this.dataLoading = false;
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total;
          if (this.table.list.length > 0) {
            this.$refs.dataTable.setCurrentRow(this.table.list[0])
            this.getDataList2(this.table.list[0])
          }
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    getDataList2 (row) {
      this.actualFirst = row
      this.weightType1 = this.actualFirst.weightType == 0 ? '毛重' : this.actualFirst.weightType == 1 ? '常规皮重' : this.actualFirst.weightType == 2 ? '期限皮重' : this.actualFirst.weightType == 3 ? '历史皮重' : this.actualFirst.weightType == 4 ? '标识皮重' : this.actualFirst.weightType == 5 ? '自重皮重' : ''
      this.nowTime = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
      this.actualFirstNo1 = this.actualFirst.actualFirstNo ? this.actualFirst.actualFirstNo : ''
      this.predictionNo1 = this.actualFirst.predictionNo ? this.actualFirst.predictionNo : ''
      this.carNo1 = this.actualFirst.carNo ? this.actualFirst.carNo : ''
      this.matterName1 = this.actualFirst.matterName ? this.actualFirst.matterName : ''
      this.meterTypeName1 = this.actualFirst.meterTypeName ? this.actualFirst.meterTypeName : ''
      this.forwardingUnitName1 = this.actualFirst.forwardingUnitName ? this.actualFirst.forwardingUnitName : ''
      this.receivingUintName1 = this.actualFirst.receivingUintName ? this.actualFirst.receivingUintName : ''
      this.createTime1 = this.actualFirst.createTime ? this.actualFirst.createTime : ''
      this.addWeight1 = this.actualFirst.addWeight ? this.actualFirst.addWeight / 1000 : 0
      this.specName1 = this.actualFirst.specName ? this.actualFirst.specName : ''
      if (this.actualFirst.weightType == 0) {
        this.meterWeight1 = this.actualFirst.meterWeight ? (this.actualFirst.meterWeight / 1000).toFixed(2) : ''
        this.meterWeight2 = ''
      } else {
        this.meterWeight2 = this.actualFirst.meterWeight ? (this.actualFirst.meterWeight / 1000).toFixed(2) : ''
        this.meterWeight1 = ''
      }
      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;
        });
    },
    searchDatas () {
      this.page.pageNum = 1;
      this.searchData()
    },
    searchData () {
      this.$refs['searchData1'].validate((valid) => {
        if (valid) {
          this.dataLoading = true;
          this.search.valueFlag1 = this.search.valueFlag === '有效' ? 1 : this.search.valueFlag === '作废' ? 0 : this.search.valueFlag === '结净' ? 2 : ''
          if (isNaN(this.search.strDate) && !isNaN(Date.parse(this.search.strDate))) {
          } else {
            this.search.strDate = formatDate(this.search.strDate, 'yyyy-MM-dd HH:mm:ss')
          }
          if (isNaN(this.search.envDate) && !isNaN(Date.parse(this.search.envDate))) {
          } else {
            this.search.envDate = formatDate(this.search.envDate, 'yyyy-MM-dd HH:mm:ss')
          }
          this.axios.get('pass/systemBase/v1/meterworkcaractualfirsts/selectView' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize + '&carNo=' + this.search.carNo
            + '&baseSpotNo=' + this.search.baseSpotNo + '&meterTypeName=' + this.search.meterTypeName + '&matterNo=' + this.search.matterNo + '&valueFlag=' + this.search.valueFlag1
            + '&createTime1=' + this.search.strDate + '&createTime2=' + this.search.envDate)
            .then(res => {
              this.dataLoading = false;
              this.table.list = res.data.list;
              this.page.totalPage = res.data.total;
              if (this.table.list.length > 0) {
                this.$refs.dataTable.setCurrentRow(this.table.list[0])
                this.getDataList2(this.table.list[0])
              }
            }).catch(e => {
              this.dataLoading = false;
            });
        }
      })
    },
    printQRCode () {
      if (JSON.stringify(this.actualFirst) === "{}") {
        this.$message.warning('请选择一次计量数据')
        return
      }
      let str = this.actualFirst.actualFirstNo + ',' + this.actualFirst.meterWeight + ',1'
      this.axios.post('pass/systemBase/v1/meterworkcaractualfirsts/encryptionForWeb', { str }, { individualType: 'json' })
        .then(res => {
          if (res.code == 0 || res.code == 200) {
            let qrCode = res.data
            setTimeout(() => {
              document.getElementById("XQ2").innerHTML = ""; //置空
              new QRCode(document.getElementById("XQ2"), {
                text: qrCode,
                width: 128,
                height: 158,
                colorDark: "#000000",
                colorLight: "#ffffff",
              })
              setTimeout(() => {
                this.printPage('printContent');
              }, 500)
            }, 100)
          }
        }).catch(e => {
          this.$message.error(res.message)
        })
    },
    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;
        })
    },
    getMatterNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1')
        .then(res => {
          this.matList = [...res.data]
          this.matterNameItem = [...res.data].slice(0, 300);
        })
    },
    getMeterTypeNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001006' + '&validFlag=1')
        .then(res => {
          this.meterTypeNameItem = res.data;
        })
    }
  }
}
</script>
<style scoped>
</style>