<template>
  <div id="main" class="h-all">
    <!--<el-scrollbar style="height: 100%">-->
    <el-dialog
      @close="close"
      v-dialogDrag
      :title=title
      style="font-size: 10px;" width='750px'
      :visible.sync="createElementDiscoveryVisible">
      <el-row>
        <el-form :model="form" inline="true" ref="form" style="width: 1600px">
            <el-row>
              <el-form-item style="margin-bottom: -10px; float:left;">
                <el-form-item :label="$t('ResourceManagement.templateName')+':'"
                              prop="string" :label-width="formLabelWidth">
                  <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.templateName"
                            autocomplete="off"
                            v-on:blur="templateNameCheck">
                  </el-input>
                </el-form-item>
                <el-form-item :label="$t('ResourceManagement.subnet')+':'"
                              prop="string" :label-width="formLabelWidth">
                  <el-select size='mini' clearable v-model="form.subnet" v-on:change="subnetCheck" :placeholder="$t('ResourceManagement.selectSubnet')">
                    <el-option v-for="item in subnetList"
                               :key="item.subnetKey"
                               :label="item.subnetName"
                               :value="item.subnetKey">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item style="margin-bottom: -10px; float:left;">
                <el-form-item :label="$t('ResourceManagement.protocolName')+':'" :label-width="formLabelWidth">
                  <template>
                    <el-checkbox-group v-model="form.checkList" min @change="disableOrNot">
                      <el-checkbox :label=0 size="mini" style="width: 100px">{{$t("ResourceManagement.SNMPProtocol")}}</el-checkbox>
                      <el-checkbox :label=2 size="mini" style="width: 100px">{{$t("ResourceManagement.IPMIProtocol")}}</el-checkbox>
                      <el-checkbox :label=1 size="mini" style="width: 100px">{{$t("ResourceManagement.ICMPProtocol")}}</el-checkbox>
                    </el-checkbox-group>
                  </template>
                </el-form-item>
              </el-form-item>
            </el-row>
          <el-row>
            <el-form-item style="margin-bottom: -10px; float:left;">
              <el-form-item :label="$t('ResourceManagement.IPMIUserName')+':'"
                            prop="string" :label-width="formLabelWidth">
                <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.ipmiUserName"
                          autocomplete="off"
                          :disabled="ipmiFlag"
                          v-on:blur="IpmiUserNameCheck">
                </el-input>
              </el-form-item>
              <el-form-item :label="$t('ResourceManagement.IPMIPassword')+':'"
                            prop="string" :label-width="formLabelWidth">
                <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.ipmiPassword"
                          :disabled="ipmiFlag"
                          autocomplete="off"
                          style="width: 173px"
                          v-on:blur="IpmiPasswordCheck">
                </el-input>
              </el-form-item>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item style="margin-bottom: -10px; float:left">
              <el-form-item :label="$t('ResourceManagement.SNMPProtocolVersion')+':'"
                            prop="string" :label-width="formLabelWidth">
                <el-select size='mini'
                           style="width: 158px"
                           collapse-tags
                           v-model="form.snmpProtocolVersion"
                           v-on:change="SNMPVersionCheck"
                           :placeholder="$t('ResourceManagement.selectSnmpVersion')">
                  <el-option v-for="item in snmpList"
                             :key="item.key"
                             :label="item.label"
                             :value="item.key">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item :label="$t('ResourceManagement.SNMPGroupName')+':'"
                            prop="string" :label-width="formLabelWidth">
                <el-input size='mini' :placeholder="$t('common.placeholder')"
                          style="width: 173px"
                          v-model="form.snmpGroupName"
                          autocomplete="off"
                          v-on:blur="snmpGroupNameCheck">
                </el-input>
              </el-form-item>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item style="margin-bottom: -10px; float:left">
              <el-form-item :label="$t('ResourceManagement.GETPortName')+':'"
                            prop="string" :label-width="formLabelWidth">
                <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.getPortName"
                          autocomplete="off"
                          onkeyup="value=value.replace(/[^\d]/g,'')"
                          v-on:blur="GETPortNameCheck">
                </el-input>
              </el-form-item>
              <el-form-item :label="$t('ResourceManagement.TRAPortName')+':'"
                            prop="string" :label-width="formLabelWidth">
                <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.trapPortName"
                          autocomplete="off"
                          style="width: 173px"
                          onkeyup="value=value.replace(/[^\d]/g,'')"
                          v-on:blur="TRAPortNameCheck">
                </el-input>
              </el-form-item>
            </el-form-item>
          </el-row>
            <el-row>
              <el-form-item style="margin-bottom: -10px; float:left;">
                <el-form-item :label="$t('DeviceConfigurationManagement.ipInterval')+':'" :label-width="formLabelWidth">
                  <el-input v-on:blur="ipCheckSelf(form.input1)" size = 'mini' :placeholder="$t('common.placeholder')" v-model="form.input1" clearable style="width: 140px"></el-input>
                  <label>-</label>
                  <el-input v-on:blur="ipCheckSelf(form.input2)" size = 'mini' :placeholder="$t('common.placeholder')"  v-model="form.input2" clearable style="width: 140px"></el-input>
                </el-form-item>
                <el-form-item :label="$t('ResourceManagement.station')+':'"
                              prop="string" label-width="100px" style="margin-left: -20px">
                  <el-input size='mini' :placeholder="$t('common.placeholder')"
                            v-model="form.station"
                            style="width: 120px"
                            autocomplete="off">
                  </el-input>
                </el-form-item>
                <el-button icon="el-icon-circle-plus-outline"  style="margin-left: -10px" type="primary" size = 'mini' @click="addItemIp" >{{ $t("common.add")}}</el-button>
              </el-form-item>
            </el-row>
            <el-row>
              <div v-for="(item, index) in form.dynamicItem" :key="index">
                <el-row>
                  <el-form-item style="margin-bottom: -10px; float:left">
                    <el-form-item :prop="'dynamicItem.' + index" :label="$t('DeviceConfigurationManagement.ipInterval')+':'" :label-width="formLabelWidth">
                      <el-input v-on:blur="ipCheckSelf(item.input1)" size = 'mini' :placeholder="$t('common.placeholder')" v-model="item.input1" clearable style="width: 140px"></el-input>
                      <label>-</label>
                      <el-input v-on:blur="ipCheckSelf(item.input2)" size = 'mini' :placeholder="$t('common.placeholder')"  v-model="item.input2" clearable style="width: 140px"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('ResourceManagement.station')+':'"
                                  prop="string" label-width="100px" style="margin-left: -20px">
                      <el-input size='mini' :placeholder="$t('common.placeholder')"
                                v-model="item.station"
                                style="width: 120px"
                                autocomplete="off">
                      </el-input>
                    </el-form-item>
                    <el-button icon="el-icon-delete" style="margin-left: -10px" type="danger" size = 'mini' @click="deleteItemIp(index)" >{{ $t("common.delete")}}</el-button>
                  </el-form-item>
                </el-row>
              </div>
            </el-row>
          <el-form-item style="margin-top:10px;margin-bottom: -10px;margin-left: -900px;margin-bottom: 10px">
            <el-button icon="el-icon-circle-check" type="primary" size="mini" @click="onSubmit">{{$t("common.ok")}}</el-button>
            <el-button icon='el-icon-circle-close' size="mini" @click="close">{{$t("common.cancel")}}</el-button>
          </el-form-item>
        </el-form>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import EdTemplateService from '@/domain/services/Template/EdTemplateService'
