<!--计量物料配置管理-->
<template>
  <div class="systemBase">
    <div>
      <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
        <!-- <div class="common-operation-button-div"> -->
        <el-form
          :inline="true"
          :model="search"
          ref="searchForm"
          @submit.native.prevent
          style="padding-left: 15px"
        >
          <el-form-item>
            <div style="font-size: 16px; padding: 0px 0px">
              计量物料配置管理
            </div>
          </el-form-item>
          <el-form-item prop="matterName" label="物料名称">
            <el-input
              v-model="search.matterName"
              clearable
              size="small"
              style="width: 150px"
              placeholder="请输入"
              @keyup.enter.native="searchDatas"
            ></el-input>
          </el-form-item>
          <el-form-item prop="meterCode" label="计量码">
            <el-input
              v-model="search.meterCode"
              clearable
              size="small"
              style="width: 150px"
              placeholder="请输入"
              @keyup.enter.native="searchDatas"
            ></el-input>
          </el-form-item>
          <el-form-item prop="validFlag" label="状态">
            <el-select
              v-model="search.validFlag"
              clearable
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="item in validFlagList"
                :key="item"
                :value="item"
                :label="item === '0' ? '无效' : item === '1' ? '有效' : '全部'"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="allowedTareWeight"
            label="是否可用期限皮"
            style="width: 200px"
          >
            <el-select
              v-model="search.allowedTareWeight"
              clearable
              size="small"
              style="width: 100px"
            >
              <el-option
                v-for="item in allowedTareWeightList"
                :key="item"
                :value="item"
                :label="item === '0' ? '否' : item === '1' ? '是' : '全部'"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="allowedAddWeight"
            label="是否可用附加重量"
            size="small"
            style="width: 200px"
          >
            <el-select
              v-model="search.allowedAddWeight"
              clearable
              style="width: 90px"
            >
              <el-option
                v-for="item in allowedAddWeightList"
                :key="item"
                :value="item"
                :label="item === '0' ? '否' : item === '1' ? '是' : '全部'"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="scaleValidPeriod"
            label="预报有效天数"
            size="small"
            style="width: 200px"
          >
            <el-input
              v-model="search.scaleValidPeriod"
              clearable
              size="small"
              placeholder="请输入"
              style="width: 100px"
              @keyup.enter.native="searchDatas"
            ></el-input>
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              icon="el-icon-refresh"
              type="primary"
              size="mini"
              @click="resetData"
              >重置</el-button
            >
          </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-circle-plus-outline"
              type="primary"
              size="mini"
              @click="addData"
              v-loading.fullscreen.lock="operateLoading"
              v-privilege="activeMenu + 'ADD'"
              >新增</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              icon="el-icon-edit"
              type="primary"
              size="mini"
              v-loading.fullscreen.lock="operateLoading"
              @click="modifyData"
              v-privilege="activeMenu + 'UPDATE'"
              >修改</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-check"
              v-loading.fullscreen.lock="operateLoading"
              @click="recoveryData"
              v-privilege="activeMenu + 'RECOVERY'"
              >启用</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              size="mini"
              type="danger"
              plain
              icon="el-icon-remove-outline"
              v-loading.fullscreen.lock="operateLoading"
              @click="abolishData"
              v-privilege="activeMenu + 'ABOLISH'"
              >废除</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-check"
              v-loading.fullscreen.lock="operateLoading"
              @click="usefulTareWeight"
              v-privilege="activeMenu + 'USEFULT'"
              >可用期限皮重</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              size="mini"
              type="danger"
              plain
              icon="el-icon-remove-outline"
              v-loading.fullscreen.lock="operateLoading"
              @click="cancelTareWeight"
              v-privilege="activeMenu + 'CANCELT'"
              >取消期限皮重</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-check"
              v-loading.fullscreen.lock="operateLoading"
              @click="usefulAddWeight"
              v-privilege="activeMenu + 'USEFULA'"
              >可用附加皮重</el-button
            >
          </el-form-item>
          <el-form-item label-width="20px">
            <el-button
              size="mini"
              type="danger"
              plain
              icon="el-icon-remove-outline"
              v-loading.fullscreen.lock="operateLoading"
              @click="cancelAddWeight"
              v-privilege="activeMenu + 'CANCELA'"
              >取消附加皮重</el-button
            >
          </el-form-item>
        </el-form>
        <!-- </div> -->
      </div>
      <div class="common-table-div">
        <el-table
          v-loading="dataLoading"
          :row-class-name="tableRowClassName"
          ref="dataTable"
          border
          :height="tableHeight"
          @selection-change="handleSelectionChange"
          :data="table.list"
          @row-click="rowChange"
          :bigDataShow="groupList"
          highlight-current-row
          :exchangeFilterMap="{
            validFlag: { '0': '无效', '1': '有效' },
            allowedAddWeight: { '0': '否', '1': '是' },
            allowedTareWeight: { '0': '否', '1': '是' },
          }"
          :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"
            min-width="100px"
            prop="matterNo"
            label="物料编号"
            align="center"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="100px"
            prop="matterName"
            label="物料名称"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="100px"
            prop="specName"
            label="规格"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="100px"
            prop="indexCode"
            label="索引码"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="100px"
            prop="meterCode"
            label="计量码"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="100px"
            prop="mnemonicCode"
            label="助记码"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="120px"
            prop="matterNatureName"
            label="物料属性名称"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="120px"
            prop="typeName"
            label="物料类型"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="120px"
            prop="meterNatureName"
            label="计量属性名称"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="80px"
            prop="validFlag"
            label="状态"
            align="center"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.validFlag == 1">有效</span>
              <span v-else-if="scope.row.validFlag == 0">无效</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="120px"
            prop="allowedTareWeight"
            label="是否可用期限皮重"
            align="center"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.allowedTareWeight == 1">是</span>
              <span v-else-if="scope.row.allowedTareWeight == 0">否</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="120px"
            prop="allowedAddWeight"
            label="是否可用附加重量"
            align="center"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.allowedAddWeight == 1">是</span>
              <span v-else-if="scope.row.allowedAddWeight == 0">否</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="120px"
            prop="scaleValidPeriod"
            label="预报有效天数"
            align="center"
          >
          </el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="80px"
            prop="createManName"
            label="创建人"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="160px"
            prop="createTime"
            label="创建时间"
            align="center"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="80px"
            prop="updateManName"
            label="修改人"
            align="left"
          ></el-table-column>
          <el-table-column
            sortable
            :show-overflow-tooltip="true"
            min-width="160px"
            prop="updateTime"
            label="修改时间"
            align="center"
          ></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, 5000]"
          :page-size="page.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.totalPage"
        >
        </el-pagination>
      </div>
      <!-- <div ref="editTitle" class="common-title-div" style="border-top: 1px solid #d5d5d5;">编辑区
      </div> -->
      <div
        ref="editDiv"
        class="commom-edit-div"
        style="border-top: 1px solid #d5d5d5; margin-top: 10px"
      >
        <el-form
          ref="baseData"
          label-width="80px"
          :inline="true"
          :rules="ruleValidate"
          :model="baseData"
        >
          <el-form-item prop="matterName" label="物料名称">
            <el-input
              v-model="baseData.matterName"
              clearable
              size="small"
              style="width: 150px"
              placeholder="请输入"
              @blur="myBlur"
            ></el-input>
          </el-form-item>
          <el-form-item prop="mnemonicCode" label="助记码">
            <el-input
              v-model="baseData.mnemonicCode"
              clearable
              size="small"
              style="width: 150px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="specName" label="规格">
            <el-input
              v-model="baseData.specName"
              clearable
              size="small"
              style="width: 150px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="indexCode" label="索引码">
            <el-input
              v-model="baseData.indexCode"
              clearable
              size="small"
              style="width: 150px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="matterNatureNo" label="物料属性">
            <el-select
              v-model="baseData.matterNatureNo"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="(item, index) in matterNatureType"
                :key="index"
                :label="item.baseName"
                :value="item.baseCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="meterNatureNo" label="计量属性">
            <el-select
              v-model="baseData.meterNatureNo"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="(item, index) in meteringType"
                :key="index"
                :label="item.baseName"
                :value="item.baseCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="meterCode" label="计量码">
            <el-input
              v-model="baseData.meterCode"
              clearable
              style="width: 150px"
              size="small"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="allowedTareWeight"
            label-width="110px"
            label="是否可用期限皮重"
          >
            <el-select
              v-model="baseData.allowedTareWeight"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="(item, index) in allowedTareWeightType"
                :key="index"
                :label="item.allowedTareWeight"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="allowedAddWeight"
            label-width="110px"
            label="是否可用附加重量"
          >
            <el-select
              v-model="baseData.allowedAddWeight"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="(item, index) in allowedAddWeightType"
                :key="index"
                :label="item.allowedAddWeight"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            prop="scaleValidPeriod"
            label-width="110px"
            label="预报有效天数"
          >
            <el-input
              v-model="baseData.scaleValidPeriod"
              type="number"
              size="mini"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="isNeedCheckCar"
            label-width="110px"
            label="是否需要核查"
          >
            <el-select
              v-model="baseData.isNeedCheckCar"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="item in checkTypeList"
                :key="item.id"
                :label="item.value"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item
            prop="reportCode"
            label-width="110px"
            label="物料类型"
          >
            <el-select
              v-model="baseData.reportCode"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 150px"
            >
              <el-option
                v-for="item in matTypeList"
                :key="item.baseCode"
                :label="item.baseName"
                :value="item.baseCode"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import {
  meterbasematterinfos,
  combaseinfos
} from '../../../utils/api.js';
import {
  discard,
  Recovery,
  add,
  modify
} from '../../../utils/httpRequest.js';
import pinyinUtils from '../../../utils/pinyin/pinyinUtils.js'
export default {
  data () {
    return {
      dataLoading: false,
      operateLoading: false,
      icoreFilterFlag: true,
      matterNatureIndex: 0,
      meterNatureIndex: 0,
      matterNatureType: [],
      meteringType: [],
      allowedTareWeightType: [
        { id: '0', allowedTareWeight: '否' },
        { id: '1', allowedTareWeight: '是' }
      ],
      allowedAddWeightType: [
        { id: '0', allowedAddWeight: '否' },
        { id: '1', allowedAddWeight: '是' }
      ],
      table: {
        list: []
      },
      multipleSelection: [],
      tableHeight: 0,
      page: {
        pageSize: 500,
        pageNum: 1,
        totalPage: 0
      },
      ruleValidate: {
        matterName: [{
          required: true,
          message: '物料名称不能为空',
          trigger: 'change'
        }],
        meterNatureNo: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
        matterNatureNo: [{
          required: true,
          message: '该项不能为空',
          trigger: 'change'
        }],
      },
      search: {
        matterName: '',
        meterCode: '',
        validFlag: '',
        allowedTareWeight: '',
        allowedAddWeight: '',
        scaleValidPeriod: ''
      },
      baseData: {
        matterName: '',
        mnemonicCode: '',
        matterNatureNo: '',
        matterNatureName: '',
        meterNatureNo: '',
        meterNatureName: '',
        meterCode: '',
        indexCode: '',
        allowedAddWeight: '0',
        allowedTareWeight: '0',
        scaleValidPeriod: '5',
        specName: '',
        reportCode: ''
      },
      activeMenu: '',
      validFlagList: ['0', '1', ''],
      allowedTareWeightList: ['0', '1', ''],
      allowedAddWeightList: ['0', '1', ''],
      groupList: [8, 1],
      matTypeList: [],
      checkTypeList: [
        {
          id: '0',
          value: '不需要'
        },
        {
          id: '1',
          value: '需要'
        }
      ]
    }
  },
  async created () {
    this.tableHeight = (window.innerHeight - 220) > 400 ? window.innerHeight - 220 : 400;
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
    // 获取物料类型数据
    const { data: res } = await this.axios.get('pass/systemBase/v1/combaseinfos/?pageNum=1&pageSize=500&pBaseCode=001035');
    this.matTypeList = [...res.list]
    console.log(res, '物料类型数据');
  },
  mounted () {
    this.getDataList();
  },
  methods: {
    getCode (code, arr, codeKey, nameKey) {
      if (!code) {
        return '';
      }
      let targetRow = arr.find(item => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : '';
    },
    rowChange (row, column, event) {
      this.baseData = Object.assign({}, row);
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    getTableHeight (dom) {
      return (window.innerHeight - dom.offsetTop);
    },
    resetData () {
      this.$refs['searchForm'].resetFields && this.$refs['searchForm'].resetFields();
    },
    addData () {
      let _this = this;
      _this.$refs['baseData'].validate((valid) => {
        if (valid) {
          _this.operateLoading = true;
          let baseDataAdd = {};
          baseDataAdd.matterName = _this.baseData.matterName
          baseDataAdd.mnemonicCode = _this.baseData.mnemonicCode
          baseDataAdd.meterCode = _this.baseData.meterCode
          baseDataAdd.indexCode = _this.baseData.indexCode
          baseDataAdd.matterNatureNo = _this.baseData.matterNatureNo
          baseDataAdd.meterNatureNo = _this.baseData.meterNatureNo
          baseDataAdd.allowedTareWeight = _this.baseData.allowedTareWeight
          baseDataAdd.allowedAddWeight = _this.baseData.allowedAddWeight
          baseDataAdd.matterNatureName = _this.getCode(this.baseData.matterNatureNo, this.matterNatureType, 'baseCode', 'baseName');
          baseDataAdd.meterNatureName = _this.getCode(this.baseData.meterNatureNo, this.meteringType, 'baseCode', 'baseName');
          // 新增规格字段
          baseDataAdd.specName = _this.baseData.specName
          // 如果界面上的有效天数不为空，则取界面上填写的有效天数，否则默认为5天
          baseDataAdd.scaleValidPeriod = _this.baseData.scaleValidPeriod - 0 !== 0 ? _this.baseData.scaleValidPeriod : '5'
          add(meterbasematterinfos, baseDataAdd, (e) => {
            _this.operateLoading = false;
            if (!e) {
              _this.$refs['baseData'].resetFields && _this.$refs['baseData'].resetFields();
              _this.baseData.allowedAddWeight = '0'
              _this.baseData.allowedTareWeight = '0'
              _this.baseData.scaleValidPeriod = '5'
              _this.baseData.isNeedCheckCar = '0'
            }
            console.log()
            // 新增成功后，将新增数据作为查询条件
            _this.search.matterName = baseDataAdd.matterName
            _this.search.meterCode = baseDataAdd.meterCode
            _this.search.allowedTareWeight = baseDataAdd.allowedTareWeight
            _this.search.allowedAddWeight = baseDataAdd.allowedAddWeight
            _this.search.scaleValidPeriod = baseDataAdd.scaleValidPeriod
            _this.searchDatas();
            // _this.getDataList();
          })
        }
      });
    },
    modifyData () {
      let _this = this;
      _this.$refs['baseData'].validate((valid) => {
        if (valid) {
          _this.operateLoading = true;
          _this.baseData.matterNatureName = _this.getCode(this.baseData.matterNatureNo, this.matterNatureType, 'baseCode', 'baseName');
          _this.baseData.meterNatureName = _this.getCode(this.baseData.meterNatureNo, this.meteringType, 'baseCode', 'baseName');
          modify(meterbasematterinfos + _this.baseData.matterNo + '/', _this.baseData, (e) => {
            _this.operateLoading = false;
            if (!e) {
              _this.$refs['baseData'].resetFields && _this.$refs['baseData'].resetFields();
            }
            // _this.getDataList();
            _this.searchDatas();
          })
        }
      });
    },
    usefulTareWeight () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请勾选数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/meterbasematterinfos/useTare', this.multipleSelection, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('操作成功');
          // this.getDataList();
          this.searchDatas();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },//可用期限皮重
    cancelTareWeight () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请勾选数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/meterbasematterinfos/unTare', this.multipleSelection, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('操作成功');
          // this.getDataList();
          this.searchDatas();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },//取消期限皮重
    usefulAddWeight () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请勾选数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/meterbasematterinfos/useAddWeight', this.multipleSelection, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('操作成功');
          // this.getDataList();
          this.searchDatas();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },//可用附加皮重
    cancelAddWeight () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请勾选数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/meterbasematterinfos/unAddWeight', this.multipleSelection, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('操作成功');
          // this.getDataList();
          this.searchDatas();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },//取消附加皮重
    recoveryData () {
      let _this = this;
      _this.operateLoading = true;
      Recovery(meterbasematterinfos + 'Recovery', _this.multipleSelection, (e) => {
        _this.operateLoading = false;
        if (!e) {
          // _this.getDataList();
          _this.searchDatas();
        }
      });
    },
    abolishData () {
      let _this = this;
      _this.operateLoading = true;
      discard(meterbasematterinfos + 'abolish', _this.multipleSelection, (e) => {
        _this.operateLoading = false;
        if (!e) {
          // _this.getDataList();
          _this.searchDatas();
        }
      });
    },
    searchDatas () {
      this.page.pageNum = 1
      this.searchData()
    },
    searchData () {
      console.log(this.search)
      this.$refs.dataTable.bodyWrapper.scrollTop = 0;
      let obj = {
        pageNum: this.page.pageNum,
        pageSize: this.page.pageSize,
        matterName: this.search.matterName,
        meterCode: this.search.meterCode,
        validFlag: this.search.validFlag,
        allowedTareWeight: this.search.allowedTareWeight,
        allowedAddWeight: this.search.allowedAddWeight,
        scaleValidPeriod: this.search.scaleValidPeriod
      }
      this.axios.post('pass/systemBase/v1/meterbasematterinfos/listLike', obj, { individualType: 'json' })
        .then(res => {
          if (res.data.list.length < 64) {
            this.groupList = [8]
          } else {
            this.groupList = [8, 1]
          }
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total
        })
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    getTableHeight (dom) {
      return (window.innerHeight - dom.offsetTop);
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData()
    },

    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData()
    },
    getDataList () {
      this.getDataList2();
      this.getDataList3();
      this.dataLoading = true;
      this.axios.get(meterbasematterinfos + '?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;
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    getDataList2 () {
      this.axios.get(combaseinfos + 'noPage' + '?pBaseCode=001003' + '&validFlag=1')
        .then(res => {
          this.matterNatureType = res.data;
          this.baseData.matterNatureNo = res.data.length > 0 ? res.data[0].baseCode : ''
        })
    },
    getDataList3 () {
      this.axios.get(combaseinfos + 'noPage' + '?pBaseCode=001004' + '&validFlag=1')
        .then(res => {
          this.meteringType = res.data;
          this.baseData.meterNatureNo = res.data.length > 0 ? res.data[0].baseCode : ''
        })
    },
    tableRowClassName ({
      row,
      rowIndex
    }) {
      if (row.validFlag !== '1') {
        return 'error-row2';
      }
      return '';
    },
    myBlur () {
      if (this.baseData.matterName) {
        this.baseData.mnemonicCode = pinyinUtils.initial(this.baseData.matterName);
      }
    }
  }
}
</script>

<style scoped>
.el-select {
  width: 100%;
}
</style>