2021-04-13 20:33:12 +08:00
|
|
|
<template>
|
|
|
|
|
<el-table
|
|
|
|
|
id="roleTable"
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:height="height"
|
|
|
|
|
border
|
|
|
|
|
@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']"
|
2021-05-07 19:10:28 +08:00
|
|
|
:sortable="item.sortable"
|
2021-04-13 20:33:12 +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-13 20:33:12 +08:00
|
|
|
<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 === 'type'">
|
|
|
|
|
{{findServerType(scope.row[item.prop]).text}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="item.prop === 'checkTime'">{{utcTimeToTimezoneStr(scope.row[item.prop])}}</span>
|
|
|
|
|
<span v-else-if="item.prop === 'status'">
|
|
|
|
|
<el-popover :content="$t('asset.assetStatPre')+(scope.row.checkTime?utcTimeToTimezoneStr(scope.row.checkTime):$t('asset.assetStatDown'))" placement="right" trigger="hover" width="200">
|
|
|
|
|
<div slot="reference" style="width: 20px">
|
2021-04-28 18:59:58 +08:00
|
|
|
<div :class="{'active-icon green-bg':scope.row[item.prop] == '1','active-icon red-bg':scope.row[item.prop] == '0' || scope.row[item.prop] == '-1' || scope.row[item.prop] == '-2'}"></div>
|
2021-04-13 20:33:12 +08:00
|
|
|
</div>
|
|
|
|
|
</el-popover>
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
</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">
|
2021-05-19 14:04:16 +08:00
|
|
|
<button class="table-operation-item" v-has="'agent_edit'" @click="tableOperation(['edit', scope.row])"><i class="nz-icon nz-icon-edit"></i></button>
|
2021-05-19 14:26:09 +08:00
|
|
|
<el-dropdown size="medium" v-has="['agent_delete']" trigger="hover" @command="tableOperation">
|
2021-04-13 20:33:12 +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-13 20:33:12 +08:00
|
|
|
</div>
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
2021-06-16 17:17:18 +08:00
|
|
|
<el-dropdown-item v-has="'agent_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-04-13 20:33:12 +08:00
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import table from '@/components/common/mixin/table'
|
|
|
|
|
import { agent } from '@/components/common/js/constants'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'agentTable',
|
|
|
|
|
mixins: [table],
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
agent: agent,
|
|
|
|
|
tableTitle: [
|
|
|
|
|
{
|
|
|
|
|
label: 'ID',
|
|
|
|
|
prop: 'id',
|
|
|
|
|
show: true,
|
2021-05-07 19:10:28 +08:00
|
|
|
width: 80,
|
2021-06-30 17:11:46 +08:00
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
2021-05-24 15:31:48 +08:00
|
|
|
label: this.$t('config.agent.dataCenter'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'dc',
|
2021-05-07 19:10:28 +08:00
|
|
|
show: true,
|
2021-06-30 17:11:46 +08:00
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
2021-05-14 17:51:02 +08:00
|
|
|
label: this.$t('config.agent.host'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'host',
|
|
|
|
|
show: true
|
|
|
|
|
}, {
|
2021-05-14 17:51:02 +08:00
|
|
|
label: this.$t('config.agent.port'),
|
2021-04-13 20:33:12 +08:00
|
|
|
prop: 'port',
|
|
|
|
|
show: true
|
|
|
|
|
}, {
|
|
|
|
|
label: this.$t('config.agent.type'),
|
|
|
|
|
prop: 'type',
|
2021-05-07 19:10:28 +08:00
|
|
|
show: true,
|
2021-06-30 17:11:46 +08:00
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('asset.state'),
|
|
|
|
|
prop: 'status',
|
2021-05-07 19:10:28 +08:00
|
|
|
show: true,
|
2021-06-30 17:11:46 +08:00
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('config.agent.checkTime'),
|
|
|
|
|
prop: 'checkTime',
|
|
|
|
|
show: false
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
findServerType (type) {
|
|
|
|
|
if (!this.promServerType) {
|
|
|
|
|
this.promServerType = []
|
|
|
|
|
this.agent.theData.forEach(item => {
|
|
|
|
|
this.promServerType = this.promServerType.concat(item.children)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return this.promServerType.find(item => {
|
|
|
|
|
return item.value == type
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|