From 0ae255185f422781f8a5cc4c52ad56ee0d3a1e6e Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期五, 29 十一月 2024 19:07:15 +0800 Subject: [PATCH] 1.首页可拖拽 2.没有名字去掉悬浮层 3.增加了背景 --- src/components/equ-add-form.vue | 39 ++++++++++++++++++++++++++++++--------- 1 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/components/equ-add-form.vue b/src/components/equ-add-form.vue index 250f5b1..8613c6b 100644 --- a/src/components/equ-add-form.vue +++ b/src/components/equ-add-form.vue @@ -20,7 +20,8 @@ class="value select" placeholder="请选择交换机" v-model="name" - clearable filterable + clearable filterable + :disabled="nameDisabled" > <option disabled selected value >请选择交换机</option> <option v-for="item in switchList" @@ -44,7 +45,8 @@ class="value select" placeholder="请选择交换机柜" v-model="cabinetName" - clearable filterable + clearable filterable + :disabled="cabinetNameDisabled" > <option disabled selected value >请选择交换机柜</option> <option v-for="item in cabinetList" @@ -84,7 +86,7 @@ /> </div> <div class="flex m-t-2rem"> - <div class="label ">端口:</div> + <div class="label require">端口:</div> <input class="value input" v-model="port" @@ -99,6 +101,7 @@ placeholder="请选择厂区" disabled clearable filterable v-model="selectcode" + :disabled="areaCodeDisabled" > <!-- @change="updateDeviceList" --> <option disabled selected value>- 请选择厂区</option> @@ -171,6 +174,9 @@ // selectswitchindex: "", cabinetList:[], switchList:[], + nameDisabled: false, + cabinetNameDisabled: false, + areaCodeDisabled: false, }; }, mounted() { @@ -216,7 +222,11 @@ }, async submit() { //todo 提交设备 - if (!this.name || !this.selectcode || !this.cabinetName || !this.networkPort) { + if (this.ipAddress && !this.isValidIP(this.ipAddress)) { + this.$message.warning("请输入有效的IP地址"); + return; + } + if (!this.name || !this.selectcode || !this.cabinetName || !this.networkPort || !this.port ) { this.$message.warning("数据未填写完整"); return; } @@ -251,8 +261,8 @@ areaCode: this.selectcode, switchName: this.name, - areaRow:this.cur_item?.row, - areaCell:this.cur_item?.cell, + areaRow:this.cur_item?.row?this.cur_item?.row:-1, + areaCell:this.cur_item?.cell?this.cur_item?.cell:-1, }, }; @@ -262,6 +272,7 @@ this.$message.success("创建成功"); this.open = false; this.$emit("update", {}); + this.$emit("update-server-info", this.code,this.name); } }, openform(locInfo = {}) { @@ -280,7 +291,8 @@ this.open = !this.open; } }, - openConfigform(code, cabinetName) { + openConfigform(code, switchName,cabinetName,config) { + console.log('openConfigform',code,switchName,cabinetName); if (this.open) { this.open = !this.open; } else { @@ -288,14 +300,23 @@ this.locInfo = {}; this.selectcode = code; console.log("this.locInfo", this.locInfo); - this.name = cabinetName; + this.name = switchName; + this.cabinetName = cabinetName; this.port = this.locInfo.port || ""; this.networkPort = this.locInfo.name || ""; this.macAddress = this.locInfo.macAddress || ""; this.ipAddress = this.locInfo.ipAddress || ""; - this.open = !this.open; } + if (config === 1) { + this.nameDisabled = true; // 将nameDisabled设置为禁用 + this.cabinetNameDisabled = true; // 将cabinetName设置为禁用 + this.areaCodeDisabled = true; // 将areaCode设置为不禁用 + } + }, + isValidIP(ip) { + const regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; + return regex.test(ip); }, }, watch: { -- Gitblit v1.9.3