feat: 补充 IPAM 页面

This commit is contained in:
@changcode
2022-03-03 18:06:45 +08:00
parent cc4f5698ec
commit 82b3ee216c
7 changed files with 117 additions and 36 deletions

View File

@@ -0,0 +1,26 @@
.right-box-ipam {
.cidr {
display: flex;
}
.cidr-title {
float: none;
text-align: left;
color: $--color-text-regular;
padding: 0 0 6px 0;
font-size: 14px;
}
.cidr-title::before {
content: '*';
color: #EC7F66;
margin-right: 4px;
}
.cidr-addr.el-form-item.is-required {
flex: 3;
margin-right: 5px;
}
}
.el-select-dropdown.right-box__select-width .el-select-dropdown__item {
text-overflow:ellipsis;
white-space:nowrap;
width: 199px;
}

View File

@@ -44,6 +44,7 @@
@import './common/rightBox/locationCascader.scss'; @import './common/rightBox/locationCascader.scss';
@import './common/rightBox/menuBox.scss'; @import './common/rightBox/menuBox.scss';
@import './common/rightBox/moduleBox.scss'; @import './common/rightBox/moduleBox.scss';
@import './common/rightBox/ipam.scss';
@import './common/rightBox/chartRightBox/chartRightBox.scss'; @import './common/rightBox/chartRightBox/chartRightBox.scss';
@import './common/rightBox/mibBox.scss'; @import './common/rightBox/mibBox.scss';
@import './common/rightBox/assetBactchEditBox.scss'; @import './common/rightBox/assetBactchEditBox.scss';

View File

