<template>
  <!-- 业务子网创建对话框 -->
  <el-dialog
    @close="close"
    @opened="checked"
    v-dialogDrag
    v-if="createAndCopyEthernetSubnetVisible"
    :title=title
    style="font-size: 10px;" width='800px'
    :visible.sync="createAndCopyEthernetSubnetVisible">
    <el-form :model="form" inline="true" ref="form">

      <el-form-item :label="'*'+$t('EthernetSubnetDialog.serviceSubnetId')+':'" :label-width="formLabelWidth" style="margin-bottom: -10px;">
        <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.serviceSubnetID"
                  style="width:200px"
                  v-on:blur="serviceSubnetIDCheck"
                  autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item :label="'*'+$t('EthernetSubnetDialog.serviceSubnetName')+':'" :label-width="formLabelWidth" style="margin-bottom: -10px;">
        <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.serviceSubnetName"
                  v-on:blur="serviceSubnetNameCheck"
                  style="width:200px"
                  autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item :label="'*'+$t('EthernetSubnetDialog.serviceSubnetTopologyType')+':'" :label-width="formLabelWidth" style="margin-bottom: -10px;">
        <el-select v-model="form.serviceSubnetTopo" size="mini" :placeholder="$t('common.selectOption')"
                   clearable="true" v-on:change="serviceTopoCheck"
                   style="width: 200px">
          <el-option
            v-for="item in EveSubnetTopoList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item :label="'*'+$t('EthernetSubnetDialog.serviceType')+':'" :label-width="formLabelWidth" style="margin-bottom: -10px;">
        <el-select size='mini' v-model="form.serviceTypeID" :placeholder="$t('common.selectOption')" clearable="true"
                   v-on:change="serviceTypeCheck"
                   style="width:200px">
          <el-option
            v-for="item in SeverTypeList"
            :key="item.serviceTypeID"
            :label="item.serviceTypeName"
            :value="item.serviceTypeID">
          </el-option>
        </el-select>
      </el-form-item>
      <!-- 下面是附属设备的列表 -->
      <el-form-item :label="$t('EthernetSubnetDialog.addAffiliateDevices')" style="margin-bottom: -10px;margin-top: 15px"></el-form-item>
      <!-- 附属设备的列表 -->
      <el-table
        tooltip-effect="dark"
        fit="true"
        height="250"
        header-row-class-name="table-header"
        cell-class-name="table-cell"
        ref="table"
        :data="deviceList"
        align="center"
        highlight-current-row
        @current-change="handleCurrentChange"
        @selection-change="handleSelectionChangeCreate">

        <el-table-column
          type="selection"
          width="28px"
          height="30px">
        </el-table-column>

        <el-table-column
          prop="deviceKey"
          :label="$t('EthernetSubnetDialog.networkElementName')"
          :formatter="formatEndDeviceKey"
          width="250px"
          height="30px"
        >
        </el-table-column>

        <el-table-column
          :label="$t('EthernetSubnetDialog.ports')"
          height="30px"
          visEdit="true"
        >
          <template slot-scope="scope">
            <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="scope.row.port"
                      style="width:200px;height: 35px;margin-top:5px"

                      v-on:blur="portCheck(scope.row.deviceKey,scope.row.port,1)"
                      v-on:change="selectDevice(scope.row.deviceKey,scope.row.port)"
                      autocomplete="off"></el-input>
            <small style="font-size: 9px">
              {{$t('EthernetSubnetDialog.inputNumber')}}
            </small>
          </template>
        </el-table-column>

      </el-table>

    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button size='mini' type="primary" @click="createEthernetSubnet">
        {{$t("common.createBtn")}}
      </el-button>
      <el-button size='mini' @click="close">{{$t("common.cancel")}}</el-button>
    </div>
  </el-dialog>
</template>

