diff --git a/nezha-fronted/src/assets/css/main.css b/nezha-fronted/src/assets/css/main.css index c5c4cddb6..d94920bc7 100644 --- a/nezha-fronted/src/assets/css/main.css +++ b/nezha-fronted/src/assets/css/main.css @@ -401,7 +401,7 @@ html { font-weight: bold; } .pop-item, .pop-item-wider { - padding-top: 15px; + padding-top: 25px; } .pop-item-wider .el-form-item__label { width: 80px !important; @@ -466,6 +466,10 @@ html { font-size: 16px; color: black; } +.pop-item-wider .right-box-form .el-form-item .el-form-item__label { + font-size: 14px; + line-height: 32px; +} .right-box-form-left.right-box-form .el-form-item .el-form-item__label { padding: 0 20px 0 0; font-size: 14px; diff --git a/nezha-fronted/src/components/common/dcConfig.vue b/nezha-fronted/src/components/common/dcConfig.vue index baa9cf58d..c2a14ac3a 100644 --- a/nezha-fronted/src/components/common/dcConfig.vue +++ b/nezha-fronted/src/components/common/dcConfig.vue @@ -7,8 +7,7 @@ {{$t('overall.delete')}} - {{$t('overall.save')}} - {{$t('overall.edit')}} + {{$t('overall.save')}} @@ -21,18 +20,18 @@ - + - + - + - + @@ -129,34 +128,22 @@ console.log("save") temp.$post('idc', temp.idc).then(response => { if (response.code === 200) { - temp.$notify({ - message: h('i', {style: 'color: teal'}, temp.$t("tip.saveSuccess")), - duration: 2000 - }); + temp.$message({duration: 1000, type: 'success', message: temp.$t("tip.deleteSuccess")}); temp.$emit("after"); temp.esc(); } else { - temp.$notify({ - message: h('i', {style: 'color: teal'}, response.msg), - duration: 2000 - }); + this.$message.error(response.msg); } }) }else{ console.log("edit") this.$put('idc', temp.idc).then(response => { if (response.code === 200) { - temp.$notify({ - message: h('i', {style: 'color: teal'}, temp.$t("tip.saveSuccess")), - duration: 2000 - }); + temp.$message({duration: 1000, type: 'success', message: temp.$t("tip.deleteSuccess")}); temp.$emit("after"); temp.esc(); } else { - temp.$notify({ - message: h('i', {style: 'color: teal'}, response.msg), - duration: 2000 - }); + this.$message.error(response.msg); } }) } @@ -203,6 +190,7 @@ watch:{ postIdc: { immediate: true, + deep: true, handler(n, o) { if (n && n.id) { this.title = this.$t('asset.createAssetTab.editIdcTab.title') + " ID:" + n.id; diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index 50de2aabe..6fcbe918f 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -7,8 +7,13 @@ - {{item.name}} - {{item.name}} + + + + + + @@ -491,13 +496,16 @@ this.idcSelectedData = item } }); + return } else { this.IDCOptionData.forEach(item => { if (item.id === data) { - this.addIdcData.popName = item.name - this.addIdcData.location = item.location - this.addIdcData.principal = item.principal - this.addIdcData.tel = item.tel + this.addIdcData.id = item.id; + this.addIdcData.name = item.name; + this.addIdcData.popName = item.name; + this.addIdcData.location = item.location; + this.addIdcData.principal = item.principal; + this.addIdcData.tel = item.tel; } }); } @@ -585,13 +593,6 @@ padding: 0 15px; } - - .checkbox-edit { - position: absolute; - right: 10px; - font-size: 16px; - } - .tab-input-square { border: 1px solid #aaaaaa; height: 25px; @@ -721,4 +722,11 @@ .asset .content-left .el-checkbox__input.is-checked .el-checkbox__inner, .asset .content-left .el-checkbox__input.is-indeterminate .el-checkbox__inner { background-color: #e07700; } + + + .checkbox-edit { + position: absolute; + right: 10px; + font-size: 16px; + } diff --git a/nezha-fronted/src/components/page/asset/assetAddUnit.vue b/nezha-fronted/src/components/page/asset/assetAddUnit.vue index 57f5ee7f7..f923e556b 100644 --- a/nezha-fronted/src/components/page/asset/assetAddUnit.vue +++ b/nezha-fronted/src/components/page/asset/assetAddUnit.vue @@ -247,7 +247,12 @@ :value="item.id" > {{ item.name }} - + + + + + - + @@ -399,13 +405,13 @@ {{$t('asset.createAssetTab.editCabinetTab.title')}} - - + + - + {{popCabinetData.uSize}} - + - + - + @@ -515,18 +521,18 @@ {{$t('asset.createAssetTab.AddCabinetTab.title')}} - - + + - + {{addCabinetData.uSize}} - + - + - + @@ -802,6 +808,17 @@ idcId: [ {required: true, message: this.$t('validate.required'), trigger: 'change'} ], + }, + cabRules: { + name: [ + {required: true, message: this.$t('validate.required'), trigger: 'blur'} + ], + uSize: [ + {required: true, type: 'number', min: 1, max: 47, message: this.$t('validate.required'), trigger: 'blur'} + ], + idcId: [ + {required: true, message: this.$t('validate.required'), trigger: 'blur'} + ] } } }, @@ -870,7 +887,8 @@ if (response.code === 200) { this.IDCOptionData = response.data.list; this.markOptionData(this.IDCOptionData) - this.$store.state.assetData.idcData = this.IDCOptionData + this.$store.state.assetData.idcData = this.IDCOptionData; + this.$emit('refreshData'); } }) }, @@ -1010,40 +1028,44 @@ }) } if (type === 'asset') { - let modelId = '' - let authType = '' - if (this.assetData.modelId !== '') { - modelId = this.assetData.modelId.join(',').split(',')[1] - } else { - this.assetData.modelId = '' - } - if (this.assetData.accounts[0].user === '') { - authType = '' - } else { - authType = this.assetData.accounts[0].authType - } - let form = new FormData(); - form.append("sn", this.assetData.sn); - form.append("host", this.assetData.host); - form.append("state", this.assetData.state); - form.append("purchaseDate", this.assetData.purchaseDate); - form.append("idcId", this.assetData.idcId); - form.append("cabinetId", this.assetData.cabinetId); - form.append("modelId", modelId); - form.append("accounts[0].authType", authType); - form.append("accounts[0].user", this.assetData.accounts[0].user); - form.append("accounts[0].pwd", this.assetData.accounts[0].pwd); - form.append("accounts[0].port", this.assetData.accounts[0].port); - this.$post('asset', form).then(res => { - const h = this.$createElement; - if (res.code === 200) { - this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.sendStateData('close'); - } else { - this.$message.error(res.msg); + this.$refs.addAssetForm.validate((valid) => { + if (valid) { + let modelId = '' + let authType = '' + if (this.assetData.modelId !== '') { + modelId = this.assetData.modelId.join(',').split(',')[1] + } else { + this.assetData.modelId = '' + } + if (this.assetData.accounts[0].user === '') { + authType = '' + } else { + authType = this.assetData.accounts[0].authType + } + let form = new FormData(); + form.append("sn", this.assetData.sn); + form.append("host", this.assetData.host); + form.append("state", this.assetData.state); + form.append("purchaseDate", this.assetData.purchaseDate); + form.append("idcId", this.assetData.idcId); + form.append("cabinetId", this.assetData.cabinetId); + form.append("modelId", modelId); + form.append("accounts[0].authType", authType); + form.append("accounts[0].user", this.assetData.accounts[0].user); + form.append("accounts[0].pwd", this.assetData.accounts[0].pwd); + form.append("accounts[0].port", this.assetData.accounts[0].port); + this.$post('asset', form).then(res => { + const h = this.$createElement; + if (res.code === 200) { + this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.sendStateData('close'); + } else { + this.$message.error(res.msg); + } + }); + this.$emit('refreshData', 'true'); } - }) - this.$emit('refreshData', 'true') + }); } if (type === 'vendor') { const h = this.$createElement; @@ -1259,14 +1281,15 @@ this.clickFlush('idc', itemData) this.IDCOptionData.forEach(item => { if (item.id === data) { - this.popIdcData.name = item.name - this.popIdcData.location = item.location - this.popIdcData.principal = item.principal - this.popIdcData.tel = item.tel - this.addCabIDCData.name = item.name - this.addCabIDCData.location = item.location - this.addCabIDCData.principal = item.principal - this.addCabIDCData.tel = item.tel + this.popIdcData.id = item.id; + this.popIdcData.name = item.name; + this.popIdcData.location = item.location; + this.popIdcData.principal = item.principal; + this.popIdcData.tel = item.tel; + this.addCabIDCData.name = item.name; + this.addCabIDCData.location = item.location; + this.addCabIDCData.principal = item.principal; + this.addCabIDCData.tel = item.tel; } }); } @@ -1274,22 +1297,22 @@ getSingleCabinetData(data, type, item) { if (type !== 'edit') { this.cabinetSelectedData.uSize = 0; - this.cabinetSelectedData.remark = null + this.cabinetSelectedData.remark = null; this.cabinetOptionData.forEach(items => { if (items.id === data) { - this.cabinetSelectedData.uSize = items.uSize - this.cabinetSelectedData.remark = items.remark + this.cabinetSelectedData.uSize = items.uSize; + this.cabinetSelectedData.remark = items.remark; } }) } else { this.clickFlush('cabinet', item) - item[item.name] = !item[item.name] + item[item.name] = !item[item.name]; this.cabinetOptionData.forEach(items => { if (items.id === data) { - this.popCabinetData.name = items.name - this.popCabinetData.uSize = items.uSize - this.popCabinetData.remark = items.remark - this.popCabinetData.idcId = items.idcId + this.popCabinetData.name = items.name; + this.popCabinetData.uSize = items.uSize; + this.popCabinetData.remark = items.remark; + this.popCabinetData.idcId = items.idcId; } }) } diff --git a/nezha-fronted/src/components/page/asset/assetEditUnit.vue b/nezha-fronted/src/components/page/asset/assetEditUnit.vue index 731e2724f..3aa0ebd98 100644 --- a/nezha-fronted/src/components/page/asset/assetEditUnit.vue +++ b/nezha-fronted/src/components/page/asset/assetEditUnit.vue @@ -21,7 +21,7 @@ {{this.tabView == true ? $t('asset.asset') : $t('asset.EditAsset')}} - + {{assetData.sn}} @@ -271,7 +271,12 @@ :value="item.id" > {{ item.name }} - + + + + + - + {{assetViewData.idcName}} @@ -428,20 +434,20 @@ {{$t('asset.createAssetTab.editCabinetTab.title')}} - - + + - + {{popCabinetData.uSize}} - + - + - + @@ -543,20 +549,20 @@ {{$t('asset.createAssetTab.AddCabinetTab.title')}} - - + + - + {{addCabinetData.uSize}} - + - + - + @@ -691,7 +697,6 @@ cabinetId: '', modelId: '', assetType: '', - cabinet: {}, accounts: [{ id: '', authType: '', @@ -842,6 +847,17 @@ idcId: [ {required: true, message: this.$t('validate.required'), trigger: 'change'} ], + }, + cabRules: { + name: [ + {required: true, message: this.$t('validate.required'), trigger: 'blur'} + ], + uSize: [ + {required: true, type: 'number', min: 1, max: 47, message: this.$t('validate.required'), trigger: 'blur'} + ], + idcId: [ + {required: true, message: this.$t('validate.required'), trigger: 'blur'} + ] } } }, @@ -946,7 +962,7 @@ this.IDCOptionData = response.data.list; this.markOptionData(this.IDCOptionData) this.$store.state.assetData.idcData = this.IDCOptionData - + this.$emit('refreshData'); } }) }, @@ -1015,7 +1031,8 @@ tel: '' } if (data === 'asset') { - this.assetData.modelId = this.assetData.modelId.join(',').split(',')[1] + //this.assetData.modelId = this.assetData.modelId.join(',').split(',')[1]; + let modelId = this.assetData.modelId.join(',').split(',')[1]; let form = new FormData(); form.append("id", this.pageObj.id); form.append("sn", this.assetData.sn); @@ -1024,24 +1041,31 @@ form.append("purchaseDate", this.assetData.purchaseDate); form.append("idcId", this.assetData.idcId); form.append("cabinetId", this.assetData.cabinetId); - form.append("modelId", this.assetData.modelId); + form.append("modelId", modelId); form.append("accounts[0].id", this.assetData.accounts[0].id); form.append("accounts[0].authType", this.assetData.accounts[0].authType); form.append("accounts[0].user", this.assetData.accounts[0].user); form.append("accounts[0].pwd", this.assetData.accounts[0].pwd); form.append("accounts[0].port", this.assetData.accounts[0].port); form.append("cert", this.assetData.accounts[0].file); - this.$put('asset', form).then(res => { - const h = this.$createElement; - if (res.code === 200) { - this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.pageObj.id = ''; - this.$emit('refreshData', 'true'); - this.sendStateData('close'); + + this.$refs.assetEditForm.validate((valid) => { + if (valid) { + this.$put('asset', form).then(res => { + const h = this.$createElement; + if (res.code === 200) { + this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.pageObj.id = ''; + this.$emit('refreshData', 'true'); + this.sendStateData('close'); + } else { + this.$message.error(res.msg); + } + }); } else { - this.$message.error(res.msg); + return false; } - }) + }); } else { if (data === 'model') { item.vendorCode = this.vendorCode @@ -1056,10 +1080,20 @@ item = obj } if (data === 'cabinet') { - item.name = this.popCabinetData.name; - item.uSize = this.popCabinetData.uSize; - item.remark = this.popCabinetData.remark; - item.idcId = this.popCabinetData.idcId; + let v = true; + this.$refs.cabEditForm[0].validate((valid) => { + if (valid) { + item.name = this.popCabinetData.name; + item.uSize = this.popCabinetData.uSize; + item.remark = this.popCabinetData.remark; + item.idcId = this.popCabinetData.idcId; + } else { + v = false; + } + }); + if (!v) { + return false; + } } if (data === 'idc') { idcData.id = item.id @@ -1144,17 +1178,24 @@ }) } if (type === 'cabinet') { - this.addCabinetData.idcId = this.assetData.idcId - this.$post('cabinet', this.addCabinetData).then(res => { - const h = this.$createElement; - if (res.code === 200) { - this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.getCabinetOptionData(this.addCabinetData.idcId); - this.editPopoverClose('cabinet'); + this.$refs.cabAddForm.validate((valid) => { + if (valid) { + this.addCabinetData.idcId = this.assetData.idcId + this.$post('cabinet', this.addCabinetData).then(res => { + const h = this.$createElement; + if (res.code === 200) { + this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); + this.getCabinetOptionData(this.addCabinetData.idcId); + this.editPopoverClose('cabinet'); + } else { + this.$message.error(res.msg); + } + }); } else { - this.$message.error(res.msg); + return false; } - }) + }); + } }, deleteData(data, item) { @@ -1298,25 +1339,26 @@ this.idcSelectedData = ''; this.IDCOptionData.forEach(item => { if (item.id === data) { - this.idcSelectedData = item + this.idcSelectedData = item; } }); this.getCabinetOptionData(this.assetData.idcId); - this.assetData.cabinetId = '' - this.cabinetSelectedData.uSize = '' + this.assetData.cabinetId = ''; + this.cabinetSelectedData.uSize = ''; this.cabinetSelectedData.remark = null } else { - this.clickFlush('idc', itemData) + this.clickFlush('idc', itemData); this.IDCOptionData.forEach(item => { if (item.id === data) { - this.popIdcData.name = item.name - this.popIdcData.location = item.location - this.popIdcData.principal = item.principal - this.popIdcData.tel = item.tel - this.addCabIDCData.name = item.name - this.addCabIDCData.location = item.location - this.addCabIDCData.principal = item.principal - this.addCabIDCData.tel = item.tel + this.popIdcData.id = item.id; + this.popIdcData.name = item.name; + this.popIdcData.location = item.location; + this.popIdcData.principal = item.principal; + this.popIdcData.tel = item.tel; + this.addCabIDCData.name = item.name; + this.addCabIDCData.location = item.location; + this.addCabIDCData.principal = item.principal; + this.addCabIDCData.tel = item.tel; } }); } diff --git a/nezha-fronted/src/router/index.js b/nezha-fronted/src/router/index.js index 569fbee18..50caeac03 100644 --- a/nezha-fronted/src/router/index.js +++ b/nezha-fronted/src/router/index.js @@ -34,7 +34,7 @@ export default new Router({ children: [ { path: '/dashboard', - component: resolve => require(['../components/page/dashboard.vue'], resolve), + component: resolve => require(['../components/page/dashboard/panel.vue'], resolve), }, { path: '/panel',