<template>
  <div id="main">
    <!-- 以太网E-Line业务修改对话框 -->
    <el-dialog v-dialogDrag style="font-size: 10px;" width='1200px' :title="$t('EthernetELineServiceConfigurationManagement.uppdateE_Line')"
               :visible.sync="dialog_elineUpdate"  @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.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" :disabled="vpnId_input_disable" style="width:150px"></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" :disabled="serviceTypeID_input_disable">
                <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" :disabled="serviceSubnetID_input_disable" 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" :disabled="reversion_input_disable">
                <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" type="number"
                        :disabled="wtr_input_disable" style="width:99px">
                <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.selectOption')" style="width: 150px"
                         :clearable="true" v-on:change="protectionModeCheck" :disabled="protectionMode_input_disable">
                <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.selectOption')" 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="width:1100px">
          <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" :disabled="encapsulationType_select_disable">
                <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">
                <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" type="number"
                        autocomplete="off" style="width:150px" :disabled="vlanRangeStart_input_disable"></el-input>
              <span> - </span>
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.vlanRangeEnd" type="number"
                        autocomplete="off" style="width:150px" :disabled="vlanRangeEnd_input_disable"></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.selectOption')" style="width: 150px" :clearable="true" :disabled="qosProfile_select_disable">
                <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('EveModelConfigurationManagement.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" :disabled="cosId_select_disable">
                <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" type="number"
                        autocomplete="off" style="width:95px" :disabled="limitedBandwidth_select_disable">
                <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="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" :disabled="isDualHomed_select_disable">
                <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" :disabled="startDeviceId_select_disable">
                <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" :disabled="startDevicePort_select_disable">
                <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" :disabled="end1DeviceId_select_disable">
                <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" :disabled="end1DevicePort_select_disable">
                <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"
                        :disabled="startTime1_disable"
              >
              </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="updateElineTemplate"
                   v-loading.fullscreen.lock="fullscreenLoading">{{$t("common.updateBtn")}}
        </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 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 HelperUtil from "../../../utils/HelperUtil";
  import legitimacyCheck from "../../../utils/legitimacyCheck";
  import ServiceSubnetService from '@/domain/services/Business/ServiceSubnetService.js'
  import SelectElineTemplateDialog from '../ElineDialog/SelectElineTemplateDialog.vue';

  export default {
    name: 'UpdateEthernetELineServiceConfigurationManagement',
    props:['command'],
    components:{
      //创建、复制对话框
      ElRow,
      SelectElineTemplateDialog,
    },
    data: function () {   //存放数据
      return {
        dialog_elineUpdate:true,
        form: this.command.target,

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

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

        //业务类型过滤
        ServiceTypeList: [],
        //保护模式过滤
        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: [
          {
            profileName: 'profileName1'
          },
          {
            profileName: 'profileName2'
          }
        ],
        //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: [],

        //弹框中的窗口是否可输入约束
        vpnId_input_disable: true,
        serviceTypeID_input_disable: true,
        serviceSubnetID_input_disable: true,
        reversion_input_disable: true,
        protectionMode_input_disable: true,
        encapsulationType_select_disable:true,
        qosProfile_select_disable: true,
        cosId_select_disable: true,
        limitedBandwidth_select_disable: true,
        isDualHomed_select_disable: true,
        startDeviceId_select_disable: true,
        startDevicePort_select_disable: true,
        end1DeviceId_select_disable: true,
        end1DevicePort_select_disable: true,
        startTime_select_disable: true,

        wtr_input_disable: true,
        oaminfo_select_disable: true,
        vlanAccess_select_disable: true,
        vlanRangeStart_input_disable: true,
        vlanRangeEnd_input_disable: true,
        vlanRangeSet_input_disable: true,
        ccmInterval_select_disable: true,
        l2AccessType_select_disable: true,    //vlan协议，vlan类别为vlan-type，可选
        end2DeviceIdList_disable: true,   //第二个业务终点设备；是否双规模式为true，可选
        end2DevicePortList_disable: true,   //第二个业务终点设备端口；是否双规模式为true，可选
        startTime1_disable: true,

        //设备列表
        deviceList: [],
        //子网列表
        subnetList: [],
        //业务子网下拉菜单
        serviceSubnetIDList:[],


        //模板选择窗口
        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();
      this.initCheck_Update();
    },
    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');
      }
    },
    watch:{
      innerVisible(newVal, oldVal){
        this.initCheck();
        deep: true
      },
      '$i18n.locale' () {
        this.queryNodeTypeChange()
      },
    },
    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设置方式设置range、set字段是否变灰
        if (this.form.vlanAccess === 0) {
          this.vlanRangeSet_input_disable = true
          this.form.vlanSet = "";
        } else {
          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
        }
        //根据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++;
        }
        //this.form.startTime = new Date(this.handleUpdateTime(this.form.startTime)).toISOString();
        this.getElineDeviceListUpdate();
      },

      /***
       * 初始化过滤（修改）， 只有名称可以修改
       */
      initCheck_Update: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 = "";
        }
        if(this.form.startTime !== ''){
          this.form.startTime = this.handleUpdateTime(this.form.startTime);
        }
        this.getElineDeviceListUpdate();
      },

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

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

      //开始时间被清空后重新赋值
      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: "开始时间不能大于结束时间！"})
          }
        }

      },

      /**
       *  处理时间格式，转换为时间
       */
      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
      },

      /**
       *   设置时间格式
       */
      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;
        }
      },

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

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

      //根据保护模式处理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.form.oamInfo = null;
          this.ccmInterval_select_disable = false
        }
        return
      },

      //根据业务类型的改变，获得业务起点设备列表
      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: '当前输入有误'})
        }
      },

      //根据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.alertWindows("业务ID不能为空");
          return false;
        }

        //业务名称是否为空
        if(this.form.serviceName === "" || this.form.serviceName === null){
          this.alertWindows("业务名称不能为空");
          return false;
        }

        //业务类型是否为空
        if(this.form.serviceTypeID === "" || this.form.serviceTypeID === null){
          this.alertWindows("业务类型不能为空");
          return false;
        }

        //是否回滚是否为空
        if(this.form.reversion === "" || this.form.reversion === null){
          this.alertWindows("是否回滚不能为空");
          return false;
        }

        //回滚等待时间是否为空
        if(this.form.reversion === 0){  //是否回滚选是，那么回滚时间不能为空
          if(this.form.wtr === "" || this.form.wtr === null){
            this.alertWindows("回滚等待时间不能为空");
            return false;
          }
        }

        //保护模式是否为空
        if(this.form.protectionMode === "" || this.form.protectionMode === null){
          this.alertWindows("保护模式不能为空");
          return false;
        }

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

        //ccm间隔时间是否为空
        if(this.form.protectionMode !== 0){  //保护模式选unprotect，那么oam选项为空,剩余的选择都不能为空
          if(this.form.oamInfo === "" || this.form.oamInfo === null){
            this.alertWindows("ccm间隔时间不能为空");
            return false;
          }
        }

        //封装类别是否为空
        if(this.form.encapsulationType === "" || this.form.encapsulationType === null){
          this.alertWindows("封装类别不能为空");
          return false;
        }

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

        //qos策略名称是否为空
        if(this.form.qosProfile === "" || this.form.qosProfile === null){
          this.alertWindows("qos策略名称不能为空");
          return false;
        }

        //cos-Id是否为空
        if(this.form.cosId === "" || this.form.cosId === null){
          this.alertWindows("cos-Id不能为空");
          return false;
        }

        //最高带宽是否为空
        if(this.form.limitedBandwidth === "" || this.form.limitedBandwidth === null){
          this.alertWindows("最高带宽不能为空");
          return false;
        }

        //业务起点设备是否为空
        if(this.form.startDeviceId === "" || this.form.startDeviceId === null){
          this.alertWindows("业务起点设备不能为空");
          return false;
        }

        //业务起点设备端口是否为空
        if(this.form.startDevicePort === "" || this.form.startDevicePort === null){
          this.alertWindows("业务起点设备端口不能为空");
          return false;
        }

        //业务终点设备是否为空
        if(this.form.end1DeviceId === "" || this.form.end1DeviceId === null){
          this.alertWindows("业务终点设备不能为空");
          return false;
        }

        //业务终点设备端口是否为空
        if(this.form.end1DevicePort === "" || this.form.end1DevicePort === null){
          this.alertWindows("业务终点设备端口不能为空");
          return false;
        }

        //双规模式第二个不能为空
        if(this.form.isDualHomed === 0){
          //第二个业务终点设备是否为空
          if(this.form.end2DeviceId === "" || this.form.end2DeviceId === null){
            this.alertWindows("第二个业务终点设备不能为空");
            return false;
          }

          //第二个业务终点设备端口是否为空
          if(this.form.end2DevicePort === "" || this.form.end2DevicePort === null){
            this.alertWindows("第二个业务终点设备端口不能为空");
            return false;
          }
        }

        //开站时间是否为空
        if(this.form.startTime === "" || this.form.startTime === null){
          this.alertWindows("开站时间不能为空");
          return false;
        }

        //起始设备、终止设备不能相同
        if(this.form.end1DeviceId === this.form.startDeviceId){
          this.alertWindows("业务起点设备和终点设备不能相同");
          return false;
        }
        if(this.form.end2DeviceId === this.form.startDeviceId){
          this.alertWindows("业务起点设备和第二个业务终点设备不能相同");
          return false;
        }
        if(this.form.end2DeviceId === this.form.end1DeviceId){
          this.alertWindows("业务终点设备和第二个业务终点设备不能相同");
          return false;
        }

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

      //提示弹窗
      alertWindows:function (message) {
        this.$alert(message, '提示', {
          confirmButtonText: '确定',
          type: 'warning'
        })
      },

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

      /***
       * @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 () {
        console.log('获取全部qosfile信息：')
        //调用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
      getElineDeviceListUpdate: function () {
        //调用domin函数
        this.elineDeviceList = {};
        let _this = this;
        ElineService.getElineDeviceList(this.form.serviceTypeID).then(result => {
          //成功
          _this.elineDeviceList = Object.values(result);
          _this.getSubnetList();
          _this.getAllDeviceUpdate();
        }).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
       */
      getAllDeviceUpdate: function () {
        //调用domin函数
        let _this = this;
        DeviceService.getAllDeviceCollection().then(result => {
          //成功
          _this.deviceList = Object.values(result)
          _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);
          }
        }

        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 16:30
       */
      updateElineTemplate: 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.modifyEline({
          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.$message({
            type: 'success',
            message: '修改成功！ ',
            duration: 10000,
            showClose: true,
          })
          _this.Loading.closeLoading(loadingInstance);
          _this.InfoTip.successTip(_this,HelperUtil.getStatusCodeObjectByCode(_this.successCode.MODIFY_CODE));
          this.command.done()
        }).catch(err => {
          //失败
          _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;
        }
      },

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

      /***
       *  关闭对话框，向父组件通信
       */
      close:function () {
        //this.$emit("update:dialog_elineUpdate", false);
        this.command.done()
      },
    },
  }
</script>

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