<template>
  <div id="main" class="h-all">
    <!--<el-scrollbar style="height: 100%">-->
    <el-row>
    <!--<vue-scroll>-->
      <el-col :span="12">
        <!--<el-main id="box">-->
        <el-form :model="form1" ref="form1" style="margin-left: -1900px;" label-width="2020px">
          <el-form-item style="margin-bottom: -10px;float: left; letter-spacing: 3px;margin-left: 4px" :label="$t('DeviceConfigurationManagement.ipInterval')+':'" prop="inputIpAddress">
            <el-col :span="8">
              <el-input size = 'mini' :placeholder="$t('common.placeholder')" v-model="form1.input1" clearable style="margin-left: 4px;width: 145px"></el-input>
            </el-col>
            <el-col :span="2">
              <label style="font-size: 10px;margin-left: 18px;">-</label>
            </el-col>
            <el-col :span="8">
              <el-input size = 'mini' :placeholder="$t('common.placeholder')"  v-model="form1.input2" clearable style="margin-left: 17px;width: 145px"></el-input>
            </el-col>
            <el-col :span="2">
              <el-button icon="el-icon-circle-plus-outline"  style="margin-left: 28px" type="primary" size = 'mini' @click="addItem" >{{ $t("common.add")}}</el-button>
            </el-col>
          </el-form-item>
          <div v-for="(item, index) in form1.dynamicItem" :key="index">
            <el-form-item style="margin-bottom: -10px;float: left; letter-spacing: 3px;margin-left: 3px" :label="$t('DeviceConfigurationManagement.ipInterval')+':'" :prop="'dynamicItem.' + index + '.inputIpAddress'">
              <el-col :span="8">
                <el-input size = 'mini' :placeholder="$t('common.placeholder')" v-model="item.input1" clearable style="margin-left: 5px;width: 145px"></el-input>
              </el-col>
              <el-col :span="2">
                <label style="font-size: 10px;margin-left: 18px;">-</label>
              </el-col>
              <el-col :span="8">
                <el-input size = 'mini' :placeholder="$t('common.placeholder')"  v-model="item.input2" clearable style="margin-left: 17px;width: 145px"></el-input>
              </el-col>
              <el-col :span="2">
                <el-button icon="el-icon-delete"  style="margin-left: 28px" type="primary" size = 'mini' @click="deleteItem" >{{ $t("common.delete")}}</el-button>
              </el-col>
            </el-form-item>
          </div>
          <el-form-item style="margin-bottom: -10px;float: left;" :label="$t('DeviceConfigurationManagement.findWay')+':'" prop="radio">
            <el-col>
              <template>
                <el-radio-group v-model="form1.radio" style="margin-left: 10px">
                  <el-radio :label=0 border size="mini" style="width: 145px;">{{$t("DeviceConfigurationManagement.SNMP")}}</el-radio>
                  <el-radio :label=1 border size="mini" style="width: 145px;margin-left: 15px">{{$t("DeviceConfigurationManagement.PING")}}</el-radio>
                </el-radio-group>
              </template>
            </el-col>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px;float: left" :label="$t('DeviceConfigurationManagement.linkFind')+':'" prop="checkedLinks">
            <el-col>
              <template>
                <el-checkbox-group v-model="form1.checkedLinks" style="margin-left: 10px" @change="changeLinks">
                  <!--<el-checkbox v-for="link in links" :label="link" :key="link"  size="mini" >{{link}}</el-checkbox>-->
                  <el-checkbox :label='$t("DeviceConfigurationManagement.linkDiscoveryProtocol")' border size="mini">{{$t("DeviceConfigurationManagement.linkDiscoveryProtocol")}}</el-checkbox>
                  <el-checkbox :label='$t("DeviceConfigurationManagement.foundDownDevice")' border size="mini" style="margin-left: 15px;width: 145px">{{$t("DeviceConfigurationManagement.foundDownDevice")}}</el-checkbox>
                </el-checkbox-group>
              </template>
            </el-col>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px;float: left;" :label="$t('DeviceConfigurationManagement.snmpVersion')+':'" prop="snmpVersion">
            <!--<el-col :span="1.5">-->
            <!--<label style="font-size: 10px;fo" >{{$t('DeviceConfigurationManagement.ipInterval')}}:</label>-->
            <!--</el-col>-->
            <el-col>
              <el-select clearable size='mini' v-model="form1.snmpVersion" :placeholder="$t('common.selectOption')" autocomplete="off" v-on:change="snmpVersionCheck" style="margin-left: 10px;width: 145px">
                <el-option
                  v-for="item in SNMPList"
                  :key="item.key"
                  :label="item.label"
                  :value="item.key"
                >
                </el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px;float: left" :label="$t('DeviceConfigurationManagement.snmpPort')+':'" prop="snmpPort">
            <el-col>
              <el-input size = 'mini' :placeholder="$t('common.placeholder')" v-model="form1.snmpPort" v-on:blur="textLengthCheck(form1.snmpPort)&&snmpPortCheck()" autocomplete="off" style="width:145px;margin-left: 10px"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px;float: left" :label="$t('DeviceConfigurationManagement.chooseSubnet')+':'" prop="subnetKey">
            <el-select clearable size='mini' v-model="form1.subnetKey" v-on:change="subnetKeyCheck" :placeholder="$t('common.placeholderSelect')"
                       autocomplete="off"
                       style="width:145px;margin-left: 10px">
              <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 style="margin-bottom: -10px;margin-left: 90px;float: left">
            <el-button type="primary" size="mini" @click="onSubmitInit">{{$t("common.ok")}}</el-button>
            <el-button size="mini" @click="clear">{{$t("common.reset")}}</el-button>
          </el-form-item>
        </el-form>
        <!--</el-main>-->
      </el-col>
    <!--</vue-scroll>-->
      <el-col :span="12">
        <el-main>
          <el-card shadow="never" v-if="false">
            <div slot="header">
              <span>{{isOk ? '开始搜索...':'搜索完成'}}</span>
            </div>
            <div>
              {{isOk ? '开始搜索...':'搜索完成'}}
              <br>
              {{isOk ? '开始搜索...':'搜索完成'}}
              {{isOk ? '开始搜索...':'搜索完成'}}
              {{isOk ? '开始搜索...':'搜索完成'}}
            </div>
          </el-card>
        </el-main>
      </el-col>
    </el-row>
    <!--</el-scrollbar>-->
    <el-container class="h-all">
      <!--<el-header height="auto">-->
        <!--<el-row>-->
          <!--<el-col :span="1.5">-->
            <!--<label style="font-size: 10px" >{{$t('DeviceConfigurationManagement.ipInterval')}}:</label>-->
          <!--</el-col>-->
          <!--<el-col :span="4.5">-->
            <!--<el-input size = 'mini' :placeholder="$t('common.placeholder')" v-model="ipInput1" clearable style="margin-left: 10px;"></el-input>-->
          <!--</el-col>-->
          <!--<el-col :span="1.5">-->
            <!--<label style="font-size: 10px;margin-left: 10px;">-</label>-->
          <!--</el-col>-->
          <!--<el-col :span="4.5">-->
            <!--<el-input size = 'mini' :placeholder="$t('common.placeholder')"  v-model="ipInput2" clearable style="margin-left: 10px;"></el-input>-->
          <!--</el-col>-->
          <!--<el-col :span="4.5">-->
            <!--<el-button icon="el-icon-circle-plus-outline"  type="primary" size = 'mini' @click="query" v-loading.fullscreen.lock="fullscreenLoading">{{ $t("common.findBtn")}}</el-button>-->
          <!--</el-col>-->
        <!--</el-row>-->
        <!--<el-row type="flex">-->
          <!--<el-progress :text-inside="true" :stroke-width="18" :percentage="rateOfProgress" style="width: 32.5%; padding-top: 7px; margin-right: 10px;"></el-progress>-->
          <!--<el-button icon="el-icon-tickets"  type="primary" size = 'mini' @click="updateInit" v-loading.fullscreen.lock="fullscreenLoading">{{ $t("common.saveBtn")}}</el-button>-->
        <!--</el-row>-->
      <!--</el-header>-->
      <!--<el-main class="adapt-height-box">-->
        <!--<el-table-->
          <!--:empty-text="$t('common.noData')"-->
          <!--border-->
          <!--header-row-class-name="table-header"-->
          <!--cell-class-name="table-cell"-->
          <!--class="adapt-height"-->
          <!--height="auto"-->
          <!--:row-style="tableRowClassName"-->
          <!--:cell-style="cellStyleClass"-->
          <!--style="font-size: 10px;width:100%;height:100%"-->
          <!--:header-cell-style="{height:'15px', fontSize:'10px',color:'#595959', background:'#EBEEF5'}"-->
          <!--ref="singleTable"-->
          <!--:data="deviceList"-->
          <!--highlight-current-row-->
          <!--tooltip-effect="dark"-->

          <!--@selection-change="handleSelectionChange">-->
          <!--<el-badge value="new" >-->
            <!--<el-table-column-->
              <!--type="selection"-->
              <!--:selectable='checkboxForMain'-->
              <!--:index="curSelectNum"-->
              <!--width="28">-->
            <!--</el-table-column>-->
          <!--</el-badge>-->

          <!--<el-table-column-->
            <!--prop="uuid"-->
            <!--:label="$t('DeviceConfigurationManagement.uuid')"-->
            <!--fixed-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="200"-->
            <!--style="font-size: 10px;">-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--width="200"-->
            <!--:show-overflow-tooltip="true"-->
            <!--prop="deviceName"-->
            <!--fixed-->
            <!--:label="$t('DeviceConfigurationManagement.deviceName')">-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="deviceType"-->
            <!--:label="$t('DeviceConfigurationManagement.deviceType')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="100"-->
            <!--:formatter="formatdeviceType"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="deviceModel"-->
            <!--:label="$t('DeviceConfigurationManagement.deviceModel')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="100"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="locationKey"-->
            <!--:label="$t('DeviceConfigurationManagement.locationKey')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="150"-->
            <!--:formatter="formatLocationKey"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->

            <!--prop="cabinetKey"-->
            <!--:label="$t('DeviceConfigurationManagement.cabinetKey')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="150"-->
            <!--:formatter="formatCabinetKey"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->

            <!--prop="subnetKey"-->
            <!--width="150"-->
            <!--:label="$t('DeviceConfigurationManagement.subnetKey')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--:formatter="formatSubnetKey"-->
          <!--&gt;-->

          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="ipAddress"-->
            <!--width="190"-->
            <!--:show-overflow-tooltip="true"-->
            <!--:label="$t('DeviceConfigurationManagement.ipAddress')">-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="snmpVersion"-->
            <!--width="100"-->
            <!--:label="$t('DeviceConfigurationManagement.snmpVersion')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--:formatter="formatsnmpVersion"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--width="95"-->
            <!--prop="snmpPort"-->
            <!--:label="$t('DeviceConfigurationManagement.snmpPort')"-->
            <!--:show-overflow-tooltip="true"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--width="100"-->
            <!--prop="trapPort"-->
            <!--:label="$t('DeviceConfigurationManagement.trapPort')"-->
            <!--:show-overflow-tooltip="true"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="deviceStatus"-->
            <!--:label="$t('DeviceConfigurationManagement.deviceStatus')"-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="100"-->
            <!--:formatter="formatdeviceStatus"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--prop="deviceVersion"-->
            <!--:show-overflow-tooltip="true"-->
            <!--width="110"-->
            <!--:label="$t('DeviceConfigurationManagement.deviceVersion')">-->
          <!--</el-table-column>-->

          <!--<el-table-column-->
            <!--width="200"-->
            <!--prop="startTime"-->
            <!--:label="$t('DeviceConfigurationManagement.startTime')"-->
            <!--:show-overflow-tooltip="true"-->
          <!--&gt;-->
          <!--</el-table-column>-->
          <!--<el-table-column-->
            <!--width="200"-->
            <!--prop="configFileName"-->
            <!--:label="$t('ProfileManagement.configFileName')"-->

          <!--&gt;-->
          <!--</el-table-column>-->
        <!--</el-table>-->
        <!--<el-dialog @close="dialogClose"-->
                   <!--@opened="updateDeviceInit"-->
                   <!--v-if="updateDeviceVisible"-->
                   <!--:title="$t('DeviceConfigurationManagement.updateDeviceInfo')"-->
                   <!--v-dialogDrag-->
                   <!--style="font-size: 10px; " width='750px' heigt='700px'-->
                   <!--:visible.sync="updateDeviceVisible">-->
          <!--<el-row>-->

            <!--&lt;!&ndash;<el-form :model="form" inline="true" ref="form" style="margin-bottom: -20px;margin-top:-20px">&ndash;&gt;-->
            <!--<el-form :model="form" inline="true" ref="form">-->

              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item prop="number"-->
                              <!--:label="'*'+ $t('DeviceConfigurationManagement.uuid')+':'"-->
                              <!--:label-width="formLabelWidth">-->
                  <!--<el-input type="age" size='mini' :placeholder="$t('common.doNotEdit')" v-model="form.uuid"-->
                            <!--v-on:blur="uuidCheck "-->
                            <!--autocomplete="off"-->
                            <!--:disabled="someInputCanntSel"-->
                            <!--style="width:200px" readonly></el-input>-->
                <!--</el-form-item>-->
                <!--<el-form-item prop="string"-->
                              <!--:label="'*'+ $t('DeviceConfigurationManagement.deviceName')+':'"-->
                              <!--:label-width="formLabelWidth">-->
                  <!--<el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.deviceName"-->
                            <!--v-on:blur="deviceNameCheck "-->
                            <!--autocomplete="off"-->
                            <!--style="width:200px"></el-input>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item prop="string"-->
                              <!--:label=" $t('DeviceConfigurationManagement.deviceType')+':'"-->
                              <!--:label-width="formLabelWidth">-->
                  <!--<el-input size='mini' unselectable="on" :placeholder="$t('common.doNotEdit')"-->
                            <!--v-model="form.deviceTypeLabel"-->
                            <!--autocomplete="off"-->

                            <!--style="width:200px" readonly-->
                            <!--:disabled="someInputCanntSel"></el-input>-->
                <!--</el-form-item>-->
                <!--<el-form-item prop="string"-->
                              <!--:label=" $t('DeviceConfigurationManagement.deviceModel')+':'" :label-width="formLabelWidth">-->
                  <!--<el-input size='mini' unselectable="on" :placeholder="$t('common.doNotEdit')" v-model="form.deviceModel"-->
                            <!--autocomplete="off"-->

                            <!--style="width:200px" prop="string" readonly-->
                            <!--:disabled="someInputCanntSel"></el-input>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item :label=" $t('DeviceConfigurationManagement.locationKey')+':'"-->
                              <!--:label-width="formLabelWidth"-->
                              <!--prop="string">-->
                  <!--<el-select clearable size="mini" v-model="form.locationKey"-->
                             <!--:placeholder="$t('common.placeholderSelect')"-->
                             <!--autocomplete="off"-->

                             <!--style="width:200px">-->
                    <!--<el-option v-for="item in locationList" :key="item.locationKey" :label="item.locationName"-->
                               <!--:value="item.locationKey"></el-option>-->
                  <!--</el-select>-->
                <!--</el-form-item>-->
                <!--<el-form-item :label=" $t('DeviceConfigurationManagement.cabinetKey')+':'"-->
                              <!--:label-width="formLabelWidth"-->
                              <!--prop="string">-->
                  <!--<el-select clearable size='mini' v-model="form.cabinetKey" :placeholder="$t('common.placeholderSelect')"-->
                             <!--autocomplete="off"-->

                             <!--style="width:200px">-->
                    <!--<el-option v-for="item in cabinetList" :key="item.cabinetKey" :label="item.cabinetName"-->
                               <!--:value="item.cabinetKey"></el-option>-->
                    <!--&lt;!&ndash;cabinetKeyList   &ndash;&gt;-->
                  <!--</el-select>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item :label=" $t('DeviceConfigurationManagement.subnetKey')+':'"-->
                              <!--:label-width="formLabelWidth"-->
                              <!--prop="string">-->
                  <!--<el-select clearable size='mini' v-model="form.subnetKey" :placeholder="$t('common.placeholderSelect')"-->
                             <!--autocomplete="off"-->
                             <!--style="width:200px">-->
                    <!--<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-->
                  <!--:label="'*'+ $t('DeviceConfigurationManagement.ipAddress')+':'"-->
                  <!--:label-width="formLabelWidth" prop="string">-->
                  <!--<el-input size='mini' :placeholder="$t('common.doNotEdit')" v-model="form.ipAddress"-->
                            <!--autocomplete="off"-->
                            <!--v-on:blur="ipCheck"-->
                            <!--style="width:200px" readonly></el-input>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item unselectable="on"-->
                              <!--:label="'*'+ $t('DeviceConfigurationManagement.snmpVersion')+':'"-->
                              <!--:label-width="formLabelWidth"-->
                              <!--prop="string">-->
                  <!--<el-select clearable size='mini' v-model="deviceSNMP" :placeholder="$t('common.placeholderSelect')"-->
                             <!--autocomplete="off"-->
                             <!--v-on:change="deviceSNMPCheck"-->
                             <!--style="width:200px">-->
                    <!--<el-option v-for="item in deviceSNMPList" :key="item.key" :label="item.label"-->
                               <!--:value="item.key"></el-option>-->
                  <!--</el-select>-->
                <!--</el-form-item>-->
                <!--<el-form-item :label="'*'+ $t('DeviceConfigurationManagement.snmpPort')+':'"-->
                              <!--:label-width="formLabelWidth" prop="string">-->
                  <!--<el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.snmpPort" autocomplete="off"-->
                            <!--v-on:blur="getnumberCheck"-->
                            <!--style="width:200px"></el-input>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item :label="'*'+ $t('DeviceConfigurationManagement.trapPort')+':'"-->
                              <!--:label-width="formLabelWidth" prop="string">-->
                  <!--<el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.trapPort" autocomplete="off"-->
                            <!--v-on:blur="trapnumberCheck"-->
                            <!--style="width:200px"></el-input>-->
                <!--</el-form-item>-->
                <!--<el-form-item-->
                  <!--:label="'*'+ $t('DeviceConfigurationManagement.deviceStatus')+':'"-->
                  <!--:label-width="formLabelWidth"-->
                  <!--prop="string">-->
                  <!--<el-select clearable size='mini' v-model="valueState" :placeholder="$t('common.placeholderSelect')"-->
                             <!--autocomplete="off"-->
                             <!--v-on:change="valueStateCheck " style="width:200px">-->
                    <!--&lt;!&ndash;:formatter="formatStateKey"&ndash;&gt;-->
                    <!--<el-option v-for="item in deviceStatusList" :key="item.key" :label="item.label"-->
                               <!--:value="item.key"></el-option>-->
                  <!--</el-select>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
              <!--<el-form-item style="margin-bottom: -10px;">-->
                <!--<el-form-item :label="$t('DeviceConfigurationManagement.deviceVersion')+':'"-->
                              <!--:label-width="formLabelWidth" prop="string">-->
                  <!--<el-input size='mini' :placeholder="$t('common.doNotEdit')" v-model="form.deviceVersion"-->
                            <!--autocomplete="off"-->
                            <!--:disabled="someInputCanntSel"s-->
                            <!--style="width:200px" readonly></el-input>-->
                <!--</el-form-item>-->
                <!--<el-form-item :label=" $t('DeviceConfigurationManagement.startTime')+':'"-->
                              <!--:label-width="formLabelWidth">-->
                  <!--<el-input size='mini' :placeholder="$t('common.timeFormat')" v-model="form.startTime"-->
                            <!--autocomplete="off"-->
                            <!--v-on:blur="timeCheak"-->
                            <!--style="width:200px"></el-input>-->
                <!--</el-form-item>-->
              <!--</el-form-item>-->
            <!--</el-form>-->
          <!--</el-row>-->
          <!--<el-row style="margin-bottom: 0px;" slot="footer" class="dialog-footer">-->
            <!--<el-button size='mini' type="primary" @click="confirmUpdate">-->
              <!--{{$t("common.saveBtn")}}-->
            <!--</el-button>-->
            <!--<el-button size='mini' @click="dialogClose">{{$t("common.cancel")}}</el-button>-->
          <!--</el-row>-->
        <!--</el-dialog>-->
      <!--</el-main>-->
    </el-container>
    <!--command命令弹窗-->

  </div>
