This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/table/settings/ipamTable.vue

190 lines
6.4 KiB
Vue
Raw Normal View History

2022-03-03 10:33:29 +08:00
<template>
<el-table
id="modelTable"
ref="dataTable"
:data="tableData"
:height="height"
border
:default-sort="orderBy"
2022-03-03 10:33:29 +08:00
@header-dragend="dragend"
@sort-change="tableDataSort"
@selection-change="selectionChange"
>
<el-table-column
:resizable="false"
align="center"
type="selection"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in customTableTitle"
v-if="item.show"
:key="`col-${index}`"
:fixed="item.fixed"
:label="item.label"
:min-width="`${item.minWidth}`"
:prop="item.prop"
:resizable="true"
:sort-orders="['ascending', 'descending']"
:sortable="item.sortable"
:width="`${item.width}`"
>
<template slot="header">
<span class="data-column__span">{{item.label}}</span>
<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>
<template v-else-if="item.prop === 'CIDR'">
2022-10-20 17:08:16 +08:00
<copy :copyData='scope.row.addr + "/" + scope.row.mask' :showInfo='scope.row.addr || scope.row.mask'>
<template slot="copy-text">
{{ scope.row.addr }}/{{scope.row.mask}}
</template>
</copy>
</template>
2022-03-03 10:33:29 +08:00
<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>
<template v-else-if="item.prop === 'name'">
2022-10-20 17:08:16 +08:00
<copy :copyData='scope.row[item.prop]' :showInfo='scope.row[item.prop]'>
<template slot="copy-text">
{{scope.row[item.prop]?scope.row[item.prop]:'-'}}
</template>
</copy>
</template>
2022-03-03 10:33:29 +08:00
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column
:resizable="false"
:width="operationWidth"
fixed="right">
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
<div slot-scope="scope" class="table-operation-items">
<button class="table-operation-item" @click="showBottomBox('ipam', scope.row)" :title="$t('overall.view')"><i class="nz-icon nz-icon-view1"></i></button>
2022-03-03 18:06:45 +08:00
<el-dropdown size="medium" trigger="click" v-has="['ipam_edit', 'ipam_delete']" @command="tableOperation">
<div class="table-operation-item table-operation-item--more" :title="$t('overall.moreOperations')">
2022-03-03 10:33:29 +08:00
<i class="nz-icon nz-icon-more3"></i>
</div>
<el-dropdown-menu slot="dropdown" class="right-box-select-top right-public-box-dropdown-top">
2022-03-16 15:55:19 +08:00
<el-dropdown-item v-has="'ipam_edit'" :command="['edit', scope.row]"><i class="nz-icon nz-icon-edit"></i><span class="operation-dropdown-text">{{$t('overall.edit')}}</span></el-dropdown-item>
2022-03-03 18:06:45 +08:00
<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 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 v-has="'ipam_delete'" :command="['delete', scope.row]">
<delete-button
ref="deleteButton"
:from="'ipam'"
:forceDeleteShow="true"
:type="'link'"
:title="$t('overall.delete')"
id="account-list-delete"
v-has="'ipam_delete'"
:api="api"
:single="true"
:delete-objs="singleDelete"
@before="delFlag=true"
></delete-button>
</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> -->
2022-03-03 10:33:29 +08:00
</el-dropdown-menu>
</el-dropdown>
</div>
</el-table-column>
<template slot="empty">
<div v-if="!loading" class="table-no-data">
<svg class="icon" aria-hidden="true">
<use xlink:href="#nz-icon-no-data-list"></use>
</svg>
<div class="table-no-data__title">No results found</div>
</div>
<div v-else>&nbsp;</div>
</template>
</el-table>
</template>
<script>
import table from '@/components/common/mixin/table'
import deleteButton from '@/components/common/deleteButton'
2022-10-20 17:08:16 +08:00
import copy from '@/components/common/copy'
2022-03-03 10:33:29 +08:00
export default {
name: 'ipamTable',
mixins: [table],
components: {
2022-10-20 17:08:16 +08:00
deleteButton,
copy
},
2022-03-03 10:33:29 +08:00
props: {
loading: Boolean
},
data () {
return {
tableTitle: [ // 原始table列
{
label: 'ID',
prop: 'id',
show: true,
width: 80,
sortable: 'custom'
}, {
label: this.$t('overall.name'),
prop: 'name',
show: true,
minWidth: 200,
sortable: 'custom'
}, {
label: this.$t('overall.type'),
prop: 'type',
show: true,
width: 200,
sortable: 'custom'
}, {
label: 'CIDR',
prop: 'CIDR',
show: true,
minWidth: 200,
sortable: 'custom'
}, {
label: this.$t('overall.dc'),
prop: 'dc',
show: true,
width: 200,
sortable: 'custom'
}, {
label: this.$t('overall.vlan'),
prop: 'vlan',
show: true,
width: 200
2022-03-03 10:33:29 +08:00
}, {
label: this.$t('overall.remark'),
prop: 'remark',
minWidth: 200,
show: true
}
]
}
},
methods: {
tableDataSort (item) {
let orderBy = ''
2022-03-03 18:06:45 +08:00
let str = item.prop
2022-03-03 10:33:29 +08:00
if (str === 'dc') {
orderBy = str
}
2022-03-03 18:06:45 +08:00
if (str === 'CIDR') {
str = 'addr'
orderBy = str
}
2022-03-03 10:33:29 +08:00
if (item.order === 'ascending') {
orderBy = str
}
if (item.order === 'descending') {
orderBy = '-' + str
}
this.$emit('orderBy', orderBy)
}
}
}
</script>