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">
|
|
|
|
|
<!--<div class="nz-btn-group float-left" style="padding-top: 4px;" v-if="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>-->
|
|
|
|
|
<div class="nz-tab" v-if="isEdit">
|
|
|
|
|
<div class="nz-tab-item-box" @click="changeLoginType(1)" id="account-logintype-1">
|
2020-01-17 18:57:24 +08:00
|
|
|
<div class="nz-tab-item" :class="{'nz-tab-item-active' : account.authType == 1}">{{$t('asset.createAssetTab.password')}}</div>
|
2020-01-09 17:58:22 +08:00
|
|
|
</div>
|
2020-01-17 16:06:35 +08:00
|
|
|
<div @click="changeLoginType(2)" class="nz-tab-item-box">
|
2020-01-17 18:57:24 +08:00
|
|
|
<div class="nz-tab-item" :class="{'nz-tab-item-active' : account.authType == 2}">{{$t('asset.createAssetTab.ssh')}}</div>
|
2020-01-17 16:06:35 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-01-17 18:57:24 +08:00
|
|
|
<el-form-item :label="$t('asset.createAssetTab.loginType')" size="mini" v-if="!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-01 18:07:40 +08:00
|
|
|
<el-input autocomplete="new-password" size="small" v-model="account.user" v-if="isEdit"/>
|
2020-01-10 18:16:25 +08:00
|
|
|
<div class="right-box-form-content-txt" v-if="!isEdit">{{account.user}}</div>
|
2020-01-09 17:58:22 +08:00
|
|
|
</el-form-item>
|
2020-01-16 18:11:15 +08:00
|
|
|
<el-form-item :label="$t('asset.createAssetTab.password')" v-show="account.authType==1" v-if="isEdit">
|
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-01 18:07:40 +08:00
|
|
|
<el-input size="small" v-model.number="account.port" v-if="isEdit"/>
|
2020-01-10 18:16:25 +08:00
|
|
|
<div class="right-box-form-content-txt" v-if="!isEdit">{{account.port}}</div>
|
2020-01-09 17:58:22 +08:00
|
|
|
</el-form-item>
|
2020-01-10 18:16:25 +08:00
|
|
|
<el-form-item :label="this.$t('asset.createAssetTab.ssh')" v-show="account.authType==2" prop="file" v-if="isEdit">
|
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>
|
|
|
|
|
</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-01-10 18:16:25 +08:00
|
|
|
isEdit:{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
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
uploadTip:''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
resetData:function(){
|
|
|
|
|
this.account={
|
|
|
|
|
id:null,
|
|
|
|
|
user:"",
|
|
|
|
|
authType:1,
|
|
|
|
|
pwd:"",
|
|
|
|
|
port:null,
|
|
|
|
|
privateKey:null,
|
|
|
|
|
uploadFile:null
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
changeLoginType:function(loginType){
|
|
|
|
|
this.account.authType=loginType;
|
|
|
|
|
if(loginType == 1){//密码登录
|
2020-02-27 09:23:37 +08:00
|
|
|
this.clearPrivateKey();
|
2020-01-09 17:58:22 +08:00
|
|
|
}
|
|
|
|
|
if(loginType == 2){//公钥登录
|
|
|
|
|
this.account.pwd='';
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-02-27 09:23:37 +08:00
|
|
|
clearPrivateKey:function(){
|
|
|
|
|
this.account.privateKey=null;
|
|
|
|
|
},
|
2020-03-04 20:30:25 +08:00
|
|
|
|
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){
|
|
|
|
|
// if (n && n.id) {
|
|
|
|
|
// this.account=n;
|
|
|
|
|
// } else {
|
|
|
|
|
// this.resetData();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</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*/
|
|
|
|
|
</style>
|