2020-08-26 10:05:56 +08:00
|
|
|
|
<template>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<div class="mc" @click.self="clickOutside">
|
2021-06-02 17:16:00 +08:00
|
|
|
|
<div class="right-box right-box-project-asset">
|
2021-05-26 10:58:15 +08:00
|
|
|
|
<div class="right-box-title">{{ moduleName }} / {{$t('asset.asset')}}</div>
|
2021-05-19 16:09:05 +08:00
|
|
|
|
<nz-data-list
|
|
|
|
|
|
ref="dataList"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title.sync="tableTitle"
|
|
|
|
|
|
:from="fromRoute.asset"
|
|
|
|
|
|
:layout="dataListLayout"
|
|
|
|
|
|
:search-msg="searchMsg"
|
|
|
|
|
|
@search="search"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template v-slot:default="slotProps">
|
|
|
|
|
|
<asset-table
|
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
|
v-loading="tools.loading"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title="tableTitle"
|
|
|
|
|
|
:height="mainTableHeight"
|
|
|
|
|
|
:table-data="tableData"
|
2021-05-27 17:58:29 +08:00
|
|
|
|
:showOption="false"
|
2021-05-19 16:09:05 +08:00
|
|
|
|
@orderBy="tableDataSort"
|
|
|
|
|
|
@reload="getTableData"></asset-table>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 分页组件 -->
|
|
|
|
|
|
<template v-slot:pagination>
|
|
|
|
|
|
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</nz-data-list>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-08-26 10:05:56 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-05-19 16:09:05 +08:00
|
|
|
|
import dataListMixin from '@/components/common/mixin/dataList'
|
|
|
|
|
|
import assetTable from '@/components/common/table/asset/assetTable'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
2021-05-19 16:09:05 +08:00
|
|
|
|
name: 'assetTableProject',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
moduleId: {},
|
2021-05-26 10:58:15 +08:00
|
|
|
|
projectId: {},
|
|
|
|
|
|
moduleName: String
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-05-19 16:09:05 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
assetTable
|
|
|
|
|
|
},
|
|
|
|
|
|
mixins: [dataListMixin],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
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) {
|
2021-05-14 15:24:32 +08:00
|
|
|
|
value = this.$t('project.project.projectName')
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} 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 {
|
2021-05-19 16:09:05 +08:00
|
|
|
|
url: 'asset/asset',
|
|
|
|
|
|
tableId: 'projectAsset',
|
|
|
|
|
|
dataListLayout: ['searchInput'],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
pageObj: {
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: this.$CONSTANTS.defaultPageSize,
|
|
|
|
|
|
total: 0
|
|
|
|
|
|
},
|
|
|
|
|
|
mainTableHeight: '100%',
|
|
|
|
|
|
tableTitle: [
|
|
|
|
|
|
{
|
2021-05-19 16:09:05 +08:00
|
|
|
|
label: 'ID',
|
|
|
|
|
|
prop: 'id',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 110,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('overall.name'),
|
|
|
|
|
|
prop: 'name',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
show: true,
|
2021-06-16 11:18:04 +08:00
|
|
|
|
width: 110,
|
2020-08-27 18:00:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{
|
2021-05-19 16:09:05 +08:00
|
|
|
|
label: this.$t('asset.manageIp'),
|
|
|
|
|
|
prop: 'manageIp',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
show: true,
|
2021-05-19 16:09:05 +08:00
|
|
|
|
width: 140,
|
2020-09-10 09:18:37 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{
|
2021-05-19 16:09:05 +08:00
|
|
|
|
label: this.$t('asset.pingInfo'),
|
|
|
|
|
|
prop: 'pingInfo',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 110
|
|
|
|
|
|
},{
|
|
|
|
|
|
label: this.$t('asset.alertNum'),
|
|
|
|
|
|
prop: 'alertNum',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 140,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, {
|
2021-05-19 16:09:05 +08:00
|
|
|
|
label: this.$t('asset.endpointNum2'),
|
|
|
|
|
|
prop: 'endpointNum',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 160,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}],
|
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
2021-05-19 16:09:05 +08:00
|
|
|
|
label: 'ids',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
2021-06-16 11:18:04 +08:00
|
|
|
|
name: this.$t('overall.name'),
|
2021-05-19 16:09:05 +08:00
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'name',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
disabled: false
|
2021-06-16 11:18:04 +08:00
|
|
|
|
},{
|
|
|
|
|
|
name: this.$t('asset.manageIp'),
|
2021-03-19 18:52:19 +08:00
|
|
|
|
type: 'input',
|
2021-05-19 16:09:05 +08:00
|
|
|
|
label: 'manageIp',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}]
|
|
|
|
|
|
},
|
|
|
|
|
|
tableData: [],
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
tableHeight: '100%',
|
2021-06-16 17:17:18 +08:00
|
|
|
|
searchLabel: {},
|
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()
|
2021-05-19 16:09:05 +08:00
|
|
|
|
this.getTableData()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-05-19 16:09:05 +08:00
|
|
|
|
getTableData: function () {
|
|
|
|
|
|
this.tools.loading = true
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
|
|
|
|
|
|
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
|
2021-05-19 16:09:05 +08:00
|
|
|
|
this.$set(this.searchLabel, 'moduleIds', this.moduleId)
|
|
|
|
|
|
this.$get(this.url, { ...this.searchLabel }).then(response => {
|
|
|
|
|
|
this.tools.loading = false
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
|
this.deleteBox.ids = ''
|
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
pageNo (val) {
|
|
|
|
|
|
this.pageObj.pageNo = val
|
2021-05-19 16:09:05 +08:00
|
|
|
|
this.getTableData()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
pageSize (val) {
|
|
|
|
|
|
this.pageObj.pageSize = val
|
|
|
|
|
|
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val)
|
2021-05-19 16:09:05 +08:00
|
|
|
|
this.getTableData()
|
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)
|
2021-05-19 16:09:05 +08:00
|
|
|
|
this.getTableData()
|
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) {
|
2021-04-25 16:28:09 +08:00
|
|
|
|
if (e.column.label == 'Alerts' || e.column.label == this.$t('asset.alerts')) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
2021-05-19 16:09:05 +08:00
|
|
|
|
this.getTableData()
|
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;
|
2021-05-19 16:09:05 +08:00
|
|
|
|
padding-left: 20px;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
z-index: 1;
|
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;
|
|
|
|
|
|
}
|
2021-05-19 16:09:05 +08:00
|
|
|
|
.right-box /deep/ .list-page .main-container{
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
}
|
2020-08-27 18:00:03 +08:00
|
|
|
|
/* end--table*/
|
2020-08-26 10:05:56 +08:00
|
|
|
|
</style>
|