import SubnetService from '../../../domain/services/SubnetService'
import HelperUtil from '../../../utils/HelperUtil'
import legitimacyCheck from '../../../utils/legitimacyCheck'

export default {
  name: 'CreateElementDiscovery',
  props: ['command'],
  data: function () {
    return {
      createElementDiscoveryVisible: false,
      title: this.command.title,
      initList: this.command.target,
      subnetList: [],
      check: null,
      ipmiFlag: true,
      form: {
        templateName: '',
        subnet: '',
        checkList: [0],
        station: '',
        snmpProtocolVersion: '0',
        getPortName: '',
        trapPortName: '',
        snmpGroupName: '',
        ipmiUserName: '',
        ipmiPassword: '',
        input1: '',
        input2: '',
        dynamicItem: []
      },
      snmpList: [
        {
          key: '0',
          label: 'v1'
        },
        {
          key: '1',
          label: 'v2c'
        },
        {
          key: '2',
          label: 'v3'
        }
      ],
      tableHeight: window.innerHeight * 0.7,
      formLabelWidth: '120px'
    }
  },
  methods: {
    /**
     * @Description  : 确认
     * @author       : ls
     * @date         : 2020/4/23 15:08
     * @param        :
     * @return       :
     */
    onSubmit: function () {
      if (!this.totalCheck()) {
        return
      }
      let formTemplate = {}
      let inputIpList = ''
      let stationArr = ''
      inputIpList = inputIpList.concat(this.form.input1).concat(' - ').concat(this.form.input2)
      stationArr = stationArr.concat(this.form.station)
      if (this.form.dynamicItem.length !== 0) {
        for (var i = 0; i < this.form.dynamicItem.length; i++) {
          inputIpList = inputIpList.concat(',').concat(this.form.dynamicItem[i].input1).concat(' - ').concat(this.form.dynamicItem[i].input2)
          stationArr = stationArr.concat(',').concat(this.form.dynamicItem[i].station)
        }
      }
      formTemplate.ips = inputIpList
      formTemplate.discoveryTemplateName = this.form.templateName
      formTemplate.subnetKey = this.form.subnet
      formTemplate.station = stationArr
      formTemplate.snmpVersion = this.form.snmpProtocolVersion
      formTemplate.snmpGroup = this.form.snmpGroupName
      formTemplate.snmpPort = this.form.getPortName
      formTemplate.trapPort = this.form.trapPortName
      formTemplate.ipmiUserName = this.form.ipmiUserName
      formTemplate.ipmiPassword = this.form.ipmiPassword

      formTemplate.manageType = this.form.checkList
      if (this.form.checkList.length === 1) {
        if (this.form.checkList[0] === 0) {
          formTemplate.manageType = '100'
        } else if (this.form.checkList[0] === 1) {
          formTemplate.manageType = '010'
        } else {
          formTemplate.manageType = '001'
        }
      } else if (this.form.checkList.length === 2) {
        if (this.form.checkList[0] === 0 && this.form.checkList[1] === 1) {
          formTemplate.manageType = '110'
        } else if (this.form.checkList[0] === 0 && this.form.checkList[1] === 2) {
          formTemplate.manageType = '101'
        } else {
          formTemplate.manageType = '011'
        }
      } else {
        formTemplate.manageType = '111'
      }
      let _this = this
      let loadingInstance = _this.Loading.openLoading()
      EdTemplateService.createTemplate(formTemplate).then(result => {
        _this.Loading.closeLoading(loadingInstance)
        _this.InfoTip.successTip(_this, HelperUtil.getStatusCodeObjectByCode(_this.successCode.ADD_CODE))
        _this.close()
      }).catch(err => {
        _this.Loading.closeLoading(loadingInstance)
        this.InfoTip.errorTip(this, err)
      })
    },
    /**
     * @Description  : 显示
     * @author       : ls
     * @date         : 2020/4/23 13:30
     * @param        :
     * @return       :
     */
    disableOrNot: function () {
      this.ipmiFlag = this.form.checkList.includes(2) ? false : true
      if (this.form.checkList.length === 0) {
        this.form.checkList = [0]
      }
    },
    /**
     * @Description  : 提交校验
     * @author       : ls
     * @date         : 2020/4/23 16:37
     * @param        :
     * @return       :
     */
    totalCheck: function () {
      if (!this.templateNameCheck()) {
        return false
      }
      if (!this.subnetCheck()) {
        return false
      }
      if (!this.snmpGroupNameCheck()) {
        return false
      }
      if (this.ipmiFlag === false) {
        if (!this.IpmiUserNameCheck()) {
          return false
        }
        if (!this.IpmiPasswordCheck()) {
          return false
        }
      }
      if (!this.SNMPVersionCheck()) {
        return false
      }
      if (!this.snmpGroupNameCheck()) {
        return false
      }
      if (!this.GETPortNameCheck()) {
        return false
      }
      if (!this.TRAPortNameCheck()) {
        return false
      }
      if (this.form.input1 === '' || this.form.input2 === '') {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('DeviceConfigurationManagement.ipInterval'))
        return false
      }
      if (!HelperUtil.ipCheck1(this.form.input1, this.form.input2)) {
        return false
      }
      if (!HelperUtil.checkIpOrder(this.form.input1, this.form.input2)) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.CORRECT_IP_ORDER), this.$t('DeviceConfigurationManagement.ipInterval'))
        return false
      }
      if (!HelperUtil.checkIpIntervalLength(this.form.input1, this.form.input2)) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.NOT_IN_SAME_INTERVAL), this.$t('DeviceConfigurationManagement.ipInterval'))
        return false
      }
      if (!this.stationCheck(this.form.station)) {
        return false
      }
      for (var i = 0; i < this.form.dynamicItem.length; i++) {
        if (this.form.dynamicItem[i].input1 === '' || this.form.dynamicItem[i].input2 === '') {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('DeviceConfigurationManagement.ipInterval'))
          return false
        }
        if (!HelperUtil.ipCheck1(this.form.dynamicItem[i].input1, this.form.dynamicItem[i].input2)) {
          return false
        }
        if (!HelperUtil.checkIpOrder(this.form.dynamicItem[i].input1, this.form.dynamicItem[i].input2)) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.CORRECT_IP_ORDER), this.$t('DeviceConfigurationManagement.ipInterval'))
          return false
        }
        if (!HelperUtil.checkIpIntervalLength(this.form.dynamicItem[i].input1, this.form.dynamicItem[i].input2)) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.NOT_IN_SAME_INTERVAL), this.$t('DeviceConfigurationManagement.ipInterval'))
          return false
        }
        if (!this.stationCheck(this.form.dynamicItem[i].station)) {
          return false
        }
      }
      return true
    },
    /**
     * @Description  : 名称校验
     * @author       : ls
     * @date         : 2020/4/23 13:03
     * @param        :
     * @return       :
     */
    templateNameCheck: function () {
      if (!this.check.textNullCheck(this.form.templateName)) {
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.templateName'))
        return false
      }
      return true
    },
    /**
     * @Description  : 子网校验
     * @author       : ls
     * @date         : 2020/4/23 13:11
     * @param        :
     * @return       :
     */
    subnetCheck: function () {
      var result = this.check.textNullCheck(this.form.subnet)
      if (!result) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.subnet'))
        return false
      }
      return true
    },
    /**
     * @Description  : SNMP协议校验
     * @author       : ls
     * @date         : 2020/4/23 16:46
     * @param        :
     * @return       :
     */
    SNMPVersionCheck: function () {
      var result = this.check.textNullCheck(this.form.snmpProtocolVersion)
      if (!result) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.SNMPProtocolVersion'))
        return false
      }
      return true
    },
    /**
     * @Description  : GET端口
     * @author       : ls
     * @date         : 2020/4/23 16:49
     * @param        :
     * @return       :
     */
    GETPortNameCheck: function () {
      var result = this.check.textNullCheck(this.form.getPortName)
      if (!result) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.GETPortName'))
        return false
      }
      return true
    },
    /**
     * @Description  : Trap端口校验
     * @author       : ls
     * @date         : 2020/5/29 13:14
     * @param        :
     * @return       :
     */
    TRAPortNameCheck: function () {
      var result = this.check.textNullCheck(this.form.trapPortName)
      if (!result) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.TRAPortName'))
        return false
      }
      return true
    },
    /**
     * @Description  : 团体名校验
     * @author       : ls
     * @date         : 2020/4/23 16:32
     * @param        :
     * @return       :
     */
    snmpGroupNameCheck: function () {
      if (!this.check.textNullCheck(this.form.snmpGroupName)) {
        // 输入不可为空
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.SNMPGroupName'))
        return false
      }
      return true
    },
    /**
     * @Description  : IPMI用户名校验
     * @author       : ls
     * @date         : 2020/4/23 16:54
     * @param        :
     * @return       :
     */
    IpmiUserNameCheck: function () {
      if (!this.check.textNullCheck(this.form.ipmiUserName)) {
        // 输入不可为空
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.IPMIUserName'))
        return false
      }
      return true
    },
    /**
     * @Description  : IPMI密码校验
     * @author       : ls
     * @date         : 2020/4/23 16:55
     * @param        :
     * @return       :
     */
    IpmiPasswordCheck: function () {
      if (!this.check.textNullCheck(this.form.ipmiPassword)) {
        // 输入不可为空
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.IPMIPassword'))
        return false
      }
      return true
    },
    /**
     * @Description  :支持输入
     * @author       : ls
     * @date         : 2020/5/28 16:13
     * @param        :
     * @return       :
     */
    stationBlur: function (e) {
      this.form.station = e.target.value
    },
    /**
     * @Description  : 车站校验
     * @author       : ls
     * @date         : 2020/4/23 16:09
     * @param        :
     * @return       :
     */
    stationCheck: function (sta) {
      var result = this.check.textNullCheck(sta)
      if (!result) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.station'))
        return false
      }
      return true
    },
    /**
     * @Description  : IP校验
     * @author       : ls
     * @date         : 2020/4/23 14:21
     * @param        :
     * @return       :
     */
    ipCheck1: function (ip1) {
      var reg = /^([1-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))(.([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))){3}$/

      var re = new RegExp(reg)
      if (ip1 === '') {
        return false
      }
      if ((!re.test(ip1))) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.IPCHECK_CODE), this.$t('ResourceManagement.ipAddress'))
        return false
      } else {
        return true
      }
    },
    ipCheckSelf: function (ip) {
      if (ip === '') {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('ResourceManagement.ipDomain'))
        return
      }
      if (!this.ipCheck1(ip)) {
      }
    },
    ipCheck: function (ip1, ip2) {
      if (!HelperUtil.checkIpOrder(ip1, ip2)) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.CORRECT_IP_ORDER), this.$t('ResourceManagement.ipAddress'))
        return
      }

      if (!HelperUtil.checkIpIntervalLength(ip1, ip2)) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.NOT_IN_SAME_INTERVAL), this.$t('ResourceManagement.ipAddress'))
        return
      }
    },
    /**
     * @Description  : 关闭
     * @author       : ls
     * @date         : 2020/4/23 12:34
     * @param        :
     * @return       :
     */
    close: function () {
      this.command.done()
    },
    /**
     * @Description  : 添加IP
     * @author       : ls
     * @date         : 2020/4/23 11:42
     * @param        :
     * @return       :
     */
    addItemIp: function () {
      this.form.dynamicItem.push({
        input1: '',
        input2: '',
        station: ''
      })
    },
    /**
     * @Description  : 删除IP
     * @author       : ls
     * @date         : 2020/4/23 12:10
     * @param        :
     * @return       :
     */
    deleteItemIp: function (val) {
      this.form.dynamicItem.splice(val, 1)
    },
    ipAddressCheck: function () {
      if (this.form1.input1 === '' || this.form1.input2 === '') {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('DeviceConfigurationManagement.ipInterval'))
        return
      }
      // 校验 IP 格式
      if (!this.ipCheck1(this.form1.input1, this.form1.input2)) {
        return
      }

      if (!HelperUtil.checkIpOrder(this.form1.input1, this.form1.input2)) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.CORRECT_IP_ORDER), this.$t('DeviceConfigurationManagement.ipInterval'))
        return
      }

      if (!HelperUtil.checkIpIntervalLength(this.form1.input1, this.form1.input2)) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.NOT_IN_SAME_INTERVAL), this.$t('DeviceConfigurationManagement.ipInterval'))
        return
      }

      for (var i = 0; i < this.form1.dynamicItem.length; i++) {
        if (typeof (this.form1.dynamicItem[i].input1) === 'undefined' || typeof (this.form1.dynamicItem[i].input2) === 'undefined') {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('DeviceConfigurationManagement.ipInterval'))
          return
        }
        // 校验 IP 格式
        if (!this.ipCheck1(this.form1.dynamicItem[i].input1, this.form1.dynamicItem[i].input2)) {
          return
        }

        if (!HelperUtil.checkIpOrder(this.form1.dynamicItem[i].input1, this.form1.dynamicItem[i].input2)) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.CORRECT_IP_ORDER), this.$t('DeviceConfigurationManagement.ipInterval'))
          return
        }

        if (!HelperUtil.checkIpIntervalLength(this.form1.dynamicItem[i].input1, this.form1.dynamicItem[i].input2)) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.NOT_IN_SAME_INTERVAL), this.$t('DeviceConfigurationManagement.ipInterval'))
          return
        }
      }

      if (this.form1.checkedLinks.length === 0) {
        this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.LINK_PROTOCOL))
        return
      }

      if (!this.snmpPortCheck()) {
        return
      }
      if (!this.snmpVersionCheck()) {
        return
      }
      if (!this.subnetKeyCheck()) {

      }
    },
    /**
     * @Description  : getAllSubnet
     * @author       : ls
     * @date         : 2020/4/25 17:13
     * @param        :
     * @return       :
     */
    getAllSubnet: function () {
      let _this = this
      SubnetService.getAllSubnetCollection().then(result => {
        // 成功
        _this.subnetList = Object.values(result)
      }).catch(err => {
        // 失败
        _this.InfoTip.errorTip(_this, err)
      })
    },
  },
  created: function () {
    this.check = legitimacyCheck()
    this.getAllSubnet()
  },
  // 初始化函数，加载数据
  mounted () {
    this.createElementDiscoveryVisible = true
  }
}
</script>

<style scoped lang="scss">
  /*!* 外层布局容器样式 *!*/
  .el-header {
    background-color: #f9fafc;
    color: #333;
    line-height: 40px;
  }

  #box{
    width:100%;
    height:100%;
    overflow:hidden;
  }
  .el-card__header {
    background-color: greenyellow;
  }

  /* .el-input {
     width: 330px;
   }*/

  /deep/ .el-textarea__inner{
    font-size: 12px;
  }
</style>
