<template>
  <div id="main">
    <!-- 以太网E-Line业务创建对话框 -->
    <el-dialog v-dialogDrag
               style="font-size: 10px; padding-top: 0px;" width='1200px'
               :title="dialogTitle"
               :visible.sync="dialog_elineCreate"
               @close="close()"
    >
      <!--  内置对话框  -->
      <SelectElineTemplateDialog
        :innerVisible.sync="innerVisible"
        :form.sync="form"
      ></SelectElineTemplateDialog>
      <el-row>
        <el-form :model="form" inline="true" ref="form" style="width:1100px" >
          <el-divider contentPosition="left">{{ $t("EthernetELineServiceConfigurationManagement.BasicInformation") }}</el-divider>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.chooseTemplate')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-button size='mini' type="primary" @click="openElineTemplateSelect"
                         v-loading.fullscreen.lock="fullscreenLoading">{{ $t("EthernetELineServiceConfigurationManagement.clickChoose") }}
              </el-button>
            </el-form-item>
            <el-form-item label="" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
            </el-form-item>
            <el-form-item label="" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.vpnId1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.vpnId"
                        autocomplete="off" style="width:150px" v-on:change="vpnIdChange"></el-input>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.serviceName1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.serviceName"
                        autocomplete="off" style="width:150px"></el-input>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.serviceTypeID1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.serviceTypeID" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px" v-on:change="serviceTypeChange">
                <el-option
                  v-for="item in ServiceTypeList"
                  :key="item.serviceTypeID"
                  :label="item.serviceTypeName"
                  :value="item.serviceTypeID">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.serviceSubnetID1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.serviceSubnetID" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px" v-on:change="serviceSubnetIDChange">
                <el-option
                  v-for="item in serviceSubnetIDList"
                  :key="item.serviceSubnetID"
                  :label="item.serviceSubnetName"
                  :value="item.serviceSubnetID">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.reversion1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.reversion" :placeholder="$t('common.selectOption')"
                         autocomplete="off" v-on:change="reversionCheck" style="width:150px">
                <el-option
                  v-for="item in reversionFlag"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.wtr1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.wtr" autocomplete="off"
                        :disabled="wtr_input_disable" style="width:95px" v-on:change="wtrCheck">
                <template slot="append" style="">{{$t('EthernetELineServiceConfigurationManagement.minute')}}</template>
              </el-input>
              <small style="font-size: 9px">
               {{$t('EthernetELineServiceConfigurationManagement.inputNumber')}}
              </small>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.protectionMode1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select v-model="form.protectionMode" size="mini" :placeholder="$t('common.placeholder1')" style="width: 150px"
                          v-on:change="protectionModeCheck">
                <el-option
                  v-for="item in protectionModeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.oamInfo1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.oamInfo" :placeholder="$t('common.selectOption')" autocomplete="off"
                         v-on:change="oamInfoCheck" style="width:150px" :disabled="oaminfo_select_disable">
                <el-option
                  v-for="item in oamInfoFlag"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.ccmInterval1')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px; height:28px">
              <el-select v-model="form.ccmInterval" size="mini" :placeholder="$t('common.placeholder1')" style="width: 150px"
                         :disabled="ccmInterval_select_disable" :clearable="true">
                <el-option
                  v-for="item in ccmIntervalList"
                  :key="item.value"
                  :label="item.ccmIntervalTime"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
        </el-form>
      </el-row>
      <el-row >
        <el-form :model="form" inline="true" ref="form" style="margin-bottom: -20px;margin-top:-10px;width:1100px" labelPosition="right">
        <el-divider contentPosition="left">{{ $t("EthernetELineServiceConfigurationManagement.vlanInformation") }}</el-divider>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.encapsulationType1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.encapsulationType" :placeholder="$t('common.selectOption')"
                         autocomplete="off" v-on:change="encapsulationTypeCheck" style="width:150px" >
                <el-option
                  v-for="item in encapsulationTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.l2AccessType1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.l2AccessType" :placeholder="$t('common.selectOption')"
                         :disabled="l2AccessType_select_disable" autocomplete="off" style="width:150px" v-on:change="l2AccessTypeCheck">
                <el-option
                  v-for="item in l2AccessTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.vlanAccess1')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.vlanAccess" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px" v-on:change="vlanAccessCheck" :disabled="vlanAccess_select_disable">
                <el-option
                  v-for="item in vlanAccessList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.vlanRange')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px;" >

              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.vlanRangeStart"
                        autocomplete="off" style="width:150px" :disabled="vlanRangeStart_input_disable" v-on:change="vlanRangeStartCheck"></el-input>
              <span> - </span>
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.vlanRangeEnd"
                        autocomplete="off" style="width:150px" :disabled="vlanRangeEnd_input_disable" v-on:change="vlanRangeEndCheck"></el-input>
              <small style="font-size: 9px">
                {{$t('EthernetELineServiceConfigurationManagement.inputNumber')}}
              </small>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.vlanSet1')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.vlanSet" autocomplete="off"
                        style="width:150px" :disabled="vlanRangeSet_input_disable" v-on:change="vlanSetCheck"></el-input>
              <small style="font-size: 9px">
                {{$t('EthernetELineServiceConfigurationManagement.inputNumber1')}}
              </small>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.qosProfile1')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px;">
              <el-select v-model="form.qosProfile" size="mini" :placeholder="$t('common.placeholder1')" style="width: 150px" :clearable="true">
                <el-option
                  v-for="item in CDPProfileCreationList"
                  :key="item.profileName"
                  :label="item.profileName"
                  :value="item.profileName">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.cosId1')" :label-width="formLabelWidth"  style="margin-bottom: -10px;margin-top: -10px; ">
              <el-select size='mini' v-model="form.cosId" :placeholder="$t('common.selectOption')" autocomplete="off"
                         style="width:150px">
                <el-option
                  v-for="item in cosIdList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.limitedBandwidth1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.limitedBandwidth" v-on:change="limitedBandwidthCheck"
                        autocomplete="off" style="width:95px">
                <template slot="append" style="">{{$t('EthernetELineServiceConfigurationManagement.mbit')}}</template>
              </el-input>
              <small style="font-size: 9px">
                {{$t('EthernetELineServiceConfigurationManagement.inputNumber')}}
              </small>
            </el-form-item>
          </el-form-item>
        </el-form>
      </el-row>
      <el-row>
        <el-form :model="form" inline="true" ref="form" style="margin-bottom: -20px;margin-top:-10px;width:1100px">
          <el-divider contentPosition="left">{{ $t("EthernetELineServiceConfigurationManagement.deviceinformation") }}</el-divider>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.isDualHomed1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.isDualHomed" :placeholder="$t('common.selectOption')"
                         autocomplete="off" v-on:change="isDualHomedCheck" style="width:150px">
                <el-option
                  v-for="item in isDualHomedList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.startDeviceId1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.startDeviceId" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px" v-on:change="startDeviceIdChange">
                <el-option
                  v-for="item in startDeviceIdList"
                  :key="item.deviceKey"
                  :label="item.deviceName"
                  :value="item.deviceKey">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.startDevicePort1')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.startDevicePort" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px">
                <el-option
                  v-for="item in startDevicePortList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.end1DeviceId1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.end1DeviceId" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px" v-on:change="end1DeviceIdChange">
                <el-option
                  v-for="item in end1DeviceIdList"
                  :key="item.deviceKey"
                  :label="item.deviceName"
                  :value="item.deviceKey">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.end1DevicePort1')" :label-width="formLabelWidth"
                          style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.end1DevicePort" :placeholder="$t('common.selectOption')"
                         autocomplete="off" style="width:150px">
                <el-option
                  v-for="item in end1DevicePortList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.end2DeviceId')+':'"
                          :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.end2DeviceId" :placeholder="$t('common.selectOption')"
                         :disabled="end2DeviceIdList_disable" autocomplete="off" style="width:150px" v-on:change="end2DeviceIdChange">
                <el-option
                  v-for="item in end2DeviceIdList"
                  :key="item.deviceKey"
                  :label="item.deviceName"
                  :value="item.deviceKey">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.end2DevicePort')+':'"
                          :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-select size='mini' v-model="form.end2DevicePort" :placeholder="$t('common.selectOption')"
                         autocomplete="off" :disabled="end2DevicePortList_disable" style="width:150px">
                <el-option
                  v-for="item in end2DevicePortList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EthernetELineServiceConfigurationManagement.startTime1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.startTime"
                        autocomplete="off"
                        v-on:blur="timeCheak"
                        style="width:150px"></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="createEline"
                   v-loading.fullscreen.lock="fullscreenLoading">{{createBtnName}}
        </el-button>
        <el-button size='mini' @click="close()">{{$t("common.cancel")}}</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
  import ElRow from "element-ui/packages/row/src/row";
  import ElDialog from "../../../../node_modules/element-ui/packages/dialog/src/component.vue";
  import SelectElineTemplateDialog from '../ElineDialog/SelectElineTemplateDialog.vue';
  import HelperUtil from "../../../utils/HelperUtil";
  import legitimacyCheck from "../../../utils/legitimacyCheck";
  import ElineService from '@/domain/services/Business/ElineService.js'
  import ServiceTypeService from '@/domain/services/Business/ServiceTypeService.js'
  import CDPService from '@/domain/services/Business/CDPService.js'
  import DeviceService from '@/domain/services/DeviceService.js'
  import ServiceSubnetService from '@/domain/services/Business/ServiceSubnetService.js'

  export default {
    name: 'CreateEthernetELineServiceConfigurationManagement',
    components:{
      //创建、复制对话框
      ElRow,
      SelectElineTemplateDialog,
    },
    props:['command'],
    data: function () {   //存放数据
      return {
        //对话框名称
        dialogTitle:"业务模板创建",
        dialog_elineCreate:true,
        form:this.command.target,
        title:this.command.title,
        createBtnName: "创建",

        //window.innerHeight:浏览器的可用高度
        tableHeight: window.innerHeight * 0.7,
        fullscreenLoading: false,
        formLabelWidth: '180px',

        //日期控件
        beginTimestamp: "",  //开始时间
        addTimestamp: "00.000",  //查询时间默认添加

        //业务类型过滤
        ServiceTypeList: [],
        //子网（根据业务类型获得列表中所拥有的所有子网）
        serviceSubnetIDList:[],
        //保护模式过滤
        protectionModeList: [
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.unprotected')
          },
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.one2one')
          },
          {
            value: 2,
            label: this.$t('EthernetELineServiceConfigurationManagement.lspone2one')
          },
        ],
        //是否回滚过滤
        reversionFlag: [
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.is')
          },
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.no')
          }
        ],
        //oam选项过滤
        oamInfoFlag: [
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.is')
          },
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.no')
          }
        ],
        //vlan设置方式过滤
        vlanAccessList: [
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.vlanRange1')
          },
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.vlanSet')
          }
        ],
        //vlan类别过滤
        encapsulationTypeList: [
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.ethernetType')
          },
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.vlanType')
          }
        ],
        //l2AccessType类别过滤
        l2AccessTypeList:[
          {
            value: 0,
            label: "untag"
          },
          {
            value: 1,
            label: "dot1q"
          },
          {
            value: 2,
            label: "qinq"
          },
        ],
        cosIdList: [
          {
            value: '0',
            label: '0'
          },
          {
            value: '1',
            label: '1'
          },
          {
            value: '2',
            label: '2'
          },
          {
            value: '3',
            label: '3'
          },
          {
            value: '4',
            label: '4'
          },
          {
            value: '5',
            label: '5'
          },
          {
            value: '6',
            label: '6'
          },
          {
            value: '7',
            label: '7'
          },
        ],
        //是否默认
        defaultFlagList: [
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.default')
          },
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.nonDefault')
          }
        ],
        //qos策略名称下拉框列表绑定
        CDPProfileCreationList: [],
        //ccm间隔时间下拉框列表绑定
        ccmIntervalList: [
          {
            ccmIntervalTime: '3.3min',
            value:1
          },
          {
            ccmIntervalTime: '10min',
            value:2
          },
          {
            ccmIntervalTime: '60min',
            value:3
          },
          {
            ccmIntervalTime: '100min',
            value:4
          },
          {
            ccmIntervalTime: '600min',
            value:5
          },
          {
            ccmIntervalTime: '6000min',
            value:6
          }
        ],

        //业务起点设备下拉框列表
        startDeviceIdList: [],
        //业务起点设备端口下拉框列表
        startDevicePortList: [],
        //业务终点设备下拉框列表
        end1DeviceIdList: [],
        //业务终点设备端口下拉框列表
        end1DevicePortList: [],
        //是否双规模式列表
        isDualHomedList:[
          {
            value: 1,
            label: this.$t('EthernetELineServiceConfigurationManagement.no')
          },
          {
            value: 0,
            label: this.$t('EthernetELineServiceConfigurationManagement.is')
          }
        ],
        //第二个业务终点设备下拉框列表
        end2DeviceIdList: [],
        //第二个业务终点设备端口下拉框列表
        end2DevicePortList: [],
        //业务状态下拉框列表
        elineStatusList: [
          {
            value: "submitted",
            label: 'submitted'
          },
          {
            value: "success",
            label: 'success'
          },
          {
            value: "failure",
            label: 'failure'
          },
        ],
        //获取的eline设备列表（第一个string是子网ID，第二个就是对应的设备）
        elineDeviceList: [],

        //弹框中的窗口是否可输入约束
        wtr_input_disable: false,
        oaminfo_select_disable: false,
        vlanAccess_select_disable: false,
        vlanRangeStart_input_disable: false,
        vlanRangeEnd_input_disable: false,
        vlanRangeSet_input_disable: false,
        ccmInterval_select_disable: false,
        l2AccessType_select_disable: false,    //vlan协议，vlan类别为vlan-type，可选
        end2DeviceIdList_disable: false,   //第二个业务终点设备；是否双规模式为true，可选
        end2DevicePortList_disable: false,   //第二个业务终点设备端口；是否双规模式为true，可选

        //设备列表
        deviceList: [],
        //子网列表
        subnetList: [],

        //模板选择窗口
        innerVisible: false,

        //用于复制的使用，只能执行一次，赋值是不要进行清空操作
        IsserviceTypeChangeTime: 0,//没有用到
        IsserviceSubnetIDChangeTime: 0,
        IsStartDevicePortTime: 0,
        IsEnd1DevicePortTime: 0,
        IsEnd2DevicePortTime: 0,
      }
    },
    //vue加载初始化函数，加载数据
    created: function () {
      //获取下拉框业务类型信息
      this.getAllServiceType();
      //获取下拉框qos信息
      this.getAllCDPProfileCreation();
      this.getAllDevice();
      //this.getElineDeviceList();
      //初始化过滤
      this.initCheck();
    },
    computed: {
      openTab() {
        return this.$store.state.openTab;
      },
      activeIndex: {
        get() {
          return this.$store.state.activeIndex;
        },
        set(val) {
          this.$store.commit('set_active_index', val);
        }
      },
      queryNodeTypeChange(){
        this.reversionFlag[0].label=this.$t('EthernetELineServiceConfigurationManagement.is');
        this.reversionFlag[1].label=this.$t('EthernetELineServiceConfigurationManagement.no');
        this.oamInfoFlag[0].label=this.$t('EthernetELineServiceConfigurationManagement.is');
        this.oamInfoFlag[1].label=this.$t('EthernetELineServiceConfigurationManagement.no');
        this.defaultFlagList[0].label=this.$t('EthernetELineServiceConfigurationManagement.default');
        this.defaultFlagList[1].label=this.$t('EthernetELineServiceConfigurationManagement.nonDefault');
        this.isDualHomedList[0].label=this.$t('EthernetELineServiceConfigurationManagement.is');
        this.isDualHomedList[1].label=this.$t('EthernetELineServiceConfigurationManagement.no');
      },
    },
    methods: {
      /***
       * 初始化过滤
       */
      initCheck:function () {
        this.wtr_input_disable = false;
        this.vlanAccess_select_disable = false;
        this.vlanRangeStart_input_disable = false;
        this.vlanRangeEnd_input_disable = false;
        this.vlanRangeSet_input_disable = false;
        this.oaminfo_select_disable = false;
        this.ccmInterval_select_disable = false;
        this.l2AccessType_select_disable = false;
        this.end2DeviceIdList_disable = false;
        this.end2DevicePortList_disable = false;

        //vlan协议选择
        if(this.form.l2AccessType === 0){
          this.form.vlanAccess = 1;
          this.vlanAccess_select_disable = true;
        }

        //根据vlan设置方式设置range、set字段是否变灰
        if (this.form.vlanAccess === 0) {
          this.vlanRangeSet_input_disable = true
          this.form.vlanSet = "";
        } else if(this.form.vlanAccess === 1){
          this.vlanRangeStart_input_disable = true;
          this.vlanRangeEnd_input_disable = true
          this.form.vlanRangeStart = "";
          this.form.vlanRangeEnd = "";
        }
        //根据是否回滚设置回滚时间字段是否变灰
        if (this.form.reversion === 1) {
          this.wtr_input_disable = true;
          this.form.wtr = "";
        }
        //根据保护模式设置oam是否可选
        if(this.form.protectionMode === 0){
          this.oaminfo_select_disable = false;
        }else if(this.form.protectionMode === 1 || this.form.protectionMode === 2){
          this.oaminfo_select_disable = true;
          this.form.oaminfo = ""
        }
        //根据ocm选项设置ccm间隔时间
        if (this.form.oamInfo === 1) {
          this.ccmInterval_select_disable = true;
          this.form.ccmInterval = "";
        }
        //encapsulationType为vlan-tye时,l2AccessType可选
        if (this.form.encapsulationType === 0) {
          this.l2AccessType_select_disable = true;
          this.vlanAccess_select_disable = true;
          this.vlanRangeStart_input_disable = true;
          this.vlanRangeEnd_input_disable = true;
          this.vlanRangeSet_input_disable =true;
          this.form.l2AccessType = "";
          this.form.vlanAccess = "";
          this.form.vlanRangeStart = "";
          this.form.vlanRangeEnd = "";
          this.form.vlanSet = "";
        }else{
        }
        //双归模式判断
        if (this.form.isDualHomed === 1) {
          this.end2DeviceIdList_disable = true;
          this.end2DevicePortList_disable = true;
          this.form.end2DeviceId = "";
          this.form.end2DevicePort = "";
          this.IsEnd2DevicePortTime++;
        }



        if(this.title === "复制以太网E-Line业务"){
          this.createBtnName = this.$t('common.copyBtn');
          this.dialogTitle = this.$t('EthernetELineServiceConfigurationManagement.copyE_Line');
          this.getElineDeviceListCopy();  //根据业务类型获取deviceList
          this.form.startTime = this.handleUpdateTime(this.form.startTime);
        } else{
          this.createBtnName = this.$t('common.createBtn');
          this.dialogTitle = this.$t('EthernetELineServiceConfigurationManagement.creatE_Line');
          this.getCurentTime();//设置默认时间
        }

      },

      /**
       * ----------时间处理方法------------------------------------------------------
       * */

      /***
       * @Description  : 获取默认时间
       * @author       : zf
       * @date         : 2019/1/4 11:32
       */
      setDefaultDateTime: function () {
        console.log("setDefaultDateTime");
        const end = new Date();
        this.form.startTime = end
      },

      //获取当前时间
      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
        }
        this.form.startTime = year + seperator1 + month + seperator1 + strDate + ' ' + hour + seperator2 + minu + seperator2 + sec + '.' + ms

      },

      //开始时间被清空后重新赋值
      beginDateChange: function () {
        const setTimes = new Date();
        if (this.endTimestamp !== null) {
          if (this.beginTimestamp > this.endTimestamp) {
            setTimes.setTime(this.endTimestamp.getTime() - (60 * 60 * 1000));
            this.beginTimestamp = setTimes;
            this.InfoTip.warningTip(this,{message: this.$t('EthernetELineServiceConfigurationManagement.startTimeThanEndTime')})
          }
        }

      },

      /**
       *  处理时间格式，转换为时间
       */
      handleUpdateTime: function (time) {
        let showDate;
        let arr;

        if (time !== "") {
          arr = time.split(".");
          showDate = "" + arr[0].substring(0, 4) + "-" + arr[0].substring(4, 6) + "-" + arr[0].substring(6, 8) + " ";
          showDate = showDate + arr[1].substring(0, 2) + ":" + arr[1].substring(2, 4) + ":" + arr[1].substring(4, 6) + "." + arr[2];
        }
        else {
          showDate = ""
        }
        return showDate
      },

      timeLigalTransform: function (timeString) {
        timeString = timeString.replace(/-/g,"")
        timeString = timeString.replace(/\s+/g,".")
        timeString = timeString.replace(/:/g,"")
        return timeString
      },

      /**
       *   设置时间格式
       */
      setTimeFormat: function () {
        var year;
        var month;
        var day;
        var hours;
        var minutes;
        let format = typeof(this.form.startTime);
        if (this.form.startTime !== '') {
          year = '' + this.form.startTime.getFullYear();
          month = '' + (this.form.startTime.getMonth() + 1);
          day = '' + this.form.startTime.getDate();
          hours = '' + this.form.startTime.getHours();
          minutes = '' + this.form.startTime.getMinutes();
          if (month.length === 1) {
            month = '0' + month
          }
          if (day.length === 1) {
            day = '0' + day
          }
          if (hours.length === 1) {
            hours = '0' + hours
          }
          if (minutes.length === 1) {
            minutes = '0' + minutes
          }
          var begin = '' + year + month + day + '.' + hours + minutes + this.addTimestamp;
          this.form.startTime = begin;
        }
      },

      //时间合法性验证
      timeCheak: function () {
//        var result = false
        let deviceCheck = legitimacyCheck()

        var result = deviceCheck.timeCheck(this.form.startTime)
        if (!result) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_ENTER_VALID_TIME))

          return false
        }
        return true
      },

      /**
       * ----------过滤方法------------------------------------------------------
       * */
      //根据是否回滚限制回滚时间是否可填
      reversionCheck: function () {
        if (this.form.reversion === 1) {
          this.wtr_input_disable = true;
          this.form.wtr = ''
        } else {
          this.wtr_input_disable = false
        }
        return
      },

      //判断回滚时间是否为负
      wtrCheck:function () {
        let legCheck = legitimacyCheck();
        let IslegCheck = legCheck.positiveIntegerCheck(this.form.wtr);
        if(IslegCheck === false){
          this.form.wtr = "";
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.inputInteger')})
        }
      },

      //判断vlan-rang起点是否为负
      vlanRangeStartCheck:function () {
        let legCheck = legitimacyCheck();
        let IslegCheck = true;
        //填写内容不为空
        if(this.form.vlanRangeStart !== ""){
          IslegCheck = legCheck.positiveIntegerCheck(this.form.vlanRangeStart);
        }
        if(IslegCheck === false){
          this.form.vlanRangeStart = "";
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.inputInteger')})
          return;
        }
        //判断起点是否小于终点
        if(this.form.vlanRangeEnd !== null && this.form.vlanRangeEnd !== ""){
          if(parseInt(this.form.vlanRangeEnd) < parseInt(this.form.vlanRangeStart)){
            this.form.vlanRangeStart = "";
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vlanRangeStartGreaterEnd')})
          }
        }
      },

      //判断vlan-rang终点是否为负
      vlanRangeEndCheck:function () {
        let legCheck = legitimacyCheck();
        let IslegCheck = true;
        //填写内容不为空
        if(this.form.vlanRangeEnd !== ""){
          IslegCheck = legCheck.positiveIntegerCheck(this.form.vlanRangeEnd);
        }
        if(IslegCheck === false){
          this.form.vlanRangeEnd = "";
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.inputInteger')})
          return
        }
        //判断起点是否小于终点
        if(this.form.vlanRangeStart !== null && this.form.vlanRangeStart !== ""){
          if(parseInt(this.form.vlanRangeEnd) < parseInt(this.form.vlanRangeStart)){
            this.form.vlanRangeEnd = "";
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vlanRangeStartSmallerEnd')})
          }
        }
      },

      //判断最高带宽是否为负
      limitedBandwidthCheck:function () {
        let legCheck = legitimacyCheck();
        let IslegCheck = legCheck.positiveIntegerCheck(this.form.limitedBandwidth);
        if(IslegCheck === false){
          this.form.limitedBandwidth = "";
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.inputInteger')})
        }
      },

      //根据保护模式处理oaminfo字段
      protectionModeCheck: function () {
        if (this.form.protectionMode === 0) {
          this.form.oamInfo = 1
          this.form.ccmInterval = ''
          this.oaminfo_select_disable = false
          this.ccmInterval_select_disable = true
        } else {
          this.form.oamInfo = 0
          if (this.form.protectionMode === 1) {
            this.form.ccmInterval = 2
          }
          if (this.form.protectionMode === 2) {
            this.form.ccmInterval = 1
          }
          this.oaminfo_select_disable = true;
          this.ccmInterval_select_disable = false
        }
        return
      },

      //vpnid发生改变，检验输入的是否正确
      //要求：创建时业务Id进行校验，只能填字母、数字、横杠-、下划线 _  。比如service-1 、a_1 这种是允许的，其他的特殊字符比如$%^&*都不行
      vpnIdChange:function () {
        var pattern = new RegExp("[%`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
        if(pattern.test(this.form.vpnId)){
          this.form.vpnId = "";
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vpnIdCheck')})
        }
      },

      //根据业务类型的改变，获得业务起点设备列表
      serviceTypeChange: function () {
        this.getElineDeviceList();
        this.serviceSubnetIDList = [];
        //当业务类型改变的时候，业务子网、起点终点设备端口都应该从新选择
        this.form.serviceSubnetID = "";

        //当业务类型改变的时候，业务子网、起点终点设备端口都应该从新选择
        this.form.startDeviceId = "";
        this.startDeviceIdList = [];
        this.form.startDevicePort = "";
        this.startDevicePortList = [];
        this.form.end1DeviceId = "";
        this.end1DeviceIdList = [];
        this.form.end1DevicePort = "";
        this.end1DevicePortList = [];
        this.form.end2DeviceId = "";
        this.end2DeviceIdList = [];
        this.form.end2DevicePort = "";
        this.end2DevicePortList = [];
      },

      //业务起点设备改变，获得对应设备的设备端口(设备端口是以逗号为隔断的string)
      startDeviceIdChange: function () {
        this.startDevicePortList = [];
        if(this.IsStartDevicePortTime === 0){
          this.IsStartDevicePortTime++;
        }else {
          this.form.startDevicePort = "";
        }
        for (let i = 0; i < this.elineDeviceList.length; i++) {
          if (this.elineDeviceList[i].value.deviceKey === this.form.startDeviceId && this.elineDeviceList[i].key === this.form.serviceSubnetID) {
            this.form.serviceSubnetID = this.elineDeviceList[i].value.serviceSubnetID;  //在这里把起点设备所属的设备子网当作设备子网ID
            let portList = this.elineDeviceList[i].value.port.split(',');
            for(let j=0; j<portList.length; j++){
              let port = {};
              port.value = portList[j];
              port.label = portList[j];
              this.startDevicePortList.push(port);
            }
            break;
          }
        }
      },

      //业务终点设备改变，获得对应设备的设备端口(设备端口是以逗号为隔断的string)
      end1DeviceIdChange: function () {
        this.end1DevicePortList = [];
        if(this.IsEnd1DevicePortTime === 0){
          this.IsEnd1DevicePortTime++;
        }else {
          this.form.end1DevicePort = "";
        }
        for (let i = 0; i < this.elineDeviceList.length; i++) {
          if (this.elineDeviceList[i].value.deviceKey === this.form.end1DeviceId && this.elineDeviceList[i].key === this.form.serviceSubnetID) {
            let portList = this.elineDeviceList[i].value.port.split(',');
            for(let j=0; j<portList.length; j++){
              let port = {};
              port.value = portList[j];
              port.label = portList[j];
              this.end1DevicePortList.push(port);
            }
            break;
          }
        }
      },

      //双规模式下，第二个业务终点设备改变，获得对应设备的设备端口(设备端口是以逗号为隔断的string)
      end2DeviceIdChange: function () {
        this.end2DevicePortList = [];
        if(this.IsEnd2DevicePortTime === 0){
          this.IsEnd2DevicePortTime++;
        }else {
          this.form.end2DevicePort = "";
        }
        for (let i = 0; i < this.elineDeviceList.length; i++) {
          if (this.elineDeviceList[i].value.deviceKey === this.form.end2DeviceId && this.elineDeviceList[i].key === this.form.serviceSubnetID) {
            let portList = this.elineDeviceList[i].value.port.split(',');
            for(let j=0; j<portList.length; j++){
              let port = {};
              port.value = portList[j];
              port.label = portList[j];
              this.end2DevicePortList.push(port);
            }
            break;
          }
        }
      },

      //vlanset检查
      vlanSetCheck:function () {
        let legCheck = legitimacyCheck();
        let IslegCheck = legCheck.portCheck(this.form.vlanSet)
        if(IslegCheck === false){
          this.form.vlanSet = "";
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.inputInteger')})
        }
      },

      //当选择utag时，vlan设置方式选择vlan-set
      l2AccessTypeCheck:function () {
        this.form.vlanRangeStart = "";
        this.form.vlanRangeEnd = "";
        this.form.vlanSet = "";
        if(this.form.l2AccessType === 0){
          this.form.vlanAccess = 1;
          this.vlanAccess_select_disable = true;
          this.vlanAccessCheck();
        }else{
          this.form.vlanAccess = "";
          this.vlanAccess_select_disable = false;
          this.vlanRangeStart_input_disable = false;
          this.vlanRangeEnd_input_disable = false;
        }
      },

      //根据vlan设置方式修改start-range、endrange、vlan-set是否可disable
      vlanAccessCheck: function () {
        if (this.form.vlanAccess === 0) {
          this.form.vlanSet = ''
          this.vlanRangeStart_input_disable = false
          this.vlanRangeEnd_input_disable = false
          this.vlanRangeSet_input_disable = true
          this.form.vlanRangeSet = '';
        } else {
          this.form.vlanRangeStart = ''
          this.form.vlanRangeEnd = ''
          this.vlanRangeStart_input_disable = true
          this.vlanRangeEnd_input_disable = true
          this.vlanRangeSet_input_disable = false
        }
        return
      },

      //根据vlan类别，确定vlan协议是否可选，encapsulationType为vlan-tye时可选
      encapsulationTypeCheck:function () {
        if(this.form.encapsulationType === 1){    //encapsulationType为vlan-tye
          this.l2AccessType_select_disable = false;
          this.vlanAccess_select_disable = false;
          this.vlanRangeStart_input_disable = false;
          this.vlanRangeEnd_input_disable = false;
          this.vlanRangeSet_input_disable =false;
        }else{
          this.l2AccessType_select_disable = true;
          this.vlanAccess_select_disable = true;
          this.vlanRangeStart_input_disable = true;
          this.vlanRangeEnd_input_disable = true;
          this.vlanRangeSet_input_disable =true;
          this.form.l2AccessType = '';
          this.form.vlanAccess = '';
          this.form.vlanRangeStart = '';
          this.form.vlanRangeEnd = '';
          this.form.vlanSet = '';
        }
      },

      //根据oam选项设置ccm间隔时间
      oamInfoCheck: function () {
        if (this.form.oamInfo === 1) {
          this.ccmInterval_select_disable = true;
          this.form.ccmInterval = '';
        } else {
          this.ccmInterval_select_disable = false
        }
      },

      /**
       * @Description  ：是否双规模式触发第二的双规模式是否
       */
      isDualHomedCheck:function () {
        if(this.form.isDualHomed === 1){
          this.end2DeviceIdList_disable = true;
          this.end2DevicePortList_disable = true;
          this.form.end2DeviceId = "";
          this.form.end2DevicePort = ""
        }else{
          this.end2DeviceIdList_disable = false;
          this.end2DevicePortList_disable = false;
        }
      },

      //在点击创建或者删除之前检查数据是否都有填写
      finalCheck:function () {
        //业务ID是否为空
        if(this.form.vpnId === "" || this.form.vpnId === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vpnIdEmpty')});
          return false;
        }

        //业务名称是否为空
        if(this.form.serviceName === "" || this.form.serviceName === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.serviceNameEmpty')});
          return false;
        }

        //业务类型是否为空
        if(this.form.serviceTypeID === "" || this.form.serviceTypeID === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.serviceTypeIDEmpty')});
          return false;
        }

        //是否回滚是否为空
        if(this.form.reversion === "" || this.form.reversion === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.reversionEmpty')});
          return false;
        }

        //回滚等待时间是否为空
        if(this.form.reversion === 0){  //是否回滚选是，那么回滚时间不能为空
          if(this.form.wtr === "" || this.form.wtr === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.wtrEmpty')});
            return false;
          }
        }

        //保护模式是否为空
        if(this.form.protectionMode === "" || this.form.protectionMode === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.protectionModeEmpty')});
          return false;
        }

        //oam选项是否为空
        if(this.form.protectionMode === 0){  //保护模式选unprotect，那么oam选项为空,剩余的选择都不能为空
          if(this.form.oamInfo === "" || this.form.oamInfo === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.oamInfoEmpty')});
            return false;
          }
        }

        //ccm间隔时间是否为空
        if(this.form.protectionMode !== 0){  //保护模式选unprotect，那么oam选项为空,剩余的选择都不能为空
          if(this.form.ccmInterval === "" || this.form.ccmInterval === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.ccmIntervalEmpty')});
            return false;
          }
        }

        //封装类别是否为空
        if(this.form.encapsulationType === "" || this.form.encapsulationType === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.encapsulationTypeEmpty')});
          return false;
        }

        //封装类别选vlan-type，当前模式下的vlan不应为空
        if(this.form.encapsulationType === 1){
          //vlan协议是否为空
          if(this.form.l2AccessType === "" || this.form.l2AccessType === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.l2AccessTypeEmpty')});
            return false;
          }
          //vlan设置方式是否为空
          if(this.form.vlanAccess === "" || this.form.vlanAccess === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vlanAccessEmpty')});
            return false;
          }
          //vlan设置方式选择range，起点和终点不能为空
          if(this.form.vlanAccess === 0){
            //vlan-range起点是否为空
            if(this.form.vlanRangeStart === "" || this.form.vlanRangeStart === null){
              this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vlanRangeStartEmpty')});
              return false;
            }
            //vlan-range终点是否为空
            if(this.form.vlanRangeEnd === "" || this.form.vlanRangeEnd === null){
              this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vlanRangeEndEmpty')});
              return false;
            }
          }else{
            //vlan-set集合是否为空
            if(this.form.vlanSet === "" || this.form.vlanSet === null){
              this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.vlanSetEmpty')});
              return false;
            }
          }
        }

        //qos策略名称是否为空
        if(this.form.qosProfile === "" || this.form.qosProfile === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.qosProfileEmpty')});
          return false;
        }

        //cos-Id是否为空
        if(this.form.cosId === "" || this.form.cosId === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.cosIdEmpty')});
          return false;
        }

        //最高带宽是否为空
        if(this.form.limitedBandwidth === "" || this.form.limitedBandwidth === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.limitedBandwidthEmpty')});
          return false;
        }

        //业务起点设备是否为空
        if(this.form.startDeviceId === "" || this.form.startDeviceId === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.startDeviceIdEmpty')});
          return false;
        }

        //业务起点设备端口是否为空
        if(this.form.startDevicePort === "" || this.form.startDevicePort === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.startDevicePortEmpty')});
          return false;
        }

        //业务终点设备是否为空
        if(this.form.end1DeviceId === "" || this.form.end1DeviceId === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.end1DeviceIdEmpty')});
          return false;
        }

        //业务终点设备端口是否为空
        if(this.form.end1DevicePort === "" || this.form.end1DevicePort === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.end1DevicePortEmpty')});
          return false;
        }

        //双规模式第二个不能为空
        if(this.form.isDualHomed === 0){
          //第二个业务终点设备是否为空
          if(this.form.end2DeviceId === "" || this.form.end2DeviceId === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.end2DeviceIdEmpty')});
            return false;
          }

          //第二个业务终点设备端口是否为空
          if(this.form.end2DevicePort === "" || this.form.end2DevicePort === null){
            this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.end2DevicePortEmpty')});
            return false;
          }
        }

        //开站时间是否为空
        if(this.form.startTime === "" || this.form.startTime === null){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.startTimeEmpty')});
          return false;
        }

        //起始设备、终止设备不能相同
        // if(this.form.end1DeviceId === this.form.startDeviceId){
        //   this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.endAndStartDeviceIdEmpty')});
        //   return false;
        // }
        if(this.form.end2DeviceId === this.form.startDeviceId){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.end2AndStartDeviceIdEmpty')});
          return false;
        }
        if(this.form.end2DeviceId === this.form.end1DeviceId){
          this.InfoTip.warningTip(this, {message: this.$t('EthernetELineServiceConfigurationManagement.end2AndendDeviceIdEmpty')});
          return false;
        }

        if(this.timeCheak() === false){
          return false;
        }

        //以上问题均没有出现，可以进行创建
        return true;
      },

      /**
       * ----------获取数据------------------------------------------------------
       * */

      /***
       * @Description  : 获取所有设备列表
       * @author       : lxy
       * @date         : 2018/12/24 11:29
       */
      getAllDevice: function () {
        //调用domin函数
        let _this = this;
        DeviceService.getAllDeviceCollection().then(result => {
          //成功
          _this.optionsDeviceName = Object.values(result);
          _this.deviceList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /**
       * @Description  ：获取下拉框所有业务类型消息
       * @date         : 2019/03/19 15:20
       */
      getAllServiceType: function () {
        console.log('获取全部业务类型信息：');
        //调用domin函数
        let _this = this;
        ServiceTypeService.getAllServiceTypeCollection().then(result => {
          //成功
          _this.ServiceTypeList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /**
       * @Description  ：获取下拉框所有qosfile消息
       * @date         : 2019/03/19 16:56
       */
      getAllCDPProfileCreation: function () {
        //调用domin函数
        let _this = this;
        CDPService.getAllCDPCollection().then(result => {
          //成功
          _this.CDPProfileCreationList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /**
       * @Description  ：获取设备列表（第一个string是子网ID，第二个就是对应的设备拿的是deviceKey,port）
       * @date         : 2019/03/19 16:56
       */
      getElineDeviceList: function () {
        //调用domin函数
        this.elineDeviceList = {};
        let _this = this;
        ElineService.getElineDeviceList(this.form.serviceTypeID).then(result => {
          //成功
          _this.elineDeviceList = Object.values(result);
          _this.getSubnetList();
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        });
      },

      //复制模式下，根据业务类型serviceTypeID，获取elineDeviceList
      getElineDeviceListCopy: function () {
        //调用domin函数
        this.elineDeviceList = {};
        let _this = this;
        if(this.form.serviceTypeID !== ""){
          ElineService.getElineDeviceList(this.form.serviceTypeID).then(result => {
            //成功
            _this.elineDeviceList = Object.values(result);
            _this.getSubnetList();
            _this.getAllDeviceCopy();
          }).catch(err => {
            //失败
            _this.InfoTip.errorTip(_this, err);
          });
        }
      },

      /**
       * @Description  ：获取业务子网列表
       * @date         : 2019/03/19 16:56
       */
      getSubnetList: function () {
        //调用domin函数
        let _this = this;
        ServiceSubnetService.getAllEveSubnetCollection().then(result => {
          //成功
          _this.subnetList = Object.values(result);
          _this.handleElineDeviceList();
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /***
       * @Description  : 获取所有设备列表(复制专用)
       * @author       : lxy
       * @date         : 2018/12/24 11:29
       */
      getAllDeviceCopy: function () {
        //调用domin函数
        let _this = this;
        DeviceService.getAllDeviceCollection().then(result => {
          //成功
          _this.deviceList = Object.values(result)
          //_this.serviceTypeChange();
          _this.serviceSubnetIDChange();
          _this.startDeviceIdChange();
          _this.end1DeviceIdChange();
          _this.end2DeviceIdChange();
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /**
       * --------业务类型处理函数-----------------------------------------------------------------------
       */

      /**
       * 根据业务子网ID获得业务子网名称
       */
      getSubnetNameBySubnetId:function (key) {
        let _this = this;
        for(let i=0; i<_this.subnetList.length; i++){
          if(_this.subnetList[i].serviceSubnetID === key){
            return _this.subnetList[i].serviceSubnetName;
          }
        }
        return key;
      },

      /**
       * 根据设备ID获得业务子网名称
       */
      getDeviceNameByDeviceId:function (key) {
        this.getAllDevice();
        for(let i=0; i<this.deviceList.length; i++){
          if(this.deviceList[i].deviceKey === key){
            return this.deviceList[i].deviceName;
          }
        }
        return key;
      },

      /**
       * @Description  ：处理设备列表的信息：获得列表中的所有子网
       * @date         : 2019/03/19 16:56
       */
      handleElineDeviceList: function () {
        //获取子网列表
        let serviceSubnetIDList1 = [];
        for(let i=0; i<this.elineDeviceList.length; i++){
          if(serviceSubnetIDList1.indexOf(this.elineDeviceList[i].key) === -1){
            serviceSubnetIDList1.push(this.elineDeviceList[i].key);
          }
        }

        this.serviceSubnetIDList = [];
        //将子网按照格式放入下拉列表中
        for(let j=0; j<serviceSubnetIDList1.length; j++){
          let subnet = {};
          subnet.serviceSubnetID = serviceSubnetIDList1[j];
          subnet.serviceSubnetName = this.getSubnetNameBySubnetId(serviceSubnetIDList1[j]);
          this.serviceSubnetIDList.push(subnet);
        }
      },

      /***
       * @Description  : 设备名称处理
       * @author       : zf
       * @date         : 2018/12/24 16:07
       */
      handleDeviceKeys: function (deviceKey) {
        //获取设备列表
        let _this = this;
        DeviceService.getAllDeviceCollection().then(result => {
          //成功
          _this.deviceList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        });
//        let flag = 0;//标记是否查到，0未查到，1查到
        for (let i = 0; i < this.deviceList.length; i++) {
          if (this.deviceList[i].deviceKey === deviceKey) {
            return this.deviceList[i].deviceName;
          }
        }
        return deviceKey;
      },

      /**
       * @Description  ：当业务子网数据发生变化，确定可以选择的业务起点、终点设备
       * @date         : 2019/03/19 16:56
       */
      serviceSubnetIDChange:function () {
        let serviceDeviceList = [];
        for(let i=0; i<this.elineDeviceList.length; i++){
          if(this.form.serviceSubnetID === this.elineDeviceList[i].key){
            serviceDeviceList.push(this.elineDeviceList[i].value.deviceKey);
          }
        }

        //为了复制的时候赋值，IsserviceSubnetIDChangeTime第一次为0不会将值清空，之后进行操作或者选择模板都会清空
        if(this.IsserviceSubnetIDChangeTime === 0){
          this.IsserviceSubnetIDChangeTime++;
        }else{
          //业务子网数据变化，起点终点设备及端口清空
          this.form.startDeviceId = "";
          this.form.startDevicePort = "";
          this.startDevicePortList = [];
          this.form.end1DeviceId = "";
          this.form.end1DevicePort = "";
          this.end1DevicePortList = [];
          this.form.end2DeviceId = "";
          this.form.end2DevicePort = "";
          this.end2DevicePortList = [];
        }

        this.startDeviceIdList = [];
        this.end1DeviceIdList = [];
        this.end2DeviceIdList = [];
        for(let i=0; i<serviceDeviceList.length; i++){
          let device = {};
          device.deviceKey = serviceDeviceList[i];
          device.deviceName = this.getDeviceNameByDeviceId(serviceDeviceList[i]);
          this.startDeviceIdList.push(device);
          this.end1DeviceIdList.push(device);
          this.end2DeviceIdList.push(device);
        }
      },

      /**
       * -----------------------------创建和复制方法----------------------------------------------------------------------------
       * */
      /**
       * @Description  ：创建业务
       * @date         : 2019/03/19 15:59
       */
      createEline: function () {
        //检查输入情况
        if(this.finalCheck() === false){
          return;
        }
        this.handleCreateElineModelData();
        this.form.startTime = this.timeLigalTransform(this.form.startTime);
        let _this = this;
        let loadingInstance = _this.Loading.openLoading();
        ElineService.addEline({
          vpnId: this.form.vpnId,
          serviceName: this.form.serviceName,
          serviceTypeID: this.form.serviceTypeID,
          protectionMode: this.form.protectionMode,
          reversion: this.form.reversion,
          wtr: parseInt(this.form.wtr),

          oamInfo: this.form.oamInfo,
          ccmInterval: this.form.ccmInterval,
          encapsulationType: this.form.encapsulationType,
          l2AccessType: this.form.l2AccessType,
          startDeviceId: this.form.startDeviceId,
          startDevicePort: this.form.startDevicePort,
          end1DeviceId: this.form.end1DeviceId,
          end1DevicePort: this.form.end1DevicePort,
          isDualHomed:this.form.isDualHomed,
          end2DeviceId: this.form.end2DeviceId,
          end2DevicePort: this.form.end2DevicePort,

          vlanAccess: this.form.vlanAccess,
          vlanRangeStart: parseInt(this.form.vlanRangeStart),
          vlanRangeEnd: parseInt(this.form.vlanRangeEnd),
          vlanSet: this.form.vlanSet,
          cosId: this.form.cosId,
          limitedBandwidth: parseInt(this.form.limitedBandwidth),
          qosProfile: this.form.qosProfile,
          startTime: this.form.startTime,
          elineStatus: this.form.elineStatus,

          serviceSubnetID: this.form.serviceSubnetID,
        }).then(result => {
          //成功
          _this.Loading.closeLoading(loadingInstance);
          _this.InfoTip.successTip(_this,HelperUtil.getStatusCodeObjectByCode(_this.successCode.ADD_CODE));
          this.command.done();
        }).catch(err => {
          //失败
          this.handleDataFrom999ToNull();
          _this.Loading.closeLoading(loadingInstance);
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /**
       * 内容处理，把int类型的字段为""的，都赋值为-999
       */
      handleCreateElineModelData:function () {
        //vlan协议
        if(this.form.l2AccessType === ""){
          this.form.l2AccessType = -999;
        }
        //vlan-range起点
        if(this.form.vlanRangeStart === ""){
          this.form.vlanRangeStart = -999;
        }
        //vlan-range终点
        if(this.form.vlanRangeEnd === ""){
          this.form.vlanRangeEnd = -999;
        }
        //回滚等待时间
        if(this.form.wtr === ""){
          this.form.wtr = -999;
        }
        //oam选项
        if(this.form.oamInfo === ""){
          this.form.oamInfo = -999;
        }
        //ccm间隔时间
        if(this.form.ccmInterval === ""){
          this.form.ccmInterval = -999;
        }
        //vlan设置方式
        if(this.form.vlanAccess === ""){
          this.form.vlanAccess = -999;
        }

        //第二个业务终点端口
        if(this.form.end2DevicePort === ""){
          this.form.end2DevicePort = -999;
        }


      },

      /**
       * 内容处理，把int类型的字段为-999的，都赋值为""
       */
      handleDataFrom999ToNull:function () {
        //vlan协议
        if(this.form.l2AccessType === -999){
          this.form.l2AccessType = "";
        }
        //vlan-range起点
        if(this.form.vlanRangeStart === -999){
          this.form.vlanRangeStart = "";
        }
        //vlan-range终点
        if(this.form.vlanRangeEnd === -999){
          this.form.vlanRangeEnd = "";
        }
        //回滚等待时间
        if(this.form.wtr === -999){
          this.form.wtr = "";
        }
        //oam选项
        if(this.form.oamInfo === -999){
          this.form.oamInfo = "";
        }
        //ccm间隔时间
        if(this.form.ccmInterval === -999){
          this.form.ccmInterval = "";
        }
        //vlan设置方式
        if(this.form.vlanAccess === -999){
          this.form.vlanAccess = "";
        }

        //第二个业务终点端口
        if(this.form.end2DevicePort === -999){
          this.form.end2DevicePort = "";
        }

        //起始时间格式更改
        this.form.startTime = this.handleUpdateTime(this.form.startTime);
      },

      /**
       * @Description  ：打开ELINE模板选择对话框
       * @date         : 2019/03/19 15:59
       */
      openElineTemplateSelect:function () {
        //打开对话框
        this.innerVisible = true;
      },

      /***
       *  关闭对话框，向父组件通信
       */
      close:function () {
        this.command.done();
      },
    },

    watch:{
      innerVisible(newVal, oldVal){
        //当选择结束后再调用，不要一打开选择模板界面就监听执行一遍
        if(newVal === false){
          this.form.serviceSubnetID = "";
          this.initCheck();
          this.getElineDeviceListCopy();
        }
        deep: true
      },
      '$i18n.locale' () {
        this.queryNodeTypeChange()
      },
    },
  }
</script>

<style scoped>
  /*!* 外层布局容器样式 *!*/
  .el-header {
    background-color: #f9fafc;
    color: #333;
    line-height: 40px;
  }
  /deep/ .el-input__inner{
    height: 28px !important;
  }
  /deep/ .el-dialog__body{
    padding-top: 0px !important;
  }
  /deep/ .el-input-group__append{
    padding-left: 0px !important;
    padding-right: 0px !important;
    font-size: 9px !important;
  }
</style>
