<!--洁净维护-->
<template>
  <div class="systemBase">
    <div>
      <div style="border-right: 1px solid #d5d5d5">
        <el-row>
          <el-col :span="24">
            <div
              style="
                margin-top: 10px;
                padding-top: 10px;
                border-bottom: 1px solid #d5d5d5;
                border-top: 1px solid #d5d5d5;
              "
            >
              <el-form
                ref="search2"
                :inline="true"
                :model="search2"
                :rules="ruleValidateSearch2"
              >
                <el-form-item label-width="80px">
                  <div style="font-size: 16px; padding: 0px 20px">
                    结净计量数据维护
                  </div>
                </el-form-item>
                <el-form-item prop="strDate" label="毛重开始时间">
                  <el-date-picker
                    v-model="search2.strDate"
                    clearable
                    type="datetime"
                    style="width: 180px"
                    placeholder="选择日期"
                    size="small"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item prop="envDate" label="毛重结束时间">
                  <el-date-picker
                    v-model="search2.envDate"
                    clearable
                    type="datetime"
                    style="width: 180px"
                    placeholder="选择日期"
                    size="small"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item prop="matterNo" label="物资名称">
                  <el-select
                    v-model="search2.matterNo"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in matterNameItem"
                      :key="index"
                      :label="item.matterName"
                      :value="item.matterNo"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="baseSpotNo" label="毛重计量点">
                  <el-select
                    v-model="search2.baseSpotNo"
                    clearable
                    filterable
                    collapse-tags
                    size="small"
                    style="width: 120px"
                  >
                    <el-option
                      v-for="(item, index) in baseSpotNameItem"
                      :key="index"
                      :label="item.baseSpotName"
                      :value="item.baseSpotNo"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-button
                    icon="el-icon-search"
                    type="primary"
                    size="mini"
                    @click="searchData2"
                    v-loading.fullscreen.lock="operateLoading"
                    v-privilege="activeMenu + 'SEARCH2'"
                    >查询</el-button
                  >
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-button
                    type="danger"
                    plain
                    icon="el-icon-remove-outline"
                    size="mini"
                    @click="unCleanData"
                    v-loading.fullscreen.lock="operateLoading"
                    v-privilege="activeMenu + 'RELIEVE2'"
                    >解除</el-button
                  >
                </el-form-item>
              </el-form>
            </div>
            <div class="common-table-div">
              <el-table
                v-loading="dataLoading3"
                ref="dataTable3"
                highlight-current-row
                border
                :height="tableHeight"
                @selection-change="handleSelectionChange"
                :data="table.list3"
                :exchangeFilterMap="{
                  uploadFlag: { '0': '待审核', '1': '待上传', '2': '已上传' },
                  grossMode: {
                    '1': '远程计量',
                    '2': '智能计量',
                    '3': '手工录入',
                    '4': '放行智能计量',
                    '5': '滞后匹配',
                  },
                  tareMode: {
                    '1': '远程计量',
                    '2': '智能计量',
                    '3': '手工录入',
                    '4': '放行智能计量',
                    '5': '滞后匹配',
                  },
                  netMode: { '1': '正常结净', '2': '匹配结净' },
                }"
                :icore-filter-flag="true"
              >
                <el-table-column
                  type="index"
                  label="序号"
                  fixed="left"
                  align="center"
                ></el-table-column>
                <el-table-column
                  type="selection"
                  width="55"
                  align="center"
                  fixed="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="predictionNo"
                  label="预报编号"
                  min-width="120"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="noticeNo"
                  label="通知单号"
                  min-width="120"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="railwayCarriageNo"
                  label="车厢序号"
                  min-width="80"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="matterName"
                  label="物资名称"
                  min-width="120"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="grossWeight"
                  label="毛重"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.grossWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="tareWeight"
                  label="皮重"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.tareWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="netWeight"
                  label="净重"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.netWeight - 0) / 10) / 100 }}
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="waterNum"
                  label="水分"
                  min-width="100"
                  align="right"
                >
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="dryWeight"
                  label="干重"
                  min-width="100"
                  align="right"
                >
                  <template slot-scope="scope">
                    {{ Math.floor((scope.row.dryWeight - 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="actualFirst1No"
                  min-width="120"
                  label="毛重作业编号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="baseSpot1Name"
                  min-width="120"
                  label="毛重计量点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="grossTime"
                  min-width="160"
                  label="毛重计量时间"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="grossManName"
                  min-width="120"
                  label="毛重计量员"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="grossClass"
                  min-width="120"
                  label="毛重班次"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="grossGroup"
                  min-width="120"
                  label="毛重班组"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="grossMode"
                  label="毛重计量方式"
                  align="left"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.grossMode == 1">远程计量</span>
                    <span v-else-if="scope.row.grossMode == 2">智能计量</span>
                    <span v-else-if="scope.row.grossMode == 3">手工录入</span>
                    <span v-else-if="scope.row.grossMode == 4"
                      >放行智能计量</span
                    >
                    <span v-else-if="scope.row.grossMode == 5">滞后匹配</span>
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="actualFirst2No"
                  label="皮重作业编号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="baseSpot2Name"
                  label="皮重计量点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160"
                  prop="tareTime"
                  label="皮重计量时间"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="tareManName"
                  label="皮重计量员"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="netClass"
                  label="皮重班次"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="tareGroup"
                  label="皮重班组"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="tareMode"
                  label="皮重计量方式"
                  align="left"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.tareMode == 1">远程计量</span>
                    <span v-else-if="scope.row.tareMode == 2">智能计量</span>
                    <span v-else-if="scope.row.tareMode == 3">手工录入</span>
                    <span v-else-if="scope.row.tareMode == 4"
                      >放行智能计量</span
                    >
                    <span v-else-if="scope.row.tareMode == 5">滞后匹配</span>
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="netSpot3Name"
                  label="净重计量点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160"
                  prop="netTime"
                  label="净重计量时间"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="netManName"
                  label="净重计量员"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="netClass"
                  label="净重班次"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="netGroup"
                  label="净重班组"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100"
                  prop="netMode"
                  label="结净方式"
                  align="left"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.netMode == 1">正常结净</span>
                    <span v-else-if="scope.row.netMode == 2">匹配结净</span>
                  </template>
                </el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="contractNo"
                  min-width="120"
                  label="合同号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="batchNo"
                  min-width="120"
                  label="批次号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="customerSupplierName"
                  min-width="120"
                  label="供应商"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="forwardingUnitName"
                  min-width="120"
                  label="发货单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="receivingUintName"
                  min-width="120"
                  label="收货单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="materialName"
                  min-width="120"
                  label="材质"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="specName"
                  min-width="120"
                  label="规格"
                  align="left"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" prop="" label="绑定卡号" min-width="100" align="left"></el-table-column> -->
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="loadPointName"
                  min-width="120"
                  label="卸货地点"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="sampleNo"
                  min-width="120"
                  label="取样编号"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="sampleVoucher"
                  min-width="120"
                  label="取样凭证"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="carrierUnitName"
                  min-width="120"
                  label="承运单位"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="meterTypeName"
                  min-width="120"
                  label="业务类型"
                  align="left"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  prop="uploadFlag"
                  min-width="120"
                  label="状态"
                  align="center"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.uploadFlag == 0">待审核</span>
                    <span v-else-if="scope.row.uploadFlag == 1">待上传</span>
                    <span v-else-if="scope.row.uploadFlag == 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="page3.pageNum"
                :page-sizes="[50, 100, 200, 400]"
                :page-size="page3.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page3.totalPage"
              >
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>
<script>
import { formatDate } from '@/utils/util.js';
export default {
  data () {
    return {
      dataLoading: false,
      dataLoading2: false,
      dataLoading3: false,
      dataLoading4: false,
      operateLoading: false,
      icoreFilterFlag: false,
      page: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page3: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page4: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      table: {
        list: [],
        list2: [],
        list3: [],
        list4: []
      },
      multipleSelection3: [],
      multipleSelection: {},
      multipleSelection2: {},
      multipleSelection4: {},
      tableHeight: 0,
      tableHeight2: 0,
      tableHeight3: 0,
      dataList: {},
      search: {
        railwayNo: '',
        strDate: '',
        envDate: ''
      },
      search2: {
        railwayNo: '',
        strDate: '',
        envDate: '',
        baseSpotNo: '',
        matterNo: ''
      },
      ruleValidateSearch: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify,
          trigger: 'blur'
        }]
      },
      ruleValidateSearch2: {
        envDate: [{
          required: true,
          validator: this.endTimeVerify2,
          trigger: 'blur'
        }],
        strDate: [{
          required: true,
          validator: this.strTimeVerify2,
          trigger: 'blur'
        }]
      },
      activeMenu: '',
      matterNameItem: [],
      sdrList: [],
      rcvList: [],
      groupList: [8, 3],
      baseSpotNameItem: []
    }
  },
  created () {
    this.tableHeight = window.innerHeight - 180 < 100 ? 350 : (window.innerHeight - 220)
    this.search.envDate = new Date()
    this.search.strDate = new Date(new Date().setDate(new Date().getDate() - 7))
    this.search2.envDate = new Date()
    this.search2.strDate = new Date(new Date().setDate(new Date().getDate() - 7))
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted () {
    this.getBaseSpotNameItem()
    this.getMatterName()
  },
  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()
      }
    },
    endTimeVerify2 (rule, value, callback) {
      if (this.search2.strDate !== '' && this.search2.envDate === '') {
        callback(new Error('结束时间不能为空！'));
      } else if (this.search2.envDate) {
        if (Date.parse(this.search2.envDate) > Date.parse(this.search2.strDate)) {
          callback();
        } else {
          callback(new Error('结束时间不得早于开始时间！'));
        }
      } else {
        callback();
      }
    },
    strTimeVerify2 (rule, value, callback) {
      if (this.search2.envDate !== '' && this.search2.strDate === '') {
        callback(new Error('开始时间不能为空！'));
      } else {
        callback()
      }
    },
    getMatterName (val) {
      let dataObj = {
        pageNum: 1,
        pageSize: 1000,
        memo: '动态轨道衡',
        validFlag: '1'
      }
      this.axios.post('pass/systemBase/v1/meterbasematterinfos/listLike', dataObj, { individualType: 'json' })
        .then(res => {
          this.matterNameItem = [...res.data.list];
          console.log(this.matterNameItem)
        })
    },
    getAllList (val) {
      this.getDataList2(val)
    },
    getDataList2 (row) {//皮重
      this.dataLoading2 = true;
      this.dataList = row
      this.axios.get('pass/systemBase/v1/meterworkrailwayactfirsts/selectNet' + '?pageNum=' + this.page2.pageNum + '&pageSize=' + this.page2.pageSize + '&weightType=1&flag=1' + '&railwayNo=' + row.railwayNo)
        .then(res => {
          this.dataLoading2 = false;
          this.table.list2 = res.data.list;
          this.page2.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading2 = false;
        });
    },
    searchData2 (flag = 1) {//查询净重
      this.$refs['search2'].validate((valid) => {
        if (valid) {
          this.dataLoading3 = true;
          if (flag === 1) {
            this.page3.pageNum = 1;
          }
          this.search2.strDate = formatDate(this.search2.strDate, 'yyyy-MM-dd HH:mm:ss')
          this.search2.envDate = formatDate(this.search2.envDate, 'yyyy-MM-dd HH:mm:ss')
          this.axios.get('pass/systemBase/v1/meterworkrailwayactuals/selectDiff' + '?pageNum=' + this.page3.pageNum + '&pageSize=' + this.page3.pageSize + '&railwayNo=' + this.search2.railwayNo
            + '&createTime1=' + this.search2.strDate + '&createTime2=' + this.search2.envDate + '&flag=1&baseSpot1No=' + this.search2.baseSpotNo+`&matterNo=${this.search2.matterNo}`)
            .then(res => {
              this.dataLoading3 = false;
              this.table.list3 = res.data.list;
              if (res.data.list.length < 64) {
                this.groupList = [8]
              } else {
                this.groupList = [8, 3]
              }
              this.page3.totalPage = res.data.total;
            }).catch(e => {
              this.dataLoading3 = false;
            });
        }
      })
    },
    getBaseSpotNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasespotinfos/noPage' + '?validFlag=1' + '&spotTypeNo=001002002&spotTypeName=轨道衡')
        .then(res => {
          this.baseSpotNameItem = res.data;
        })
    },
    //解除
    unCleanData () {
      if (this.multipleSelection3.length < 1) {
        this.$message.warning('请选择您要解除结净的数据！');
        return false;
      }
      this.axios.post('pass/systemBase/v1/meterworkrailwayactuals/removeDt', this.multipleSelection3, { individualType: 'json' }).then(res => {
        if (res.code == '0' || res.code == '200') {
          this.$message.success('解除成功');
          this.searchData2();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    pageSizeChange (size) {
      this.page3.pageSize = size;
      this.searchData2();
    },
    pageCurrentChange (index) {
      this.page3.pageNum = index;
      this.searchData2(2);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.getDataList2(this.dataList);
    },
    handleSelectionChange (val) {//净重
      this.multipleSelection3 = val;
    }
  }
}
</script>

<style scoped>
</style>