feat: ipam ip 二级菜单编辑页面

This commit is contained in:
@changcode
2022-03-17 09:46:56 +08:00
parent e074264ea9
commit 291562452a
3 changed files with 193 additions and 22 deletions

View File

@@ -18,7 +18,7 @@
<ip-details-table
ref="dataTable"
:api="url"
:orderByFa="'id'"
:orderByFa="orderBy"
v-loading="tools.loading"
:loading="tools.loading"
:custom-table-title="tools.customTableTitle"
@@ -33,10 +33,18 @@
@selectionChange="selectionChange"
></ip-details-table>
</template>
<template v-slot:top-tool-right>
<button id="ipam-ip" class="top-tool-btn margin-r-10 margin-l-10" @click.stop="add">
<i class="nz-icon nz-icon-create-square"></i>
</button>
</template>
<template v-slot:pagination>
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
</template>
</nz-bottom-data-list>
<transition name="right-box">
<ip-details-box v-if="rightBox.show" :obj="object" @close="closeRightBox"></ip-details-box>
</transition>
</div>
</template>
@@ -46,17 +54,28 @@ import dataListMixin from '@/components/common/mixin/dataList'
import subDataListMixin from '@/components/common/mixin/subDataList'
import detailViewRightMixin from '@/components/common/mixin/detailViewRightMixin'
import ipDetailsTable from '@/components/common/table/settings/ipDetailsTable'
import ipDetailsBox from '@/components/common/rightBox/ipDetailsBox'
export default {
name: 'IpDetails',
mixins: [dataListMixin, subDataListMixin, detailViewRightMixin],
components: {
nzBottomDataList,
ipDetailsTable
ipDetailsTable,
ipDetailsBox
},
data () {
return {
url: '/ipam/ip',
tableId: 'IpDetails', // 需要分页的table的id用于记录每页数量
blankObject: {
id: '',
name: '',
addr: '',
mac: '',
state: '',
remark: '',
asset: { id: '', name: '' }
},
searchMsg: { // 给搜索框子组件传递的信息
zheze_none: true,
searchLabelList: [{
@@ -99,8 +118,42 @@ export default {
delete this.searchLabel.orderBy
}
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'id', this.obj.id)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
this.tools.loading = true
this.tableData = [{
id: 1,
name: 'node-1',
subnet: {
id: 1,
name: 'bj'
},
asset: {
id: 1,
name: 'bj'
},
addr: '192.168.40.0',
mac: '1a:1b:6b:1d:65:1d',
remark: '',
state: 1,
uts: 1646982371692
}, {
id: 2,
name: 'node-1',
subnet: {
id: 1,
name: 'bj'
},
asset: {
id: 1,
name: 'bj'
},
addr: '192.168.40.0',
mac: '1a:1b:6b:1d:65:1d',
remark: '',
state: 1,
uts: 1646982371692
}]
this.$get(this.url, { ...this.searchLabel }).then(response => {
this.tools.loading = false
if (response.code === 200) {
@@ -119,15 +172,16 @@ export default {
})
}
},
watch: {
obj: {
immediate: true,
deep: true,
handler (n, o) {
if (n) {
console.log(n)
this.getTableData()
}
}
}
}
}
</script>

View File

@@ -0,0 +1,124 @@
<template>
<div class="right-box right-box-ipam" v-clickoutside="{obj:editipDetails,func:clickOutside}" >
<!-- begin--标题-->
<div class="right-box__header">
<div class="header__title">{{editipDetails.id ? ($t("overall.ipam.edit")) : $t("overall.ipam.create")}}</div>
<div class="header__operation">
<span v-cancel="{obj: editipDetails, func: esc}"><i class="nz-icon nz-icon-close"></i></span>
</div>
</div>
<!-- begin--表单-->
<div class="right-box__container">
<div class="container__form">
<el-form :model="editipDetails" label-position="top" label-width="120px" :rules="rules" ref="ipDetailsForm">
<el-form-item :label="$t('overall.name')" prop="name">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipDetails.name" size="small"></el-input>
</el-form-item>
<el-form-item label="IP" prop="addr">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipDetails.addr" size="small"></el-input>
</el-form-item>
<el-form-item label="MAC" prop="mac">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipDetails.mac" size="small"></el-input>
</el-form-item>
<el-form-item :label="$t('config.ipamip.asset')" prop="asset">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipDetails.asset.name" size="small"></el-input>
</el-form-item>
<el-form-item :label="$t('overall.state')" prop="state">
<el-input maxlength="256" rows="4" show-word-limit placeholder="" v-model="editipDetails.state" size="small"></el-input>
</el-form-item>
<el-form-item :label="$t('overall.remark')" prop="remark">
<el-input maxlength="256" rows="4" show-word-limit type="textarea" placeholder="" v-model="editipDetails.remark" size="small" id="mib-box-input-remark"></el-input>
</el-form-item>
</el-form>
</div>
</div>
<!--底部按钮-->
<div class="right-box__footer">
<button v-cancel="{obj:editipDetails,func:esc}" id="model-box-esc" class="footer__btn footer__btn--light">
<span>{{$t('overall.cancel')}}</span>
</button>
<button :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" @click="save" class="footer__btn" id="model-box-save">
<span>{{$t('overall.save')}}</span>
</button>
</div>
</div>
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'ipDetailsBox',
props: {
obj: Object
},
mixins: [editRigthBox],
data () {
return {
editipDetails: {},
rules: {
name: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
addr: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
mac: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
]
}
}
},
methods: {
clickOutside () {
this.esc(false)
},
/* 关闭弹框 */
esc (refresh) {
this.$emit('close', refresh)
},
/* 保存 */
save () {
this.$refs.ipDetailsForm.validate((valid) => {
if (valid) {
this.prevent_opt.save = true
if (!this.editipDetails.id) {
this.$post('/ipam/ip', this.editipDetails).then(response => {
if (response.code == 200 && response.msg == 'success') {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(response.msg)
}
this.prevent_opt.save = false
})
} else {
this.$put('/ipam/ip', this.editipDetails).then(response => {
if (response.code == 200 && response.msg == 'success') {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(response.msg)
}
this.prevent_opt.save = false
})
}
} else {
this.prevent_opt.save = false
}
})
}
},
watch: {
obj: {
immediate: true,
deep: true,
handler (n, o) {
this.isEdit = true
this.editipDetails = JSON.parse(JSON.stringify(n))
}
}
}
}
</script>

View File

@@ -33,16 +33,9 @@
<div class="col-resize-area"></div>
</template>
<template slot-scope="scope" :column="item">
<!-- <span v-if="item.prop === 'dc'">{{scope.row[item.prop]?scope.row[item.prop].name:'-'}}</span>-->
<!-- <span v-else-if="item.prop === 'CIDR'">-->
<!-- <template>{{ scope.row.addr }} / {{scope.row.mask}}</template>-->
<!-- </span>-->
<!-- <span v-else-if="item.prop === 'type'">-->
<!-- <template v-if="scope.row.type === 4">IPV4</template>-->
<!-- <template v-else-if="scope.row.type === 6">IPV6</template>-->
<!-- </span>-->
<span v-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
<span v-else>-</span>
<template v-if="item.prop === 'asset'">{{scope.row.asset.name}}</template>
<template v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
<template v-else>-</template>
</template>
</el-table-column>
<el-table-column
@@ -93,7 +86,7 @@ export default {
sortable: 'custom'
}, {
label: 'IP',
prop: 'ip',
prop: 'addr',
show: true,
minWidth: 200,
sortable: 'custom'
@@ -105,12 +98,12 @@ export default {
sortable: 'custom'
}, {
label: 'MAC',
prop: 'MAC',
prop: 'mac',
show: true,
minWidth: 200,
sortable: 'custom'
}, {
label: this.$t('overall.asset'),
label: this.$t('config.ipamip.asset'),
prop: 'asset',
show: true,
width: 200,