2021-04-22 12:25:23 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div v-clickoutside="{obj: editAsset, func: esc}" class="right-box right-box-asset">
|
|
|
|
|
|
<div class="right-box__header">
|
|
|
|
|
|
<div class="header__title">{{editAsset.id ? $t('asset.editAsset') : $t('asset.createAsset')}}</div>
|
|
|
|
|
|
<div class="header__operation">
|
|
|
|
|
|
<span v-cancel="{obj: editAsset, func: esc}"><i class="nz-icon nz-icon-close"></i></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="right-box__container">
|
|
|
|
|
|
<div class="container__form">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-form ref="form" :model="editAsset" :rules="rules" label-position="top" label-width="120px">
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<el-form-item :label="$t('overall.name')" prop="name">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="128" show-word-limit v-model="editAsset.name" size="small"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('overall.type')" prop="typeId">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<select-asset-type id="asset-type" :asset-type-data="options.typeOptions" :show-type="editAsset.type" size="small"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
@selectAssetType="selectType">
|
|
|
|
|
|
<template v-slot:trigger>
|
|
|
|
|
|
<el-input v-model="editAsset.type.name" :clearable="true" :readonly="true" placeholder="" size="small"></el-input>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</select-asset-type>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item v-if="editAsset.type && editAsset.type.vm === 1" :label="$t('overall.parent')" prop="pid">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="editAsset.pid"
|
|
|
|
|
|
class="right-box__select"
|
2021-10-29 12:02:34 +08:00
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
size="small"
|
2021-10-13 15:47:56 +08:00
|
|
|
|
:placeholder="$t('el.select.placeholder')"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
value-key="id">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-option v-for="p in options.parentAssetOptions" :key="p.id" :label="p.name" :value="p.id"></el-option>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.state')" prop="stateId">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select v-model="editAsset.stateId" class="right-box__select" :placeholder="$t('el.select.placeholder')" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="id">
|
2021-10-21 18:37:35 +08:00
|
|
|
|
<el-option v-for="state in options.stateOptions" :key="state.id" :label="state.name" :value="state.id">
|
|
|
|
|
|
<div style="display: flex;justify-content: space-between;padding: 5px;">
|
2022-03-25 14:25:13 +08:00
|
|
|
|
<div>{{$t(state.name)}}</div>
|
|
|
|
|
|
<div style="width: 450px;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;color: #999999" :title="state.remark">{{$t(state.remark)}}</div>
|
2021-10-21 18:37:35 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-option>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.manageIp')" prop="manageIp">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="64" show-word-limit v-model="editAsset.manageIp" size="small"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.sn')" prop="sn">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="128" show-word-limit v-model="editAsset.sn" size="small"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.number')" prop="number">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="128" show-word-limit v-model="editAsset.number" size="small"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.brandAndModel')" class="placeholder-emphasize" prop="brandAndModel">
|
2022-04-22 16:36:05 +08:00
|
|
|
|
<div @click="judgeType">
|
|
|
|
|
|
<el-cascader
|
|
|
|
|
|
ref="cascader"
|
|
|
|
|
|
:clearable="true"
|
|
|
|
|
|
:disabled="judgeTypes"
|
2021-04-26 21:42:15 +08:00
|
|
|
|
v-model="editAsset.brandAndModel"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
:placeholder="lockModelInputValue"
|
2021-04-26 21:42:15 +08:00
|
|
|
|
:options="options.brandAndModelOptions"
|
|
|
|
|
|
:props="{ label: 'name', value: 'id' }"
|
2021-10-29 12:02:34 +08:00
|
|
|
|
popper-class="prevent-clickoutside right-public-box-dropdown-top right-box-select-top limit-height"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 100%;"
|
|
|
|
|
|
></el-cascader>
|
2022-04-22 16:36:05 +08:00
|
|
|
|
</div>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
2021-08-10 14:26:12 +08:00
|
|
|
|
<el-form-item :label="$t('asset.location')" prop="location" class="is-required">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<location-cascader v-if="!vmLock" ref="locationCascader" :dc-option="options.dcOptions" :default-model-u-size="1" @change="setLocationData"></location-cascader>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<el-input v-else v-model="lockLocationInputValue" disabled size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.purchaseDate')" prop="purchaseDate">
|
2021-04-28 15:18:21 +08:00
|
|
|
|
<my-date-picker
|
2021-04-22 12:25:23 +08:00
|
|
|
|
id="asset-box-input-parchase-date"
|
|
|
|
|
|
v-model="editAsset.purchaseDate"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
size="small"
|
2021-10-29 14:25:59 +08:00
|
|
|
|
popper-class="right-box-select-top"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
type="date"
|
2022-01-04 15:36:55 +08:00
|
|
|
|
:format="timeFormatStrToDatePickFormat(timeFormatMain, 1)">
|
2021-04-28 15:18:21 +08:00
|
|
|
|
</my-date-picker>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- labels -->
|
2022-04-06 17:40:19 +08:00
|
|
|
|
<div class="form__sub-title">{{$t('config.assetLabel.assetLabel')}}</div>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<div v-for="(label, i) in editAsset.fields" :key="i" class="form__dotted-item">
|
|
|
|
|
|
<el-form-item :prop="'fields.' + i + '.value'">
|
|
|
|
|
|
<template v-slot:label>
|
|
|
|
|
|
<div class="form__labels-label">
|
|
|
|
|
|
<span>{{label.name}}</span>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<div>
|
2021-11-18 15:15:19 +08:00
|
|
|
|
<span @click="removeLabel(label)" class="form__labels-label__span"><i class="nz-icon nz-icon-minus"></i></span>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</div>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<template v-if="label.action !== 1">
|
|
|
|
|
|
<template v-if="label.type.toUpperCase() === assetConstants.labelTypeData.TEXT">
|
|
|
|
|
|
<el-input v-model="label.value[0]" size="small"/>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.MULTITEXT">
|
|
|
|
|
|
<div v-for="(value, i) in label.value" :key="i" class="label__multi-text">
|
|
|
|
|
|
<el-input v-model="label.value[i]" size="small"/>
|
2021-07-13 10:30:28 +08:00
|
|
|
|
<span @click="addMultiTextRow(label)" style="margin: 0 5px"><i class="nz-icon nz-icon-plus"></i></span>
|
|
|
|
|
|
<span @click="removeMultiTextRow(label, i)"><i class="nz-icon nz-icon-minus"></i></span>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.TEXTAREA">
|
2022-06-10 14:55:46 +08:00
|
|
|
|
<el-input v-model="label.value[0]" :maxlength="4096" show-word-limit size="small" :rows="2" type="textarea"/>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.RADIO">
|
2021-05-26 16:35:10 +08:00
|
|
|
|
<el-radio-group v-model="label.value[0]">
|
|
|
|
|
|
<el-radio v-for="item in JSON.parse(label.param).items" :key="item.name" :label="item.name">{{item.name}}</el-radio>
|
|
|
|
|
|
</el-radio-group>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.CHECKBOX">
|
2021-06-02 16:55:17 +08:00
|
|
|
|
<el-checkbox-group v-model="label.value">
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<el-checkbox v-for="item in JSON.parse(label.param).items" :key="item.name" :label="item.name" :value="item.name"></el-checkbox>
|
|
|
|
|
|
</el-checkbox-group>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.SELECT">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select v-model="label.value[0]" class="right-box__select" :placeholder="$t('el.select.placeholder')" popper-class="right-box-select-top prevent-clickoutside" size="small">
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<el-option v-for="item in JSON.parse(label.param).items" :key="item.name" :label="item.name" :value="item.name"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.INTEGER">
|
|
|
|
|
|
<el-input v-model="label.value[0]" oninput="value=value.replace(/[^\d]/g,'')" size="small"></el-input>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.DOUBLE">
|
2021-08-26 17:10:32 +08:00
|
|
|
|
<el-input-number v-model="label.value[0]" :controls="false" size="small" :precision="JSON.parse(label.param).decimals" style="width: 100%;text-align: left" :max="10000000000000000000" :min="-10000000000000000000"></el-input-number>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.DATETIME">
|
|
|
|
|
|
<template v-if="JSON.parse(label.param).subType === assetConstants.labelSubTypeData.time">
|
2021-08-26 17:10:32 +08:00
|
|
|
|
<div v-if="JSON.parse(label.param).interval" style="display: flex; justify-content: space-between">
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<el-time-select v-model="label.value[0]" size="small"></el-time-select>
|
|
|
|
|
|
<el-time-select v-model="label.value[1]" size="small"></el-time-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<el-time-select v-model="label.value[0]" size="small" style="width: 100%"></el-time-select>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
2021-08-26 17:10:32 +08:00
|
|
|
|
<template v-if="JSON.parse(label.param).interval">
|
2021-04-28 15:18:21 +08:00
|
|
|
|
<my-date-picker
|
2021-04-23 19:58:08 +08:00
|
|
|
|
id="asset-box-input-purchase-date"
|
2022-01-10 15:45:58 +08:00
|
|
|
|
v-model="label.value"
|
2022-01-05 18:01:30 +08:00
|
|
|
|
:type="JSON.parse(label.param).subType === assetConstants.labelSubTypeData.date ? 'daterange' : 'datetimerange'"
|
2021-04-23 19:58:08 +08:00
|
|
|
|
placeholder=""
|
2021-10-29 14:25:59 +08:00
|
|
|
|
popper-class="right-box-select-top"
|
2021-04-23 19:58:08 +08:00
|
|
|
|
size="small"
|
2022-01-05 18:01:30 +08:00
|
|
|
|
:format="timeFormatStrToDatePickFormat(timeFormatMain,JSON.parse(label.param).subType === assetConstants.labelSubTypeData.date)"
|
2021-04-23 19:58:08 +08:00
|
|
|
|
style="width: 100%">
|
2021-04-28 15:18:21 +08:00
|
|
|
|
</my-date-picker>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
2021-04-28 15:18:21 +08:00
|
|
|
|
<my-date-picker
|
2021-04-23 19:58:08 +08:00
|
|
|
|
id="asset-box-input-parchase-date"
|
|
|
|
|
|
v-model="label.value[0]"
|
|
|
|
|
|
:type="JSON.parse(label.param).subType"
|
|
|
|
|
|
placeholder=""
|
2021-10-29 14:25:59 +08:00
|
|
|
|
popper-class="right-box-select-top"
|
2021-04-23 19:58:08 +08:00
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 100%"
|
2022-01-05 18:01:30 +08:00
|
|
|
|
:format="timeFormatStrToDatePickFormat(timeFormatMain, JSON.parse(label.param).subType === assetConstants.labelSubTypeData.date)">
|
2021-04-28 15:18:21 +08:00
|
|
|
|
</my-date-picker>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.EMAIL">
|
2021-08-26 17:10:32 +08:00
|
|
|
|
<el-input v-model="label.value[0]" size="small"/>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- label的新增按钮 -->
|
|
|
|
|
|
<div class="form__flex-container hide-casc-input">
|
|
|
|
|
|
<button class="form__create-btn" type="button" @click.stop><i class="nz-icon nz-icon-create-square"></i></button>
|
|
|
|
|
|
<el-cascader
|
|
|
|
|
|
v-if="labelCascShow"
|
2021-04-26 21:42:15 +08:00
|
|
|
|
:options="options.fieldGroupOptions"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
:props="labelCascProp"
|
|
|
|
|
|
class="hide-input"
|
2021-10-29 14:25:59 +08:00
|
|
|
|
popper-class="prevent-clickoutside right-box-select-top limit-height"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
size="small"
|
|
|
|
|
|
@change="addLabel"
|
|
|
|
|
|
></el-cascader>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- SSH -->
|
|
|
|
|
|
<template v-if="editAsset.type && editAsset.type.authProtocol === assetConstants.authProtocolData.ssh">
|
2022-02-18 11:01:29 +08:00
|
|
|
|
<div class="form__sub-title">SSH
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-switch v-model="editAsset.showSSH" :active-value="true" :inactive-value="false" size="small"></el-switch>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="editAsset.showSSH">
|
|
|
|
|
|
<el-form-item :label="$t('asset.authType')" prop="authType">
|
|
|
|
|
|
<el-select v-model="editAsset.authType" class="right-box__select" :placeholder="$t('el.select.placeholder')" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="value" clearable>
|
|
|
|
|
|
<el-option v-for="type in assetConstants.authTypeOptions" :key="type.value" :label="type.label" :value="type.value"/>
|
|
|
|
|
|
</el-select>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
2022-02-18 11:01:29 +08:00
|
|
|
|
<el-form-item :label="$t('asset.userName')" prop="authUsername">
|
|
|
|
|
|
<el-input maxlength="64" show-word-limit v-model="editAsset.authUsername" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- Key支持私钥 -->
|
|
|
|
|
|
<template v-if="editAsset.authType === assetConstants.authTypeData.key">
|
|
|
|
|
|
<el-form-item :label="$t('asset.privateKey')" prop="authPriKey">
|
|
|
|
|
|
<el-input v-model="editAsset.authPriKey" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-form-item :label="$t('asset.pin')" prop="authPin">
|
|
|
|
|
|
<el-input maxlength="256" show-word-limit v-model="editAsset.authPin" size="small" type="password"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.port')" prop="authProtocolPort">
|
|
|
|
|
|
<el-input v-model="editAsset.authProtocolPort" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<!-- TELNET -->
|
|
|
|
|
|
<template v-if="editAsset.type && editAsset.type.authProtocol === assetConstants.authProtocolData.telnet">
|
|
|
|
|
|
<div class="form__sub-title">TELNET</div>
|
2021-07-28 14:12:58 +08:00
|
|
|
|
<el-form-item :label="$t('asset.userName')" prop="authUsername">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="64" show-word-limit v-model="editAsset.authUsername" size="small"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
2021-04-27 10:50:44 +08:00
|
|
|
|
<el-form-item :label="$t('asset.pin')" prop="authPin">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="256" show-word-limit v-model="editAsset.authPin" size="small" type="password"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.usernamePrompt')" prop="authUserTip">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="64" show-word-limit v-model="editAsset.authUserTip" size="small"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
2021-04-27 10:50:44 +08:00
|
|
|
|
<el-form-item :label="$t('asset.pinPrompt')" prop="authPinTip">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="64" show-word-limit v-model="editAsset.authPinTip" size="small" type="password"/>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form-item>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<el-form-item :label="$t('asset.port')" prop="authProtocolPort">
|
|
|
|
|
|
<el-input v-model="editAsset.authProtocolPort" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<!-- SNMP -->
|
|
|
|
|
|
<template v-if="editAsset.type && editAsset.type.snmpEnable === 1">
|
|
|
|
|
|
<div class="form__sub-title">SNMP</div>
|
|
|
|
|
|
<el-form-item :label="$t('asset.snmpCredential')" prop="snmpCredentialId">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select v-model="editAsset.snmpCredentialId" class="right-box__select" :placeholder="$t('el.select.placeholder')" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="id">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-option v-for="snmp in options.snmpCredentialOptions" :key="snmp.id" :label="snmp.name" :value="snmp.id"></el-option>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
2021-07-28 14:12:58 +08:00
|
|
|
|
<!-- TALON -->
|
2021-08-16 10:48:58 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="el-form__sub-title">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span class="endpoint-title-content">
|
|
|
|
|
|
<i class="nz-icon nz-icon-arrow-down" :class="talonShowTow?'':'is-active'" @click="talonShowTow = !talonShowTow"></i>
|
|
|
|
|
|
TALON
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
placement="right"
|
|
|
|
|
|
trigger="hover"
|
2021-11-05 15:41:25 +08:00
|
|
|
|
popper-class="prevent-clickoutside"
|
2021-08-27 09:32:28 +08:00
|
|
|
|
:content="$t('asset.talonPrompt')">
|
2021-08-16 10:48:58 +08:00
|
|
|
|
<i slot="reference" class="nz-icon nz-icon-about"></i>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
2021-08-19 17:00:47 +08:00
|
|
|
|
<div>
|
2021-11-30 16:08:02 +08:00
|
|
|
|
<el-switch v-model="editAsset.clientEnable" :active-value="1" :inactive-value="0" size="small"></el-switch>
|
2021-08-19 17:00:47 +08:00
|
|
|
|
</div>
|
2021-07-28 14:12:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
2021-08-16 10:48:58 +08:00
|
|
|
|
<!-- <el-form-item :label="$t('asset.userName')" prop="clientUser">
|
|
|
|
|
|
<el-input maxlength="64" show-word-limit v-model="editAsset.clientUser" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.pin')" prop="clientPin">
|
|
|
|
|
|
<el-input type="password" show-word-limit v-model="editAsset.clientPin" size="small"/>
|
|
|
|
|
|
</el-form-item> -->
|
2021-08-19 17:00:47 +08:00
|
|
|
|
<div v-if="editAsset.clientEnable === 1" v-show="talonShowTow">
|
2021-08-16 10:48:58 +08:00
|
|
|
|
<el-form-item label="Token" prop="clientToken">
|
|
|
|
|
|
<el-input v-model="editAsset.clientToken" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.port')" prop="clientPort">
|
|
|
|
|
|
<el-input v-model="editAsset.clientPort" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
<!-- <transition name="el-zoom-in-top">
|
2021-07-28 14:12:58 +08:00
|
|
|
|
<div v-show="showAllTalonOption">
|
|
|
|
|
|
<el-form-item :label="$t('asset.address')" prop="clientAddress">
|
|
|
|
|
|
<el-input v-model="editAsset.clientAddress" size="small"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
<template v-if="showAddressOption">
|
|
|
|
|
|
<div style="text-align: center;margin-bottom: 40px">
|
2021-11-17 11:12:06 +08:00
|
|
|
|
<span class="nz-btn-size-normal-new nz-btn-style-light" style="border: none" @click="showAddress">
|
2021-07-28 14:12:58 +08:00
|
|
|
|
{{$t('overall.moreOption')}}<i class="nz-icon nz-icon-arrow-down"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
2021-08-16 10:48:58 +08:00
|
|
|
|
</template> -->
|
2021-07-28 14:12:58 +08:00
|
|
|
|
</template>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="right-box__footer">
|
|
|
|
|
|
<button id="asset-edit-cancel" v-cancel="{obj: editAsset, func: esc}" class="footer__btn footer__btn--light">
|
|
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button id="asset-edit-save" :class="{'footer__btn--disabled': prevent_opt.save}" :disabled="prevent_opt.save" class="footer__btn" @click="save">
|
|
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-11-04 14:24:42 +08:00
|
|
|
|
import { host, port, noSpecialChar } from '@/components/common/js/validate'
|
2021-04-22 12:25:23 +08:00
|
|
|
|
import { asset as assetConstants } from '@/components/common/js/constants'
|
|
|
|
|
|
import selectAssetType from '@/components/common/popBox/selectAssetType'
|
|
|
|
|
|
import locationCascader from '@/components/common/rightBox/locationCascader'
|
2021-07-05 14:43:47 +08:00
|
|
|
|
import editRigthBox from '../../mixin/editRigthBox'
|
2022-01-05 18:01:30 +08:00
|
|
|
|
import bus from '@/libs/bus'
|
2021-07-05 14:43:47 +08:00
|
|
|
|
|
2021-04-22 12:25:23 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'assetBox',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
selectAssetType,
|
|
|
|
|
|
locationCascader
|
|
|
|
|
|
},
|
|
|
|
|
|
props: {
|
|
|
|
|
|
obj: {
|
|
|
|
|
|
type: Object
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-07-05 14:43:47 +08:00
|
|
|
|
mixins: [editRigthBox],
|
2021-04-22 12:25:23 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
const vm = this
|
|
|
|
|
|
return {
|
|
|
|
|
|
assetConstants,
|
2022-04-22 16:36:05 +08:00
|
|
|
|
judgeTypes: true,
|
2021-07-28 14:12:58 +08:00
|
|
|
|
showAllTalonOption: false,
|
|
|
|
|
|
showAddressOption: true,
|
2021-08-16 10:48:58 +08:00
|
|
|
|
talonShowTow: true,
|
2021-04-22 12:25:23 +08:00
|
|
|
|
editAsset: {},
|
2021-09-27 14:46:08 +08:00
|
|
|
|
minWidth: '',
|
2021-04-22 12:25:23 +08:00
|
|
|
|
url: 'asset/asset',
|
|
|
|
|
|
rightBox: { model: { show: false } },
|
|
|
|
|
|
vmLock: false, // 当自己是虚拟机时,锁定品牌型号位置为parent的,无法修改
|
|
|
|
|
|
lockModelInputValue: '', // model锁定时的显示内容
|
|
|
|
|
|
lockLocationInputValue: '', // location锁定时显示的内容
|
|
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
options: { // 下拉选项的option数据
|
|
|
|
|
|
cabinetOptions: [],
|
|
|
|
|
|
metaOptions: [],
|
|
|
|
|
|
dcOptions: [],
|
|
|
|
|
|
stateOptions: [],
|
|
|
|
|
|
snmpCredentialOptions: [],
|
|
|
|
|
|
brandAndModelOptions: [],
|
|
|
|
|
|
modelOptions: [],
|
|
|
|
|
|
fieldGroupOptions: [],
|
|
|
|
|
|
parentAssetOptions: [],
|
|
|
|
|
|
typeOptions: []
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
labelCascShow: true, // 用来控制label的cascader的重新渲染
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
name: [
|
2021-08-04 10:32:53 +08:00
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
|
2021-11-04 14:24:42 +08:00
|
|
|
|
{ validator: noSpecialChar, trigger: 'blur' }
|
2021-04-22 12:25:23 +08:00
|
|
|
|
],
|
|
|
|
|
|
pid: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
manageIp: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
|
|
|
|
|
|
{ validator: host, trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
modelId: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
typeId: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
stateId: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
2021-04-26 21:42:15 +08:00
|
|
|
|
brandAndModel: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
2021-04-22 12:25:23 +08:00
|
|
|
|
dcId: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
authProtocolPort: [
|
2021-06-02 16:41:09 +08:00
|
|
|
|
// { required: true, message: this.$t('validate.required'), trigger: 'change' },
|
2021-04-22 12:25:23 +08:00
|
|
|
|
{ validator: port, trigger: 'blur' }
|
2021-08-09 14:21:17 +08:00
|
|
|
|
],
|
|
|
|
|
|
sn: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
location: [
|
2021-08-10 14:26:12 +08:00
|
|
|
|
// { required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
{ validator: this.checkLocation, trigger: 'blur' }
|
2021-08-16 10:48:58 +08:00
|
|
|
|
],
|
|
|
|
|
|
clientToken: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
clientPort: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
2021-04-22 12:25:23 +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' }
|
|
|
|
|
|
],
|
|
|
|
|
|
dcId: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
labelCascProp: {
|
|
|
|
|
|
lazy: true,
|
|
|
|
|
|
value: 'id',
|
|
|
|
|
|
label: 'name',
|
|
|
|
|
|
lazyLoad (node, resolve) {
|
|
|
|
|
|
const { level } = node
|
2021-05-25 19:47:22 +08:00
|
|
|
|
if (node && node.data) {
|
2021-07-13 10:11:36 +08:00
|
|
|
|
vm.$get('asset/field/meta', { groupIds: node.data.id, pageSize: -1 }).then(response => {
|
2021-05-25 19:47:22 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
const meta = response.data.list.map(item => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
leaf: level >= 1,
|
|
|
|
|
|
disabled: vm.editAsset.fields.some(a => a.id === item.id)
|
|
|
|
|
|
}))
|
|
|
|
|
|
vm.options.metaOptions = meta
|
|
|
|
|
|
resolve(meta)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
2022-05-31 17:31:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
assetId: ''
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
obj: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
2021-07-15 11:56:25 +08:00
|
|
|
|
this.isEdit = true
|
2022-02-18 11:01:29 +08:00
|
|
|
|
const editAsset = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
if (editAsset.authType) {
|
|
|
|
|
|
editAsset.showSSH = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
editAsset.showSSH = false
|
|
|
|
|
|
}
|
|
|
|
|
|
this.editAsset = editAsset
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.editAsset.brandAndModel = [this.editAsset.brand.id, this.editAsset.model.id]
|
2021-10-21 18:37:35 +08:00
|
|
|
|
this.editAsset.stateId = n.state ? n.state.id : 2
|
2021-04-23 19:58:08 +08:00
|
|
|
|
this.editAsset.typeId = n.type ? n.type.id : ''
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
if (n.id) {
|
|
|
|
|
|
this.lockModelInputValue = `${n.brand.name} / ${n.model.name}`
|
|
|
|
|
|
}
|
2021-09-15 15:17:01 +08:00
|
|
|
|
if (this.$refs.locationCascader) {
|
|
|
|
|
|
this.$refs.locationCascader.initComponet({ cabinet: n.cabinet, dc: n.dc, u: [n.cabinetStart, n.cabinetEnd] })
|
|
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'editAsset.type': {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
2021-05-17 21:24:06 +08:00
|
|
|
|
if (n.id) {
|
2021-07-15 15:30:23 +08:00
|
|
|
|
this.vmLock = n.vm === 1 // vm == 1 时,锁定model和location
|
2021-05-17 21:24:06 +08:00
|
|
|
|
if (this.editAsset.id) { // 有id表示是修改asset,需要注意不要覆盖掉原有的port
|
|
|
|
|
|
const oldPort = this.obj.authProtocolPort // 原有的port
|
|
|
|
|
|
const oldAuthProtocol = this.obj.type.authProtocol // 原有的协议
|
|
|
|
|
|
if (n.authProtocol === oldAuthProtocol) { // 切换后与原有的协议相同,则恢复到原有的port
|
|
|
|
|
|
this.editAsset.authProtocolPort = oldPort
|
|
|
|
|
|
} else { // 否则使用默认port
|
|
|
|
|
|
if (n.authProtocol === this.assetConstants.authProtocolData.ssh) {
|
|
|
|
|
|
this.editAsset.authProtocolPort = 22
|
|
|
|
|
|
} else if (n.authProtocol === this.assetConstants.authProtocolData.telnet) {
|
|
|
|
|
|
this.editAsset.authProtocolPort = 23
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (n.authProtocol === this.assetConstants.authProtocolData.ssh) {
|
|
|
|
|
|
this.editAsset.authProtocolPort = 22
|
|
|
|
|
|
} else if (n.authProtocol === this.assetConstants.authProtocolData.telnet) {
|
|
|
|
|
|
this.editAsset.authProtocolPort = 23
|
|
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'editAsset.pid': {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
2021-08-04 10:32:53 +08:00
|
|
|
|
if (this.editAsset.pid === -1) {
|
|
|
|
|
|
this.editAsset.pid = ''
|
|
|
|
|
|
}
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (n && n !== -1) {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
if (this.vmLock) {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (this.options.parentAssetOptions.length === 0) {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.getParentAsset().then(res => {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
const asset = this.options.parentAssetOptions.find(a => a.id === n)
|
2021-04-22 12:25:23 +08:00
|
|
|
|
if (asset) {
|
2021-05-13 11:40:22 +08:00
|
|
|
|
this.editAsset.brandId = asset.brand ? asset.brand.id : ''
|
2021-05-13 14:25:03 +08:00
|
|
|
|
this.editAsset.brand = asset.brand
|
2021-05-13 11:40:22 +08:00
|
|
|
|
this.editAsset.modelId = asset.model ? asset.model.id : ''
|
2021-05-13 14:25:03 +08:00
|
|
|
|
this.editAsset.model = asset.model
|
2021-05-13 11:40:22 +08:00
|
|
|
|
this.editAsset.dcId = asset.dc ? asset.dc.id : ''
|
|
|
|
|
|
this.editAsset.cabinetId = asset.cabinet ? asset.cabinet.id : ''
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.editAsset.cabinetStart = asset.cabinetStart
|
|
|
|
|
|
this.editAsset.cabinetEnd = asset.cabinetEnd
|
2021-05-13 14:25:03 +08:00
|
|
|
|
if (!asset.cabinet) {
|
|
|
|
|
|
asset.cabinet = {}
|
2021-05-13 11:40:22 +08:00
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.lockModelInputValue = `${asset.brand.name} / ${asset.model.name}`
|
|
|
|
|
|
this.lockLocationInputValue = `${asset.dc.name} / ${asset.cabinet.name} / ${asset.cabinetStart}-${asset.cabinetEnd}`
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
const asset = this.options.parentAssetOptions.find(a => a.id === n)
|
2021-04-22 12:25:23 +08:00
|
|
|
|
if (asset) {
|
2021-05-13 11:40:22 +08:00
|
|
|
|
this.editAsset.brandId = asset.brand ? asset.brand.id : ''
|
2021-05-13 14:25:03 +08:00
|
|
|
|
this.editAsset.brand = asset.brand
|
2021-05-13 11:40:22 +08:00
|
|
|
|
this.editAsset.modelId = asset.model ? asset.model.id : ''
|
2021-05-13 14:25:03 +08:00
|
|
|
|
this.editAsset.model = asset.model
|
2021-05-13 11:40:22 +08:00
|
|
|
|
this.editAsset.dcId = asset.dc ? asset.dc.id : ''
|
|
|
|
|
|
this.editAsset.cabinetId = asset.cabinet ? asset.cabinet.id : ''
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.editAsset.cabinetStart = asset.cabinetStart
|
|
|
|
|
|
this.editAsset.cabinetEnd = asset.cabinetEnd
|
2021-05-13 14:25:03 +08:00
|
|
|
|
if (!asset.cabinet) {
|
|
|
|
|
|
asset.cabinet = {}
|
2021-05-13 11:40:22 +08:00
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.lockModelInputValue = `${asset.brand.name} / ${asset.model.name}`
|
|
|
|
|
|
this.lockLocationInputValue = `${asset.dc.name} / ${asset.cabinet.name} / ${asset.cabinetStart}-${asset.cabinetEnd}`
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-05-13 14:25:03 +08:00
|
|
|
|
this.editAsset.brandAndModel = [this.editAsset.brand.id, this.editAsset.model.id]
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.getParentAsset()
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.getModelData()
|
|
|
|
|
|
this.getStateData()
|
|
|
|
|
|
this.getDcData()
|
|
|
|
|
|
this.getTypeTreeData()
|
|
|
|
|
|
this.getSnmpCredentialData()
|
|
|
|
|
|
this.getFieldGroupData()
|
2021-04-22 12:25:23 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2022-04-22 16:36:05 +08:00
|
|
|
|
judgeType () {
|
|
|
|
|
|
if (!this.editAsset.type.name) {
|
2022-04-26 09:38:33 +08:00
|
|
|
|
this.$message.error(this.$t('asset.assetBox.message.type'))
|
2022-04-22 16:36:05 +08:00
|
|
|
|
return false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.judgeTypes = false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
clickOutside () {
|
|
|
|
|
|
this.esc(false)
|
|
|
|
|
|
},
|
2021-07-28 14:12:58 +08:00
|
|
|
|
showAddress () {
|
|
|
|
|
|
this.showAddressOption = false
|
|
|
|
|
|
this.showAllTalonOption = true
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
setLocationData ({ cabinet, dc, u }) {
|
2021-09-02 18:23:47 +08:00
|
|
|
|
this.editAsset.cabinetId = cabinet ? cabinet.id : ''
|
|
|
|
|
|
this.editAsset.dcId = dc ? dc.id : ''
|
2022-02-15 13:52:01 +08:00
|
|
|
|
if (this.editAsset.dcId) {
|
|
|
|
|
|
this.$refs.form.validateField('location')
|
|
|
|
|
|
}
|
2021-05-25 19:47:22 +08:00
|
|
|
|
if (u) {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.editAsset.cabinetStart = u[0]
|
|
|
|
|
|
this.editAsset.cabinetEnd = u[1]
|
2021-09-02 18:23:47 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.editAsset.cabinetStart = ''
|
|
|
|
|
|
this.editAsset.cabinetEnd = ''
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
removeLabel (label) {
|
|
|
|
|
|
let index = 0
|
|
|
|
|
|
this.editAsset.fields.find((f, i) => {
|
|
|
|
|
|
if (label.id === f.id) {
|
|
|
|
|
|
index = i
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
return false
|
|
|
|
|
|
})
|
|
|
|
|
|
this.editAsset.fields.splice(index, 1)
|
|
|
|
|
|
this.labelCascShow = false
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.labelCascShow = true
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-23 19:58:08 +08:00
|
|
|
|
addMultiTextRow (label) {
|
|
|
|
|
|
label.value.push('')
|
|
|
|
|
|
},
|
2021-07-13 10:30:28 +08:00
|
|
|
|
removeMultiTextRow (label, index) {
|
|
|
|
|
|
if (label.value.length === 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
label.value.splice(index, 1)
|
|
|
|
|
|
},
|
2021-04-23 19:58:08 +08:00
|
|
|
|
blankLabelValue (label) {
|
|
|
|
|
|
if (label.type.toUpperCase() === this.assetConstants.labelTypeData.CHECKBOX) {
|
2021-06-02 16:55:17 +08:00
|
|
|
|
const arr = []
|
|
|
|
|
|
if (label.param && JSON.parse(label.param).items) {
|
|
|
|
|
|
JSON.parse(label.param).items.forEach(item => {
|
|
|
|
|
|
if (item.check) {
|
|
|
|
|
|
arr.push(item.name)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
return arr
|
2021-05-13 19:02:23 +08:00
|
|
|
|
} else if (label.type.toUpperCase() === this.assetConstants.labelTypeData.MULTITEXT || label.type.toUpperCase() === assetConstants.labelTypeData.TEXT || label.type.toUpperCase() === assetConstants.labelTypeData.TEXTAREA) {
|
2021-04-23 19:58:08 +08:00
|
|
|
|
return ['']
|
2021-06-02 16:55:17 +08:00
|
|
|
|
} else if (label.type.toUpperCase() === this.assetConstants.labelTypeData.RADIO || label.type.toUpperCase() === assetConstants.labelTypeData.SELECT) {
|
|
|
|
|
|
const arr = ['']
|
|
|
|
|
|
if (label.param && JSON.parse(label.param).items) {
|
|
|
|
|
|
JSON.parse(label.param).items.forEach(item => {
|
|
|
|
|
|
if (item.check) {
|
|
|
|
|
|
arr[0] = item.name
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
return arr
|
2021-04-23 19:58:08 +08:00
|
|
|
|
} else {
|
2021-05-26 16:35:10 +08:00
|
|
|
|
return ['']
|
2021-04-23 19:58:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
getParentAsset () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get(this.url, { pageSize: -1, vmh: 1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.options.parentAssetOptions = response.data.list
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
selectType (type) {
|
2022-04-22 16:36:05 +08:00
|
|
|
|
this.$refs.cascader.$refs.panel.clearCheckedNodes()
|
|
|
|
|
|
this.$refs.cascader.$refs.panel.activePath = []
|
|
|
|
|
|
this.editAsset.brandAndModel = ''
|
|
|
|
|
|
this.lockModelInputValue = ''
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.editAsset.type = { ...type }
|
|
|
|
|
|
this.editAsset.typeId = type.id ? type.id : ''
|
2021-11-26 17:45:22 +08:00
|
|
|
|
this.editAsset.authType = ''
|
|
|
|
|
|
this.editAsset.authUsername = ''
|
|
|
|
|
|
this.editAsset.authPin = ''
|
|
|
|
|
|
this.editAsset.authUserTip = ''
|
|
|
|
|
|
this.editAsset.authPinTip = ''
|
|
|
|
|
|
this.editAsset.snmpCredentialId = ''
|
|
|
|
|
|
this.editAsset.authProtocolPort = ''
|
|
|
|
|
|
this.editAsset.pid = ''
|
2022-04-22 16:36:05 +08:00
|
|
|
|
this.getModelData()
|
2021-04-22 12:25:23 +08:00
|
|
|
|
},
|
|
|
|
|
|
addLabel ([groupId, metaId]) {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
const label = this.options.metaOptions.find(m => m.id === metaId)
|
2021-04-23 19:58:08 +08:00
|
|
|
|
this.editAsset.fields.push({ ...label, value: this.blankLabelValue(label), action: 0 })
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.labelCascShow = false
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.labelCascShow = true
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
/* 关闭弹框 */
|
|
|
|
|
|
esc (refresh) {
|
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
this.$emit('close', refresh)
|
|
|
|
|
|
},
|
|
|
|
|
|
getCabinetData (id) {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('cabinet?dcId=' + id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.options.cabinetOptions = response.data.list
|
|
|
|
|
|
for (let i = 0; i < this.options.cabinetOptions.length; i++) {
|
|
|
|
|
|
this.$set(this.options.cabinetOptions[i], 'children', this.options.dcOptions)
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-04-26 21:42:15 +08:00
|
|
|
|
resolve(this.options.cabinetOptions)
|
2021-04-22 12:25:23 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
save () {
|
2022-05-31 17:31:32 +08:00
|
|
|
|
const self = this
|
|
|
|
|
|
// console.log(123123132, self, 'params.id')
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (this.prevent_opt.save) { return }
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.prevent_opt.save = true
|
|
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (this.editAsset.brandAndModel.length === 2) {
|
|
|
|
|
|
this.editAsset.brandId = parseInt(this.editAsset.brandAndModel[0])
|
|
|
|
|
|
this.editAsset.modelId = parseInt(this.editAsset.brandAndModel[1])
|
|
|
|
|
|
}
|
2021-11-26 17:45:22 +08:00
|
|
|
|
if (this.editAsset.type.authProtocol !== assetConstants.authProtocolData.ssh) {
|
|
|
|
|
|
this.editAsset.authType = ''
|
|
|
|
|
|
}
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.$refs.form.validate((valid) => {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
if (valid) {
|
2021-07-19 17:04:46 +08:00
|
|
|
|
const params = JSON.parse(JSON.stringify(this.editAsset))
|
2022-01-05 18:01:30 +08:00
|
|
|
|
params.fields.forEach(field => {
|
|
|
|
|
|
if (field.type === 'DATETIME') {
|
|
|
|
|
|
const param = JSON.parse(field.param)
|
2022-01-10 15:45:58 +08:00
|
|
|
|
if (param.subType !== 'time') {
|
|
|
|
|
|
const fmt = param.subType === 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
|
2022-01-10 15:32:17 +08:00
|
|
|
|
field.value = field.value.map(time => bus.timeFormate(new Date(time), fmt))
|
2022-01-05 18:01:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (params.purchaseDate) {
|
|
|
|
|
|
params.purchaseDate = bus.timeFormate(new Date(params.purchaseDate), 'YYYY-MM-DD')
|
|
|
|
|
|
}
|
2022-02-18 11:01:29 +08:00
|
|
|
|
if (!params.showSSH) {
|
|
|
|
|
|
params.authType = ''
|
|
|
|
|
|
params.authUsername = ''
|
|
|
|
|
|
params.authPriKey = ''
|
|
|
|
|
|
params.authPin = ''
|
|
|
|
|
|
}
|
2021-07-19 17:04:46 +08:00
|
|
|
|
if (params.type.vm !== 1) {
|
|
|
|
|
|
params.parent = {}
|
2021-08-04 10:32:53 +08:00
|
|
|
|
params.pid = '-1'
|
2021-07-19 17:04:46 +08:00
|
|
|
|
}
|
2021-08-26 17:10:32 +08:00
|
|
|
|
if (params.fields) {
|
|
|
|
|
|
params.fields.forEach(field => {
|
|
|
|
|
|
if (field.type.toUpperCase() === assetConstants.labelTypeData.CHECKBOX) { // 控制 check 选择中的顺序 跟 创建的一致
|
|
|
|
|
|
const arr = []
|
|
|
|
|
|
const items = JSON.parse(field.param).items
|
|
|
|
|
|
items.forEach(item => {
|
|
|
|
|
|
const findItem = field.value.find(fieldValue => fieldValue == item.name)
|
|
|
|
|
|
if (findItem) {
|
|
|
|
|
|
arr.push(item.name)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
field.value = arr
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-07-19 17:04:46 +08:00
|
|
|
|
if (params.id) {
|
|
|
|
|
|
this.$put(this.url, params).then(res => {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
if (res.code === 200) {
|
2022-06-14 16:12:27 +08:00
|
|
|
|
this.messageShow(this.$t('tip.saveSuccess'), '/endpoint', { assetId: res.data.id }, false, 'guide.addEndpoint')
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2021-07-19 17:04:46 +08:00
|
|
|
|
this.$post(this.url, params).then(res => {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
if (res.code === 200) {
|
2022-06-14 16:12:27 +08:00
|
|
|
|
this.messageShow(this.$t('tip.saveSuccess'), '/endpoint', { assetId: res.data.id }, true, 'guide.addEndpoint')
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-04-26 21:42:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
getStateData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('asset/stateConf?pageSize=-1').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.options.stateOptions = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getDcData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('dc', { pageSize: -1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.dcData = response.data.list
|
|
|
|
|
|
this.options.dcOptions = response.data.list.map(d => { return { ...d, value: d.id } })
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getTypeTreeData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('asset/typeConf/tree').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.options.typeOptions = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getSnmpCredentialData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('snmp/credential', { pageSize: -1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.options.snmpCredentialOptions = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getFieldGroupData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('asset/field/group', { pageSize: -1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.options.fieldGroupOptions = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getModelData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
2022-04-22 16:36:05 +08:00
|
|
|
|
this.$get('asset/model?pageSize=-1&typeIds=' + this.editAsset.typeId).then(response => {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.options.modelOptions = response.data.list
|
|
|
|
|
|
const titleSearchData = {}
|
|
|
|
|
|
this.options.modelOptions.forEach(m => {
|
|
|
|
|
|
if (titleSearchData[m.brand.name]) {
|
|
|
|
|
|
titleSearchData[m.brand.name].children.push(m)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
titleSearchData[m.brand.name] = { ...m.brand, children: [m] }
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.options.brandAndModelOptions = Object.keys(titleSearchData).map(b => titleSearchData[b])
|
2022-04-22 16:36:05 +08:00
|
|
|
|
if (!this.editAsset.type.name) {
|
|
|
|
|
|
this.judgeTypes = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.judgeTypes = false
|
|
|
|
|
|
}
|
2021-04-26 21:42:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2021-08-10 14:26:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
checkLocation (rule, value, callback) {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
if (this.editAsset.cabinetId) {
|
|
|
|
|
|
callback()
|
|
|
|
|
|
} else if (this.editAsset.dcId) {
|
|
|
|
|
|
callback()
|
|
|
|
|
|
} else if (this.editAsset.cabinetStart && this.editAsset.cabinetEnd) {
|
|
|
|
|
|
callback()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
callback(new Error(vm.$t('validate.required')))
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 100)
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|