<template>
  <div id="main">
    <!-- 业务模板创建对话框 -->
    <el-dialog v-dialogDrag style="font-size: 10px;" width='1200px' :title="dialogTitle" :visible.sync="dialog_elineTemplateCreate" @close="close()" >
      <el-row>
        <el-form :model="form" inline="true" ref="form" style="width:1100px">
          <el-divider contentPosition="left">{{ $t("EveModelConfigurationManagement.BasicInformation") }}</el-divider>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EveModelConfigurationManagement.ElineTemplateName1')" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-input size='mini' :placeholder="$t('common.placeholder1')" v-model="form.elineTemplateName"
                        autocomplete="off" style="width:150px"></el-input>
            </el-form-item>
            <el-form-item :label="$t('EveModelConfigurationManagement.serviceType1')" :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  :label="placeHolder" :label-width="formLabelWidth" style="margin-bottom: -10px;margin-top: -10px;">
              <el-checkbox v-model="form.defaultFlag" trueLabel=1; falseLabel=0>{{$t('EveModelConfigurationManagement.setDefaultTemplate')}}</el-checkbox>
            </el-form-item>
          </el-form-item>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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">
          <el-divider contentPosition="left">{{ $t("EveModelConfigurationManagement.vlanInformation") }}</el-divider>
          <el-form-item style="margin-bottom: -10px; float:left">
            <el-form-item :label="$t('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('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">
                <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('EveModelConfigurationManagement.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>
      <div slot="footer" class="dialog-footer">
        <el-button size = 'mini' type="primary" @click="createElineTemplate" v-loading.fullscreen.lock="fullscreenLoading">{{createBtnName}}</el-button>
        <el-button size = 'mini' @click="close()" >{{$t("common.cancel")}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import ElineTemplateService from '@/domain/services/Business/ElineTemplateService.js'
  import ServiceTypeService from '@/domain/services/Business/ServiceTypeService.js'
  import CDPService from '@/domain/services/Business/CDPService.js'
  import HelperUtil from "../../../utils/HelperUtil";
  import legitimacyCheck from "../../../utils/legitimacyCheck";

  export default {
    name: 'CreateEveModelConfigurationManagementDialog',

    //1.声明从父组件接收value
    props: ['command'],

    data: function () {   //存放数据
      return {
        //对话框名称
        dialogTitle:"业务模板创建",

        dialog_elineTemplateCreate: true,
        title: this.command.title,
        form:this.command.target,
        createBtnName: "创建",

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

        //业务类型过滤
        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('EveModelConfigurationManagement.is')
          },
          {
            value:1,
            label:this.$t('EveModelConfigurationManagement.no')
          }
        ],
        //oam选项过滤
        oamInfoFlag:[
          {
            value:0,
            label:this.$t('EveModelConfigurationManagement.is')
          },
          {
            value:1,
            label:this.$t('EveModelConfigurationManagement.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('EveModelConfigurationManagement.default')
          },
          {
            value:0,
            label: this.$t('EveModelConfigurationManagement.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
          }
        ],

        //弹框中的窗口是否可输入约束
        wtr_input_disable1:false,
        oaminfo_select_disable:false,
        vlanRangeStart_input_disable:false,
        vlanRangeEnd_input_disable:false,
        vlanRangeSet_input_disable:false,
        ccmInterval_select_disable:false,
        l2AccessType_select_disable:false,

        //占位符
        placeHolder: " ",
      }
    },
    //vue加载初始化函数，加载数据
    created:function(){
      //获取下拉框业务类型信息
      this.getAllServiceType();
      //获取下拉框qos信息
      this.getAllCDPProfileCreation();
      //初始化过滤
      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);
        }
      }
    },
    watch:{
    },
    methods: {
      //过滤
      initCheck:function () {
        this.wtr_input_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;

        //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.title === "业务模板的复制"){
          this.createBtnName = this.$t('common.copyBtn');
          this.dialogTitle = this.$t('EveModelConfigurationManagement.CopyElineTemplate');
        }else{
          this.createBtnName = this.$t('common.createBtn');
          this.dialogTitle = this.$t('EveModelConfigurationManagement.CreateElineTemplate');
        }
      },

      //根据是否回滚限制回滚时间是否可填
      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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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('EveModelConfigurationManagement.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
      },

      //当选择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
        }else{
          this.form.vlanRangeStart = "";
          this.form.vlanRangeEnd = "";
          this.vlanRangeStart_input_disable = true;
          this.vlanRangeEnd_input_disable = true;
          this.vlanRangeSet_input_disable = false
        }
        return
      },

      //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('EveModelConfigurationManagement.inputInteger')})
        }
      },

      //根据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
          this.form.ccmInterval = ''
        }
      },

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

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

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

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

        //保护模式是否为空
        if(this.form.protectionMode === "" || this.form.protectionMode === null){
          this.InfoTip.warningTip(this, {message: this.$t('EveModelConfigurationManagement.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('EveModelConfigurationManagement.oamInfoEmpty')});
            return false;
          }
        }

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

        //封装类别是否为空
        if(this.form.encapsulationType === "" || this.form.encapsulationType === null){
          this.InfoTip.warningTip(this, {message: this.$t('EveModelConfigurationManagement.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('EveModelConfigurationManagement.l2AccessTypeEmpty')});
            return false;
          }
          //vlan设置方式是否为空
          if(this.form.vlanAccess === "" || this.form.vlanAccess === null){
            this.InfoTip.warningTip(this, {message: this.$t('EveModelConfigurationManagement.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('EveModelConfigurationManagement.vlanRangeStartEmpty')});
              return false;
            }
            //vlan-range终点是否为空
            if(this.form.vlanRangeEnd === "" || this.form.vlanRangeEnd === null){
              this.InfoTip.warningTip(this, {message: this.$t('EveModelConfigurationManagement.vlanRangeEndEmpty')});
              return false;
            }
          }else{
            //vlan-set集合是否为空
            if(this.form.vlanSet === "" || this.form.vlanSet === null){
              this.InfoTip.warningTip(this, {message: this.$t('EveModelConfigurationManagement.vlanSetEmpty')});
              return false;
            }
          }
        }

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

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

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

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

      /***
       *  ------------获取---------------------------------------------------------------
       */
      /**
       * @Description  ：获取下拉框所有业务类型消息
       * @date         : 2019/03/19 15:20
       */
      getAllServiceType: function (){
        //调用domin函数
        let _this = this;
        ServiceTypeService.getAllServiceTypeCollection().then(result => {
          //成功
          _this.ServiceTypeList = 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 = result
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /***
       * -------------创建和复制---------------------------------------------------------
       */
      /**
       * @Description  ：创建业务模板
       * @date         : 2019/03/19 15:59
       */
      createElineTemplate: function () {
        //检查输入情况
        if(this.finalCheck() === false){
          return;
        }
        this.handleCreateElineModelData();
        let _this = this;
        let loadingInstance = _this.Loading.openLoading();
        ElineTemplateService.addElineTemplate({
          elineTemplateKey:'',
          elineTemplateName:this.form.elineTemplateName,
          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,
          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,
          defaultFlag:parseInt(this.form.defaultFlag),

          delFlag: 0,
          modifyTime: ''
        }).then(result => {
          //成功
          this.command.done();
          _this.Loading.closeLoading(loadingInstance);
          _this.InfoTip.successTip(_this,HelperUtil.getStatusCodeObjectByCode(_this.successCode.ADD_CODE));

        }).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;
        }
      },

      /**
       * 内容处理，把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 = "";
        }
      },

      /***
       * 关闭对话框
       */
      close:function () {
        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>
