{{$t('asset.createAssetTab.cli')}}
-
+
{{$t('config.account.account')}}
+
-
+
+
+
+
+
{{account.protocol}}
+
+ Required
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
@@ -227,6 +244,8 @@
firstShowModel: false,
visible: '',
vendorModelData: '',
+ showAccountOp: false,
+ errorProtocol: [], //校验不通过的account
assetData: {
id: '',
sn: '',
@@ -241,7 +260,8 @@
host:'',
port:'',
},
- accounts: [{
+ accounts: [],
+ /*accounts: [{
id: '',
authType: 1,
protocol:'SSH',
@@ -251,14 +271,15 @@
userTip:"",
passwordTip:'',
reloginPasswordTip:''
- }],
+ }],*/
tags: [],
exporter: 0
},
+ selectableAccountTypes: ["SSH", "TELNET", "SNMP"],
modelSize:1,
initLocationData:null,
locationInfo:null,
- accountSwitch:false,//true 开启,false 关闭
+ //accountSwitch:false,//true 开启,false 关闭
accountData: '',
assetViewData: {
assetType: '',
@@ -459,7 +480,20 @@
'assetData.idcId': function(n, o) {
this.addCabinetData.idcId = n;
},
- accountSwitch(n) {
+ 'assetData.accounts': {
+ deep: true,
+ handler(n) {
+ let temp = ["SSH", "TELNET", "SNMP"];
+ n.forEach(item => {
+ let i = temp.indexOf(item.protocol);
+ if (i > -1) {
+ temp.splice(i, 1);
+ }
+ });
+ this.selectableAccountTypes = temp;
+ }
+ },
+ /*accountSwitch(n) {
if (n) {
if (!this.assetData.accounts[0]) {
!this.assetData.accounts.push({
@@ -487,7 +521,7 @@
}else{
this.changeProtocolSwitch=true;
}
- },
+ },*/
locationInfo:{
deep:true,
handler(n,o){
@@ -509,6 +543,64 @@
this.$refs.tagEditBoxScrollbar.update();
});
},
+ addAccount(type) {
+ if (type == "SSH") {
+ this.assetData.accounts.push({
+ authType: 1,
+ protocol: "SSH",
+ port: 22,
+ params: {
+ user: "",
+ method: "password",
+ password: "",
+ key: "",
+ passwordKey: ""
+ }
+ });
+ } else if (type == "TELNET") {
+ this.assetData.accounts.push({
+ protocol: "TELNET",
+ port: 23,
+ params: {
+ user: "",
+ password: "",
+ userTip: "",
+ passwordTip: "",
+ reloginTip: ""
+ }
+ });
+ } else if (type == "SNMP") {
+ this.assetData.accounts.push({
+ protocol: "SNMP",
+ port: 161,
+ params: {
+ version:2,
+ community:"public",
+ security_name:"",
+ security_level:"",
+ auth_password:"",
+ priv_password:"",
+ auth_protocol:"",
+ priv_protocol:"",
+ context_name:""
+ }
+ });
+ }
+ this.accountType = type;
+ this.showAccountOp = false;
+ this.$nextTick(() => {
+ let sbWrap = this.$refs.scrollbar.$refs.wrap;
+ sbWrap.scrollTop = sbWrap.scrollHeight;
+ });
+ },
+ removeAccount(index) {
+ this.assetData.accounts.splice(index, 1);
+ if (this.assetData.accounts.length > 0) {
+ this.accountType = this.assetData.accounts[0].protocol;
+ } else {
+ this.accountType = "";
+ }
+ },
removeTag: function(index) {
this.assetData.tags.splice(index, 1);
this.$nextTick(() => {
@@ -525,6 +617,7 @@
this.getIDCOptionData();
this.getVendorOptionData();
this.getAssetTypeOptionData();
+ this.showAccountOp = false;
},
editQuit() {
for (let i of this.assetTypeOptionData) {
@@ -595,8 +688,12 @@
this.assetData.state = this.obj.state
this.assetData.idcId = this.obj.idc.id;
this.assetData.tags = this.obj.tags;
+ this.assetData.accounts = this.obj.accounts;
this.assetData.cabinetId = this.obj.cabinet == null ? '' : this.obj.cabinet.id
this.assetData.purchaseDate = this.obj.purchaseDate;
+ if (this.assetData.accounts && this.assetData.accounts.length > 0) {
+ this.accountType = this.assetData.accounts[0].protocol.toUpperCase();
+ }
// this.assetData.accounts[0].id = this.obj.accounts[0].id
// this.assetData.accounts[0].authType = this.obj.accounts[0].authType
// this.assetData.accounts[0].user = this.obj.accounts[0].user
@@ -604,12 +701,12 @@
// this.assetData.accounts[0].port = this.obj.accounts[0].port
// this.assetData.accounts[0].cert = this.obj.accounts[0].privateKey
this.assetData.accounts=this.obj.accounts[0]?this.obj.accounts:[];
- this.accountSwitch=this.assetData.accounts.length>0;
+ //this.accountSwitch=this.assetData.accounts.length>0;
this.idcSelectedData.location = this.obj.idc.location
this.idcSelectedData.principal = this.obj.idc.principal
this.idcSelectedData.tel = this.obj.idc.tel
this.cabinetSelectedData.uSize = this.obj.cabinet == null ? '' : this.obj.cabinet.uSize
- this.cabinetSelectedData.remark = this.obj.cabinet == null ? '' : this.obj.cabinet.remark
+ this.cabinetSelectedData.remark = this.obj.cabinet == null ? '' : this.obj.cabinet.remark;
this.getAllModelOptionData(this.assetType);
} else {
this.resetAsset();
@@ -739,17 +836,7 @@
port:'',
},
locationInfo:null,
- accounts: [{
- id: '',
- authType: 1,
- protocol: 'SSH',
- user: '',
- pwd: '',
- port: '',
- userTip:"",
- passwordTip:'',
- reloginPasswordTip:''
- }],
+ accounts: [],
tags: []
};
this.assetType = '';
@@ -790,12 +877,14 @@
}
}
- if (!this.accountSwitch) {
+ /*if (!this.accountSwitch) {
this.assetData.accounts = [];
- }
+ }*/
- if(this.$refs.accountConfigBox&&this.$refs.accountConfigBox.length>0){
- this.$refs.accountConfigBox[0].validateAccount();
+ if(this.$refs.accountConfigBox && this.$refs.accountConfigBox.length > 0) {
+ this.$refs.accountConfigBox.forEach(box => {
+ box.validateAccount();
+ });
}
this.$refs.assetEditForm.validate((valid) => {
@@ -896,8 +985,14 @@
})
}
},
- setAccountValideResult:function(result){
- this.accountValideResult=result;
+ setAccountValideResult(result, protocol) {
+ this.accountValideResult = result;
+ let index = this.errorProtocol.indexOf(protocol);
+ if (result) {
+ index != -1 ? this.errorProtocol.splice(index, 1) : "";
+ } else {
+ index == -1 ? this.errorProtocol.push(protocol) : "";
+ }
},
//新增型号弹框关闭后重置弹框内容
resetVendor() {
@@ -982,6 +1077,13 @@
}
},
+ changeProtocolType(type) {
+ this.accountType = type;
+ this.$nextTick(() => {
+ let sbWrap = this.$refs.scrollbar.$refs.wrap;
+ sbWrap.scrollTop = sbWrap.scrollHeight;
+ });
+ },
deleteData(data, item) {
this.$confirm(this.$t("tip.confirmDelete"), {
confirmButtonText: this.$t("tip.yes"),
diff --git a/nezha-fronted/src/components/common/rightBox/moduleBox.vue b/nezha-fronted/src/components/common/rightBox/moduleBox.vue
index 27ca49fcf..8289d0803 100644
--- a/nezha-fronted/src/components/common/rightBox/moduleBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/moduleBox.vue
@@ -42,7 +42,7 @@
-