feat: asset基本功能
This commit is contained in:
@@ -79,10 +79,82 @@
|
||||
<template v-slot:label>
|
||||
<div class="form__labels-label">
|
||||
<span>{{label.name}}</span>
|
||||
<span @click="removeLabel(label)"><i class="nz-icon nz-icon-minus"></i></span>
|
||||
<div>
|
||||
<el-checkbox v-model="label.action" :false-label="0" :label="$t('overall.delete')" :true-label="1" size="small" style="padding-right: 20px;"></el-checkbox>
|
||||
<span @click="removeLabel(label)"><i class="nz-icon nz-icon-minus"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-input v-model="label.value" size="small"/>
|
||||
<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"/>
|
||||
<span><i class="nz-icon nz-icon-minus"></i></span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.TEXTAREA">
|
||||
<el-input v-model="label.value[0]" :maxlength="4096" size="small" type="textarea"/>
|
||||
</template>
|
||||
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.RADIO">
|
||||
<el-radio v-for="item in JSON.parse(label.param).items" :key="item.name" v-model="label.value[0]" :label="item.name">{{item.name}}</el-radio>
|
||||
</template>
|
||||
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.CHECKBOX">
|
||||
<el-checkbox-group v-model="label.value">
|
||||
<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">
|
||||
<el-select v-model="label.value[0]" class="right-box__select" popper-class="right-box-select-dropdown prevent-clickoutside" size="small">
|
||||
<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">
|
||||
<el-input v-model="label.value[0]" oninput="value=value.replace(/[^0-9.]/g,'')" size="small"></el-input>
|
||||
</template>
|
||||
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.DATETIME">
|
||||
<template v-if="JSON.parse(label.param).subType === assetConstants.labelSubTypeData.time">
|
||||
<div v-if="label.interval" style="display: flex; justify-content: space-between">
|
||||
<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>
|
||||
<template v-if="label.interval">
|
||||
<el-date-picker
|
||||
id="asset-box-input-purchase-date"
|
||||
v-model="label.value[0]"
|
||||
:type="JSON.parse(label.param).subType === assetConstants.labelSubTypeData.date ? 'dateRange' : 'datetimerange'"
|
||||
placeholder=""
|
||||
size="small"
|
||||
style="width: 100%">
|
||||
</el-date-picker>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-date-picker
|
||||
id="asset-box-input-parchase-date"
|
||||
v-model="label.value[0]"
|
||||
:type="JSON.parse(label.param).subType"
|
||||
placeholder=""
|
||||
size="small"
|
||||
style="width: 100%"
|
||||
value-format="yyyy-MM-dd">
|
||||
</el-date-picker>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else-if="label.type.toUpperCase() === assetConstants.labelTypeData.EMAIL">
|
||||
<input v-model="label.value[0]" size="small"></input>
|
||||
</template>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<!-- label的新增按钮 -->
|
||||
@@ -137,6 +209,9 @@
|
||||
<el-form-item :label="$t('asset.passwordPrompt')" prop="authPinTip">
|
||||
<el-input v-model="editAsset.authPinTip" size="small"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('asset.port')" prop="authProtocolPort">
|
||||
<el-input v-model="editAsset.authProtocolPort" size="small"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<!-- SNMP -->
|
||||
<template v-if="editAsset.type && editAsset.type.snmpEnable === 1">
|
||||
@@ -295,9 +370,9 @@ export default {
|
||||
immediate: true,
|
||||
handler (n) {
|
||||
this.editAsset = JSON.parse(JSON.stringify(n))
|
||||
this.editAsset.stateId = n.state ? n.state.id : ''
|
||||
this.editAsset.typeId = n.type ? n.type.id : ''
|
||||
this.$nextTick(() => {
|
||||
this.editAsset.stateId = n.state ? n.state.id : ''
|
||||
this.editAsset.typeId = n.type ? n.type.id : ''
|
||||
if (n.id) {
|
||||
this.lockModelInputValue = `${n.brand.name} / ${n.model.name}`
|
||||
}
|
||||
@@ -391,6 +466,18 @@ export default {
|
||||
this.labelCascShow = true
|
||||
})
|
||||
},
|
||||
addMultiTextRow (label) {
|
||||
label.value.push('')
|
||||
},
|
||||
blankLabelValue (label) {
|
||||
if (label.type.toUpperCase() === this.assetConstants.labelTypeData.CHECKBOX) {
|
||||
return []
|
||||
} else if (label.type.toUpperCase() === this.assetConstants.labelTypeData.MULTITEXT) {
|
||||
return ['']
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
getParentAsset () {
|
||||
return new Promise(resolve => {
|
||||
this.$get(this.url, { pageSize: -1, vmh: 1 }).then(response => {
|
||||
@@ -407,7 +494,7 @@ export default {
|
||||
},
|
||||
addLabel ([groupId, metaId]) {
|
||||
const label = this.metaData.find(m => m.id === metaId)
|
||||
this.editAsset.fields.push({ id: label.id, value: '', name: label.name })
|
||||
this.editAsset.fields.push({ ...label, value: this.blankLabelValue(label), action: 0 })
|
||||
this.labelCascShow = false
|
||||
this.$nextTick(() => {
|
||||
this.labelCascShow = true
|
||||
|
||||
Reference in New Issue
Block a user