<!--计量点配置-->
<template>
  <div class="systemBase">
    <div class="common-title-div">计量点配置
      <div class="common-operation-button-div">
        <el-button icon="el-icon-circle-plus-outline" type="primary" size="mini" v-loading.fullscreen.lock="operateLoading"
          @click="addMetering" v-privilege="activeMenu + 'ADD'">新增</el-button>
        <el-button icon="el-icon-edit" type="primary" size="mini" @click="modifyBaseData" v-loading.fullscreen.lock="operateLoading" v-privilege="activeMenu + 'UPDATE'">修改</el-button>
        <el-button size="mini" type="primary" icon="el-icon-check" @click="enableBaseData" v-loading.fullscreen.lock="operateLoading" v-privilege="activeMenu + 'RECOVERY'">启用</el-button>
        <el-button size="mini" type="danger" plain icon="el-icon-remove-outline" @click="discardBaseData" v-loading.fullscreen.lock="operateLoading" v-privilege="activeMenu + 'ABOLISH'">废除</el-button>
      </div>
    </div>
    <div class="common-table-div">
      <el-table :row-class-name="tableRowClassName" v-loading="dataLoading" ref="merteringTable" border :height="tableHeight" highlight-current-row
         @current-change="handleCurrentChange" :data="table.list" @row-click="rowChange"
         :exchangeFilterMap="{'validFlag':{'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 :show-overflow-tooltip="true" sortable min-width="120px" prop="baseSpotNo" label="计量点编号" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="baseSpotName" label="计量点名称" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="spotTypeName" label="计量点类型" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="videoIp" label="硬盘录像机IP" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="flatComputerIp" label="触摸屏ip" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="videoPort" label="硬盘录像机端口" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="videoUserName" label="硬盘录像机用户名" width="120" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="videoPassword" label="硬盘录像机密码" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="printerIp" label="打印机IP" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="printerName" label="打印机名称" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="countNum" label="总纸张" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="usedNum" label="已用纸张" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="spotStateName" label="计量点状态" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" 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 :show-overflow-tooltip="true" sortable min-width="120px" prop="controlIp" label="接管终端IP" align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="ledIp" label="LED屏IP" 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]" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="page.totalPage">
      </el-pagination>
    </div>
    <div class="lineDiv" v-if="detailData" style="border-bottom: 1px solid #DCDCDC;height:5px" ref="lineDiv"></div>
    <div class="common-title-div">秤点配置
      <div class="common-operation-button-div">
        <el-button icon="el-icon-circle-plus-outline" type="primary" size="mini" v-loading.fullscreen.lock="operateLoading"
          @click="addMetering2" v-privilege="activeMenu + 'ADD2'">新增</el-button>
        <el-button icon="el-icon-edit" type="primary" size="mini" @click="modifyBaseData2" v-loading.fullscreen.lock="operateLoading" v-privilege="activeMenu + 'UPDATE2'">修改</el-button>
        <el-button size="mini" type="primary" icon="el-icon-check" @click="enableBaseData2" v-loading.fullscreen.lock="operateLoading" v-privilege="activeMenu + 'RECOVERY2'">启用</el-button>
        <el-button size="mini" type="danger" plain icon="el-icon-remove-outline" @click="discardBaseData2"
          v-loading.fullscreen.lock="operateLoading" v-privilege="activeMenu + 'ABOLISH2'">废除</el-button>
      </div>
    </div>
    <div class="common-table-div">
      <el-table :row-class-name="tableRowClassName" v-loading="dataLoading2" ref="merteringTable2" border :height="tableHeight2" highlight-current-row
         @current-change="handleCurrentChange2" :data="table2.list" @row-click="rowChange2"
         :exchangeFilterMap="{'validFlag':{'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="120px" prop="scalePointNo" label="秤点编号" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="scalePointName" label="秤点名称" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="baseSpotNo" label="计量点编号" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="baseSpotName" label="计量点名称" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="weighInstrumentModel" label="称重仪表型号" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="weighInstrumentParam" label="称重仪表参数" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="moxaIp" label="MOXA卡IP" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="moxaPort" label="MOXA卡端口" width="120" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" 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>
    </div>
    <div class="common-foot-style">
      <el-pagination v-loading="dataLoading2" @size-change="pageSizeChange2" @current-change="pageCurrentChange2"
        :current-page="page2.pageNum" :page-sizes="[100, 500, 1000]" :page-size="page2.pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="page2.totalPage">
      </el-pagination>
    </div>
    <el-row style="border-top: 1px solid #d5d5d5;">
      <el-col :span="18">
        <div ref="editTitle" class="common-title-div" style="border-right: 1px solid #d5d5d5;">计量点编辑区
        </div>
        <div ref="editDiv" class="commom-edit-div" style="border-right: 1px solid #d5d5d5;">
          <el-form ref="baseData" label-width="110px" :rules="ruleValidate" :model="baseData" :inline="true">
                <el-form-item prop="baseSpotName" label="计量点名称">
                  <el-input v-model="baseData.baseSpotName" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="videoIp" label="硬盘录像机IP">
                  <el-input v-model="baseData.videoIp" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="printerIp" label="打印机IP">
                  <el-input v-model="baseData.printerIp" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="flatComputerIp" label="触摸屏ip">
                  <el-input v-model="baseData.flatComputerIp" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="spotTypeNo" label="计量点类型">
                  <el-select v-model="baseData.spotTypeNo" clearable filterable style="width:120px" collapse-tags placeholder="请选择计量点类型" size="small">
                    <el-option v-for="(item,index) in spotType" :key="index" :label="item.baseName" :value="item.baseCode">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="videoPort" label="硬盘录像机端口">
                  <el-input v-model="baseData.videoPort" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="printerName" label="打印机名称">
                  <el-input v-model="baseData.printerName" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="spotStateNo" label="计量点状态">
                  <el-select v-model="baseData.spotStateNo" style="width:120px" clearable filterable collapse-tags placeholder="请选择计量点状态" size="small">
                    <el-option v-for="(item,index) in spotState" :key="index" :label="item.baseName" :value="item.baseCode">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item prop="videoUserName" label="硬盘录像机用户名">
                  <el-input v-model="baseData.videoUserName" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="countNum" label="总纸张">
                  <el-input v-model="baseData.countNum" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="videoPassword" label="硬盘录像机密码">
                  <el-input v-model="baseData.videoPassword" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="usedNum" label="已用纸张">
                  <el-input v-model="baseData.usedNum" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="ledIp" label="LED屏IP">
                  <el-input v-model="baseData.ledIp" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
                <el-form-item prop="controlIp" label="接管终端iIP">
                  <el-input v-model="baseData.controlIp" clearable style="width:120px" placeholder="请输入" size="small"></el-input>
                </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span="6">
        <div ref="editTitle" class="common-title-div">秤点编辑区
        </div>
        <div ref="editDiv" class="commom-edit-div">
          <el-form ref="baseData2" label-width="100px" :rules="ruleValidate2" :model="baseData2">
            <el-row>
              <el-col :span="18">
                <el-form-item prop="scalePointName" label="秤点名称">
                  <el-input v-model="baseData2.scalePointName" clearable size="small" placeholder="请输入"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="18">
                <el-form-item prop="baseSpotNo" label="计量点名称">
                  <el-select v-model="baseData2.baseSpotNo" clearable  filterable size="small" placeholder="请选择计量点名称">
                    <el-option v-for="(item,index) in meteringList" :key="index" :label="item.baseSpotName" :value="item.baseSpotNo">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="18">
                <el-form-item prop="moxaIp" label="moxa卡IP">
                  <el-input v-model="baseData2.moxaIp" clearable size="small" placeholder="请输入"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="18">
                <el-form-item prop="moxaPort" label="MOXA卡端口">
                  <el-input v-model="baseData2.moxaPort" clearable size="small" placeholder="请输入"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import {
    meterbasespotinfos,
    meterbasescalepoints,
    combaseinfos
  } from '../../../utils/api.js';
  import {
    discard,
    Recovery,
    modify,
    add
  } from '../../../utils/httpRequest.js';
  import {
    getCookie
  } from '@/utils/util.js';
  import {
    cookieUserId,
    cookieUserName
  } from '@/config/config.js';
  export default {
    data () {
     const flatComputerIpIsIp = (rule, value, callback) => {
        const isIp=  /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
       if (this.baseData.flatComputerIp) {
         if (!isIp.test(this.baseData.flatComputerIp)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
        }
       }
     const controlIpIsIp = (rule, value, callback) => {
        const isIp=  /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/
       if (!isIp.test(this.baseData.controlIp)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
       }
      const videoIpIsIp = (rule, value, callback) => {
        const isIp=  /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/
       if (!isIp.test(this.baseData.videoIp)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
       }
     const printerIpIsIp = (rule, value, callback) => {
        const isIp=  /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/
       if (this.baseData.printerIp) {
       if (!isIp.test(this.baseData.printerIp)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
       }
       }
      const ledIpIsIp = (rule, value, callback) => {
        const isIp=  /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/
       if (!isIp.test(this.baseData.ledIp)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
       }
      const moxaIpIsIp = (rule, value, callback) => {
        const isIp=  /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/
       if (!isIp.test(this.baseData2.moxaIp)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
       }
      return {
        dataLoading: false,
        dataLoading2: false,
        operateLoading: false,
        icoreFilterFlag: true,
        meteringList: [],
        spotType: [],
        spotState: [],
        multipleSelection: [],
        multipleSelection2: [],
        table: {
          list: []
        },
        table2: {
          list: []
        },
        activeMenu: '',
        tableHeight:0,
        tableHeight2:0,
        baseData: {
          baseSpotName: '',
          spotTypeNo: '',
          spotTypeName: '',
          videoIp: '',
          printerIp: '',
          videoPort: '',
          printerName: '',
          spotStateNo: '',
          spotStateName: '',
          videoUserName: '',
          countNum: '',
          videoPassword: '',
          usedNum: '',
          ledIp: '',
          controlIp: '',
          flatComputerIp: ''
        },
        baseData2: {
          scalePointName: '',
          baseSpotNo: '',
          baseSpotName: '',
          moxaIp: '',
          moxaPort: ''
        },
        ruleValidate: {
          baseSpotName: [{
            required: true,
            message: '计量点名称不能为空',
            trigger: 'change'
          }],
          scalePointName: [{
            required: true,
            message: '秤点名称不能为空',
            trigger: 'change'
          }],
          spotTypeNo: [{
            required: true,
            message: '该项不能为空',
            trigger: 'change'
          }],
          spotStateNo: [{
            required: true,
            message: '该项不能为空',
            trigger: 'change'
          }],
          // flatComputerIp: [{
          //    required: true, 
          //    validator: flatComputerIpIsIp, 
          //    trigger: 'blur',
          // }],
          // controlIp: [{
          //    required: true, 
          //    validator: controlIpIsIp, 
          //    trigger: 'blur',
          // }],
          videoIp: [{
             required: true, 
             validator: videoIpIsIp, 
             trigger: 'blur',
          }],
          // printerIp: [{
          //    required: true, 
          //    validator: printerIpIsIp, 
          //    trigger: 'blur',
          // }],
          // ledIp: [{
          //    required: true, 
          //    validator: ledIpIsIp, 
          //    trigger: 'blur',
          // }]
        },
        ruleValidate2: {
          scalePointName: [{
            required: true,
            message: '该项不能为空',
            trigger: 'change'
          }],
          baseSpotNo: [{
            required: true,
            message: '该项不能为空',
            trigger: 'change'
          }],
          moxaIp: [{
             required: true, 
             validator: moxaIpIsIp, 
             trigger: 'blur',
          }]
        },
        page: {
          pageSize: 500,
          pageNum: 1,
          totalPage: 0
        },
        page2: {
          pageSize: 500,
          pageNum: 1,
          totalPage: 0
        },
        firstRow: '',
        detailData: true,
        activeMenu: ''
      }
    },
    created () {
      this.tableHeight = (window.innerHeight - 400)/2 > 300 ? (window.innerHeight - 400)/2 : 300
      this.tableHeight2 = (window.innerHeight - 400)/2 > 160 ? (window.innerHeight - 400)/2 : 160
      this.activeMenu = window.top.localStorage.getItem('activeMenu')
    },
    mounted () {
      this.getBaseDataList();
      // this.getBaseDataList2();
      this.getMeteringTypeDataList();
      this.getMeteringStateDataList();
      this.changeTableHeigh()
    },
    methods: {
      getCode (code, arr, codeKey, nameKey) {
       if (!code) {
         return '';
       }
       let targetRow = arr.find(item => {
         return item[codeKey] === code;
       });
       return targetRow ? targetRow[nameKey] : '';
     },
     changeTableHeigh () {
       var tableDiv = this.$refs.merteringTable.$el
       var dtable = this.$refs.merteringTable2.$el
       var oDiv = this.$refs.lineDiv
       oDiv.onmousedown = function(ev){
       var theight = parseInt(tableDiv.offsetHeight)//parseInt为了不指向对象
       var dheight = parseInt(dtable.offsetHeight)
       oDiv.style.cursor = 's-resize'
       var ev = ev || event;
       //鼠标按下坐标
       var mouseDownX = ev.clientX;
       var mouseDownY = ev.clientY;
       // IE8 取消默认行为-设置全局捕获
       if(oDiv.setCapture){
       oDiv.setCapture();
       }
       document.onmousemove = function(ev){
       var ev = ev || event;
       // 鼠标移动时的鼠标位置
       var mouseMoveX = ev.clientX;
       var mouseMoveY = ev.clientY;
       tableDiv.style.height = theight+(mouseMoveY-mouseDownY)+"px"
       dtable.style.height = dheight +(mouseDownY-mouseMoveY)+"px"
       }
       }
       document.onmouseup = function(){
       document.onmousemove = null;
       // 释放全局捕获
       if(oDiv.releaseCapture){
       oDiv.releaseCapture();
       }
       }
       return false;
      },
       handleCurrentChange (val) {
        this.multipleSelection = [];
        this.multipleSelection.push(val);
      },
      handleCurrentChange2 (val) {
        this.multipleSelection2 = [];
        this.multipleSelection2.push(val);
      },
      getTableHeight (dom) {
        return (window.innerHeight - dom.offsetTop);
      },
      tableRowClassName ({
        row,
        rowIndex
      }) {
        if (row.validFlag !== '1') {
          return 'error-row2';
        }
        return '';
      },
      rowChange (row, column, event) {
        this.baseData = Object.assign ({}, row);
        this.firstRow = row
        this.getBaseDataList2(row)
      },
      rowChange2 (row, column, event) {
        this.baseData2 = Object.assign ({}, row);
        for (var i = 0; i < this.meteringList.length; i++) {
          if (this.meteringList[i].baseSpotNo === row.baseSpotNo) {
            this.meteringIndex = i;
          }
        }
      },
      addMetering () {
        let _this = this;
        _this.$refs['baseData'].validate((valid) => {
          if (valid) {
            _this.operateLoading = true;
            let baseDataAdd = {};
            baseDataAdd.baseSpotName = _this.baseData.baseSpotName
            baseDataAdd.videoIp = _this.baseData.videoIp
            baseDataAdd.printerIp = _this.baseData.printerIp
            baseDataAdd.videoPort = _this.baseData.videoPort
            baseDataAdd.printerName = _this.baseData.printerName
            baseDataAdd.videoUserName = _this.baseData.videoUserName
            baseDataAdd.countNum = _this.baseData.countNum
            baseDataAdd.videoPassword = _this.baseData.videoPassword
            baseDataAdd.usedNum = _this.baseData.usedNum
            baseDataAdd.ledIp = _this.baseData.ledIp
            baseDataAdd.controlIp = _this.baseData.controlIp
            baseDataAdd.flatComputerIp = _this.baseData.flatComputerIp
            baseDataAdd.spotTypeNo = _this.baseData.spotTypeNo;
            baseDataAdd.spotStateNo = _this.baseData.spotStateNo;
            baseDataAdd.spotTypeName = _this.getCode (this.baseData.spotTypeNo, this.spotType, 'baseCode', 'baseName')
            baseDataAdd.spotStateName = _this.getCode (this.baseData.spotStateNo, this.spotState, 'baseCode', 'baseName')
            add(meterbasespotinfos, baseDataAdd, (e) => {
              _this.operateLoading = false;
              if (!e) {
                _this.$refs['baseData'].resetFields && _this.$refs['baseData'].resetFields();
                _this.getBaseDataList();
              }
            })
          }
        });
      },
      modifyBaseData () {
        let _this = this;
        _this.$refs['baseData'].validate((valid) => {
          if (valid) {
            _this.baseData.spotTypeName = _this.getCode (this.baseData.spotTypeNo, this.spotType, 'baseCode', 'baseName')
            _this.baseData.spotStateName = _this.getCode (this.baseData.spotStateNo, this.spotState, 'baseCode', 'baseName')
            _this.operateLoading = true;
            modify(meterbasespotinfos + _this.baseData.baseSpotNo + '/', _this.baseData, (e) => {
              _this.operateLoading = false;
              if (!e) {
                _this.$refs['baseData'].resetFields && _this.$refs['baseData'].resetFields();
              }
              _this.getBaseDataList();
            });
          }
        });
      },
      enableBaseData () {
        this.operateLoading = true;
        Recovery(meterbasespotinfos + 'Recovery', this.multipleSelection, (e) => {
          this.operateLoading = false;
          if (!e) {
            this.getBaseDataList();
          }
        });
      },
      discardBaseData () {
        this.operateLoading = true;
        discard(meterbasespotinfos + 'abolish', this.multipleSelection, (e) => {
          this.operateLoading = false;
          if (!e) {
            this.getBaseDataList();
          }
        });
      },
      getBaseDataList () {
        this.getBaseDataList3();
        this.dataLoading = true;
        this.axios.get(meterbasespotinfos + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize)
          .then(res => {
            this.dataLoading = false;
            this.table.list = res.data.list;
            if (this.table.list.length > 0) {
               this.firstRow = res.data.list[0]
               this.$refs.merteringTable.setCurrentRow(res.data.list[0])
               this.getBaseDataList2 (res.data.list[0])
            }
            this.page.totalPage = res.data.total;
          }).catch(e => {
            this.dataLoading = false;
          });
      },
      pageSizeChange (size) {
        this.page.pageSize = size;
        this.getBaseDataList();
      },

      pageCurrentChange (index) {
        this.page.pageNum = index;
        this.getBaseDataList();
      },
      addMetering2 () {
        let _this = this;
        _this.$refs['baseData2'].validate((valid) => {
          if (valid) {
            let _this = this;
             let baseDataAdd = {}
             baseDataAdd.scalePointName = _this.baseData2.scalePointName
             baseDataAdd.moxaIp = _this.baseData2.moxaIp
             baseDataAdd.moxaPort = _this.baseData2.moxaPort
             baseDataAdd.baseSpotNo = _this.baseData2.baseSpotNo
             baseDataAdd.baseSpotName = _this.getCode (this.baseData2.baseSpotNo, this.meteringList, 'baseSpotNo', 'baseSpotName')
            _this.operateLoading = true;
            add(meterbasescalepoints, baseDataAdd, (e) => {
              _this.operateLoading = false;
              if (!e) {
                _this.$refs['baseData2'].resetFields && _this.$refs['baseData2'].resetFields();
              }
              _this.getBaseDataList2(this.firstRow);
            })
          }
        });
      },
      modifyBaseData2 () {
        this.operateLoading = true;
        this.baseData2.baseSpotName = this.getCode (this.baseData2.baseSpotNo, this.meteringList, 'baseSpotNo', 'baseSpotName')
        modify(meterbasescalepoints + this.baseData2.scalePointNo + '/', this.baseData2, (e) => {
          this.operateLoading = false;
          if (!e) {
            this.$refs['baseData2'].resetFields && this.$refs['baseData2'].resetFields();
            this.getBaseDataList2(this.firstRow);
          }
        });
      },
      enableBaseData2 () {
        this.operateLoading = true;
        Recovery(meterbasescalepoints + 'Recovery', this.multipleSelection2, (e) => {
          this.operateLoading = false;
          if (!e) {
            this.getBaseDataList2(this.firstRow);
          }
        });
      },
      discardBaseData2 () {
        this.operateLoading = true;
        discard(meterbasescalepoints + 'abolish', this.multipleSelection2, (e) => {
          this.operateLoading = false;
          if (!e) {
            this.getBaseDataList2(this.firstRow);
          }
        })
      },
      getBaseDataList2 (row) {
        this.dataLoading2 = true;
        this.axios.get(meterbasescalepoints + '/' + '?pageNum=' + this.page2.pageNum + '&pageSize=' + this.page2.pageSize + '&baseSpotNo=' + row.baseSpotNo)
          .then(res => {
            this.dataLoading2 = false;
            this.table2.list = res.data.list;
            this.page2.totalPage = res.data.total;
          }).catch(e => {
            this.dataLoading2 = false;
          });
      },
      getBaseDataList3 () {
        this.axios.get('pass/systemBase/v1/meterbasespotinfos/noPage/'+ '?validFlag=1')
            .then(res => {
              this.meteringList = res.data;
              this.baseData2.baseSpotNo = res.data.length > 0 ? res.data[0].baseSpotNo : ''
            })
      },
      pageSizeChange2 (size) {
        this.page2.pageSize = size;
        this.getBaseDataList2(this.firstRow);
      },

      pageCurrentChange2 (index) {
        this.page2.pageNum = index;
        this.getBaseDataList2(this.firstRow);
      },
      getMeteringTypeDataList () {
        this.axios.get(combaseinfos + 'noPage' + '?pBaseCode=001002' + '&validFlag=1')
          .then(res => {
            this.spotType = res.data;
            this.baseData.spotTypeNo = res.data.length > 0 ? res.data[0].baseCode : ''
          })
      },
      getMeteringStateDataList () {
        this.axios.get(combaseinfos + 'noPage' + '?pBaseCode=001001' + '&validFlag=1')
          .then(res => {
            this.spotState = res.data;
            this.baseData.spotStateNo = res.data.length > 0 ? res.data[0].baseCode : ''
          })
      }
    }

  }
</script>

<style>
  .lineDiv:hover{
    cursor:s-resize;
  }
  .el-select {
    width: 100%;
  }
</style>