@@ -948,15 +948,17 @@ export default {
target: this.searchLabel, target: this.searchLabel,
isSearchInput: true, isSearchInput: true,
propertyName: 'dc', propertyName: 'dc',
type: 'string', type: 'number',
defaultJson: { defaultJson: {
name: 'Date center',
type: 'dc',
label: 'dcIds',
disabled: false, disabled: false,
label: 'dcId', val: '',
name: 'Data center', valnum: '',
type: 'input', listStr: 'dcSelect'
val: ''
}, },
jsonKey: 'val' jsonKey: 'valnum'
} }
} }
} }

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="right-box right-box-mib" v-clickoutside="{obj:editipam,func:clickOutside}" > <div class="right-box right-box-ipam" v-clickoutside="{obj:editipam,func:clickOutside}" >
<!-- begin--标题--> <!-- begin--标题-->
<div class="right-box__header"> <div class="right-box__header">
<div class="header__title">{{editipam.id ? ($t("overall.ipam.edit")) : $t("overall.ipam.create")}}</div> <div class="header__title">{{editipam.id ? ($t("overall.ipam.edit")) : $t("overall.ipam.create")}}</div>
@@ -21,24 +21,41 @@
clearable clearable
collapse-tags collapse-tags
placeholder="" placeholder=""
popper-class="right-box-select-top right-public-box-dropdown-top prevent-clickoutside" @change="validValueType"
:disabled="!!editipam.id"
popper-class="right-box-select-top prevent-clickoutside"
size="small"> size="small">
<template v-for="item in typeList"> <template v-for="item in typeList">
<el-option :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option :key="item.value" :label="item.label" :value="item.value"></el-option>
</template> </template>
</el-select> </el-select>
</el-form-item> </el-form-item>
<div class="form__sub-title">CIDR</div> <div class="cidr-title">CIDR</div>
<el-form-item :label="$t('overall.addr')" prop="addr"> <div class="cidr">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipam.addr" size="small"></el-input> <el-form-item class="cidr-addr" prop="addr">
<el-input maxlength="256" rows="4" show-word-limit placeholder="address" v-model="editipam.addr" size="small"></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('overall.mask')" prop="mask"> <el-form-item prop="mask">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipam.mask" size="small"></el-input> <el-select id="account-input-language"
class="right-box__select"
v-model="editipam.mask"
clearable
collapse-tags
placeholder="mask"
popper-class="right-box-select-top right-box__select-width prevent-clickoutside"
size="small">
<template v-for="(item, index) in maskList">
<el-option :key="item" :label="item" :value="item" :title="'/'+item+'\('+2 ** index+'\)'">
<span>/{{item}}({{2 ** index}})</span>
</el-option>
</template>
</el-select>
</el-form-item> </el-form-item>
</div>
<el-form-item :label="$t('overall.vlan')" prop="vlan"> <el-form-item :label="$t('overall.vlan')" prop="vlan">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipam.vlan" size="small"></el-input> <el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipam.vlan" size="small"></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('overall.dc')" prop="dc"> <el-form-item :label="$t('overall.dc')" prop="dc.name">
<div class="right-box-form-content"> <div class="right-box-form-content">
<el-select id="prom-box-input-dc" v-model="editipam.dc" placeholder="" class="right-box__select" popper-class="right-box-select-top right-public-box-dropdown-top prevent-clickoutside" size="small" value-key="id"> <el-select id="prom-box-input-dc" v-model="editipam.dc" placeholder="" class="right-box__select" popper-class="right-box-select-top right-public-box-dropdown-top prevent-clickoutside" size="small" value-key="id">
<el-option v-for="item in dcData" :id="'prom-edit-dc-op-'+item.id" :key="item.id" :label="item.name" :value="item"> <el-option v-for="item in dcData" :id="'prom-edit-dc-op-'+item.id" :key="item.id" :label="item.name" :value="item">
@@ -83,6 +100,7 @@ export default {
{ label: 'IPV4', value: 4 }, { label: 'IPV4', value: 4 },
{ label: 'IPV6', value: 6 } { label: 'IPV6', value: 6 }
], ],
maskList: [],
rules: { rules: {
name: [ name: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } { required: true, message: this.$t('validate.required'), trigger: 'blur' }
@@ -96,7 +114,7 @@ export default {
mask: [ mask: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } { required: true, message: this.$t('validate.required'), trigger: 'blur' }
], ],
dc: [ 'dc.name': [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } { required: true, message: this.$t('validate.required'), trigger: 'blur' }
] ]
}, },
@@ -149,6 +167,24 @@ export default {
this.dcData = response.data.list this.dcData = response.data.list
} }
}) })
},
validValueType (e) {
const mask = []
let maskArray = []
if (e === 4) {
for (let i = 1; i <= 32; i++) {
mask.push(i)
}
maskArray = Array.from(new Set(mask))
maskArray.sort(function (a, b) { return b - a })
} else if (e === 6) {
for (let i = 1; i <= 128; i++) {
mask.push(i)
}
maskArray = Array.from(new Set(mask))
maskArray.sort(function (a, b) { return b - a })
}
this.maskList = maskArray
} }
}, },
mounted () { mounted () {
@@ -161,6 +197,23 @@ export default {
handler (n, o) { handler (n, o) {
this.isEdit = true this.isEdit = true
this.editipam = JSON.parse(JSON.stringify(n)) this.editipam = JSON.parse(JSON.stringify(n))
const mask = []
let maskArray = []
if (this.editipam.type === 4) {
for (let i = 1; i <= 32; i++) {
mask.push(i)
}
maskArray = Array.from(new Set(mask))
maskArray.sort(function (a, b) { return b - a })
this.maskList = maskArray
} else if (this.editipam.type === 6) {
for (let i = 1; i <= 128; i++) {
mask.push(i)
}
maskArray = Array.from(new Set(mask))
maskArray.sort(function (a, b) { return b - a })
}
this.maskList = maskArray
} }
}, },
'editipam.dc': function (n, o) { 'editipam.dc': function (n, o) {

View File

@@ -1466,7 +1466,7 @@ export default {
if (this.$route.path === '/asset' || this.targetTab === 'asset') { if (this.$route.path === '/asset' || this.targetTab === 'asset') {
this.getAssetStateData() this.getAssetStateData()
} }
if (this.$route.path === '/agent') { if (this.$route.path === '/agent' || this.$route.path === '/ipam') {
this.getDcData() this.getDcData()
} }
if (this.$route.path === '/model') { if (this.$route.path === '/model') {

View File

@@ -51,15 +51,15 @@
fixed="right"> fixed="right">
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div> <div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
<div slot-scope="scope" class="table-operation-items"> <div slot-scope="scope" class="table-operation-items">
<button class="table-operation-item" @click="$emit('edit', scope.row)"><i class="nz-icon nz-icon-edit"></i></button> <button class="table-operation-item" v-has="'ipam_edit'" @click="$emit('edit', scope.row)"><i class="nz-icon nz-icon-edit"></i></button>
<el-dropdown size="medium" trigger="click" @command="tableOperation"> <el-dropdown size="medium" trigger="click" v-has="['ipam_edit', 'ipam_delete']" @command="tableOperation">
<div class="table-operation-item table-operation-item--more"> <div class="table-operation-item table-operation-item--more">
<i class="nz-icon nz-icon-more3"></i> <i class="nz-icon nz-icon-more3"></i>
</div> </div>
<el-dropdown-menu slot="dropdown" class="right-box-select-top right-public-box-dropdown-top"> <el-dropdown-menu slot="dropdown" class="right-box-select-top right-public-box-dropdown-top">
<el-dropdown-item :command="['copy', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('overall.duplicate')}}</span></el-dropdown-item> <el-dropdown-item v-has="'ipam_edit'" :command="['copy', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('overall.duplicate')}}</span></el-dropdown-item>
<el-dropdown-item :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('overall.delete')}}</span></el-dropdown-item> <el-dropdown-item v-has="'ipam_delete'" :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('overall.delete')}}</span></el-dropdown-item>
<el-dropdown-item :command="['sync', scope.row]"><i class="nz-icon nz-icon-sync"></i><span class="operation-dropdown-text">{{$t('overall.syncChart')}}</span></el-dropdown-item> <el-dropdown-item v-has="'ipam_edit'" :command="['sync', scope.row]"><i class="nz-icon nz-icon-sync"></i><span class="operation-dropdown-text">{{$t('overall.syncChart')}}</span></el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
@@ -134,10 +134,14 @@ export default {
methods: { methods: {
tableDataSort (item) { tableDataSort (item) {
let orderBy = '' let orderBy = ''
const str = item.prop let str = item.prop
if (str === 'dc') { if (str === 'dc') {
orderBy = str orderBy = str
} }
if (str === 'CIDR') {
str = 'addr'
orderBy = str
}
if (item.order === 'ascending') { if (item.order === 'ascending') {
orderBy = str orderBy = str
} }

View File

@@ -10,7 +10,7 @@
@search="search" @search="search"
> >
<template v-slot:top-tool-right> <template v-slot:top-tool-right>
<button id="account-add" :title="$t('overall.createipam')" class="top-tool-btn margin-r-10" <button id="account-add" v-has="'ipam_add'" :title="$t('overall.createipam')" class="top-tool-btn margin-r-10"
type="button" @click="add"> type="button" @click="add">
<i class="nz-icon-create-square nz-icon"></i> <i class="nz-icon-create-square nz-icon"></i>
</button> </button>
@@ -20,8 +20,8 @@
id="ipam" id="ipam"
:params="searchLabel" :params="searchLabel"
:permissions="{ :permissions="{
import: 'asset_add', import: 'ipam_add',
export: 'asset_edit' export: 'ipam_edit'
}" }"
class="top-tool-export margin-r-10" class="top-tool-export margin-r-10"
export-file-name="ipam" export-file-name="ipam"
@@ -32,7 +32,7 @@
<template v-slot:before> <template v-slot:before>
<div> <div>
<el-dropdown-item> <el-dropdown-item>
<delete-button :type="'link'" :title="$t('overall.batchDel')" id="account-list-batch-delete" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button> <delete-button :type="'link'" :title="$t('overall.batchDel')" v-has="'ipam_delete'" id="account-list-batch-delete" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button>
</el-dropdown-item> </el-dropdown-item>
</div> </div>
</template> </template>
@@ -90,7 +90,7 @@ export default {
name: '', name: '',
type: 4, type: 4,
addr: '', addr: '',
mask: '', mask: '24',
vlan: '', vlan: '',
remark: '', remark: '',
dc: { id: '', name: '' } dc: { id: '', name: '' }
@@ -119,11 +119,6 @@ export default {
type: 'input', type: 'input',
label: 'addr', label: 'addr',
disabled: false disabled: false
}, {
name: this.$t('overall.mask'),
type: 'input',
label: 'mask',
disabled: false
}, { }, {
name: this.$t('overall.vlan'), name: this.$t('overall.vlan'),
type: 'input', type: 'input',
@@ -131,8 +126,8 @@ export default {
disabled: false disabled: false
}, { }, {
name: this.$t('overall.dc'), name: this.$t('overall.dc'),
type: 'input', type: 'dc',
label: 'dcId', label: 'dcIds',
disabled: false disabled: false
} }
] ]