<!--计量数据操作日志查询-->
<template>
  <div class="systemBase">
    <div>
      <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
        <el-form
          ref="searchData"
          :inline="true"
          :model="search"
          :rules="ruleValidateSearch"
          style="padding: 15px;"
        >
          <el-form-item prop="operationCarnNo" label="车号">
            <el-input
              v-model="search.operationCarnNo"
              size="small"
              clearable
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="createManName" label="操作人">
            <el-input
              v-model="search.createManName"
              size="small"
              clearable
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="operationPage" label="界面">
            <el-select
              v-model="search.operationPage"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in pageNameList"
                :key="index"
                :label="item"
                :value="item"
              >
              </el-option>
            </el-select>
          </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 + 'QUERY'"
              >查询</el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <el-row>
        <el-col :span="24">
          <div style="border-right: 1px solid #d5d5d5">
            <div class="common-table-div" id="topTable">
              <el-table
                id="excelTable"
                v-loading="dataLoading"
                ref="dataTable"
                highlight-current-row
                border
                :height="tableHeight"
                :data="table.list"
                :row-class-name="tableRowClassName"
                :icore-filter-flag="icoreFilterFlag"
              >
                <el-table-column
                  type="index"
                  label="序号"
                  :fixed="isFixed"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column type="selection" width="55" align="center" :fixed="isFixed"></el-table-column> -->
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="operationCarnNo"
                  label="车号"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="operationId"
                  label="数据主键"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="createManName"
                  label="操作人"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="createTime"
                  label="操作时间"
                  min-width="120"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="operationPage"
                  label="操作页面"
                  min-width="100"
                  align="right"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="operationFunction"
                  label="功能名称"
                  min-width="100"
                  align="right"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="operationBeforeFix"
                  label="修改前"
                  min-width="100"
                  align="right"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="operationAfterFix"
                  label="修改后"
                  min-width="100"
                  align="right"
                ></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="[100, 500, 1000]"
                :page-size="page.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page.totalPage"
              >
              </el-pagination>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
    <div id="qrcode2" ref="qrcode2" v-show="false">
      <div id="printContent" style="box-sizeing: border-box">
        <div
          style="
            text-align: center;
            width: 280px;
            -webkit-transform-origin-x: 0;
            -webkit-transition: scale(0.58);
          "
        >
          <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">
          <tr>
            <td
              style="
                width: 50px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 6px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.5);
              "
            >
              流水号
            </td>
            <td
              style="
                width: 80px;
                height: 20px;
                border: 1px solid rgb(0, 0, 0);
                font-size: 6px;
                -webkit-transform-origin-x: 0;
                -webkit-transition: scale(0.5);
              "
            >
              {{ actualNo1 }}
            </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);
              "
            >
              {{ grossWeight1 }}
            </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);
              "
            >
              {{ tareWeight1 }}
            </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);
              "
            >
              {{ netWeight1 }}
            </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);
              "
            >
              {{ 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);
              "
            >
              {{ netTime1 }}
            </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 {
      grossWeight1: '',
      tareWeight1: '',
      netWeight1: '',
      nowTime: '',
      actualNo1: '',
      predictionNo1: '',
      carNo1: '',
      matterName1: '',
      meterTypeName1: '',
      forwardingUnitName1: '',
      receivingUintName1: '',
      tareTime1: '',
      netTime1: '',
      addWeight1: '',
      specName1: '',
      dataLoading: false,
      operateLoading: false,
      icoreFilterFlag: true,
      meterTypeNameItem: [],
      matterNameItem: [],
      uploadFlagItem: [
        { uploadFlag: '待审核' },
        { uploadFlag: '待上传' },
        { uploadFlag: '已上传' }
      ],
      valueFlagList: [
        {
          id: '0',
          value: '有效'
        },
        {
          id: '1',
          value: '作废'
        }
      ],
      page: {
        pageSize: 500,
        pageNum: 1,
        totalPage: 0
      },
      isFixed: 'left',
      table: {
        list: []
      },
      pageNameList: ['汽车衡计量合同管理', '结净计量数据维护', '一次计量数据维护'],
      multipleSelection: [],
      tableHeight: 0,
      search: {
        operationCarnNo: '',
        createManName: '',
        operationPage: ''
      },
      ruleValidateSearch: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify,
          trigger: 'blur'
        }]
      },
      actualFirst: {},
      tableExportLoading: false,
      activeMenu: '',
      baseSpotNameItem: [],
      baseSpotNameItem1: []
    }
  },
  created () {
    this.tableHeight = (window.innerHeight - 220) > 400 ? window.innerHeight - 220 : 400
    this.search.envDate = new Date()
    this.search.strDate = new Date(new Date().setDate(new Date().getDate() - 7))
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted () {
    this.searchDatas()
  },
  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();
      }
    },
    getMatterName (val) {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterName=' + val)
        .then(res => {
          this.matterNameItem = res.data;
        })
    },
    strTimeVerify (rule, value, callback) {
      if (this.search.envDate && !this.search.strDate) {
        callback(new Error('开始时间不能为空！'));
      } else {
        callback()
      }
    },
    searchDatas () {
      this.page.pageNum = 1;
      this.searchData()
    },
    searchData () {
      this.$refs['searchData'].validate((valid) => {
        if (valid) {
          this.dataLoading = true;
          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/meterbaseoperationlogs/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize +
          `&operationCarnNo=${this.search.operationCarnNo}&createManName=${this.search.createManName}&operationPage=${this.search.operationPage}`)
            .then(res => {
              this.dataLoading = false;
              this.table.list = res.data.list;
              this.page.totalPage = res.data.total;
            }).catch(e => {
              this.dataLoading = false;
            });
        }
      })
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData()
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData()
    },
    getDataList () {
      this.dataLoading = true;
      this.axios.get('pass/systemBase/v1/meterworkcaractuals/' + '?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;
          this.table.list.forEach(item => {
            item.grossTime = item.grossTime ? item.grossTime + '\xa0' : item.grossTime;
            item.tareTime = item.tareTime ? item.tareTime + '\xa0' : item.tareTime;
            item.netTime = item.netTime ? item.netTime + '\xa0' : item.netTime;
            item.predictionNo = item.predictionNo ? item.predictionNo + '\xa0' : item.predictionNo;
            item.actualFirst1No = item.actualFirst1No ? item.actualFirst1No + '\xa0' : item.actualFirst1No;
            item.actualFirst2No = item.actualFirst2No ? item.actualFirst2No + '\xa0' : item.actualFirst2No;
          });
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    tableRowClassName ({
      row,
      rowIndex
    }) {
      if (row.uploadFlag === '2') {
        return 'error-row2';
      } else if (row.uploadFlag === '1') {
        return 'wait-row'
      }
      return '';
    }
  }
}
</script>

<style scoped>
</style>