<script>

  import ServiceSubnetService from '@/domain/services/Business/ServiceSubnetService.js'
  import legitimacyCheck from "../../../utils/legitimacyCheck";
  import DeviceManager from "@/domain/models/DeviceManager.js";
  import ServiceTypeService from '@/domain/services/Business/ServiceTypeService.js'
  import DeviceService from '@/domain/services/DeviceService.js'
  import HelperUtil from "@/utils/HelperUtil.js";

  export default {
    name: 'CreateAndCopyEthernetSubnet',
    props: ['command'],
    data: function () {
      return {


        selectFlag:false,
        title: this.command.title,
        initList: this.command.target,
        createAndCopyEthernetSubnetVisible: false,
        formLabelWidth: '160px',

        currentDeviceList: [],
        deviceListInit: [],
        deviceArray: [],

        //双向绑定弹出窗口input域
        form: {
          serviceSubnetID: "",
          serviceSubnetName: "",
          serviceSubnetTopo: "",
          serviceTypeID: "",
          deviceKey: '',
          port: '',
        },
        serviceSubnetIDForCopy: [],
        isPortTrue: true,
        //业务子网拓扑类型下拉列表
        EveSubnetTopoList: [
          {
            value: '0',
            label:  this.$t("EthernetSubnetDialog.singlePoint")
          }, {
            value: '1',
            label:this.$t("EthernetSubnetDialog.bus")
          }, {
            value: '2',
            label: this.$t("EthernetSubnetDialog.ring")
          }, {
            value: '3',
            label:this.$t("EthernetSubnetDialog.mesh")
          }, {
            value: '4',
            label: this.$t("EthernetSubnetDialog.hybrid")
          }],
        //业务类型下拉列表（假数据）
        SeverTypeList: [
//          {
//            serviceTypeID: '0',
//            serviceTypeName: 'serverType1'
//          },
//          {
//            serviceTypeID: '1',
//            serviceTypeName: 'serverType2'
//          },
//          {
//            serviceTypeID: '2',
//            serviceTypeName: 'serverType3'
//          }
        ],

        //附属设备列表（假数据）
        deviceList: [
//          {"deviceKey": '1', "deviceName": "name2", "port": '1,2'}, {
//          "deviceKey": '2',
//          "deviceName": "name2",
//          "port": '1'
//        }
        ],
        //记录在附属设备列表选择的哪些附属设备
        SubnetDeviceForCreate: [],
        //保存附属设备列表多选行数据
        multipleSelectionCreate: [],
      }
    },
    methods: {
      close() {
        this.command.done();
      },

      //------------------------------------获取设备信息开始-------------------------------------------------------------------


      /**
       * @Description  ：获取业务类型
       */
      getAllEvc: function () {
        console.log('获取全部业务信息：')

        ServiceTypeService.getAllServiceTypeCollection().then(result => {
          //成功
          this.SeverTypeList = Object.values(result)
        }).catch(err => {
          //失败
          this.InfoTip.errorTip(this, err);
        })

      },


//       getAllDevice() {
//        //获取设备信息
//
//        console.log("执行获取设备")
//        console.log('获取全部网元信息:')
//        let _this = this
//        DeviceService.getAllDeviceCollection().then(result => {
//          //成功
//          _this.deviceList = Object.values(result)
//          _this.deviceListInit = _this.deviceList
//          _this.deviceArray= result
//          console.log(this.deviceListInit)
//        }).catch(err => {
//          //失败
//          _this.InfoTip.errorTip(_this, err);
//        })
//
//        let deviceMgr = DeviceManager(_this.deviceArray)
//        this.deviceList = deviceMgr.createNewDeviceListWithPortNameAndKey()
//        console.log(this.deviceList)
//      },

      async getAllDevice() {
        console.log("执行获取设备")
        console.log('获取全部网元信息:')
        let _this = this
        let getAll = DeviceService.getAllDeviceCollection().then(result => {
          //成功
          _this.deviceList = Object.values(result)
          _this.deviceListInit = this.deviceList
          _this.deviceArray = result
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
        await getAll;
//        this.checked()


        let deviceMgr = DeviceManager(_this.deviceArray)
        this.deviceList = deviceMgr.createNewDeviceListWithPortNameAndKey()

//初始化
        this.form.serviceSubnetID = this.initList.serviceSubnetID;
        this.form.serviceSubnetName = this.initList.serviceSubnetName;
        this.form.serviceSubnetTopo = this.initList.serviceSubnetTopo;
//        //TODO: 调用service 初始化附属设备列表、获取业务类型,目前是假数据
//
        this.form.serviceTypeID = this.initList.serviceTypeID;
//        //附属设备
//        this.form.deviceKey = this.initList.deviceKey;
//        this.form.port = this.initList.port
//        this.currentDeviceList = this.initList.subnetDevices
//

        this.form.serviceSubnetID = this.initList.serviceSubnetID;
        this.form.serviceSubnetName = this.initList.serviceSubnetName;
        this.form.serviceSubnetTopo = this.initList.serviceSubnetTopo;
        this.form.serviceTypeID = this.initList.serviceTypeID;

        this.currentDeviceList = this.initList.currentDeviceList;

        this.serviceSubnetIDForCopy = this.initList.serviceSubnetIDForCopy;
        if (!this.initList.currentDeviceList.length) {
          return
        }

//        let tempDeviceList = this.deviceList

                this.checked()
//        console.log(this.multipleSelectionCreate)

//        //初始化时修改当前附属设备的port的值"复制，删除使用"
//        for (var i = 0; i < this.currentDeviceList.length; i++) {
//          for (var j = 0; j < this.deviceList.length; j++) {
//            if (this.deviceList[j].deviceKey == this.currentDeviceList[i].deviceKey) {
//              tempDeviceList[j].port = this.currentDeviceList[i].port
//            }
//          }
//        }
//        console.log(this.multipleSelectionCreate)
//        this.deviceList = tempDeviceList
//        this.selectFlag = true


//        let writePortList = this.multipleSelectionCreate
//        for (var k = 0; k < writePortList.length; k++) {
//          if (writePortList[k].port == '') {
//            writePortList[k].port = tempDeviceList[writePortList[k].deviceKey].port
//          }
//        }
//       this.handleSelectionChangeCreate(writePortList)

      },

      formatEndDeviceKey: function (row, column) {
        console.log("过滤设备名称")
        for (var j = 0; j < this.deviceList.length; j++) {
          if (row.deviceKey == this.deviceList[j]['deviceKey']) {
            return this.deviceList  [j]['deviceName']
          }
        }

      },
      //------------------------------------获取设备信息结束-------------------------------------------------------------------


      //------------------------------------创建开始-------------------------------------------------------------------

      /**
       * @Description  ：进入dialog以后开始初始化，
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         :
       */
//      createEthernetSubnetInit() {
//

//
//        this.form.serviceSubnetID = this.initList.serviceSubnetID;
//        this.form.serviceSubnetName = this.initList.serviceSubnetName;
//        this.form.serviceSubnetTopo = this.initList.serviceSubnetTopo;
//        //TODO: 调用service 初始化附属设备列表、获取业务类型,目前是假数据
//
//        this.form.serviceTypeID = this.initList.serviceTypeID;
//        //附属设备
//        this.form.deviceKey = this.initList.deviceKey;
//        this.form.port = this.initList.port
//        this.currentDeviceList = this.initList.subnetDevices
//
//
//        let tempDeviceList = this.deviceList
//        //初始化时修改当前附属设备的port的值"复制，删除使用"
//        for (var i = 0; i < this.currentDeviceList.length; i++) {
//          for (var j = 0; j < this.deviceList.length; j++) {
//            if (this.deviceList[j].deviceKey == this.currentDeviceList[i].deviceKey) {
//              tempDeviceList[j].port = this.currentDeviceList[i].port
//            }
//          }
//        }
//        this.deviceList = tempDeviceList
////        this.getAllEvc(),//获取业务类型
//
//      },

      /**
       * @Description  ：创建业务子网，表格多选框改变时，将所选行进行保存
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         :
       */
      handleSelectionChangeCreate(val) {
        if(this.selectFlag&&val.length===0){
          val = this.multipleSelectionCreate
          this.selectFlag = false
        }
        this.SubnetDeviceForCreate = new Array()
        this.multipleSelectionCreate = val
//        alert(val.length)

        for (var i = 0; i < this.multipleSelectionCreate.length; i++) {
          this.SubnetDeviceForCreate.push({
            deviceKey: this.multipleSelectionCreate[i].deviceKey,
            port: this.multipleSelectionCreate[i].port,
          })
        }
//
        for (var i = 0; i < this.deviceList.length; i++) {
          let foundFlag = false;
          for (var j = 0; j < this.multipleSelectionCreate.length; j++) {
            if (this.deviceList[i].deviceKey === this.multipleSelectionCreate[j].deviceKey) {
              this.multipleSelectionCreate[j].port = this.deviceList[i].port
              foundFlag = true;
              break;
            }
          }
          if (!foundFlag) {

              this.deviceList[i].port = ''

          }
        }
      },

      /**
       * @Description  ：点击创建按钮进行业务子网的创建
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         :
       */
      createEthernetSubnet() {
        let _this = this;
        if (!(_this.totalCheck())) {
          return
        }
//        else if (this.isPortTrue == false) {
//          let message = '请输入有效的portID'
//          this.InfoTip.warningTip(this, {message: message})
//
//          return
//        }
        else {
          let ethernetSubnet = {};

          ethernetSubnet.serviceSubnetID = this.form.serviceSubnetID;
          ethernetSubnet.serviceSubnetName = this.form.serviceSubnetName;
          ethernetSubnet.serviceSubnetTopo = this.form.serviceSubnetTopo;
          ethernetSubnet.serviceTypeID = this.form.serviceTypeID;
          ethernetSubnet.subnetDevices = this.SubnetDeviceForCreate;

          console.log("创建业务子网")
          console.log(ethernetSubnet)
          let loadingInstance = _this.Loading.openLoading();
          //TODO：调用service 实现子网的创建
          ServiceSubnetService.addEveSubnet(ethernetSubnet).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);
          });
        }
      },


      //------------------------------------创建结束-------------------------------------------------------------------

      //------------------------------------验证开始-------------------------------------------------------------------

      totalCheck() {
        console.log(this.multipleSelectionCreate)
        this.SubnetDeviceForCreate = new Array()
        for (var i = 0; i < this.multipleSelectionCreate.length; i++) {
          this.SubnetDeviceForCreate.push({
            deviceKey: this.multipleSelectionCreate[i].deviceKey,
            port: this.multipleSelectionCreate[i].port,
          })
//          }
        }
        if (!this.serviceSubnetNameCheck()) {
          return false
        }
        if (!this.serviceSubnetIDCheck()) {
          return false
        }
        if (!this.serviceTopoCheck()) {
          return false
        }
        if (!this.serviceTypeCheck()) {
          return false
        }

        if (this.SubnetDeviceForCreate.length === 0) {
//          let message = '请输入有效的portID'
//          this.InfoTip.warningTip(this, {message: message})
//           let message = '请至少选择一条设备'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_AT_LEAST_ONE_DEVICE))
          return false
        }
        if (this.isPortTrue == false) {
          // let message = '请输入有效的portID'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_A_VALID_PORT_ID))
          return false
        }



        for (var i = 0; i < this.SubnetDeviceForCreate.length; i++) {
          if (this.SubnetDeviceForCreate[i].port === '' || this.SubnetDeviceForCreate[i].port === null) {
            // let message = '请输入有效的portID'


            this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_A_VALID_PORT_ID))
            return false
          }
        }

        return true
      },
      checked: function () {


        //初始化选中状态
        //首先el-table添加ref="tableCopy"引用标识
        for (var i = 0; i < this.currentDeviceList.length; i++) {
          for (var j = 0; j < this.deviceList.length; j++) {
                if (this.currentDeviceList[i].deviceKey == this.deviceList[j].deviceKey) {
                  this.$refs.table.toggleRowSelection(this.deviceList[j], true);
            }
          }
        }
        let tempDeviceList = this.deviceList

        //初始化时修改当前附属设备的port的值"复制，删除使用"
        for (var i = 0; i < this.currentDeviceList.length; i++) {
          for (var j = 0; j < this.deviceList.length; j++) {
            if (this.deviceList[j].deviceKey == this.currentDeviceList[i].deviceKey) {
              tempDeviceList[j].port = this.currentDeviceList[i].port
            }
          }
        }
        this.deviceList = tempDeviceList
        this.selectFlag = true

        console.log("执行默认选中完成")
//        console.log("输出输出")
//        console.log(tempDeviceList)
//        console.log(this.deviceList)

      },

      selectDevice: function (tempDeviceKey, tempPort) {
        for (var j = 0; j < this.deviceList.length; j++) {
          if (tempDeviceKey == this.deviceList[j].deviceKey) {
            if (tempPort != null && tempPort != '') {
              this.$refs.table.toggleRowSelection(this.deviceList[j], true);
            }

          }
        }
        let tempDeviceList = this.deviceList


//        for (var i = 0; i < this.currentDeviceList.length; i++) {
//          for (var j = 0; j < this.deviceList.length; j++) {
//            if (this.deviceList[j].deviceKey == this.currentDeviceList[i].deviceKey) {
//              tempDeviceList[j].port = this.currentDeviceList[i].port
//            }
//          }
//        }
        this.deviceList = tempDeviceList
        this.selectFlag = true

      },
      // 验证附属设备portID合法性
      portCheck: function (tempDeviceKey, tempPort, flag) {
        console.log(  tempPort)
        this.isPortTrue = true
        //flag==1代表新增
        if (flag == 1) {
          this.SubnetDeviceForCreate = new Array()
          for (var i = 0; i < this.multipleSelectionCreate.length; i++) {
            if (tempDeviceKey == this.multipleSelectionCreate[i].deviceKey) {//&&tempPort!=this.multipleSelectionCreate[i].port){
              this.multipleSelectionCreate[i].port = tempPort
            }
          }
          console.log(  this.multipleSelectionCreate)
          for (var i = 0; i < this.multipleSelectionCreate.length; i++) {
            this.SubnetDeviceForCreate.push({
              deviceKey: this.multipleSelectionCreate[i].deviceKey,
              port: this.multipleSelectionCreate[i].port,
            })
          }
        }
        for (var m = 0; m < this.multipleSelectionCreate.length; m++) {
          if (tempDeviceKey === this.multipleSelectionCreate[m]["deviceKey"]) {
            if (tempPort === '' || tempPort === null) {
              this.isPortTrue = false
              console.log(this.isPortTrue)
            }
            //判断“，”合法性，防止多个‘，’连接
            var tempPortList0 = new Array()
            tempPortList0 = tempPort.split('')
            for (var i = 0; i < tempPortList0.length; i++) {
              if (tempPortList0[i] == ',' && tempPortList0[i + 1] == ',') {
                this.isPortTrue = false
                // let message = '请输入有效的portID'
                this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_A_VALID_PORT_ID))

                return false
              }
            }
            var tempPortList = new Array()
            tempPortList = tempPort.split(',')
            var numReg = /^-?[0-9]\d*$/
            var numRe = new RegExp(numReg)
            for (var j = 0; j < tempPortList.length; j++) {
              if (!numRe.test(tempPortList[j])) {
                this.isPortTrue = false
              }
              for (var k = 0; k < tempPortList.length; k++) {
                if (tempPortList[j] == tempPortList[k]) {
                  if (j != k) {
                    this.isPortTrue = false
                    this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_A_VALID_PORT_ID))
                    return false
                  }
                }
              }

            }
            if (tempPortList0[tempPortList0.length - 1] == ',') {
              this.isPortTrue = false
            }
          }
          else {
            this.isPortTrue = true
          }
        }
        if (this.isPortTrue == false) {
          // let message = '请输入有效的portID'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_A_VALID_PORT_ID))
          return false
        }
        else {

        }
      },

      /**
       * @Description  ：业务子网名称校验： 不能为空
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         :
       */
      serviceSubnetNameCheck: function () {
        let eveSubnetCheck = legitimacyCheck()
        if (!eveSubnetCheck.textNullCheck(this.form.serviceSubnetName)) {
          // let message = '业务子网名称不可为空'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.SERVICE_SUBNET_NAME_CANNOT_BE_EMPTY))
//          this.$message({
//            type: 'warning',
//            message: '业务子网名称不可为空！ ',
//            duration: 10000,
//            showClose: true,
//          });
          return false
        }
        this.textLengthCheck(this.form.serviceSubnetName)
        return true
      },


      /**
       * @Description  ：业务子网ID非空校验
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/3/13
       */
      serviceSubnetIDCheck: function () {

        let serviceSubnetIDCheck = legitimacyCheck()
        if (!serviceSubnetIDCheck.textNullCheck(this.form.serviceSubnetID)) {
          // let message = '业务子网编号不可为空！ '
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.SERVICE_SUBNET_ID_CANNOT_BE_EMPTY))
//          this.$message({
//            type: 'warning',
//            message: '业务类型编号不可为空！ ',
//            duration: 10000,
//            showClose: true,
//          });
          return false
        } else if (!this.numCheck(this.form.serviceSubnetID)) {
          return false
        }
        else if (!this.textLengthCheck(this.form.serviceSubnetID)) {
          return false
        }
        return true
      },

      /**
       * @Description  ：业务扑类型非空校验
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/3/13
       */
      serviceTopoCheck: function () {

        let serviceSubnetIDCheck = legitimacyCheck()
        if (!serviceSubnetIDCheck.textNullCheck(this.form.serviceSubnetTopo)) {
          // let message = '业务扑类型不可为空！ '
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.SERVICE_TOPOLOGY_TYPE_CANNOT_BE_EMPTY))
//          this.$message({
//            type: 'warning',
//            message: '业务类型编号不可为空！ ',
//            duration: 10000,
//            showClose: true,
//          });
          return false
        } else if (!this.numCheck(this.form.serviceSubnetTopo)) {
          return false
        }
        else if (!this.textLengthCheck(this.form.serviceSubnetTopo)) {
          return false
        }
        return true
      },

      /**
       * @Description  ：业务类型非空校验
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/3/13
       */
      serviceTypeCheck: function () {

        let serviceSubnetIDCheck = legitimacyCheck()
        if (!serviceSubnetIDCheck.textNullCheck(this.form.serviceTypeID)) {
          // let message = '业务类型不可为空！ '
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.SERVICE_TYPE_CANNOT_BE_EMPTY))
//          this.$message({
//            type: 'warning',
//            message: '业务类型编号不可为空！ ',
//            duration: 10000,
//            showClose: true,
//          });
          return false
        } else if (!this.numCheck(this.form.serviceTypeID)) {
          return false
        }
        else if (!this.textLengthCheck(this.form.serviceTypeID)) {
          return false
        }
        return true
      },


      /**
       * @Description  ：输入数字
       * @author       : bjh
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/1/15 16:09
       */
      numCheck: function (checkNumber) {
        let _this = this
        let serviceSubnetIDCheck = legitimacyCheck()
        if (!serviceSubnetIDCheck.numberCheck(checkNumber)) {
          // let message = '请输入有效的数字'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_A_VALID_NUMBER))
//          this.$message({
//            type: 'warning',
//            message: '请输入有效的数字！ ',
//            duration: 10000,
//            showClose: true,
//          });
          return false
        }
        return true
      },

      /**
       * @Description  ：文本框所输入的字符长度校验： 控制在20之内
       * @author       : bjh
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/1/15 16:09
       */
      textLengthCheck: function (checkString) {
        let subnetCheck = legitimacyCheck()
        if (!subnetCheck.textLengthCheck(checkString)) {
          let message = '所输文本长度必须控制在20之内'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.LENGTH_CODE))
//          this.$message({
//            type: 'warning',
//            message: '所输文本长度必须控制在20之内！ ',
//            duration: 10000,
//            showClose: true,
//          });
          return false
        }
        return true
      },


      //------------------------------------验证结束-------------------------------------------------------------------

    },

    created() {
      console.log('业务子网创建初始化加载数据')
//      console.log(this.initList)

//      this.currentDeviceList = this.initList.currentDeviceList;
      this.getAllEvc()

//      console.log(this.currentDeviceList)
//      console.log( this.initList.currentDeviceList)
    },
    mounted() {
      this.getAllDevice()
      this.createAndCopyEthernetSubnetVisible = true
    },
//    watch:{
//      deviceList(newVal){
//        alter("change")
//      }
//    },
  }
</script>

<style scoped></style>
