2020-01-09 17:58:22 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2020-01-17 16:06:35 +08:00
|
|
|
<el-form label-width="120px" class="" :model="account" :rules="rules" ref="accountForm">
|
2020-03-09 08:41:21 +08:00
|
|
|
<!--<div class="nz-btn-group float-left" style="padding-top: 4px;" v-show="isEdit">
|
2020-01-13 18:48:25 +08:00
|
|
|
<button type="button" @click="changeLoginType(1)" id="account-logintype-1"
|
2020-01-09 17:58:22 +08:00
|
|
|
class="nz-btn nz-btn-size-small float-left"
|
|
|
|
|
:class="{'nz-btn-disabled nz-btn-style-normal' : account.authType == 1, 'nz-btn-style-light' : account.authType == 2}">
|
|
|
|
|
<span>{{$t('asset.createAssetTab.password')}}</span>
|
|
|
|
|
</button>
|
2020-01-13 18:48:25 +08:00
|
|
|
<button type="button" @click="changeLoginType(2)" id="account-logintype-2"
|
2020-01-09 17:58:22 +08:00
|
|
|
class="nz-btn nz-btn-size-small float-left"
|
|
|
|
|
:class="{'nz-btn-disabled nz-btn-style-normal' : account.authType == 2, 'nz-btn-style-light' : account.authType == 1}">
|
|
|
|
|
<span>{{$t('asset.createAssetTab.ssh')}}</span>
|
|
|
|
|
</button>
|
2020-01-17 16:06:35 +08:00
|
|
|
</div>-->
|
2020-03-09 08:41:21 +08:00
|
|
|
<div class="nz-tab" v-show="isEdit">
|
|
|
|
|
<div class="nz-tab-item-box" @click="changeProtocolType('SSH')" id="account-logintype-1">
|
|
|
|
|
<div class="nz-tab-item" :class="{'nz-tab-item-active' : account.protocol == 'SSH','unclickable':!isAllowedChangeProtocol&&account.protocol == 'TELNET'}">{{$t('asset.createAssetTab.sshProtocol')}}</div>
|
2020-01-09 17:58:22 +08:00
|
|
|
</div>
|
2020-03-09 08:41:21 +08:00
|
|
|
<div @click="changeProtocolType('TELNET')" class="nz-tab-item-box">
|
|
|
|
|
<div class="nz-tab-item" :class="{'nz-tab-item-active' : account.protocol == 'TELNET','unclickable':!isAllowedChangeProtocol&&account.protocol == 'SSH'}">{{$t('asset.createAssetTab.telnetProtocol')}}</div>
|
2020-01-17 16:06:35 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-03-09 08:41:21 +08:00
|
|
|
<el-form-item :label="$t('asset.createAssetTab.protocol')" size="mini" v-show="!isEdit">
|
|
|
|
|
<div class="right-box-form-content-txt" >{{account.protocol=='SSH'?$t('asset.createAssetTab.sshProtocol'):$t('asset.createAssetTab.telnetProtocol')}}</div>
|
2020-01-17 18:57:24 +08:00
|
|
|
</el-form-item>
|
2020-03-09 08:41:21 +08:00
|
|
|
<!-- <el-form-item :label="$t('asset.createAssetTab.loginType')" size="mini" v-show="!isEdit">-->
|
|
|
|
|
<!-- <div class="right-box-form-content-txt" >{{account.authType==1?$t('asset.createAssetTab.password'):$t('asset.createAssetTab.ssh')}}</div>-->
|
|
|
|
|
<!-- </el-form-item>-->
|
2020-01-09 17:58:22 +08:00
|
|
|
<el-form-item :label="$t('asset.createAssetTab.account')" prop="user">
|
2020-03-09 08:41:21 +08:00
|
|
|
<el-input autocomplete="new-password" size="small" v-model="account.user" v-show="isEdit"/>
|
|
|
|
|
<div class="right-box-form-content-txt" v-show="!isEdit">{{account.user}}</div>
|
2020-01-09 17:58:22 +08:00
|
|
|
</el-form-item>
|
2020-03-09 08:41:21 +08:00
|
|
|
<el-form-item :label="$t('asset.createAssetTab.loginType')" prop="loginType" v-show="account.protocol == 'SSH'">
|
|
|
|
|
<el-radio-group v-model="account.authType" size="small">
|
|
|
|
|
<el-radio-button label="1">{{$t('asset.createAssetTab.password')}}</el-radio-button>
|
|
|
|
|
<el-radio-button label="2">{{$t('asset.createAssetTab.ssh')}}</el-radio-button>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.password')" v-show="isEdit&&(account.authType==1 || account.protocol == 'TELNET')" >
|
2020-03-01 18:07:40 +08:00
|
|
|
<el-input autocomplete="new-password" size="small" type="password" v-model="account.pwd"/>
|
2020-01-09 17:58:22 +08:00
|
|
|
</el-form-item>
|
2020-01-16 10:43:07 +08:00
|
|
|
<el-form-item :label="$t('asset.createAssetTab.port')" prop="port" style="display: inline-block">
|
2020-03-09 08:41:21 +08:00
|
|
|
<el-input size="small" v-model.number="account.port" v-show="isEdit"/>
|
|
|
|
|
<div class="right-box-form-content-txt" v-show="!isEdit">{{account.port}}</div>
|
2020-01-09 17:58:22 +08:00
|
|
|
</el-form-item>
|
2020-03-09 08:41:21 +08:00
|
|
|
<el-form-item :label="this.$t('asset.createAssetTab.ssh')" v-show="isEdit&&(account.authType==2 && account.protocol == 'SSH')" prop="file">
|
2020-02-27 09:23:37 +08:00
|
|
|
<el-input rows="4" type="textarea" placeholder="" v-model="account.privateKey" size="small"></el-input>
|
2020-01-09 17:58:22 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2020-03-09 08:41:21 +08:00
|
|
|
|
|
|
|
|
<div class="telnet-option" v-show="isEdit && account.protocol=='TELNET'">
|
|
|
|
|
<div class="telnet-option_title clickable" @click="isShowTelnetOption">login option<i style="font-size: 12px;" :class="{'el-icon-arrow-left':!showTelnetOption,'el-icon-arrow-down':showTelnetOption}"></i></div>
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.userTip')" v-show="isEdit && account.protocol=='TELNET' && showTelnetOption">
|
|
|
|
|
<el-input type="text" size="small" v-model="account.userTip" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.passwordTip')" v-show="isEdit && account.protocol=='TELNET' && showTelnetOption">
|
|
|
|
|
<el-input type="text" size="small" v-model="account.passwordTip" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.reloginPasswordTip')" v-show="isEdit && account.protocol=='TELNET' && showTelnetOption">
|
|
|
|
|
<el-input type="text" size="small" v-model="account.reloginPasswordTip" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-01-09 17:58:22 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-01-16 17:54:04 +08:00
|
|
|
import {port} from '../../common/js/validate'
|
2020-01-09 17:58:22 +08:00
|
|
|
export default {
|
|
|
|
|
name: "accountConfig",
|
|
|
|
|
props:{
|
|
|
|
|
account:{type:Object},
|
2020-03-09 08:41:21 +08:00
|
|
|
isEdit:{type:Boolean,default:true},
|
|
|
|
|
isAllowedChangeProtocol:{type:Boolean,default:true}
|
2020-01-09 17:58:22 +08:00
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
},
|
|
|
|
|
data(){
|
|
|
|
|
return {
|
|
|
|
|
rules:{
|
|
|
|
|
user:[
|
2020-01-17 15:06:09 +08:00
|
|
|
{ required: true, message:this.$t('validate.required'),trigger: 'blur'}
|
2020-01-09 17:58:22 +08:00
|
|
|
],
|
|
|
|
|
port:[
|
2020-01-17 15:06:09 +08:00
|
|
|
{required:true,message:this.$t('validate.required'),trigger: 'blur'},
|
|
|
|
|
{ validator: port, trigger: 'blur'}
|
2020-01-09 17:58:22 +08:00
|
|
|
],
|
|
|
|
|
},
|
2020-03-09 08:41:21 +08:00
|
|
|
showTelnetOption:false
|
2020-01-09 17:58:22 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
resetData:function(){
|
|
|
|
|
this.account={
|
|
|
|
|
id:null,
|
|
|
|
|
user:"",
|
|
|
|
|
authType:1,
|
2020-03-09 08:41:21 +08:00
|
|
|
protocol:'SSH',
|
2020-01-09 17:58:22 +08:00
|
|
|
pwd:"",
|
|
|
|
|
port:null,
|
|
|
|
|
privateKey:null,
|
2020-03-09 08:41:21 +08:00
|
|
|
userTip:"",
|
|
|
|
|
passwordTip:'',
|
|
|
|
|
reloginPasswordTip:''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
isShowTelnetOption:function(){
|
|
|
|
|
this.showTelnetOption=!this.showTelnetOption;
|
|
|
|
|
if(!this.showTelnetOption){
|
|
|
|
|
this.account.userTip="";
|
|
|
|
|
this.account.passwordTip="";
|
|
|
|
|
this.account.reloginPasswordTip="";
|
2020-01-09 17:58:22 +08:00
|
|
|
}
|
|
|
|
|
},
|
2020-03-09 08:41:21 +08:00
|
|
|
telnetOptionState:function(){
|
|
|
|
|
if(this.account.userTip != ''|| this.account.passwordTip != '' || this.account.reloginPasswordTip != ''){
|
|
|
|
|
this.showTelnetOption=true;
|
2020-01-09 17:58:22 +08:00
|
|
|
}
|
2020-03-09 08:41:21 +08:00
|
|
|
},
|
|
|
|
|
changeProtocolType:function(protocolType){
|
|
|
|
|
if(this.isAllowedChangeProtocol){
|
|
|
|
|
this.account.protocol=protocolType;
|
|
|
|
|
}else{
|
|
|
|
|
return ;
|
2020-01-09 17:58:22 +08:00
|
|
|
}
|
|
|
|
|
},
|
2020-02-27 09:23:37 +08:00
|
|
|
clearPrivateKey:function(){
|
|
|
|
|
this.account.privateKey=null;
|
|
|
|
|
},
|
2020-03-09 08:41:21 +08:00
|
|
|
clearTelnetOptions:function(){
|
|
|
|
|
this.account.userTip='';
|
|
|
|
|
this.account.passwordTip='';
|
|
|
|
|
this.account.reloginPasswordTip='';
|
|
|
|
|
},
|
2020-01-09 17:58:22 +08:00
|
|
|
handleChange(file,fileList) {
|
|
|
|
|
if (fileList.length > 0) {
|
|
|
|
|
this.uploadFileList = [fileList[fileList.length - 1]]
|
|
|
|
|
}
|
|
|
|
|
this.account.uploadFile = this.uploadFileList[0];
|
|
|
|
|
this.validateFile();
|
|
|
|
|
},
|
|
|
|
|
validateAccount:function(){
|
|
|
|
|
this.validateResult=false;
|
|
|
|
|
this.$refs.accountForm.validate((valid) => {
|
2020-01-17 18:57:24 +08:00
|
|
|
this.$emit("setValidateResult",valid);
|
2020-01-09 17:58:22 +08:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
watch:{
|
|
|
|
|
account:{
|
|
|
|
|
immediate:true,
|
|
|
|
|
deep:true,
|
|
|
|
|
handler(n,o){
|
2020-03-09 08:41:21 +08:00
|
|
|
if(n.authType == 1){//密码登录
|
|
|
|
|
this.clearPrivateKey();
|
|
|
|
|
}
|
|
|
|
|
if(n.authType == 2){//公钥登录
|
|
|
|
|
this.account.pwd='';
|
|
|
|
|
}
|
|
|
|
|
if(n.protocol == 'SSH'){
|
|
|
|
|
this.showTelnetOption=false;
|
|
|
|
|
this.clearTelnetOptions();
|
|
|
|
|
}else{
|
|
|
|
|
this.clearPrivateKey();
|
|
|
|
|
}
|
|
|
|
|
this.telnetOptionState();
|
2020-01-09 17:58:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
/*去除上传文件动画start*/
|
|
|
|
|
/*.upload-demo {*/
|
|
|
|
|
/* display: flex;*/
|
|
|
|
|
/*}*/
|
|
|
|
|
/deep/ .el-list-enter-active,
|
|
|
|
|
/deep/ .el-list-leave-active {
|
|
|
|
|
transition: none;
|
|
|
|
|
}
|
2020-01-17 16:06:35 +08:00
|
|
|
.nz-tab {
|
|
|
|
|
margin-bottom: 22px;
|
|
|
|
|
margin-left: 13px;
|
|
|
|
|
}
|
2020-01-09 17:58:22 +08:00
|
|
|
/deep/ .el-list-enter,
|
|
|
|
|
/deep/ .el-list-leave-active {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
|
|
|
|
/deep/ .el-upload-list {
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
|
|
|
|
/*去除上传文件动画end*/
|
2020-03-09 08:41:21 +08:00
|
|
|
.telnet-option{
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
.telnet-option:before{
|
|
|
|
|
content: "";
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: 79.9%;
|
|
|
|
|
height: 1px;
|
|
|
|
|
background-color: lightgrey;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
margin-bottom: 18px;
|
|
|
|
|
}
|
|
|
|
|
.telnet-option .telnet-option_title{
|
|
|
|
|
display: inline-block;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
margin-bottom: 18px;
|
|
|
|
|
}
|
2020-01-09 17:58:22 +08:00
|
|
|
</style>
|