2020-08-26 10:05:56 +08:00
|
|
|
|
<template>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<div class="mc" @click.self="clickOutside">
|
|
|
|
|
|
<div class="right-box right-box-project-alert">
|
|
|
|
|
|
<!-- begin--顶部按钮-->
|
|
|
|
|
|
<div class="right-box-top-btns">
|
|
|
|
|
|
<!--<button id="edit-ep-del" type="button" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light ">-->
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<!--<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-delete"></i></span>-->
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<!--<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>-->
|
|
|
|
|
|
<!--</button>-->
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">Asset</div>
|
|
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
2020-09-10 09:18:37 +08:00
|
|
|
|
<!-- begin搜素框-->
|
|
|
|
|
|
<div class="top-tools">
|
|
|
|
|
|
<div class="top-tool-main-right" :class="{'top-tool-main-right-to-left': false}">
|
|
|
|
|
|
<div class="top-tool-search">
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<search-input :inTransform="true" :searchMsg="searchMsg" @search="search"></search-input>
|
2020-09-10 09:18:37 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!--<button type="button" @click="showExportDialog" :title="$t('overall.exportExcelLower')"-->
|
|
|
|
|
|
<!--class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20" id="alert-list-export">-->
|
2020-09-11 16:34:28 +08:00
|
|
|
|
<!--<i class="nz-icon nz-icon-download1"></i>-->
|
2020-09-10 09:18:37 +08:00
|
|
|
|
<!--</button>-->
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end搜素框-->
|
|
|
|
|
|
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<!-- begin--表格-->
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<div class="right-box-form-box">
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<el-table
|
|
|
|
|
|
class="nz-table"
|
|
|
|
|
|
:height="mainTableHeight"
|
|
|
|
|
|
style="width: 100%;"
|
|
|
|
|
|
:data="tableData"
|
|
|
|
|
|
border
|
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
|
tooltip-effect="light"
|
|
|
|
|
|
ref="assetTable"
|
|
|
|
|
|
:cell-class-name="messageStyle"
|
|
|
|
|
|
@sort-change="tableDataSort"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-table-column
|
2020-11-04 15:38:34 +08:00
|
|
|
|
:resizable="true"
|
2020-08-27 18:00:03 +08:00
|
|
|
|
v-for="(item, index) in tableTitle"
|
|
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:width="item.width"
|
|
|
|
|
|
:key="`col_${index}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:fixed="item.fixed"
|
|
|
|
|
|
:show-overflow-tooltip="item.prop != 'Alert' || item.prop != 'Module'"
|
|
|
|
|
|
min-width="110px"
|
|
|
|
|
|
:class-name="item.prop == 'option' ? 'content-right-options' : ''"
|
|
|
|
|
|
:sortable="$tableSet.sortableShow(item.prop,'asset')"
|
|
|
|
|
|
:prop="$tableSet.propTitle(item.prop,'asset')"
|
|
|
|
|
|
:sort-orders="['ascending', 'descending']"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
|
<div v-if="item.prop=='HOST'">
|
|
|
|
|
|
<span>{{scope.row.host}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item.prop=='assetType'">
|
|
|
|
|
|
<span>{{scope.row.model.type.value}}</span>
|
|
|
|
|
|
</div>
|
2020-09-14 14:23:54 +08:00
|
|
|
|
<template v-if="item.prop=='SN'">{{scope.row.sn}}</template>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<div v-if="item.prop=='state'">
|
2021-01-10 13:31:02 +08:00
|
|
|
|
<span v-if="scope.row.state==1">{{ $t('asset.inStock')}}</span>
|
|
|
|
|
|
<span v-if="scope.row.state==2">{{ $t('asset.notInStock')}}</span>
|
|
|
|
|
|
<span v-if="scope.row.state==3">{{ $t('asset.suspended')}}</span>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item.prop == 'pingStatus'">
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
placement="right"
|
|
|
|
|
|
width="200"
|
|
|
|
|
|
trigger="hover"
|
|
|
|
|
|
:content="formatPingTime(scope.row.pingLastUpdate)">
|
|
|
|
|
|
<div slot="reference" style="width: 20px">
|
|
|
|
|
|
<div :class="{'active-icon green':scope.row.pingState == 1,'active-icon red':scope.row.pingState == 0}"></div><span>{{scope.row.pingRtt?scope.row.pingRtt+'ms':''}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<template v-if="item.prop=='Alert'">
|
|
|
|
|
|
|
|
|
|
|
|
<el-tooltip :content="scope.row.alertNum+' '+$t('overall.active')" placement="top" effect="light" :disabled=" scope.row.alertNum < 99">
|
|
|
|
|
|
<span :id="'asset-alerts-'+scope.row.id" class="link">
|
|
|
|
|
|
<!--@click="jumpToAlertMsg(scope.row)"-->
|
|
|
|
|
|
{{(scope.row.alertNum < 99 ? scope.row.alertNum : 99)}}
|
|
|
|
|
|
<sup class="linkSup" v-if="scope.row.alertNum > 99">+</sup>
|
|
|
|
|
|
{{' ' + $t('overall.active')}}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
</div>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<!-- end--表格-->
|
|
|
|
|
|
|
|
|
|
|
|
<!--底部分頁-->
|
|
|
|
|
|
<div class="pagination-bottom">
|
|
|
|
|
|
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-08-26 10:05:56 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'assetTable',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
moduleId: {},
|
|
|
|
|
|
projectId: {}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
tagType () {
|
|
|
|
|
|
return (key) => {
|
|
|
|
|
|
if (key == 'asset' || key == 'module' || key == 'project' || key == 'datacenter' || key == 'endpoint') {
|
|
|
|
|
|
return 'normal'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 'info'
|
2020-08-27 18:00:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
tagValue () {
|
|
|
|
|
|
return (key, value) => {
|
|
|
|
|
|
if (key == 'type') {
|
|
|
|
|
|
if (value == 1) {
|
|
|
|
|
|
value = this.$t('project.project.project')
|
|
|
|
|
|
} else if (value == 2) {
|
|
|
|
|
|
value = this.$t('module.module.module')
|
|
|
|
|
|
} else if (value == 3) {
|
|
|
|
|
|
value = this.$t('asset.asset')
|
2020-08-27 18:00:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return key + ':' + value
|
2020-08-27 18:00:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
pageObj: {
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: this.$CONSTANTS.defaultPageSize,
|
|
|
|
|
|
total: 0
|
|
|
|
|
|
},
|
|
|
|
|
|
mainTableHeight: '100%',
|
|
|
|
|
|
tableTitle: [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: this.$t('asset.tableTitle.host'),
|
|
|
|
|
|
prop: 'HOST',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 130,
|
|
|
|
|
|
fixed: 'left'
|
2020-08-27 18:00:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
label: this.$t('asset.tableTitle.device'),
|
|
|
|
|
|
prop: 'SN',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 130
|
2020-09-10 09:18:37 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
label: this.$t('asset.tableTitle.assetType'),
|
|
|
|
|
|
prop: 'assetType',
|
|
|
|
|
|
show: true
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('asset.tableTitle.assetState'),
|
|
|
|
|
|
prop: 'state',
|
|
|
|
|
|
show: true
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('asset.tableTitle.assetPing'),
|
|
|
|
|
|
prop: 'pingStatus',
|
|
|
|
|
|
show: true
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('asset.tableTitle.alerts'),
|
|
|
|
|
|
prop: 'Alert',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 100
|
|
|
|
|
|
}],
|
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'id',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 20,
|
|
|
|
|
|
name: 'SN',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'sn',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 21,
|
|
|
|
|
|
name: 'Host',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'host',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 22,
|
|
|
|
|
|
name: this.$t('asset.state'),
|
|
|
|
|
|
type: 'select',
|
|
|
|
|
|
label: 'assetState',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 23,
|
|
|
|
|
|
name: 'pingStatus',
|
|
|
|
|
|
type: 'select',
|
|
|
|
|
|
label: 'pingStatus',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}]
|
|
|
|
|
|
},
|
|
|
|
|
|
tableData: [],
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
tableHeight: '100%',
|
|
|
|
|
|
searchLabel: {
|
2020-08-27 18:00:03 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
deleteBox: {}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created () {
|
|
|
|
|
|
// 是否存在分页缓存
|
|
|
|
|
|
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
|
|
|
|
|
|
if (pageSize != 'undefined' && pageSize != null) {
|
|
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.getTableTitle()
|
|
|
|
|
|
this.getAssetList()
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
getAssetList: function () {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
|
|
|
|
|
|
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
|
|
|
|
|
|
this.$set(this.searchLabel, 'moduleId', this.moduleId)
|
|
|
|
|
|
this.$get('asset', { ...this.searchLabel }).then(response => {
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
|
this.deleteBox.ids = ''
|
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
pageNo (val) {
|
|
|
|
|
|
this.pageObj.pageNo = val
|
|
|
|
|
|
this.getAssetList()
|
|
|
|
|
|
},
|
|
|
|
|
|
pageSize (val) {
|
|
|
|
|
|
this.pageObj.pageSize = val
|
|
|
|
|
|
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val)
|
|
|
|
|
|
this.getAssetList()
|
2020-08-27 18:00:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
selectChange (s) {
|
|
|
|
|
|
const ids = []
|
|
|
|
|
|
this.deleteBox.ids = ''
|
|
|
|
|
|
s.forEach(item => {
|
|
|
|
|
|
ids.push(item.id)
|
|
|
|
|
|
})
|
|
|
|
|
|
this.deleteBox.ids = ids.join(',')
|
|
|
|
|
|
},
|
|
|
|
|
|
tableDataSort (item) {
|
|
|
|
|
|
let orderBy = ''
|
|
|
|
|
|
if (item.order === 'ascending') {
|
|
|
|
|
|
orderBy = item.prop
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item.order === 'descending') {
|
|
|
|
|
|
orderBy = '-' + item.prop
|
2020-11-21 12:21:27 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.pageObj.orderBy = orderBy
|
|
|
|
|
|
this.$set(this.searchLabel, 'orderBy', orderBy)
|
|
|
|
|
|
this.getAssetList()
|
2020-11-21 12:21:27 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* 关闭弹框 */
|
|
|
|
|
|
esc (refresh) {
|
|
|
|
|
|
this.$emit('close', refresh)
|
2020-08-27 18:00:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
clickOutside () {
|
|
|
|
|
|
this.esc(false)
|
|
|
|
|
|
},
|
|
|
|
|
|
messageStyle (e) {
|
|
|
|
|
|
if (e.column.label == 'Alerts' || e.column.label == this.$t('asset.tableTitle.alerts')) {
|
|
|
|
|
|
if (e.row.alertNum > 0) {
|
|
|
|
|
|
return 'danger'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 'success'
|
2020-11-17 09:05:43 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
return ''
|
2020-08-27 18:00:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
formatPingTime: function (str) {
|
|
|
|
|
|
if (!str || str == '') {
|
|
|
|
|
|
return this.$t('asset.assetStatPre') + this.$t('asset.assetStatDown')
|
|
|
|
|
|
}
|
|
|
|
|
|
const ds = '-'
|
|
|
|
|
|
const ts = ':'
|
|
|
|
|
|
const time = new Date(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
|
|
|
|
|
|
},
|
|
|
|
|
|
getTableTitle () {
|
|
|
|
|
|
if (localStorage.getItem('nz-sys-asset-ping-switch') === 'off') {
|
|
|
|
|
|
this.tableTitle = this.tableTitle.filter(item => item.prop !== 'pingStatus')
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
search (searchObj) {
|
|
|
|
|
|
let orderBy = ''
|
|
|
|
|
|
if (this.searchLabel.orderBy) {
|
|
|
|
|
|
orderBy = this.searchLabel.orderBy
|
|
|
|
|
|
}
|
|
|
|
|
|
this.searchLabel = {}
|
|
|
|
|
|
this.pageObj.pageNo = 1
|
|
|
|
|
|
for (const item in searchObj) {
|
|
|
|
|
|
if (searchObj[item]) {
|
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item])
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (orderBy) {
|
|
|
|
|
|
this.$set(this.searchLabel, 'orderBy', orderBy)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.$refs.assetTable && this.$refs.assetTable.bodyWrapper) {
|
|
|
|
|
|
this.$refs.assetTable.bodyWrapper.scrollTop = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
this.getAssetList()
|
2020-11-20 11:19:25 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
|
|
2020-08-27 18:00:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-08-26 10:05:56 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
.right-box-project-alert{
|
2020-10-12 13:46:31 +08:00
|
|
|
|
width: 850px;
|
2020-09-07 10:42:10 +08:00
|
|
|
|
padding-right: 30px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.right-box-title{
|
|
|
|
|
|
font-weight: bold;
|
2020-08-27 18:00:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
.mc{
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
width: 100vw;
|
|
|
|
|
|
height: 100vh;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
z-index: 11;
|
|
|
|
|
|
}
|
|
|
|
|
|
/deep/.resize-box .danger{
|
|
|
|
|
|
background-color: #f9f9f9 !important;
|
|
|
|
|
|
}
|
2020-09-10 09:18:37 +08:00
|
|
|
|
.top-tools{
|
|
|
|
|
|
float: right;
|
|
|
|
|
|
}
|
|
|
|
|
|
/deep/ .top-tools>div{
|
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
|
}
|
2020-08-27 18:00:03 +08:00
|
|
|
|
/* end--table*/
|
2020-08-26 10:05:56 +08:00
|
|
|
|
</style>
|