@@ -3,11 +3,11 @@
< div class = "right-box right-box-module" v-if = "rightBox.show" v-clickoutside="clickos" >
< div class = "right-box right-box-module" v-if = "rightBox.show" v-clickoutside="clickos" >
< ! - - begin - -顶部按钮 - - >
< ! - - begin - -顶部按钮 - - >
< div class = "right-box-top-btns" >
< div class = "right-box-top-btns" >
< button id = "module-del" type = "button" v-if = "m odule.id != '' && rightBox.isEdit" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82" >
< button id = "module-del" type = "button" v-if = "currentM odule.id != '' && rightBox.isEdit" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82" >
< span class = "right-box-top-btn-icon" > < i class = "el-icon-delete" > < / i > < / span >
< span class = "right-box-top-btn-icon" > < i class = "el-icon-delete" > < / i > < / span >
< span class = "right-box-top-btn-txt" > { { $t ( 'overall.delete' ) } } < / span >
< span class = "right-box-top-btn-txt" > { { $t ( 'overall.delete' ) } } < / span >
< / button >
< / button >
< button v-if = "!rightBox.isEdit && m odule.buildIn != 1" id="module-save" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82" >
< button v-if = "!rightBox.isEdit && currentM odule.buildIn != 1" id="module-save" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82" >
< span class = "right-box-top-btn-icon" > < i class = "nz-icon nz-icon-edit" > < / i > < / span >
< span class = "right-box-top-btn-icon" > < i class = "nz-icon nz-icon-edit" > < / i > < / span >
< span class = "right-box-top-btn-txt" > { { $t ( 'overall.edit' ) } } < / span >
< span class = "right-box-top-btn-txt" > { { $t ( 'overall.edit' ) } } < / span >
< / button >
< / button >
@@ -20,28 +20,37 @@
<!-- begin -- 表单 -- >
<!-- begin -- 表单 -- >
< el-scrollbar class = "right-box-form-box" ref = "scrollbar" >
< el-scrollbar class = "right-box-form-box" ref = "scrollbar" >
< el-form class = "right-box-form" :model = "m odule" label -position = " top " :rules = "rules" ref = "moduleForm" >
< el-form class = "right-box-form" :model = "currentM odule" label -position = " top " :rules = "rules" ref = "moduleForm" >
< el-form-item : label = '$t("project.project.project")' prop = "project" >
< el-form-item : label = '$t("project.project.project")' prop = "project" >
< el-select v-if = "rightBox.isEdit" value-key="id" popper-class="config-dropdown" v-model="m odule.project" placeholder="" size="small" >
< el-select v-if = "rightBox.isEdit" value-key="id" popper-class="config-dropdown" v-model="currentM odule.project" placeholder="" size="small" >
< el -option :id = "'module-project-'+item.id" v-for = "item in projectList" :key="item.id" :label="item.name" :value="item" > < / el -option >
< el -option :id = "'module-project-'+item.id" v-for = "item in projectList" :key="item.id" :label="item.name" :value="item" > < / el -option >
< / el-select >
< / el-select >
< div v-if = "!rightBox.isEdit && m odule.project" class="right-box-form-content-txt" > {{ m odule.project.name}} < / div >
< div v-if = "!rightBox.isEdit && currentM odule.project" class="right-box-form-content-txt" > {{ currentM odule.project.name}} < / div >
< / el -form -item >
< / el -form -item >
< el-form-item : label = '$t("project.module.moduleName")' prop = "name" >
< el-form-item : label = '$t("project.module.moduleName")' prop = "name" >
< el-input v-if = "rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model="m odule.name" size="small" > < / el -input >
< el-input v-if = "rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model="currentM odule.name" size="small" > < / el -input >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ m odule.name}} < / div >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ currentM odule.name}} < / div >
< / el -form -item >
< / el -form -item >
< el-form-item :label = "$t('overall.type')" prop = "type" >
<!-- < el-form-item :label = "$t('overall.type')" prop = "type" >
< el-radio-group v-model = "module.type" size="small" @change="updateScrollbar" :disabled="module.id" >
< el-radio-group v-model = "module.type" size="small" @change="updateScrollbar" :disabled="module.id ? true : false " >
< el -radio -button label = "http" > < / el-radio-button >
< el -radio -button label = "http" > < / el-radio-button >
< el-radio-button label = "snmp" > < / el-radio-button >
< el-radio-button label = "snmp" > < / el-radio-button >
< / el-radio-group >
< / el-radio-group >
< / el-form-item >
< / el-form-item > -- >
< div class = "nz-tab module-box-type" >
< div class = "nz-tab-item-box" @click ="changeType('http')" id = "module-type-1" >
< div class = "nz-tab-item" : class = "{'nz-tab-item-active' : currentModule.type.toLowerCase() == 'http', 'unclickable': currentModule.id}" > HTTP < / div >
< / div >
< div @click ="changeType('snmp')" class = "nz-tab-item-box" id = "module-type-2" >
< div class = "nz-tab-item" : class = "{'nz-tab-item-active' : currentModule.type.toLowerCase() == 'snmp', 'unclickable': currentModule.id}" > SNMP < / div >
< / div >
< / div >
<!-- snmp表单 -- >
<!-- snmp表单 -- >
< template v-if = "m odule.type && m odule.type == 'snmp'" >
< template v-if = "currentM odule.type && currentM odule.type == 'snmp'" >
< div class = "right-box-sub-title" > SNMP < / div >
< div class = "right-box-sub-title" > SNMP setting < / div >
< div class = "line-100 right-box-line" > < / div >
< div class = "line-100 right-box-line" > < / div >
< el-row >
< el-row >
@@ -50,7 +59,7 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "walkStr" >
< el-form-item prop = "walkStr" >
< el-input class = "snmp-walk" v-model = "m odule.walkStr" autosize type="textarea" :placeholder="$t('tip.pressEnterToAdd')" > < / el -input >
< el-input class = "snmp-walk" v-model = "currentM odule.walkStr" autosize type="textarea" :placeholder="$t('tip.pressEnterToAdd')" > < / el -input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
@@ -61,7 +70,7 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "version" >
< el-form-item prop = "version" >
< el-radio-group v -model .number = " m odule.version" size = "small" @change ="updateScrollbar" >
< el-radio-group v -model .number = " currentM odule.version" size = "small" >
< el-radio-button :label = "2" > < / el-radio-button >
< el-radio-button :label = "2" > < / el-radio-button >
< el-radio-button :label = "3" > < / el-radio-button >
< el-radio-button :label = "3" > < / el-radio-button >
< / el-radio-group >
< / el-radio-group >
@@ -75,7 +84,7 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "max_repetitions" >
< el-form-item prop = "max_repetitions" >
< el-input v -model .number = " m odule.max_repetitions" size = "small" > < / el-input >
< el-input v -model .number = " currentM odule.max_repetitions" size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
@@ -86,7 +95,7 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "retries" >
< el-form-item prop = "retries" >
< el-input v -model .number = " m odule.retries" size = "small" > < / el-input >
< el-input v -model .number = " currentM odule.retries" size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
@@ -97,7 +106,7 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "timeout" >
< el-form-item prop = "timeout" >
< el-input v -model .number = " m odule.timeout" size = "small" >
< el-input v -model .number = " currentM odule.timeout" size = "small" >
< template slot = "append" > second < / template >
< template slot = "append" > second < / template >
< / el-input >
< / el-input >
< / el-form-item >
< / el-form-item >
@@ -118,20 +127,20 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "community" >
< el-form-item prop = "community" >
< el-input v -model .trim = " m odule.community" maxlength = "64" show -word -limit size = "small" > < / el-input >
< el-input v -model .trim = " currentM odule.community" maxlength = "64" show -word -limit size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
<!-- SNMP V3 setting -- >
<!-- SNMP V3 setting -- >
< template v-if = "m odule.version == 3" >
< template v-if = "currentM odule.version == 3" >
< el -row >
< el -row >
< el-col :span = "6" >
< el-col :span = "6" >
< div class = "sub-label sub-label-required" > { { $t ( 'login.username' ) } } < / div >
< div class = "sub-label sub-label-required" > { { $t ( 'login.username' ) } } < / div >
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "username" >
< el-form-item prop = "username" >
< el-input v -model .trim = " m odule.username" maxlength = "64" show -word -limit size = "small" > < / el-input >
< el-input v -model .trim = " currentM odule.username" maxlength = "64" show -word -limit size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
@@ -142,7 +151,7 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "security_level" >
< el-form-item prop = "security_level" >
< el-radio-group v-model = "m odule.security_level" size="small" @change="updateScrollbar" >
< el-radio-group v-model = "currentM odule.security_level" size="small" @change="updateScrollbar" >
< el -radio -button label = "noAuthNoPriv" > < / el-radio-button >
< el -radio -button label = "noAuthNoPriv" > < / el-radio-button >
< el-radio-button label = "authNoPriv" > < / el-radio-button >
< el-radio-button label = "authNoPriv" > < / el-radio-button >
< el-radio-button label = "authPriv" > < / el-radio-button >
< el-radio-button label = "authPriv" > < / el-radio-button >
@@ -151,24 +160,24 @@
< / el-col >
< / el-col >
< / el-row >
< / el-row >
< el-row v-if = "m odule.security_level == 'authNoPriv' || m odule.security_level == 'authPriv'" >
< el-row v-if = "currentM odule.security_level == 'authNoPriv' || currentM odule.security_level == 'authPriv'" >
< el -col :span = "6" >
< el -col :span = "6" >
< div class = "sub-label sub-label-required" > { { $t ( 'login.password' ) } } < / div >
< div class = "sub-label sub-label-required" > { { $t ( 'login.password' ) } } < / div >
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "password" >
< el-form-item prop = "password" >
< el-input v -model .trim = " m odule.password" maxlength = "64" show -word -limit size = "small" > < / el-input >
< el-input v -model .trim = " currentM odule.password" maxlength = "64" show -word -limit size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
< el-row v-if = "m odule.security_level == 'authNoPriv' || m odule.security_level == 'authPriv'" >
< el-row v-if = "currentM odule.security_level == 'authNoPriv' || currentM odule.security_level == 'authPriv'" >
< el -col :span = "6" >
< el -col :span = "6" >
< div class = "sub-label" > { { $t ( 'project.module.authProtocol' ) } } < / div >
< div class = "sub-label" > { { $t ( 'project.module.authProtocol' ) } } < / div >
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "auth_protocol" >
< el-form-item prop = "auth_protocol" >
< el-radio-group v-model = "m odule.auth_protocol" size="small" >
< el-radio-group v-model = "currentM odule.auth_protocol" size="small" >
< el -radio -button label = "MD5" > < / el-radio-button >
< el -radio -button label = "MD5" > < / el-radio-button >
< el-radio-button label = "SHA" > < / el-radio-button >
< el-radio-button label = "SHA" > < / el-radio-button >
< / el-radio-group >
< / el-radio-group >
@@ -176,13 +185,13 @@
< / el-col >
< / el-col >
< / el-row >
< / el-row >
< el-row v-if = "m odule.security_level == 'authPriv'" >
< el-row v-if = "currentM odule.security_level == 'authPriv'" >
< el -col :span = "6" >
< el -col :span = "6" >
< div class = "sub-label" > { { $t ( 'project.module.privProtocol' ) } } < / div >
< div class = "sub-label" > { { $t ( 'project.module.privProtocol' ) } } < / div >
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "priv_protocol" >
< el-form-item prop = "priv_protocol" >
< el-radio-group v-model = "m odule.priv_protocol" size="small" >
< el-radio-group v-model = "currentM odule.priv_protocol" size="small" >
< el -radio -button label = "DES" > < / el-radio-button >
< el -radio -button label = "DES" > < / el-radio-button >
< el-radio-button label = "AES" > < / el-radio-button >
< el-radio-button label = "AES" > < / el-radio-button >
< / el-radio-group >
< / el-radio-group >
@@ -190,13 +199,13 @@
< / el-col >
< / el-col >
< / el-row >
< / el-row >
< el-row v-if = "m odule.security_level == 'authPriv'" >
< el-row v-if = "currentM odule.security_level == 'authPriv'" >
< el -col :span = "6" >
< el -col :span = "6" >
< div class = "sub-label sub-label-required" > { { $t ( 'project.module.privPassword' ) } } < / div >
< div class = "sub-label sub-label-required" > { { $t ( 'project.module.privPassword' ) } } < / div >
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "priv_password" >
< el-form-item prop = "priv_password" >
< el-input v -model .trim = " m odule.priv_password" maxlength = "64" show -word -limit size = "small" > < / el-input >
< el-input v -model .trim = " currentM odule.priv_password" maxlength = "64" show -word -limit size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
@@ -208,15 +217,15 @@
< / el-col >
< / el-col >
< el-col :span = "18" >
< el-col :span = "18" >
< el-form-item prop = "context_name" >
< el-form-item prop = "context_name" >
< el-input v -model .trim = " m odule.context_name" maxlength = "64" show -word -limit size = "small" > < / el-input >
< el-input v -model .trim = " currentM odule.context_name" maxlength = "64" show -word -limit size = "small" > < / el-input >
< / el-form-item >
< / el-form-item >
< / el-col >
< / el-col >
< / el-row >
< / el-row >
< / template >
< / template >
< el-form-item : label = '$t("project.module.description")' prop = "remark" >
< el-form-item : label = '$t("project.module.description")' prop = "remark" >
< el-input v-if = "rightBox.isEdit" type="textarea" placeholder="" maxlength="1024" show-word-limit v-model="m odule.remark" size="small" > < / el -input >
< el-input v-if = "rightBox.isEdit" type="textarea" placeholder="" maxlength="1024" show-word-limit v-model="currentM odule.remark" size="small" > < / el -input >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ m odule.remark}} < / div >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ currentM odule.remark}} < / div >
< / el -form -item >
< / el -form -item >
< div class = "right-box-form-tip" v-if = "rightBox.isEdit" >
< div class = "right-box-form-tip" v-if = "rightBox.isEdit" >
@@ -226,13 +235,13 @@
< / div >
< / div >
< el-form-item : label = '$t("project.endpoint.port")' prop = "port" >
< el-form-item : label = '$t("project.endpoint.port")' prop = "port" >
< el-input v-if = "rightBox.isEdit" placeholder="" v-model.number="m odule.port" size="small" > < / el -input >
< el-input v-if = "rightBox.isEdit" placeholder="" v-model.number="currentM odule.port" size="small" > < / el -input >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ m odule.port}} < / div >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ currentM odule.port}} < / div >
< / el -form -item >
< / el -form -item >
< el-form-item v-if = "m odule.type && m odule.type.toLowerCase() == 'http'" :label='$t("project.endpoint.path")' prop="path" >
< el-form-item v-if = "currentM odule.type && currentM odule.type.toLowerCase() == 'http'" :label='$t("project.endpoint.path")' prop="path" >
< el -input v-if = "rightBox.isEdit" placeholder="" v-model="m odule.path" size="small" > < / el -input >
< el -input v-if = "rightBox.isEdit" placeholder="" v-model="currentM odule.path" size="small" > < / el -input >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ m odule.path}} < / div >
< div v-if = "!rightBox.isEdit" class="right-box-form-content-txt" > {{ currentM odule.path}} < / div >
< / el -form -item >
< / el -form -item >
< el-form-item class = "right-box-form-param" >
< el-form-item class = "right-box-form-param" >
@@ -250,7 +259,7 @@
< / template >
< / template >
< div v-if = "rightBox.isEdit" class="param-box param-box-module" >
< div v-if = "rightBox.isEdit" class="param-box param-box-module" >
< div class = "param-box-row" v-for = "(item, index) in m odule.paramObj" >
< div class = "param-box-row" v-for = "(item, index) in currentM odule.paramObj" >
< el -form -item class = "param-box-row-key" : rules = "{required: true, message: $t('validate.required'), trigger: 'blur'}" : prop = "'paramObj.' + index + '.key'" >
< el -form -item class = "param-box-row-key" : rules = "{required: true, message: $t('validate.required'), trigger: 'blur'}" : prop = "'paramObj.' + index + '.key'" >
< el-input placeholder = "key" size = "mini" v-model = "item.key" > < / el -input >
< el-input placeholder = "key" size = "mini" v-model = "item.key" > < / el -input >
< / el-form-item >
< / el-form-item >
@@ -261,7 +270,7 @@
< span class = "param-box-row-symbol" :id = "'moduel-remove-param-'+index" @click ="removeParam(index)" > < i class = "nz-icon nz-icon-minus-square" > < / i > < / span >
< span class = "param-box-row-symbol" :id = "'moduel-remove-param-'+index" @click ="removeParam(index)" > < i class = "nz-icon nz-icon-minus-square" > < / i > < / span >
< / div >
< / div >
< / div >
< / div >
< div v-for = "(item, index) in m odule.paramObj" v-if="!rightBox.isEdit" >
< div v-for = "(item, index) in currentM odule.paramObj" v-if="!rightBox.isEdit" >
< div class = "right-box-form-content-txt" > { { item . key } } = { { item . value } } < / div >
< div class = "right-box-form-content-txt" > { { item . key } } = { { item . value } } < / div >
< / div >
< / div >
@@ -284,8 +293,7 @@
< / template >
< / template >
< script >
< script >
import { noSpecialChar } from "../js/validate" ;
import { noSpecialChar , port , nzNumber } from "../js/validate" ;
import { port } from "../js/validate" ;
export default {
export default {
name : "moduleBox" ,
name : "moduleBox" ,
@@ -295,6 +303,7 @@
} ,
} ,
data ( ) {
data ( ) {
return {
return {
currentModule : { } ,
rightBox : {
rightBox : {
show : false ,
show : false ,
title : '' ,
title : '' ,
@@ -323,6 +332,15 @@
priv _password : [
priv _password : [
{ required : true , message : this . $t ( 'validate.required' ) , trigger : 'blur' }
{ required : true , message : this . $t ( 'validate.required' ) , trigger : 'blur' }
] ,
] ,
max _repetitions : [
{ validator : nzNumber , trigger : 'blur' } ,
] ,
retries : [
{ validator : nzNumber , trigger : 'blur' } ,
] ,
timeout : [
{ validator : nzNumber , trigger : 'blur' } ,
] ,
} ,
} ,
projectList : [ ] ,
projectList : [ ] ,
}
}
@@ -341,32 +359,39 @@
clickos ( ) {
clickos ( ) {
this . esc ( ) ;
this . esc ( ) ;
} ,
} ,
changeType ( type ) {
if ( this . currentModule . id ) {
return ;
}
this . currentModule . type = type ;
this . updateScrollbar ( ) ;
} ,
//转化snmpParam属性
//转化snmpParam属性
parseSnmpParam ( ) {
parseSnmpParam ( module ) {
let snmpObj = { //下划线命名是因为业务需求
let snmpObj = { //下划线命名是因为业务需求
walk : this . module . walkStr . split ( /\n/ ) ,
walk : module . walkStr . split ( /\n/ ) ,
version : this . module . version , //2/3
version : module . version , //2/3
max _repetitions : this . module . max _repetitions ? this . module . max _repetitions : 25 ,
max _repetitions : module . max _repetitions ? module . max _repetitions : 25 ,
retries : this . module . retries ? this . module . retries : 3 ,
retries : module . retries ? module . retries : 3 ,
timeout : this . module . timeout ? this . module . timeout + "s" : "10s" , //s
timeout : module . timeout ? module . timeout + "s" : "10s" , //s
auth : {
auth : {
community : this . module . community ,
community : module . community ,
}
}
} ;
} ;
if ( this . module . version == 3 ) {
if ( module . version == 3 ) {
snmpObj . auth . username = this . module . username ;
snmpObj . auth . username = module . username ;
snmpObj . auth . security _level = this . module . security _level ;
snmpObj . auth . security _level = module . security _level ;
snmpObj . auth . context _name = module . context _name ;
}
}
if ( this . module . security _level == "authNoPriv" || this . module . security _level == "authPriv" ) {
if ( module . security _level == "authNoPriv" || module . security _level == "authPriv" ) {
snmpObj . auth . password = this . module . password ;
snmpObj . auth . password = module . password ;
snmpObj . auth . auth _protocol = this . module . auth _protocol ;
snmpObj . auth . auth _protocol = module . auth _protocol ;
if ( this . module . security _level != "authNoPriv" ) {
if ( module . security _level != "authNoPriv" ) {
snmpObj . auth . priv _password = this . module . priv _password ;
snmpObj . auth . priv _password = module . priv _password ;
snmpObj . auth . priv _protocol = this . module . priv _protocol ;
snmpObj . auth . priv _protocol = module . priv _protocol ;
}
}
}
}
this . module . snmpParam = JSON . stringify ( snmpObj ) ;
module . snmpParam = JSON . stringify ( snmpObj ) ;
} ,
} ,
//回显时解析snmpParam
//回显时解析snmpParam
reparseSnmpParam ( module ) {
reparseSnmpParam ( module ) {
@@ -380,6 +405,7 @@
if ( snmpObj . version == 3 ) {
if ( snmpObj . version == 3 ) {
module . username = snmpObj . auth . username ;
module . username = snmpObj . auth . username ;
module . security _level = snmpObj . auth . security _level ;
module . security _level = snmpObj . auth . security _level ;
module . context _name = snmpObj . auth . context _name ;
}
}
if ( snmpObj . auth . security _level == "authNoPriv" || snmpObj . auth . security _level == "authPriv" ) {
if ( snmpObj . auth . security _level == "authNoPriv" || snmpObj . auth . security _level == "authPriv" ) {
module . password = snmpObj . auth . password ;
module . password = snmpObj . auth . password ;
@@ -392,19 +418,19 @@
} ,
} ,
/*保存*/
/*保存*/
save ( ) {
save ( ) {
this . m odule. param = this . paramToJson ( this . m odule. paramObj ) ;
this . currentM odule. param = this . paramToJson ( this . currentM odule. paramObj ) ;
this . $refs . moduleForm . validate ( ( valid ) => {
this . $refs . moduleForm . validate ( ( valid ) => {
if ( valid ) {
if ( valid ) {
if ( this . m odule. type . toLowerCase ( ) == 'snmp' ) {
if ( this . currentM odule. type . toLowerCase ( ) == 'snmp' ) {
this . parseSnmpParam ( ) ;
this . parseSnmpParam ( this . currentModule ) ;
} else {
} else {
if ( this . m odule. snmpParam ) {
if ( this . currentM odule. snmpParam ) {
this . m odule. snmpParam = "" ;
this . currentM odule. snmpParam = "" ;
}
}
}
}
this . m odule. projectId = this . m odule. project . id ;
this . currentM odule. projectId = this . currentM odule. project . id ;
if ( this . m odule. id ) {
if ( this . currentM odule. id ) {
this . $put ( 'module' , this . m odule) . then ( response => {
this . $put ( 'module' , this . currentM odule) . then ( response => {
if ( response . code === 200 ) {
if ( response . code === 200 ) {
this . $message ( { duration : 1000 , type : 'success' , message : this . $t ( "tip.saveSuccess" ) } ) ;
this . $message ( { duration : 1000 , type : 'success' , message : this . $t ( "tip.saveSuccess" ) } ) ;
this . $store . commit ( 'moduleListChange' ) ;
this . $store . commit ( 'moduleListChange' ) ;
@@ -415,7 +441,7 @@
}
}
} ) ;
} ) ;
} else {
} else {
this . $post ( 'module' , this . m odule) . then ( response => {
this . $post ( 'module' , this . currentM odule) . then ( response => {
if ( response . code === 200 ) {
if ( response . code === 200 ) {
this . $message ( { duration : 1000 , type : 'success' , message : this . $t ( "tip.saveSuccess" ) } ) ;
this . $message ( { duration : 1000 , type : 'success' , message : this . $t ( "tip.saveSuccess" ) } ) ;
this . $store . commit ( 'moduleListChange' ) ;
this . $store . commit ( 'moduleListChange' ) ;
@@ -433,7 +459,7 @@
saveOrToEdit : function ( ) {
saveOrToEdit : function ( ) {
if ( ! this . rightBox . isEdit ) {
if ( ! this . rightBox . isEdit ) {
this . rightBox . isEdit = true ;
this . rightBox . isEdit = true ;
this . rightBox . title = this . $t ( "project.module.editModule" ) + " ID: " + this . m odule. id ;
this . rightBox . title = this . $t ( "project.module.editModule" ) + " ID: " + this . currentM odule. id ;
} else {
} else {
this . save ( ) ;
this . save ( ) ;
}
}
@@ -445,7 +471,7 @@
cancelButtonText : this . $t ( "tip.no" ) ,
cancelButtonText : this . $t ( "tip.no" ) ,
type : 'warning'
type : 'warning'
} ) . then ( ( ) => {
} ) . then ( ( ) => {
this . $delete ( "module?ids=" + this . m odule. id ) . then ( response => {
this . $delete ( "module?ids=" + this . currentM odule. id ) . then ( response => {
if ( response . code === 200 ) {
if ( response . code === 200 ) {
this . $message ( { duration : 1000 , type : 'success' , message : this . $t ( "tip.deleteSuccess" ) } ) ;
this . $message ( { duration : 1000 , type : 'success' , message : this . $t ( "tip.deleteSuccess" ) } ) ;
this . rightBox . show = false ;
this . rightBox . show = false ;
@@ -478,17 +504,17 @@
// 清除param
// 清除param
clearAllParam : function ( ) {
clearAllParam : function ( ) {
this . m odule. paramObj = [ ] ;
this . currentM odule. paramObj = [ ] ;
} ,
} ,
// 新增param
// 新增param
addParam : function ( ) {
addParam : function ( ) {
this . m odule. paramObj . push ( { key : '' , value : '' } ) ;
this . currentM odule. paramObj . push ( { key : '' , value : '' } ) ;
} ,
} ,
// 移除单个param
// 移除单个param
removeParam : function ( index ) {
removeParam : function ( index ) {
this . m odule. paramObj . splice ( index , 1 ) ;
this . currentM odule. paramObj . splice ( index , 1 ) ;
} ,
} ,
//将param转为json字符串格式
//将param转为json字符串格式
@@ -521,19 +547,31 @@
immediate : true ,
immediate : true ,
deep : true ,
deep : true ,
handler ( n , o ) {
handler ( n , o ) {
if ( n ) {
if ( n . type && n . type . toLowerCase ( ) == 'snmp' ) {
n . port = 161 ;
this . reparseSnmpParam ( n ) ;
}
}
if ( n && n . id ) {
if ( n && n . id ) {
this . rightBox . title = this . rightBox . isEdit ? this . $t ( "project.module.editModule" ) + " ID: " + n . id : this . $t ( "project.module.module" ) + " ID: " + n . id ;
this . rightBox . title = this . rightBox . isEdit ? this . $t ( "project.module.editModule" ) + " ID: " + n . id : this . $t ( "project.module.module" ) + " ID: " + n . id ;
} else {
if ( n . snmpParam ) {
this . reparseSnmpParam ( n ) ;
}
this . currentModule = JSON . parse ( JSON . stringify ( n ) ) ;
} else if ( n ) {
if ( ! n . type ) {
if ( ! n . type ) {
n . type = 'http' ;
n . type = 'http' ;
} else if ( n . type . toLowerCase ( ) == 'snmp' ) {
if ( n . snmpParam ) {
this . reparseSnmpParam ( n ) ;
}
}
}
this . rightBox . title = this . $t ( "project.module.createModule" ) ;
this . rightBox . title = this . $t ( "project.module.createModule" ) ;
this . currentModule = JSON . parse ( JSON . stringify ( n ) ) ;
}
}
} ,
currentModule : {
immediate : true ,
deep : true ,
handler ( n , o ) {
if ( n . type . toLowerCase ( ) == 'snmp' ) {
n . port = 161 ;
}
}
}
}
} ,
} ,
@@ -557,4 +595,7 @@
color : # F56C6C ;
color : # F56C6C ;
margin - right : 4 px ;
margin - right : 4 px ;
}
}
. module - box - type {
margin : 25 px 0 10 px - 15 px ;
}
< / style >
< / style >