2020-02-19 16:33:01 +08:00
|
|
|
|
<template>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<div class="right-box right-box-asset" v-clickoutside="clickOutside">
|
|
|
|
|
|
<!--顶部按钮-->
|
|
|
|
|
|
<div class="right-box-top-btns">
|
|
|
|
|
|
<button v-if="editAsset.id" type="button" @click="del" id="asset-edit-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-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<div class="right-box-title">{{editAsset.id ? ($t("asset.editAsset") + " ID:" + editAsset.id) : $t("asset.createAsset")}}</div>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-scrollbar class="right-box-form-box" ref="scrollbar">
|
|
|
|
|
|
<el-form ref="assetEditForm" :model="editAsset" label-width="120px" class="right-box-form right-box-form-left" :rules="rules">
|
|
|
|
|
|
<el-form-item :label="$t('asset.sn')" prop="sn">
|
|
|
|
|
|
<el-input size="small" v-model="editAsset.sn"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.host')" prop="host">
|
|
|
|
|
|
<el-input size="small" v-model="editAsset.host"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.state')">
|
|
|
|
|
|
<div class="select-style">
|
|
|
|
|
|
<el-select size="small" v-model="editAsset.state" placeholder="" popper-class="asset-dropdown" >
|
2020-02-19 16:33:01 +08:00
|
|
|
|
<el-option
|
2020-07-24 19:22:52 +08:00
|
|
|
|
:id="'asset-edit-state-op-'+item.value"
|
|
|
|
|
|
v-for="item in $CONSTANTS.asset.stateData"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value">
|
2020-02-19 16:33:01 +08:00
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<div class="right-box-sub-title">{{$t('asset.assetInfo')}}</div>
|
|
|
|
|
|
<div class="line-100 right-box-line"></div>
|
|
|
|
|
|
<!------------------------------------------资产类型---------------------------------------------->
|
|
|
|
|
|
<el-form-item :label="$t('asset.assetType')" class="right-box-form-content" prop="model.type.code">
|
|
|
|
|
|
<el-select popper-class="asset-dropdown" size="small" v-model="editAsset.model.type.code" @change="getVendorAndModelOptionData(editAsset.model.type.code)">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
:id="'asset-edit-type-op-'+item.id"
|
|
|
|
|
|
v-for="item in assetTypeData"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:value="item.code"
|
|
|
|
|
|
:label="item.value"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!------------------------------------------厂商/型号---------------------------------------------->
|
|
|
|
|
|
<el-form-item :label="$t('asset.vendorModel')" class="right-box-form-content" prop="modelId">
|
|
|
|
|
|
<el-cascader
|
|
|
|
|
|
:options="vendorAndModelOptionData"
|
|
|
|
|
|
:props="{emitPath: false}"
|
|
|
|
|
|
:disabled="editAsset.model.type.code ? false : true"
|
|
|
|
|
|
v-model="editAsset.modelId"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
class="right-box-row-with-btn"
|
|
|
|
|
|
@change="modelChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-cascader>
|
|
|
|
|
|
<div class="right-box-row-btn" @click="addVendor(editAsset.model.type.code)"><i class="el-icon-plus"></i></div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.purchaseDate')">
|
|
|
|
|
|
<div class="select-style">
|
|
|
|
|
|
<el-date-picker
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
v-model="editAsset.purchaseDate"
|
|
|
|
|
|
value-format="yyyy-MM-dd"
|
|
|
|
|
|
type="date"
|
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
placeholder="">
|
|
|
|
|
|
</el-date-picker>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--tag-->
|
|
|
|
|
|
<div class="right-box-sub-title">{{$t('overall.tag')}}
|
|
|
|
|
|
<div class="right-box-form-btns">
|
|
|
|
|
|
<button style="display: none;">第一个button会出现意料之外的hover样式,找不到原因,只好加个不可见的button规避问题</button>
|
|
|
|
|
|
<button id="module-add-param" type="button" @click="addTag">
|
|
|
|
|
|
<span><i style="font-size: 12px;" class="nz-icon nz-icon-create-square"></i></span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div></div>
|
|
|
|
|
|
<div class="line-100 right-box-line"></div>
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<template slot="label">
|
|
|
|
|
|
<span></span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div class="tag-edit-box">
|
|
|
|
|
|
<div class="tag-edit-box-head">
|
|
|
|
|
|
<div>Tag</div>
|
|
|
|
|
|
<div>Value</div>
|
|
|
|
|
|
<div>Action</div>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
</div>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-scrollbar ref="tagEditBoxScrollbar" style="height: calc(100% - 32px);">
|
|
|
|
|
|
<div class="tag-edit-box-body" v-for="(item, index) in editAsset.tags">
|
|
|
|
|
|
<el-form-item class="tag-edit tag-edit-tag" :rules="{required: true, message: $t('validate.required'), trigger: 'blur'}" :prop="'tags.' + index + '.tag'">
|
|
|
|
|
|
<el-input placeholder="tag" size="mini" v-model="item.tag"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item class="tag-edit tag-edit-value" :rules="{required: true, message: $t('validate.required'), trigger: 'blur'}" :prop="'tags.' + index + '.value'">
|
|
|
|
|
|
<el-input placeholder="value" size="mini" v-model="item.value"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<div class="param-box-row-symbol" :id="'asset-tag-remove-'+index" @click.stop="removeTag(index)"><i class="nz-icon nz-icon-minus-square"></i></div>
|
2020-06-19 18:35:13 +08:00
|
|
|
|
</div>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</el-scrollbar>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
</div>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="right-box-sub-title">{{$t('asset.location')}}</div>
|
|
|
|
|
|
<div class="line-100 right-box-line"></div>
|
|
|
|
|
|
<!------------------------------------------IDC---------------------------------------------->
|
|
|
|
|
|
<el-form-item :label="$t('asset.location')" prop="locationInfo" :rules="[{validator:locationValidator, trigger:'blur'}]">
|
|
|
|
|
|
<location-cascader :disabled="editAsset.modelId ? false : true" :default-model-u-size="modelSize" @change="setLocationData" ref="locationCascader" :idc-option="dcData"></location-cascader>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--cli-->
|
|
|
|
|
|
<div class="right-box-sub-title">{{$t('config.account.account')}}
|
|
|
|
|
|
<el-popover placement="right" width="70" trigger="click" :disabled="editAsset.accounts.length == 3" v-model.sync="showAccountOp" popper-class="no-style-class">
|
|
|
|
|
|
<button slot="reference" id="add-type" type="button" class="float-right" :class="{'nz-btn-disabled': editAsset.accounts.length == 3}">
|
|
|
|
|
|
<span><i style="font-size: 12px;" class="nz-icon nz-icon-create-square"></i></span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<ul class="el-select-dropdown__list">
|
|
|
|
|
|
<li @click="addAccount(type)" v-for="(type, index) in selectableAccountTypes" :key="index" class="el-select-dropdown__item"><span>{{type}}</span></li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="line-100 right-box-line"></div>
|
|
|
|
|
|
<div class="nz-tab" style="padding-left: 30px;">
|
|
|
|
|
|
<div class="nz-tab-item-box" v-for="(account, index) in editAsset.accounts" :key="index" @click="changeProtocolType(account.protocol)" :id="`account-login-type-${index}`">
|
|
|
|
|
|
<div class="nz-tab-item" :class="{'nz-tab-item-active': accountType == account.protocol}" style="position: relative;">
|
|
|
|
|
|
<span>{{account.protocol}}</span>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<div v-if="errorProtocol.indexOf(account.protocol) > -1" class="nz-tab-error el-form-item__error">Required</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span class="nz-tab-item-close" @click.stop="removeAccount(index)"><i class="el-icon-circle-close"></i></span>
|
2020-06-23 18:03:47 +08:00
|
|
|
|
</div>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<account-config-box v-for="(account,index) in editAsset.accounts" :account="account" v-show="account.protocol == accountType" :key="index" ref="accountConfigBox" @setValidateResult="setAccountValidResult" @protocol-type-change="protocolTypeChange"></account-config-box>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<template v-if="accountType == 'SSH' && !editAsset.id">
|
|
|
|
|
|
<el-form-item :label="$t('asset.exporter')" class="exporter-label">
|
|
|
|
|
|
<el-switch class="exporter-switch" v-model="editAsset.exporter" active-color="#ee9d3f" active-value="1" inactive-value="0" :show="!exporterDisableSwitch"></el-switch>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
|
|
|
|
|
<button @click="esc(false)" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100" id="asset-edit-cancel">
|
|
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button @click="save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100" id="asset-edit-save">
|
|
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
</div>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<model-box v-if="rightBox.model.show" ref="modelBox" @reload="modelReload" :model="model" @close="closeRightBox"></model-box>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</div>
|
2020-02-19 16:33:01 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import accountConfig from '../../page/asset/accountConfig';
|
|
|
|
|
|
import {host} from '../js/validate';
|
2020-04-08 19:18:30 +08:00
|
|
|
|
import {port} from '../js/validate'
|
2020-04-13 09:00:25 +08:00
|
|
|
|
import locationCascader from "./locationCascader";
|
2020-02-19 16:33:01 +08:00
|
|
|
|
export default {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
name: "assetBox",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
asset: Object
|
|
|
|
|
|
},
|
2020-02-19 16:33:01 +08:00
|
|
|
|
components:{
|
|
|
|
|
|
'account-config-box': accountConfig,
|
2020-04-13 09:00:25 +08:00
|
|
|
|
'location-cascader':locationCascader,
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
editAsset: {},
|
|
|
|
|
|
|
|
|
|
|
|
rightBox: {model: {show: false}},
|
|
|
|
|
|
modelData: [],
|
|
|
|
|
|
dcData: [],
|
|
|
|
|
|
assetTypeData: [],
|
|
|
|
|
|
cabinetData: [],
|
|
|
|
|
|
vendorAndModelOptionData: [], //厂商型号下拉框选择数据
|
|
|
|
|
|
|
2020-06-23 18:03:47 +08:00
|
|
|
|
showAccountOp: false,
|
|
|
|
|
|
errorProtocol: [], //校验不通过的account
|
|
|
|
|
|
selectableAccountTypes: ["SSH", "TELNET", "SNMP"],
|
2020-07-24 19:22:52 +08:00
|
|
|
|
|
|
|
|
|
|
modelSize: 1,
|
|
|
|
|
|
locationInfo: null,
|
|
|
|
|
|
|
2020-02-19 16:33:01 +08:00
|
|
|
|
accountType: '',
|
2020-07-24 19:22:52 +08:00
|
|
|
|
model: {},
|
|
|
|
|
|
blankModel: {
|
2020-03-12 12:13:45 +08:00
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
vendor: {id: '', value: '', code: '', type: ''},
|
|
|
|
|
|
type: {id: '', value: '', code: '', type: ''},
|
|
|
|
|
|
assetStat: {total: '', inStock: '', outStock: ''},
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
vendorCode: '',
|
|
|
|
|
|
typeCode: ''
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
userData: [], //用户(人)信息
|
2020-02-19 16:33:01 +08:00
|
|
|
|
cabinetSelectedData: {
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
uSize: 0,
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
idcId: '',
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
sn: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
host: [
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger: 'blur'},
|
|
|
|
|
|
{validator:host, trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
modelId: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'}
|
|
|
|
|
|
],
|
2020-07-24 19:22:52 +08:00
|
|
|
|
"model.type.code": [
|
2020-02-19 16:33:01 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'}
|
|
|
|
|
|
],
|
|
|
|
|
|
idcId: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'}
|
|
|
|
|
|
],
|
2020-04-08 19:18:30 +08:00
|
|
|
|
'impi.host':[
|
|
|
|
|
|
{validator:host,trigger:'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
'impi.port':[
|
|
|
|
|
|
{validator:port,trigger:'blur'}
|
|
|
|
|
|
]
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
cabRules: {
|
|
|
|
|
|
name: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
uSize: [
|
|
|
|
|
|
{required: true, type: 'number', min: 1, max: 47, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
idcId: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
formData:null,
|
2020-07-24 19:22:52 +08:00
|
|
|
|
accountValidResult: true,
|
|
|
|
|
|
changeProtocolSwitch: true,
|
|
|
|
|
|
exporterDisableSwitch: false
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
asset: {
|
2020-03-12 12:13:45 +08:00
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
2020-07-24 19:22:52 +08:00
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.editAsset = JSON.parse(JSON.stringify(n));
|
|
|
|
|
|
if (!this.editAsset.accounts) {
|
|
|
|
|
|
this.$set(this.editAsset, "accounts", []);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.editAsset.accounts.length > 0 && (this.accountType = this.editAsset.accounts[0].protocol);
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
console.info(n)
|
|
|
|
|
|
this.getVendorAndModelOptionData(n.model.type.code);
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
'editAsset.accounts': {
|
2020-06-23 18:03:47 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
clickOutside() {
|
|
|
|
|
|
this.esc(false);
|
|
|
|
|
|
},
|
|
|
|
|
|
/*关闭弹框*/
|
|
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
|
|
|
|
|
},
|
|
|
|
|
|
modelReload() {
|
|
|
|
|
|
|
2020-02-26 18:26:55 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
//关闭model侧滑框
|
|
|
|
|
|
closeRightBox(refresh) {
|
|
|
|
|
|
this.rightBox.model.show = false;
|
|
|
|
|
|
if (refresh) { //新增修改型号后刷新相关数据
|
|
|
|
|
|
this.getVendorData();
|
|
|
|
|
|
this.getModelData(this.editAsset.model.type.code);
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
getVendorData() {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('sys/dict/all?type=vendor').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.vendorData = response.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve(this.vendorData);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
getModelData(assetType) {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
let url = assetType ? ('model?typeCode=' + assetType) : 'model';
|
|
|
|
|
|
this.$get(url).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.modelData = response.data.list;
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve(this.modelData);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
//组织符合cascader的数据格式
|
|
|
|
|
|
getVendorAndModelOptionData(assetType) {
|
|
|
|
|
|
let request = this.getModelData(assetType);
|
|
|
|
|
|
request.then(response => {
|
|
|
|
|
|
let resultData = [];
|
|
|
|
|
|
let modelData = response;
|
|
|
|
|
|
for (let i = 0; i < modelData.length; i++) {
|
|
|
|
|
|
if (!modelData[i].vendor) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
let obj = {};
|
|
|
|
|
|
obj.id = modelData[i].vendor.id;
|
|
|
|
|
|
obj.code = modelData[i].vendor.code;
|
|
|
|
|
|
obj.value = modelData[i].vendor.code;
|
|
|
|
|
|
obj.label = modelData[i].vendor.value;
|
|
|
|
|
|
obj.children = [];
|
|
|
|
|
|
resultData.push(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
let result = [];
|
|
|
|
|
|
let obj1 = {};
|
|
|
|
|
|
for (let i = 0; i < resultData.length; i++) {
|
|
|
|
|
|
if (!obj1[resultData[i].id]) {
|
|
|
|
|
|
result.push(resultData[i]);
|
|
|
|
|
|
obj1[resultData[i].id] = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (let x = 0; x < result.length; x++) {
|
|
|
|
|
|
for (let y = 0; y < modelData.length; y++) {
|
|
|
|
|
|
if (!modelData[y].vendor) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (result[x].code === modelData[y].vendor.code) {
|
|
|
|
|
|
let obj2 = {};
|
|
|
|
|
|
obj2.value = modelData[y].id;
|
|
|
|
|
|
obj2.label = modelData[y].name;
|
|
|
|
|
|
result[x].children.push(obj2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.vendorAndModelOptionData = result;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-06-18 21:32:02 +08:00
|
|
|
|
addTag() {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.editAsset.tags.push({tag: "", value: ""});
|
2020-06-19 18:35:13 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.tagEditBoxScrollbar.update();
|
|
|
|
|
|
});
|
2020-06-18 21:32:02 +08:00
|
|
|
|
},
|
2020-06-23 18:03:47 +08:00
|
|
|
|
addAccount(type) {
|
|
|
|
|
|
if (type == "SSH") {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.editAsset.accounts.push({
|
2020-06-23 18:03:47 +08:00
|
|
|
|
authType: 1,
|
|
|
|
|
|
protocol: "SSH",
|
|
|
|
|
|
port: 22,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
user: "",
|
|
|
|
|
|
method: "password",
|
|
|
|
|
|
password: "",
|
|
|
|
|
|
key: "",
|
|
|
|
|
|
passwordKey: ""
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else if (type == "TELNET") {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.editAsset.accounts.push({
|
2020-06-23 18:03:47 +08:00
|
|
|
|
protocol: "TELNET",
|
|
|
|
|
|
port: 23,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
user: "",
|
|
|
|
|
|
password: "",
|
|
|
|
|
|
userTip: "",
|
|
|
|
|
|
passwordTip: "",
|
|
|
|
|
|
reloginTip: ""
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else if (type == "SNMP") {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.editAsset.accounts.push({
|
2020-06-23 18:03:47 +08:00
|
|
|
|
protocol: "SNMP",
|
|
|
|
|
|
port: 161,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
version:2,
|
|
|
|
|
|
community:"public",
|
2020-06-24 18:23:11 +08:00
|
|
|
|
securityName:"",
|
|
|
|
|
|
securityLevel:"",
|
|
|
|
|
|
password:"",
|
|
|
|
|
|
privPassword:"",
|
|
|
|
|
|
authProtocol:"",
|
|
|
|
|
|
privProtocol:"",
|
|
|
|
|
|
contextName:""
|
2020-06-23 18:03:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
this.accountType = type;
|
|
|
|
|
|
this.showAccountOp = false;
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
let sbWrap = this.$refs.scrollbar.$refs.wrap;
|
|
|
|
|
|
sbWrap.scrollTop = sbWrap.scrollHeight;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
removeAccount(index) {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.editAsset.accounts.splice(index, 1);
|
|
|
|
|
|
if (this.editAsset.accounts.length > 0) {
|
|
|
|
|
|
this.accountType = this.editAsset.accounts[0].protocol;
|
2020-06-23 18:03:47 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.accountType = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
removeTag(index) {
|
|
|
|
|
|
this.editAsset.tags.splice(index, 1);
|
2020-06-18 21:32:02 +08:00
|
|
|
|
this.$nextTick(() => {
|
2020-06-19 18:35:13 +08:00
|
|
|
|
this.$refs.tagEditBoxScrollbar.update();
|
2020-06-18 21:32:02 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
setLocationData(data) {
|
|
|
|
|
|
this.locationInfo = data;
|
2020-04-13 18:00:41 +08:00
|
|
|
|
},
|
2020-04-16 14:15:51 +08:00
|
|
|
|
locationValidator:function(rule, value, callback){
|
|
|
|
|
|
let $temp=this;
|
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
|
if(!this.locationInfo){
|
2020-06-21 20:58:22 +08:00
|
|
|
|
callback(new Error($temp.$t('validate.required')))
|
2020-04-16 14:15:51 +08:00
|
|
|
|
}else if(this.locationInfo && !this.locationInfo.idc){
|
2020-06-21 20:58:22 +08:00
|
|
|
|
callback(new Error($temp.$t('validate.required')))
|
2020-04-16 14:15:51 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
callback();
|
|
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
}, 100)
|
2020-04-16 14:15:51 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
modelChange(modelId) {
|
|
|
|
|
|
let model = this.modelData.find((item, index)=>{
|
|
|
|
|
|
return modelId == item.id;
|
2020-06-18 21:32:02 +08:00
|
|
|
|
});
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.modelSize = model.usize;
|
2020-04-13 18:00:41 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
getDcData() {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('idc').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.dcData = response.data.list;
|
2020-06-23 18:03:47 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
resolve(this.dcData);
|
|
|
|
|
|
});
|
2020-05-22 15:21:41 +08:00
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
getUserData() {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('sys/user/list').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.userData = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve(this.userData);
|
|
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
getCabinetData(id) {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('cabinet?idcId=' + id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.cabinetData = response.data.list;
|
|
|
|
|
|
for (let i = 0; i < this.cabinetData.length; i++) {
|
|
|
|
|
|
this.$set(this.cabinetData[i], 'children', this.dcData)
|
|
|
|
|
|
}
|
2020-05-22 15:21:41 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
resolve(this.cabinetData);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
getAssetTypeData() {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('sys/dict/all?type=assetType').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.assetTypeData = response.data;
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
resolve(this.assetTypeData);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
newModel() {
|
|
|
|
|
|
return JSON.parse(JSON.stringify(this.blankModel));
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
addVendor(assetType) {
|
|
|
|
|
|
this.model = this.newModel();
|
|
|
|
|
|
if (assetType) {
|
2020-03-12 12:13:45 +08:00
|
|
|
|
//model侧滑弹出时,自动选好assetType
|
2020-07-24 19:22:52 +08:00
|
|
|
|
for (let i = 0; i < this.assetTypeData.length; i++) {
|
|
|
|
|
|
if (this.assetTypeData[i].code == assetType) {
|
|
|
|
|
|
this.model.type.code = assetType;
|
|
|
|
|
|
this.model.type.value = this.assetTypeData[i].value;
|
2020-03-12 12:13:45 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.rightBox.model.show = true;
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
setAccountValidResult(result, protocol) {
|
|
|
|
|
|
this.accountValidResult = result;
|
2020-06-23 18:03:47 +08:00
|
|
|
|
let index = this.errorProtocol.indexOf(protocol);
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
index != -1 ? this.errorProtocol.splice(index, 1) : "";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
index == -1 ? this.errorProtocol.push(protocol) : "";
|
|
|
|
|
|
}
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
del() {
|
2020-02-19 16:33:01 +08:00
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.$delete("asset?ids=" + this.editAsset.id).then(response => {
|
2020-02-19 16:33:01 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.esc(true);
|
2020-02-19 16:33:01 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
changeProtocolType(type) {
|
|
|
|
|
|
this.accountType = type;
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
let sbWrap = this.$refs.scrollbar.$refs.wrap;
|
|
|
|
|
|
sbWrap.scrollTop = sbWrap.scrollHeight;
|
|
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
save() {
|
|
|
|
|
|
if(this.locationInfo) {
|
|
|
|
|
|
if(this.locationInfo.idc){
|
|
|
|
|
|
this.editAsset.idcId = this.locationInfo.idc.id;
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
if(this.locationInfo.cabinet) {
|
|
|
|
|
|
this.editAsset.cabinetId = this.locationInfo.cabinet.id;
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
if(this.locationInfo.u && this.locationInfo.u.length > 0) {
|
|
|
|
|
|
this.editAsset.cabinetStart = this.locationInfo.u[0];
|
|
|
|
|
|
this.editAsset.cabinetEnd = this.locationInfo.u[1];
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
|
|
|
|
|
|
if(this.$refs.accountConfigBox && this.$refs.accountConfigBox.length > 0) {
|
|
|
|
|
|
this.$refs.accountConfigBox.forEach(box => {
|
|
|
|
|
|
box.validateAccount();
|
2020-02-19 16:33:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.$refs.assetEditForm.validate((valid) => {
|
|
|
|
|
|
if (valid && this.accountValidResult) {
|
|
|
|
|
|
if (this.editAsset.id) {
|
|
|
|
|
|
this.$put('asset', this.editAsset).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
} else {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
if(this.$refs.accountConfigBox && this.$refs.accountConfigBox.length > 0){
|
|
|
|
|
|
this.$refs.accountConfigBox[0].validateAccount();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$post('asset', this.editAsset).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
2020-07-24 19:22:52 +08:00
|
|
|
|
});
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
protocolTypeChange(protocol) {
|
2020-03-13 15:59:23 +08:00
|
|
|
|
if(protocol == 'TELNET'){
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.exporterDisableSwitch = true;
|
2020-03-13 15:59:23 +08:00
|
|
|
|
}else{
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.exporterDisableSwitch = false;
|
2020-03-13 15:59:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-02-19 16:33:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.getUserData();
|
|
|
|
|
|
this.getVendorData();
|
|
|
|
|
|
this.getAssetTypeData();
|
|
|
|
|
|
this.getDcData();
|
2020-07-06 19:49:04 +08:00
|
|
|
|
this.showAccountOp = false;
|
2020-02-19 16:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2020-04-07 22:30:36 +08:00
|
|
|
|
<style >
|
|
|
|
|
|
.location-selector{
|
|
|
|
|
|
width: 512px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.location-selector .el-select-dropdown__item {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
|
|
|
|
|
.location-selector .el-cascader-node__prefix{
|
|
|
|
|
|
display: none !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
.cabinet-u-label .el-checkbox__original:checked + span{
|
|
|
|
|
|
background-color: orange;
|
|
|
|
|
|
}
|
|
|
|
|
|
.cabinet-u-label .el-checkbox__original:checked + span:after{
|
|
|
|
|
|
-webkit-transform: rotate(45deg) scaleY(1);
|
|
|
|
|
|
transform: rotate(45deg) scaleY(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
.cabinet-u-label .is-disabled{
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
border-color: #C0C4CC;
|
|
|
|
|
|
}
|
|
|
|
|
|
.cabinet-u-label .is-disabled-bg{
|
|
|
|
|
|
background-color: #F2F6FC !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
.cabinet-u-label .is-disabled-check:after{
|
|
|
|
|
|
border-color: #C0C4CC !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
2020-07-01 18:09:07 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
#module-add-param,#add-type{
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
outline: none;
|
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|