2021-04-22 12:25:23 +08:00
|
|
|
<template>
|
|
|
|
|
<el-table
|
|
|
|
|
id="roleTable"
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:height="height"
|
|
|
|
|
border
|
|
|
|
|
@header-dragend="dragend"
|
|
|
|
|
@sort-change="tableDataSort"
|
|
|
|
|
@selection-change="selectionChange"
|
2021-05-25 15:37:33 +08:00
|
|
|
@row-dblclick="(row)=>{$emit('showBottomBox', 'panelTab', row)}"
|
2021-04-22 12:25:23 +08:00
|
|
|
>
|
|
|
|
|
<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']"
|
2021-05-07 19:10:28 +08:00
|
|
|
:sortable="item.sortable"
|
2021-04-22 12:25:23 +08:00
|
|
|
:width="`${item.width}`"
|
|
|
|
|
class="data-column"
|
|
|
|
|
>
|
|
|
|
|
<template slot="header">
|
2021-05-25 17:58:38 +08:00
|
|
|
<span class="data-column__span">{{item.label}}</span>
|
2021-04-22 12:25:23 +08:00
|
|
|
<div class="col-resize-area"></div>
|
|
|
|
|
</template>
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
<template v-if="item.prop === 'type'">{{scope.row.type ? scope.row.type.name : '-'}}</template>
|
|
|
|
|
<template v-else-if="item.prop === 'state'">{{scope.row.state ? scope.row.state.name : '-'}}</template>
|
|
|
|
|
<template v-else-if="item.prop === 'endpointNum'">
|
2021-04-29 22:24:38 +08:00
|
|
|
<span style="cursor: pointer" @click="$emit('showBottomBox', 'endpointTab', scope.row)"><i class="nz-icon nz-icon-overview-endpoint monitorColor"></i> <span>{{scope.row.endpointNum ? scope.row.endpointNum : 0}}</span></span>
|
2021-04-26 21:42:15 +08:00
|
|
|
<!-- <div :class="messageStyle(item, scope.row)" @mouseenter="showTableTooltip(`${$t('asset.down')} / ${$t('asset.suspended')} / ${$t('asset.total')}`, true, $event)" @mouseleave="hideTableTooltip">
|
2021-04-22 12:25:23 +08:00
|
|
|
<span class="link" style="padding: 2px 8px" @click="showEndpoint(scope.row)">{{scope.row.endpointDownNum}}/{{scope.row.endpointSuspendedNum}}/{{scope.row.endpointNum}}</span>
|
2021-04-26 21:42:15 +08:00
|
|
|
</div>-->
|
2021-04-22 12:25:23 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'alertNum'">
|
2021-04-29 22:24:38 +08:00
|
|
|
<span style="cursor: pointer" @click="$emit('showBottomBox', 'alertMessageTab', scope.row)"><i :class="scope.row.alertNum ? 'red' : 'green'" class="nz-icon nz-icon-overview-alert"></i> <span>{{scope.row.alertNum ? scope.row.alertNum : 0}}</span></span>
|
2021-04-22 12:25:23 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'dc'">{{scope.row.dc ? scope.row.dc.name : '-'}}</template>
|
|
|
|
|
<template v-else-if="item.prop === 'cabinet'">
|
|
|
|
|
<span v-if="scope.row.cabinet && scope.row.cabinet !== '--'">{{scope.row.cabinet.name}} {{returnCabinet( scope.row.cabinetStart, scope.row.cabinetEnd)}}</span>
|
2021-07-09 15:35:58 +08:00
|
|
|
<span v-else >-</span>
|
2021-04-22 12:25:23 +08:00
|
|
|
</template>
|
2021-05-13 11:40:22 +08:00
|
|
|
<template v-else-if="item.prop == 'pingInfo'">
|
2021-05-13 14:25:03 +08:00
|
|
|
<div @mouseenter="showTableTooltip( formatPingTime(scope.row.pingInfo.lastUpdate), true, $event)" @mouseleave="hideTableTooltip" v-if="scope.row.pingInfo">
|
2021-05-13 11:40:22 +08:00
|
|
|
<div :class="{'active-icon green-bg':scope.row.pingInfo.status == 1,'active-icon red-bg':scope.row.pingInfo.status == 0}"></div><span>{{scope.row.pingInfo.rtt?scope.row.pingInfo.rtt+'ms':''}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2021-04-22 12:25:23 +08:00
|
|
|
<template v-else-if="item.prop === 'model'">{{scope.row.model ? scope.row.model.name : '-'}}</template>
|
|
|
|
|
<template v-else-if="item.prop === 'parent'">{{scope.row.parent ? scope.row.parent.name : '-'}}</template>
|
2021-07-15 14:38:55 +08:00
|
|
|
<template v-else-if="item.prop === 'children'">
|
2021-07-15 15:30:23 +08:00
|
|
|
<div @click="$emit('showBottomBox', 'assetSubTab', scope.row)" v-if="scope.row.childrenNum">
|
|
|
|
|
<i class="nz-icon nz-icon-overview-project monitorColor color23BF9A"></i>
|
|
|
|
|
{{scope.row.childrenNum}}</div>
|
|
|
|
|
<span v-else-if="scope.row.type.vm===1"> <i class="nz-icon nz-icon-overview-project monitorColor color23BF9A"></i> 0 </span>
|
2021-07-15 14:38:55 +08:00
|
|
|
<span v-else> - </span>
|
|
|
|
|
</template>
|
2021-04-22 12:25:23 +08:00
|
|
|
<template v-else-if="item.prop === 'brand'">{{scope.row.brand ? scope.row.brand.name : '-'}}</template>
|
|
|
|
|
<template v-else-if="item.prop === 'purchaseDate'">{{scope.row.purchaseDate ? scope.row.purchaseDate : '--'}}</template>
|
2021-06-02 16:55:17 +08:00
|
|
|
<template v-else>
|
|
|
|
|
<span v-if="scope.row.fields&&scope.row.fields.find(field => field.name === item.prop)">
|
|
|
|
|
{{scope.row.fields.find(field => field.name === item.prop).value.join(',')}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else>
|
|
|
|
|
{{scope.row[item.prop]}}
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
2021-04-22 12:25:23 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
:resizable="false"
|
2021-05-27 17:58:29 +08:00
|
|
|
v-if="showOption"
|
2021-04-22 12:25:23 +08:00
|
|
|
:width="operationWidth"
|
|
|
|
|
fixed="right">
|
|
|
|
|
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
|
|
|
|
|
<div slot-scope="scope" class="table-operation-items">
|
2021-06-28 09:57:57 +08:00
|
|
|
<button v-if="assetTab" class="table-operation-item" v-has="'model_edit'" @click="$emit('edit', scope.row)"><i class="nz-icon nz-icon-edit"></i></button>
|
|
|
|
|
<button v-else class="table-operation-item" @click="$emit('showBottomBox', 'panelTab', scope.row)"><i class="nz-icon nz-icon-view1"></i></button>
|
2021-05-19 14:26:09 +08:00
|
|
|
<el-dropdown size="medium" v-has="['asset_edit','asset_connect','asset_add','asset_delete']" trigger="hover" @command="tableOperation">
|
2021-04-22 12:25:23 +08:00
|
|
|
<div class="table-operation-item table-operation-item--more">
|
2021-05-27 13:53:42 +08:00
|
|
|
<i class="nz-icon nz-icon-more3"></i>
|
2021-04-22 12:25:23 +08:00
|
|
|
</div>
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
2021-06-28 09:57:57 +08:00
|
|
|
<el-dropdown-item v-if="!assetTab" v-has="'asset_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>
|
2021-05-24 10:12:01 +08:00
|
|
|
<el-dropdown-item v-has="'asset_connect'" :command="['cli', scope.row]" :disabled="!scope.row.authUsername"><i class="nz-icon nz-icon-cli"></i><span class="operation-dropdown-text">{{$t('dashboard.connect')}}</span></el-dropdown-item>
|
2021-05-19 14:04:16 +08:00
|
|
|
<el-dropdown-item v-has="'asset_add'" :command="['duplicate', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('dashboard.duplicate')}}</span></el-dropdown-item>
|
|
|
|
|
<el-dropdown-item v-has="'asset_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>
|
2021-06-01 14:26:09 +08:00
|
|
|
<el-dropdown-item v-has="'alertSilence_add'" :command="['fastSilence', scope.row, 'asset']"><i class="nz-icon nz-icon-fast-silence"></i><span class="operation-dropdown-text">{{$t('overall.silenceAlert')}}</span></el-dropdown-item>
|
2021-04-22 12:25:23 +08:00
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import table from '@/components/common/mixin/table'
|
|
|
|
|
import { showTableTooltip, hideTableTooltip } from '@/components/common/js/tools'
|
2021-05-13 11:40:22 +08:00
|
|
|
import bus from '@/libs/bus'
|
2021-04-22 12:25:23 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'assetTable',
|
|
|
|
|
mixins: [table],
|
2021-05-27 17:58:29 +08:00
|
|
|
props: {
|
|
|
|
|
showOption: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
2021-06-28 09:57:57 +08:00
|
|
|
},
|
|
|
|
|
assetTab: Boolean
|
2021-05-27 17:58:29 +08:00
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
tableTitle: [
|
|
|
|
|
{
|
2021-04-26 21:42:15 +08:00
|
|
|
label: 'ID',
|
2021-04-22 12:25:23 +08:00
|
|
|
prop: 'id',
|
2021-04-26 21:42:15 +08:00
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 110,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.name'),
|
|
|
|
|
prop: 'name',
|
2021-05-07 19:10:28 +08:00
|
|
|
show: true,
|
2021-05-24 17:46:21 +08:00
|
|
|
minWidth: 150,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-26 21:42:15 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.manageIp'),
|
|
|
|
|
prop: 'manageIp',
|
|
|
|
|
show: true,
|
2021-05-13 11:40:22 +08:00
|
|
|
width: 140,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-07-15 14:38:55 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.children'),
|
|
|
|
|
prop: 'children',
|
|
|
|
|
show: false,
|
|
|
|
|
width: 110
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.parent'),
|
|
|
|
|
prop: 'parent',
|
2021-04-26 21:42:15 +08:00
|
|
|
show: false,
|
2021-04-22 12:25:23 +08:00
|
|
|
width: 110
|
|
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.type'),
|
|
|
|
|
prop: 'type',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 140,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.state'),
|
|
|
|
|
prop: 'state',
|
|
|
|
|
show: true,
|
2021-05-13 11:40:22 +08:00
|
|
|
width: 100,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-05-13 11:40:22 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.pingInfo'),
|
|
|
|
|
prop: 'pingInfo',
|
|
|
|
|
show: true,
|
|
|
|
|
width: 110
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.dc'),
|
|
|
|
|
prop: 'dc',
|
|
|
|
|
show: true,
|
2021-05-13 11:40:22 +08:00
|
|
|
width: 140,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.cabinet'),
|
|
|
|
|
prop: 'cabinet',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 110,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.alertNum'),
|
2021-04-26 21:42:15 +08:00
|
|
|
prop: 'alertNum',
|
2021-04-22 12:25:23 +08:00
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 140,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.endpointNum2'),
|
|
|
|
|
prop: 'endpointNum',
|
|
|
|
|
show: true,
|
2021-05-13 10:06:03 +08:00
|
|
|
width: 160,
|
|
|
|
|
sortable: 'custom'
|
2021-04-26 21:42:15 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.brand'),
|
|
|
|
|
prop: 'brand',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 120,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-26 21:42:15 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.model'),
|
|
|
|
|
prop: 'model',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 110,
|
2021-05-13 10:06:03 +08:00
|
|
|
sortable: 'custom'
|
2021-04-26 21:42:15 +08:00
|
|
|
}, {
|
|
|
|
|
label: 'SN',
|
|
|
|
|
prop: 'sn',
|
|
|
|
|
show: true,
|
|
|
|
|
width: 110
|
2021-04-22 12:25:23 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.purchaseDate'),
|
|
|
|
|
prop: 'purchaseDate',
|
|
|
|
|
show: false,
|
|
|
|
|
width: 110
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
showTableTooltip,
|
|
|
|
|
hideTableTooltip,
|
2021-07-07 16:57:26 +08:00
|
|
|
tableDataSort (item) {
|
|
|
|
|
let orderBy = ''
|
2021-07-15 14:38:55 +08:00
|
|
|
const str = item.prop
|
2021-07-07 16:57:26 +08:00
|
|
|
if (str === 'dc') {
|
|
|
|
|
orderBy = str
|
|
|
|
|
}
|
|
|
|
|
if (item.order === 'ascending') {
|
|
|
|
|
orderBy = str
|
|
|
|
|
}
|
|
|
|
|
if (item.order === 'descending') {
|
|
|
|
|
orderBy = '-' + str
|
|
|
|
|
}
|
|
|
|
|
this.$emit('orderBy', orderBy)
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
messageStyle (title, row) {
|
|
|
|
|
if (title.prop === 'alertNum') {
|
|
|
|
|
if (row.alertNum > 0) {
|
|
|
|
|
return 'danger'
|
|
|
|
|
} else {
|
|
|
|
|
return 'success'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (title.label === 'endpointNum') {
|
|
|
|
|
if (row.state === 3) {
|
|
|
|
|
return 'suspended'
|
|
|
|
|
} else {
|
|
|
|
|
if (row.endpointDownNum > 0) {
|
|
|
|
|
return 'danger'
|
|
|
|
|
} else {
|
|
|
|
|
return 'success'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ''
|
|
|
|
|
},
|
|
|
|
|
showEndpoint (asset) {
|
|
|
|
|
this.bottomBox.asset = Object.assign({}, asset)
|
|
|
|
|
this.bottomBox.targetTab = 'endpoint'
|
|
|
|
|
this.bottomBox.showSubList = true
|
|
|
|
|
},
|
|
|
|
|
returnCabinet (start, end) { // 返回机柜u位信息
|
|
|
|
|
if (!start || !end) {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
return `[${start}-${end}]`
|
2021-05-13 11:40:22 +08:00
|
|
|
},
|
|
|
|
|
formatPingTime (str) {
|
|
|
|
|
if (!str || str == '') {
|
|
|
|
|
return this.$t('asset.assetStatPre') + this.$t('asset.assetStatDown')
|
|
|
|
|
}
|
|
|
|
|
const ds = '-'
|
|
|
|
|
const ts = ':'
|
|
|
|
|
const time = new Date(bus.UTCTimeToConfigTimezone(str))
|
|
|
|
|
const year = time.getFullYear()
|
|
|
|
|
const month = time.getMonth() + 1 > 9 ? time.getMonth() + 1 : ('0' + (time.getMonth() + 1))
|
|
|
|
|
const day = time.getDate() > 9 ? time.getDate() : ('0' + time.getDate())
|
|
|
|
|
const hours = time.getHours() > 9 ? time.getHours() : ('0' + time.getHours())
|
|
|
|
|
const minutes = time.getMinutes() > 9 ? time.getMinutes() : ('0' + time.getMinutes())
|
|
|
|
|
const seconds = time.getSeconds() > 9 ? time.getSeconds() : ('0' + time.getSeconds())
|
|
|
|
|
return this.$t('asset.assetStatPre') + year + ds + month + ds + day + ' ' + hours + ts + minutes + ts + seconds
|
2021-04-22 12:25:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|