diff --git a/nezha-fronted/src/components/common/header.vue b/nezha-fronted/src/components/common/header.vue index 9f4715dd5..3cb35eca8 100644 --- a/nezha-fronted/src/components/common/header.vue +++ b/nezha-fronted/src/components/common/header.vue @@ -7,7 +7,7 @@ active="1" unique-opened > - + @@ -219,7 +219,7 @@ projectData: [], //顶部菜单project列表中的数据 editProject: {id: '', name: '', remark: ''}, //新增/编辑的project currentProject: {id: '', name: '', remark: ''}, //module/endpoint弹框用来回显project - editModule: {id: '', type: 'http', name: '', project: {}, port: '', path: '', param: '', paramObj: []}, //新增/编辑的module + editModule: { type: 'http', name: '', project: {}, port: 9100, path: '', param: '', paramObj: []}, //新增/编辑的module currentModule: {id: '', name: '', project: {}, port: '', path: '', param: '', paramObj: []}, //endpoint弹框用来回显module,此处固定为空对象 editEndpoint: { //新增/编辑的endpoint id: '', @@ -324,13 +324,12 @@ } else if (item.type == 2) { this.rightBox.module.show = true; this.editModule = { - id: '', name: '', project: this.$store.state.currentProject, - port: '', + port: 9100, path: '', param: '', - type: '', + type: 'http', paramObj: [], snmpParam: '', //snmp setting 下划线命名是因为业务需求 diff --git a/nezha-fronted/src/components/common/rightBox/moduleBox.vue b/nezha-fronted/src/components/common/rightBox/moduleBox.vue index c3f62575e..4427ba51e 100644 --- a/nezha-fronted/src/components/common/rightBox/moduleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/moduleBox.vue @@ -215,7 +215,7 @@ - +
{{$t('project.module.contextName')}}
@@ -443,6 +443,11 @@ return; } this.editModule.type = type; + if(type == 'http'){ + this.editModule.port = 9100 + }else{ + this.editModule.port= 161 + } this.updateScrollbar(); }, //转化snmpParam属性 @@ -474,6 +479,9 @@ }, //回显时解析snmpParam reparseSnmpParam(module) { + if(!module.snmpParam){ + return; + } let snmpObj = JSON.parse(module.snmpParam); module.walk = snmpObj.walk; module.version = snmpObj.version; @@ -618,30 +626,15 @@ immediate: true, deep: true, handler(n, o) { - console.log('post module',n) this.editModule = JSON.parse(JSON.stringify(n)); - } - }, - editModule: { - immediate: true, - deep: true, - handler(n, o) { - if (!n.id && n.type && n.type.toLowerCase() == 'snmp') { - n.port = 161; - this.expandedWalkData = []; - this.$nextTick(() => { - this.$refs.selectWalk.show(); - }); - for (let i = 0; i < n.walk.length; i++) { - this.expandedWalkData.push(n.walk[i].substring(0, n.walk[i].lastIndexOf("."))); - } - } else if (!n.id && n.type && n.type.toLowerCase() == 'http') { - n.port = 9100; + if(n.id){ + this.reparseSnmpParam(this.editModule) }else{ - this.reparseSnmpParam(n) - } - if (!n.type) { - n.type = 'http'; + if(n.type&&n.type.toLowerCase() == 'snmp'){ + for (let i = 0; i < this.editModule.walk.length; i++) { + this.expandedWalkData.push(this.editModule.walk[i].substring(0, this.editModule.walk[i].lastIndexOf("."))); + } + } } } },