CreateAndCopySubnet.vue 4.61 KB
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
<template>
  <!-- 子网创建对话框 -->
  <el-dialog
    @close="close"
    @opened="createSubnetInit"
    v-dialogDrag
    :title=title
    style="font-size: 10px;" width='450px'
    :visible.sync="createAndCopySubnetVisible">
    <el-form :model="form" inline="true">
      <el-form-item :label="'*'+ $t('SubnetConfigurationManagement.subnetName')+':'" :label-width="formLabelWidth"
                    style="margin-bottom: -10px;">
        <el-input size='mini' :placeholder="$t('common.placeholder')" v-model="form.subnetName"
                  v-on:blur="subnetNameCheck" autocomplete="off" style="width: 152px;"></el-input>
      </el-form-item>
      <el-form-item :label="$t('SubnetConfigurationManagement.domain')+':'" :label-width="formLabelWidth"
                    style="margin-bottom: -10px; margin-left: 0px;">
        <el-input type="textarea" :rows="4" :placeholder="$t('common.placeholder')" v-model="form.domain"
                  autocomplete="off" style="width: 152px; margin-top: 10px;"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size='mini' type="primary" @click="createSubnet">
        {{$t("common.createBtn")}}
      </el-button>
      <el-button size='mini' @click="close">{{$t("common.cancel")}}</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import SubnetService from '@/domain/services/SubnetService.js'
  import legitimacyCheck from "../../../utils/legitimacyCheck";
  import HelperUtil from"../../../utils/HelperUtil";

  export default {
    props: ['command'],
    data: function () {
      return {
        title: this.command.title,
        initList: this.command.target,
        createAndCopySubnetVisible: false,
        formLabelWidth: '120px',
        form: {
          subnetName: null,
          domain: null,
        },
      }
    },
    methods: {
      close() {
        this.command.done();
      },

      //------------------------------------创建开始-------------------------------------------------------------------
      createSubnetInit(){
        this.form.subnetName = this.initList.subnetName;
        this.form.domain = this.initList.domain
      },

      createSubnet() {
        if (!this.subnetNameCheck()) {
          return

        }
        else {
          let subnet = {};
          subnet.subnetKey = '';
          subnet.subnetName = this.form.subnetName;
          subnet.domain = this.form.domain;
          subnet.delFlag = 0;
          subnet.modifyTime = '';
          SubnetService.addSubent(subnet).then(result => {
            //成功
            this.InfoTip.successTip(this,HelperUtil.getStatusCodeObjectByCode(this.successCode.ADD_CODE));
            this.command.done();
          }).catch(err => {
            this.InfoTip.errorTip(this,err);

          });
        }
      },


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

      //------------------------------------验证开始-------------------------------------------------------------------
      /**
       * @Description  :子网名称校验: 不能为空
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         :
       */
      subnetNameCheck: function () {
        let subnetCheck = legitimacyCheck()
        if (!subnetCheck.textNullCheck(this.form.subnetName)) {
          //输入不可为空
          this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.TEXT_NULL_CODE),this.$t('SubnetConfigurationManagement.subnetName'))
          return false
        }
        if(!this.textLengthCheck(this.form.subnetName)) return false
        return true
      },

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


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

    },

    created() {
      console.log('子网创建初始化加载数据')
    },

    mounted(){
      this.createAndCopySubnetVisible = true;
    }
  }
</script>