</template>

<script>
  import DeviceService from '../../../domain/services/DeviceService';
  import LocationService from '../../../domain/services/LocationService';
  import SubnetService from '../../../domain/services/SubnetService';
  import CabinetService from '../../../domain/services/CabinetService';
  import helperUtil from '../../../utils/HelperUtil'
  import Vue from 'vue'

  import loading from "../../../utils/Loading";
  import HelperUtil from "../../../utils/HelperUtil";
  import legitimacyCheck from "../../../utils/legitimacyCheck";

  export default {
    name: 'TraditionDeviceConfigurationManagement',
    components: {

    },
    data: function () {   //存放 数据
      return {
        form1: {
          inputIpAddress: '',
          input1: '',
          input2: '',
          dynamicItem: [],
          radio: 0,
          checkedLinks: [],
          snmpVersion: '0',
          snmpPort: '161',
          subnetKey: ''

        },
        SNMPList: [
          {
            key: '0',
            label: 'v1'
          },
          {
            key: '1',
            label: 'v2c'
          },
          {
            key: '2',
            label: 'v3'
          }
        ],
        subnetList: [],
        select: '',
        show: false,
        isOk: 'false',
        updateDeviceVisible:false,
        commandContext: {},
        isRefreshSave:false,
        isErrFlag:false,
        //updateInitList:[],
        form:{
          deviceKey:"",
          uuid:"",
          deviceName:"",
          deviceType:0,
          deviceModel:"",
          locationKey:"",
          cabinetKey:"",
          subnetKey:"",
          ipAddress:"",
          snmpVersion:"",
          snmpPort:0,
          trapPort:0,
          deviceStatus:1,
          deviceVersion:"",
          startTime:"",
          subcardModel1:"",
          subcardModel2:"",
          subcardModel3:"",
          configFileKey:"",
          configFileName:"",
          delFlag:0,
          modifyTime:""
        },

        someInputCanntSel:true,

        createAndCopyTitle:'',
        createAndCopyInitList:[],
        formerDeviceList:[],
        queryDeviceList:[],
        changDataDeviceList:[],

        tableHeight: window.innerHeight * 0.7,
        //IP查询输入框
        ipInput1: "",
        ipInput2: "",
        valueState: '1',
        deviceSNMP: '1',
        deviceTypeList: [
          {
            deviceTypeKey: '0',
            deviceTypeName: this.$t('DeviceConfigurationManagement.traditional')

          },
          {
            deviceTypeKey: '1',
            deviceTypeName: 'SDN',
          }
        ],

        //网元状态下拉菜单
        deviceStatusList: [
          {
            key: '0',
            label: this.$t('DeviceConfigurationManagement.inUse')
          },
          {
            key: '1',
            label: this.$t('DeviceConfigurationManagement.notInUse')
          },
        ],

        //SNMP版本下拉菜单
        deviceSNMPList: [
          {
            key: '0',
            label: 'v1'
          },
          {
            key: '1',
            label: 'v2c'
          },
          {
            key: '3',
            label: 'v3'
          }
        ],

        //IP列表
        ipInputList:{

        },

        // 进度条数量
        rateOfProgress: 0,
        //进度个数
        i1 : 0,

        //设置一个参数用于限制查询的顺序
        successQuery: 0,

        formLabelWidth: '120px',
        //多选，选中项
        multipleSelection: [],

        // 数据加载过程中，覆盖界面
        fullscreenLoading: false,

        //表格所显示内容
        deviceList:[],
        newCreateList:[],
        updateList:[],
        newCreateNum:0,
        updateNum:0,
        curSelectNum:0,
        findLoadingInstance:null,

        /* warnAlarmColor: "#fdfd08",
         severityAlarmColor: "#f97309",
         instancyAlarmColor: "#f9110b",*/

        newColor:"#fdfd08",
        updateColor:"#f97309",
      }
    },

    computed: {
      openTab () {
        return this.$store.state.openTab;
      },
      activeIndex:{
        get () {
          return this.$store.state.activeIndex;
        },
        set (val) {
          this.$store.commit('set_active_index', val);
        }
      },

    },
    watch:{
      commandContext(newVal, oldVal) {
        if (JSON.stringify(newVal) === '{}') {
          this.getAllTradDeviceInit();
          this.$refs.singleTable.clearSelection();
        }
        deep: true
      },

    },
    methods: {
      addItem: function () {
        this.form1.dynamicItem.push({
          inputIpAddress: ''
        })
      },
      deleteItem: function () {
        this.form1.dynamicItem.splice(this.form1.dynamicItem.length - 1, 1)
      },

      textLengthCheck: function (checkString) {
        let serverCheck = legitimacyCheck()
        if (!serverCheck.textLengthCheck(checkString)) {
          //所输文本长度必须控制在20之内
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.LENGTH_CODE))
          return false
        }
        return true
      },
      changeLinks: function () {
        switch (this.form1.checkedLinks.length) {
          case 2:
            this.select = 2
            break
          case 1:
            if (this.form1.checkedLinks[0] === this.$t("DeviceConfigurationManagement.linkDiscoveryProtocol")) {
              this.select = 0
            } else {
              this.select = 1
            }
            break
          case 0:
            this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.LINK_PROTOCOL))
            break
        }
      },
      snmpVersionCheck: function () {
        let serverCheck = legitimacyCheck()
        if (!serverCheck.textNullCheck(this.form1.snmpVersion)) {
          //输入不可为空
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('BasicConfigurationManagement.snmpVersion'))
          return false
        }
        return true
      },
      subnetKeyCheck: function () {
        let serverCheck = legitimacyCheck()
        if (!serverCheck.textNullCheck(this.form1.subnetKey)) {
          //输入不可为空
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('BasicConfigurationManagement.subnetKey'))
          return false
        }
        return true
      },

      //Get端口数字非空检验
      snmpPortCheck: function () {
        let serverCheck = legitimacyCheck()
        if (!serverCheck.numberCheck(this.form1.snmpPort)) {
          //请输入合法性数字
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.DIGIT_CODE), this.$t('BasicConfigurationManagement.snmpPort'))
          return false
        }
        return true
      },

      // 取值
      onSubmitInit: function () {
        // this.ipAddressCheck()
        let formDevice = {}
        let inputIpList = []
        if (this.form1.dynamicItem.length === 0) {
          inputIpList[0] = new Array(2)
          inputIpList[0][0] = this.form1.input1
          inputIpList[0][1] = this.form1.input2
        } else {
          inputIpList[0] = new Array(2)
          inputIpList[0][0] = this.form1.input1
          inputIpList[0][1] = this.form1.input2
          for (var i = 1; i < this.form1.dynamicItem.length + 1; i++) {
            inputIpList[i] = new Array(2)
            inputIpList[i][0] = this.form1.dynamicItem[i - 1].input1
            inputIpList[i][1] = this.form1.dynamicItem[i - 1].input2
          }
        }
        formDevice.iP = inputIpList
        formDevice.findType = this.form1.radio
        formDevice.findNodeType = this.select
        formDevice.snmpVersion = this.form1.snmpVersion
        formDevice.snmpPort = this.form1.snmpPort
        formDevice.subnetKey = this.form1.subnetKey
        // DeviceService.searchDevice(formDevice).then(result => {
        DeviceService.searchDevice().then(result => {

        }).catch(err => {
          this.InfoTip.errorTip(this, err)
        })
        this.show = true
      },

      clear: function () {
        this.form1.input1 = ''
        this.form1.input2 = ''
        this.form1.dynamicItem.length = 0
        this.$refs.form1.resetFields()
      },
      rowStyleClass: function ({row, rowIndex}) {
        return {"height": "20px"};
      },
      cellStyleClass: function ({row, rowIndex}) {
        return {"padding": "0"};
      },

      handleSelectionChange: function (val) {
        this.multipleSelection = val;
      },

      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()) {
          return
        }
      },

      query: async function () {
        this.isErrFlag=false;
        this.deviceList = [];
        this.queryDeviceList=[];
        this.isRefreshSave=false;
        //百分号置0
        this.rateOfProgress = 0;
        this.i1 = 0;
        if (this.ipInput1 == '' || this.ipInput2 == '') {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE),this.$t('DeviceConfigurationManagement.ipAddress'))
          return
        }
        // 校验 IP 格式
        if (!this.ipCheck()) {
          return;
        }

        if(!helperUtil.checkIpOrder(this.ipInput1,this.ipInput2)){
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.CORRECT_IP_ORDER),this.$t('DeviceConfigurationManagement.ipAddress'))
          return
        }

        if(!HelperUtil.checkIpIntervalLength(this.ipInput1,this.ipInput2)){
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.NOT_IN_SAME_INTERVAL),this.$t('DeviceConfigurationManagement.ipAddress'))

          return
        }

        //获取发送列表
        this.ipInputList = helperUtil.ipToGroup(this.ipInput1, this.ipInput2);
        //console.log("inputList!!!!!"+this.ipInputList);
        this.getAllTradDeviceInit();


        //this.i1++;
        //设置进度条百分号
        this.findLoadingInstance=loading.openLoading();
        for (let i = 0; i < this.ipInputList.length; i++) {
          //调用查询函数
          // this.DiscoverTraditionalDevices(this.ipInputList[i]);//[i]);
          let _this = this;
          let newCreateDevice;
          let newUpdateDevice;
          let newOverlapDevice;
          //console.log('ipGroup',ipGroup);
          let discover = DeviceService.discoverTraditionalDevices(this.ipInputList[i]).then(result => {
            if (JSON.stringify(result) !== '{}' || result.length == 0) {
              let tempList = Object.values(result).concat(_this.queryDeviceList);//Object.values(result);
              //设备状态的排序，新增，修改的，没动的
              _this.i1++;

              newCreateDevice = this.contrastNewObj(tempList, _this.formerDeviceList);
              newOverlapDevice = this.contrastOverlapObj(tempList, _this.formerDeviceList);
              newUpdateDevice = this.contrastUpdateObj(tempList, _this.formerDeviceList);

              let curList = newCreateDevice.concat(newUpdateDevice).concat(newOverlapDevice);
              _this.queryDeviceList = _this.filterDeviceType(curList);
              _this.deviceList = _this.queryDeviceList;
              if(_this.isRefreshSave==true){

              }else{
                _this.rateOfProgress = parseInt(_this.i1 / _this.ipInputList.length * 100);

                if(_this.rateOfProgress==100&&_this.isErrFlag==false){
                  _this.findLoadingInstance.close();
                  _this.InfoTip.successTip(_this, helperUtil.getStatusCodeObjectByCode(_this.successCode.QUERY_CODE));

                }

              }

            } else {
              _this.i1++;
              console.log('result 是空');
              _this.deviceList = _this.queryDeviceList;
              if(_this.isRefreshSave==true){

              }else{
                _this.rateOfProgress = parseInt(_this.i1 / _this.ipInputList.length * 100);
                if(_this.rateOfProgress==100&&_this.isErrFlag==false){
                  _this.findLoadingInstance.close();
                  _this.InfoTip.successTip(_this, helperUtil.getStatusCodeObjectByCode(_this.successCode.QUERY_CODE));

                }
              }

            }
          }).catch(err => {
            //失败
            _this.isErrFlag=true;
            //真实环境
            _this.deviceList = [];
            console.log('搜索传统设备失败');
            //设置进度条百分号
            _this.rateOfProgress = 0;
            _this.findLoadingInstance.close();
            _this.InfoTip.errorTip(_this, err);
          });
          await discover;
        }

      },

      /**
       * @Description  ：根据IP网段区间进行查询本网段内的设备
       * @author       : bjh
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/3/30 19:35
       */
      DiscoverTraditionalDevices:  function (ipGroup) {
        let _this = this;
        let newCreateDevice;
        let newUpdateDevice;
        let newOverlapDevice;
        //console.log('ipGroup',ipGroup);
        let discover = DeviceService.discoverTraditionalDevices(ipGroup).then(result => {

          if (JSON.stringify(result) !== '{}' || result.length == 0) {
            let tempList = Object.values(result).concat(_this.queryDeviceList);//Object.values(result);
            //设备状态的排序，新增，修改的，没动的
            _this.i1++;

            newCreateDevice = this.contrastNewObj(tempList, _this.formerDeviceList);
            newOverlapDevice = this.contrastOverlapObj(tempList, _this.formerDeviceList);
            newUpdateDevice = this.contrastUpdateObj(tempList, _this.formerDeviceList);

            let curList = newCreateDevice.concat(newUpdateDevice).concat(newOverlapDevice);
            _this.queryDeviceList = _this.filterDeviceType(curList);
            _this.deviceList = _this.queryDeviceList;
            if(_this.isRefreshSave==true){

            }else{
              _this.rateOfProgress = parseInt(_this.i1 / _this.ipInputList.length * 100);

              if(_this.rateOfProgress==100&&_this.isErrFlag==false){
                _this.findLoadingInstance.close();
                _this.InfoTip.successTip(_this, helperUtil.getStatusCodeObjectByCode(_this.successCode.QUERY_CODE));

              }

            }

          } else {
            _this.i1++;
            console.log('result 是空');
            _this.deviceList = _this.queryDeviceList;
            if(_this.isRefreshSave==true){

            }else{
              _this.rateOfProgress = parseInt(_this.i1 / _this.ipInputList.length * 100);
              if(_this.rateOfProgress==100&&_this.isErrFlag==false){
                _this.findLoadingInstance.close();
                _this.InfoTip.successTip(_this, helperUtil.getStatusCodeObjectByCode(_this.successCode.QUERY_CODE));

              }
            }

          }
        }).catch(err => {
          //失败
          _this.isErrFlag=true;
          //真实环境
          _this.deviceList = [];
          console.log('搜索传统设备失败');
          //设置进度条百分号
          _this.rateOfProgress = 0;
          _this.findLoadingInstance.close();
          _this.InfoTip.errorTip(_this, err);
        });
      },


      // 验证IP合法性
      ipCheck: function () {

        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 (this.ipInput1 === "" || this.ipInput2 === "") {
          return false
        }
        if ((!re.test(this.ipInput1)) || (!re.test(this.ipInput2))) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.IPCHECK_CODE),this.$t('DeviceConfigurationManagement.ipAddress'))
          return false
        } else {
          return true
        }

      },
      // ls验证IP合法性
      ipCheck1: function (ip1,ip2) {

        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 === "" || ip2 === "") {
          return false
        }
        if ((!re.test(ip1)) || (!re.test(ip2))) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.IPCHECK_CODE), this.$t('DeviceConfigurationManagement.ipAddress'))
          return false
        } else {
          return true
        }

      },

      /**
       * @Description  ：保存所选设备
       * @author       : bjh
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/3/30 19:36
       */
      save: function () {
        let _this=this;

        let loadingInstance = loading.openLoading();
        //调用函数
        DeviceService.batchAddDevice(this.multipleSelection).then(result => {
          //成功
          //this.refreshQueryAfterSave();
          let tempList=_this.refreshDeleteSaved(_this,_this.deviceList,_this.multipleSelection);
          _this.deviceList=tempList;
          this.$refs.singleTable.clearSelection();
          loadingInstance.close();
          this.InfoTip.successTip(this, HelperUtil.getStatusCodeObjectByCode(this.successCode.ADD_CODE))

        }).catch(err => {
          //失败
          this.$refs.singleTable.clearSelection();
          loadingInstance.close();
          this.InfoTip.errorTip(this, err);
        });

      },

      //获取所有设备
      async getAllTradDeviceInit() {
        let _this = this;
        let flag = DeviceService.getAllDeviceCollection().then(result => {
          let tempList = Object.values(result);
          _this.formerDeviceList = _this.filterDeviceType(tempList);
          // _this.deviceList=_this.filterDeviceType(tempList);
        }).catch(err => {
          console.log("传统设备发现失败");
        });

        //console.log('newCreateDevice!!!'+newCreateDevice);
        await flag;

      },

      getAllTradDeviceFirst: function () {

        let _this = this;
        DeviceService.getAllDeviceCollection().then(result => {
          let curList = Object.values(result);
          //_this.deviceList=_this.filterDeviceType(curList);
          _this.formerDeviceList = _this.filterDeviceType(curList);
        }).catch(err => {
          console.log("传统设备发现失败");
          this.InfoTip.errorTip(this, err);
        });
      },

      contrastNewObj: function (oldval, newval) {
        let newArr = new Array();
        let oldArr = new Array();
        oldArr = Object.values(oldval);
        newArr = Object.values(newval);
        let newCreate = oldArr.reduce(function (pre, cur) {
          if (newArr.every(item => item.uuid != cur.uuid)) {
            pre.push(cur);
          }
          return pre;
        }, []);
        this.newCreateNum = newCreate.length;
        return newCreate;

      },

      contrastUpdateObj: function (oldval, newval) {
        let newArray = [];
        let oldArray = [];
        oldArray = Object.values(oldval);
        newArray = Object.values(newval);
        let _this = this;
        let updateVal = oldArray.reduce(function (pre, cur, index) {
          for (let i = 0; i < newArray.length; i++) {
            if (newArray[i].uuid == cur.uuid && JSON.stringify(newArray[i]) !== JSON.stringify(cur)) {
              pre.push(cur);
            }
          }
          return pre;
        }, []);
        this.updateNum = updateVal.length;
        //console.log('jin dao Contrast'+JSON.stringify(newCreate));
        return updateVal;
      },

      contrastOverlapObj: function (oldval, newval) {
        let newArray = [
        ];
        let oldArray = [
        ];
        oldArray = Object.values(oldval);
        newArray = Object.values(newval);
        let overlapVal = oldArray.reduce(function (pre, cur, index) {
          for (let i = 0; i < newArray.length; i++) {
            if (newArray[i].uuid == cur.uuid && JSON.stringify(newArray[i]) == JSON.stringify(cur)) {
              pre.push(cur);
            }
          }
          return pre;
        }, []);
        return overlapVal;
      },

      tableRowClassName: function ({row, rowIndex}) {
        if (rowIndex < this.newCreateNum) {
          return {"background-color": this.newColor};
        } else if (rowIndex >= this.newCreateNum && rowIndex < this.newCreateNum + this.updateNum) {
          return {"background-color": this.updateColor};
        } else if (rowIndex >= this.newCreateNum + this.updateNum) {
          return {};
        }
        return '';
      },

      checkboxForMain: function (row, rowIndex) {
        if (rowIndex >= this.newCreateNum + this.updateNum) {
          return false;
        } else {
          return true;
        }
      },

      filterDeviceType: function (arr) {
        let list = arr.reduce(function (pre, cur, index) {
          if (cur.deviceType == '0') {
            pre.push(cur);
          }
          return pre;
        }, []);
        return list;
      },

      dialogClose: function () {
        this.updateDeviceVisible = false;
        //this.form={};
        this.$refs.singleTable.clearSelection();
        this.curSelectNum = 0;
      },

      confirmUpdate: function () {
        //console.log('confirmUpdate_Before',this.deviceList);
        //this.deviceList[this.curSelectNum]=this.form;

        if(!this.deviceNameCheck()){
          return
        }

        this.deviceList[this.curSelectNum].deviceKey = this.form.deviceKey;
        this.deviceList[this.curSelectNum].uuid = this.form.uuid
        this.deviceList[this.curSelectNum].deviceName = this.form.deviceName
        this.deviceList[this.curSelectNum].deviceType = this.form.deviceType //""//禁用
        this.deviceList[this.curSelectNum].deviceModel = this.form.deviceModel// ""//禁用
        this.deviceList[this.curSelectNum].locationKey = this.form.locationKey
        this.deviceList[this.curSelectNum].cabinetKey = this.form.cabinetKey
        this.deviceList[this.curSelectNum].subnetKey = this.form.subnetKey
        this.deviceList[this.curSelectNum].ipAddress = this.form.ipAddress
        this.deviceList[this.curSelectNum].snmpVersion = this.deviceSNMP;
        this.deviceList[this.curSelectNum].snmpPort = this.form.snmpPort

        this.deviceList[this.curSelectNum].trapPort = this.form.trapPort
        this.deviceList[this.curSelectNum].deviceStatus = this.valueState
        this.deviceList[this.curSelectNum].deviceVersion = this.form.deviceVersion// ""//禁用
        this.deviceList[this.curSelectNum].startTime = this.form.startTime
        this.deviceList[this.curSelectNum].subcardModel1 = this.form.subcardModel1
        this.deviceList[this.curSelectNum].subcardModel2 = this.form.subcardModel2
        this.deviceList[this.curSelectNum].subcardModel3 = this.form.subcardModel3
        this.deviceList[this.curSelectNum].configFileKey = this.form.configFileKey
        this.deviceList[this.curSelectNum].configFileName = this.form.configFileName
        this.deviceList[this.curSelectNum].delFlag = this.form.delFlag
        this.deviceList[this.curSelectNum].modifyTime = this.form.modifyTime
        this.reverseFormatDeviceTypeForUpdate();
        this.updateDeviceVisible = false;
        //this.$refs.singleTable.clearSelection();
        //this.curSelectNum=0;
        this.save();
      },
      reverseFormatDeviceTypeForUpdate: function () {
        if (this.form.deviceTypeLabel == '传统')
          this.deviceList[this.curSelectNum].deviceType = '0'
        else if (this.form.deviceTypeLabel == 'SDN')
          this.deviceList[this.curSelectNum].deviceType = '1'
        else
          this.deviceList[this.curSelectNum].deviceType = ''
      },

      updateDeviceInit: function () {
        let i;
        for (i = 0; i < this.deviceList.length; i++) {
          if (this.deviceList[i].uuid == this.multipleSelection[0].uuid) {
            break;
          }
        }
        this.curSelectNum = i;

        this.form.deviceKey = this.multipleSelection[0].deviceKey;
        this.form.uuid = this.multipleSelection[0].uuid;
        this.form.deviceName = this.multipleSelection[0].deviceName;
        this.form.deviceType = this.multipleSelection[0].deviceType;//""//禁用
        this.form.deviceModel = this.multipleSelection[0].deviceModel;// ""//禁用
        this.form.locationKey = this.multipleSelection[0].locationKey;
        this.form.cabinetKey = this.multipleSelection[0].cabinetKey;
        this.form.subnetKey = this.multipleSelection[0].subnetKey;
        this.form.ipAddress = this.multipleSelection[0].ipAddress;
        this.form.snmpVersion = this.multipleSelection[0].snmpVersion;
        this.form.snmpPort = this.multipleSelection[0].snmpPort;
        this.form.trapPort = this.multipleSelection[0].trapPort;

        if(this.multipleSelection[0].deviceStatus==null||this.multipleSelection[0].deviceStatus===''||this.multipleSelection[0].deviceStatus.length==0){
          this.valueState="1";
          this.form.deviceStatus="1";
          console.log("1jin!!!");
        }else{
          this.valueState = this.multipleSelection[0].deviceStatus.toString();
          console.log("2jin!!!");
        }



        this.form.deviceVersion = this.multipleSelection[0].deviceVersion;// ""//禁用
        this.form.startTime = this.getCurentTime();
        this.form.subcardModel1 = this.multipleSelection[0].subcardModel1;
        this.form.subcardModel2 = this.multipleSelection[0].subcardModel2;
        this.form.subcardModel3 = this.multipleSelection[0].subcardModel3;
        this.form.configFileKey = this.multipleSelection[0].configFileKey;
        this.form.configFileName = this.multipleSelection[0].configFileName;
        this.form.delFlag = this.multipleSelection[0].delFlag;
        this.form.modifyTime = this.multipleSelection[0].modifyTime;
        this.formatdeviceTypeForupdate();

      },

      formatdeviceTypeForupdate: function () {
        //console.log('this.form.deviceType' + this.form.deviceType)
        if (this.form.deviceType == '0')
          this.form.deviceTypeLabel = '传统'
        else if (this.form.deviceType == '1')
          this.form.deviceTypeLabel = 'SDN'
        else
          this.form.deviceTypeLabel = ''
      },

      valueStateCheck: function () {
        let deviceCheck = legitimacyCheck()

        var result = deviceCheck.textNullCheck(this.valueState)
        if (!result) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('DeviceConfigurationManagement.deviceStatus'))
          return false
        }
        return true

      },

      deviceNameCheck:function(){

        let deviceCheck = legitimacyCheck()

        let result = deviceCheck.textNullCheck(this.form.deviceName)
        if (!result) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE), this.$t('DeviceConfigurationManagement.deviceName'))
          return false
        }
        if (!deviceCheck.textLengthCheck(this.form.deviceName)) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.LENGTH_CODE))
          return false
        }

        return true

      },

      updateInit: function () {

        if (this.multipleSelection.length > 1) {
          //请只选择一条信息进行修改
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.SAVE_ONLY_ONE_CODE))
          return
        }
        if (this.multipleSelection.length == 0) {
          //请选择一条信息进行修改
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.SAVE_SELECT_CODE))
          return
        }
        let i;
        for (i = 0; i < this.deviceList.length; i++) {
          if (this.deviceList[i].uuid == this.multipleSelection[0].uuid) {
            break;
          }
        }
        this.curSelectNum = i;

        this.form.deviceKey = this.multipleSelection[0].deviceKey;
        this.form.uuid = this.multipleSelection[0].uuid;
        this.form.deviceName = this.multipleSelection[0].deviceName;
        this.form.deviceType = this.multipleSelection[0].deviceType;//""//禁用
        this.form.deviceModel = this.multipleSelection[0].deviceModel;// ""//禁用
        this.form.locationKey = this.multipleSelection[0].locationKey;
        this.form.cabinetKey = this.multipleSelection[0].cabinetKey;
        this.form.subnetKey = this.multipleSelection[0].subnetKey;
        this.form.ipAddress = this.multipleSelection[0].ipAddress;
        this.form.snmpVersion = this.multipleSelection[0].snmpVersion;
        this.form.snmpPort = this.multipleSelection[0].snmpPort;
        this.form.trapPort = this.multipleSelection[0].trapPort;
        //this.form.deviceStatus = this.multipleSelection[0].deviceStatus;
        this.form.deviceVersion = this.multipleSelection[0].deviceVersion;// ""//禁用
        this.form.startTime = this.multipleSelection[0].startTime;
        this.form.subcardModel1 = this.multipleSelection[0].subcardModel1;
        this.form.subcardModel2 = this.multipleSelection[0].subcardModel2;
        this.form.subcardModel3 = this.multipleSelection[0].subcardModel3;
        this.form.configFileKey = this.multipleSelection[0].configFileKey;
        this.form.configFileName = this.multipleSelection[0].configFileName;
        this.form.delFlag = this.multipleSelection[0].delFlag;
        this.form.modifyTime = this.multipleSelection[0].modifyTime;
        this.form.startTime = this.multipleSelection[0].startTime;
        this.form.startTime = this.getCurentTime()
        this.formatdeviceTypeForupdate();

        if(this.multipleSelection[0].deviceStatus==null||this.multipleSelection[0].deviceStatus===''||this.multipleSelection[0].deviceStatus.length==0){
          this.valueState="1";
          this.form.deviceStatus="1";
          console.log("1jin!!!");
        }else{
          this.valueState = this.multipleSelection[0].deviceStatus.toString();
          console.log("2jin!!!");
        }

        this.updateDeviceVisible = true;
      },

      //获取当前时间
      getCurentTime() {
        //获取当前时间
        var date = new Date()
        var seperator1 = '-'
        var seperator2 = ':'
        var year = date.getFullYear()
        var month = date.getMonth() + 1
        var strDate = date.getDate()
        var hour = date.getHours() + ''
        if (hour.length < 2) {
          hour = '0' + hour
        }
        var minu = date.getMinutes() + ''
        if (minu.length < 2) {
          minu = '0' + minu
        }
        var sec = date.getSeconds() + ''
        if (sec.length < 2) {
          sec = '0' + sec
        }
        var ms = date.getMilliseconds() + ''
        if (ms.length == 1) {
          ms = '00' + ms
        }
        else if (ms.length == 2) {
          ms = '0' + ms
        }
        if (month >= 1 && month <= 9) {
          month = '0' + month
        }
        if (strDate >= 0 && strDate <= 9) {
          strDate = '0' + strDate
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate + ' ' + hour + seperator2 + minu + seperator2 + sec + '.' + ms

        return currentdate

      },

      sortDevice: function (newList, oldList) {
        let newCreateDevice;
        let newOverlapDevice;
        let newUpdateDevice;
        let finalList = [];
        newCreateDevice = this.contrastNewObj(newList, oldList);
        newOverlapDevice = this.contrastOverlapObj(newList, oldList);
        newUpdateDevice = this.contrastUpdateObj(newList, oldList);
        if (JSON.stringify(newCreateDevice) != '[]' || JSON.stringify(newUpdateDevice) != '[]') {
          this.newCreateList = newCreateDevice;
          this.updateList = newUpdateDevice;
          let curList = newCreateDevice.concat(newUpdateDevice).concat(newOverlapDevice);
          finalList = this.filterDeviceType(curList);
          console.log("newNum!", this.newCreateNum);
          console.log("updateNum!", this.updateNum);
        }
        return finalList;
      },

      refreshDeleteSaved:function(_this,devlist,muti){
        let tempdevicelist=devlist;
        let tempmuti=muti;
        console.log("muti!!",muti)
        for(let i=0;i<tempdevicelist.length;i++){
          for(let j=0;j<tempmuti.length;j++){
            if(tempmuti[j].uuid==tempdevicelist[i].uuid&&i<=_this.newCreateNum){
              tempdevicelist.splice(i,1);
              _this.newCreateNum--;
            }else if(tempmuti[j].uuid==tempdevicelist[i].uuid&&i>_this.newCreateNum&&i<=_this.newCreateNum+_this.updateNum){
              tempdevicelist.splice(i,1);
              _this.updateNum--;
            }else{

            }
          }
        }
        return tempdevicelist;
      },

      formatLocationKey: function (row, column) {
        for (var i = 0; i < this.locationList.length; i++) {
          if (this.locationList[i]['locationKey'] == row.locationKey) {
            return this.locationList[i]['locationName']
            break
          }
        }
      },

      formatSubnetKey: function (row, column) {
        for (var i = 0; i < this.subnetList.length; i++) {
          if (this.subnetList[i]['subnetKey'] == row.subnetKey) {
            return this.subnetList[i]['subnetName']
            break
          }
        }
      },

      formatCabinetKey: function (row, column) {

        for (var i = 0; i < this.cabinetList.length; i++) {
          if (this.cabinetList[i]['cabinetKey'] == row.cabinetKey) {
            return this.cabinetList[i]['cabinetName']
            break
          }
        }
      },

      formatdeviceStatus: function (row, column) {

        //        for (var i = 0; i < this.deviceList.length; i++) {
        for (var j = 0; j < this.deviceStatusList.length; j++) {
          if (row.deviceStatus == this.deviceStatusList[j]['key']) {
            return this.deviceStatusList[j]['label']
          }
          if (row.deviceStatus == -999) {
            return ''
          }
        }

      },

      formatsnmpVersion: function (row, column) {
        for (var j = 0; j < this.deviceSNMPList.length; j++) {
          if (row.snmpVersion == this.deviceSNMPList[j]['key']) {
            return this.deviceSNMPList[j]['label']
          }
          //          break
        }

        //      }
      },

      formatdeviceType: function (row, column) {

        for (var j = 0; j < this.deviceTypeList.length; j++) {
          if (row.deviceType == this.deviceTypeList[j]['deviceTypeKey']) {
            return this.deviceTypeList[j]['deviceTypeName']
          }
        }
        //          break
      },

      getAllSubnet:function() {

        let _this = this;
        SubnetService.getAllSubnetCollection().then(result => {
          //成功
          _this.subnetList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err)
        })
      },
      getAllLocation: function () {
        let _this = this;
        //就这句没改
        LocationService.getAllLocationCollection().then(result => {
          //成功
          _this.locationListInit = result
          _this.locationList = Object.values(_this.locationListInit)

        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },
      getAllCabinet:function() {

        let _this = this;
        //就这句没改
        CabinetService.getAllCabinetCollection().then(result => {
          //成功
          _this.cabinetList = Object.values(result)
          _this.cabinetListInit = result

        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err)
        })
      }
    },
    beforeCreate: function () {

    },
    created: function () {

      this.getAllTradDeviceFirst();
      this.getAllSubnet();
      this.getAllLocation();
      this.getAllCabinet();
    },
    //初始化函数，加载数据
    mounted(){

      this.someInputCanntSel=true;
      //this.getAllTradDeviceFirst();
      //console.log("UID!!!",this._uid);
    },
  }
</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>
