fix:修复module编辑页bug

This commit is contained in:
wangwenrui
2020-09-01 13:48:16 +08:00
parent 4ab7f5cdac
commit a9564b8fea
2 changed files with 20 additions and 28 deletions

View File

@@ -7,7 +7,7 @@
active="1" active="1"
unique-opened unique-opened
> >
<el-submenu :index="'-3'" popper-class="nz-submenu" class="icon-menu-item"> <el-submenu :index="'-3'" popper-class="nz-submenu" class="icon-menu-item" :disabled="!linkData||linkData.length <1" >
<template slot="title"> <template slot="title">
<i class="nz-icon-navmore nz-icon" style="font-size: 17px;"></i> <i class="nz-icon-navmore nz-icon" style="font-size: 17px;"></i>
</template> </template>
@@ -219,7 +219,7 @@
projectData: [], //顶部菜单project列表中的数据 projectData: [], //顶部菜单project列表中的数据
editProject: {id: '', name: '', remark: ''}, //新增/编辑的project editProject: {id: '', name: '', remark: ''}, //新增/编辑的project
currentProject: {id: '', name: '', remark: ''}, //module/endpoint弹框用来回显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此处固定为空对象 currentModule: {id: '', name: '', project: {}, port: '', path: '', param: '', paramObj: []}, //endpoint弹框用来回显module此处固定为空对象
editEndpoint: { //新增/编辑的endpoint editEndpoint: { //新增/编辑的endpoint
id: '', id: '',
@@ -324,13 +324,12 @@
} else if (item.type == 2) { } else if (item.type == 2) {
this.rightBox.module.show = true; this.rightBox.module.show = true;
this.editModule = { this.editModule = {
id: '',
name: '', name: '',
project: this.$store.state.currentProject, project: this.$store.state.currentProject,
port: '', port: 9100,
path: '', path: '',
param: '', param: '',
type: '', type: 'http',
paramObj: [], paramObj: [],
snmpParam: '', snmpParam: '',
//snmp setting 下划线命名是因为业务需求 //snmp setting 下划线命名是因为业务需求

View File

@@ -215,7 +215,7 @@
</el-row> </el-row>
</template> </template>
<el-row> <el-row v-if="editModule.version == 3">
<el-col :span="6"> <el-col :span="6">
<div class="sub-label">{{$t('project.module.contextName')}}</div> <div class="sub-label">{{$t('project.module.contextName')}}</div>
</el-col> </el-col>
@@ -443,6 +443,11 @@
return; return;
} }
this.editModule.type = type; this.editModule.type = type;
if(type == 'http'){
this.editModule.port = 9100
}else{
this.editModule.port= 161
}
this.updateScrollbar(); this.updateScrollbar();
}, },
//转化snmpParam属性 //转化snmpParam属性
@@ -474,6 +479,9 @@
}, },
//回显时解析snmpParam //回显时解析snmpParam
reparseSnmpParam(module) { reparseSnmpParam(module) {
if(!module.snmpParam){
return;
}
let snmpObj = JSON.parse(module.snmpParam); let snmpObj = JSON.parse(module.snmpParam);
module.walk = snmpObj.walk; module.walk = snmpObj.walk;
module.version = snmpObj.version; module.version = snmpObj.version;
@@ -618,30 +626,15 @@
immediate: true, immediate: true,
deep: true, deep: true,
handler(n, o) { handler(n, o) {
console.log('post module',n)
this.editModule = JSON.parse(JSON.stringify(n)); this.editModule = JSON.parse(JSON.stringify(n));
} if(n.id){
}, this.reparseSnmpParam(this.editModule)
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;
}else{ }else{
this.reparseSnmpParam(n) 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(".")));
}
} }
if (!n.type) {
n.type = 'http';
} }
} }
}, },