2021-04-14 18:55:01 +08:00
|
|
|
<template>
|
|
|
|
|
<el-table
|
2021-04-16 15:02:40 +08:00
|
|
|
id="endpointTable"
|
2021-04-14 18:55:01 +08:00
|
|
|
ref="dataTable"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:height="height"
|
|
|
|
|
border
|
|
|
|
|
@header-dragend="dragend"
|
|
|
|
|
@sort-change="tableDataSort"
|
2021-04-21 16:35:48 +08:00
|
|
|
@selection-change="selectionChange"
|
2021-04-14 18:55:01 +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']"
|
|
|
|
|
:width="`${item.width}`"
|
|
|
|
|
class="data-column"
|
|
|
|
|
>
|
|
|
|
|
<template slot="header">
|
|
|
|
|
<span>{{item.label}}</span>
|
|
|
|
|
<div class="col-resize-area"></div>
|
|
|
|
|
</template>
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
<template v-if="item.prop === 'name'">
|
|
|
|
|
{{scope.row[item.prop]}}
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'type'">
|
2021-04-16 17:36:00 +08:00
|
|
|
{{scope.row.module.type}}
|
2021-04-14 18:55:01 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'project'">
|
|
|
|
|
{{scope.row[item.prop].name}}
|
|
|
|
|
</template>
|
2021-04-16 17:36:00 +08:00
|
|
|
<template v-else-if="item.prop === 'module'">
|
|
|
|
|
{{scope.row[item.prop].name}}
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'alerts'">
|
2021-04-21 16:35:48 +08:00
|
|
|
<span class="alert-num" @click="showBottomBox('endpointAlertMessage', scope.row)">
|
|
|
|
|
<i class="nz-icon nz-icon-overview-alert" :class="scope.row[item.prop]>0?'colorEF7458':'color23BF9A'"/>
|
|
|
|
|
{{scope.row.alertNum}}
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'asset'">
|
|
|
|
|
<span >
|
|
|
|
|
<i class="nz-icon nz-icon-asset" :class="scope.row[item.prop]>0?'colorEF7458':'colorEF7458'"/>
|
|
|
|
|
{{scope.row.asset.name}}
|
2021-04-16 17:36:00 +08:00
|
|
|
</span>
|
2021-04-14 18:55:01 +08:00
|
|
|
</template>
|
2021-04-16 17:36:00 +08:00
|
|
|
<template v-else-if="item.prop === 'configs'">
|
2021-04-21 16:35:48 +08:00
|
|
|
<el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'">
|
|
|
|
|
<span class="configs-endpoint">{ ... }</span>
|
|
|
|
|
<div class="endpointConfigsTips" slot="content">
|
|
|
|
|
<span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row[item.prop])"></i></span>
|
|
|
|
|
<pre >{{JSON.stringify(JSON.parse(scope.row[item.prop]),null,2)}}</pre>
|
|
|
|
|
</div>
|
2021-04-16 17:36:00 +08:00
|
|
|
</el-tooltip>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'state'">
|
2021-04-14 18:55:01 +08:00
|
|
|
{{scope.row[item.prop]}}
|
|
|
|
|
</template>
|
|
|
|
|
<span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</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">
|
2021-04-20 14:38:24 +08:00
|
|
|
<button class="table-operation-item" @click="showBottomBox('endpointQuery', scope.row)"><i class="nz-icon nz-icon-view1"></i></button>
|
2021-04-14 18:55:01 +08:00
|
|
|
<el-dropdown size="medium" trigger="hover" @command="tableOperation">
|
|
|
|
|
<div class="table-operation-item table-operation-item--more">
|
|
|
|
|
<span>…</span><i class="nz-icon nz-icon-arrow-down"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
|
<el-dropdown-item :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-04-16 15:02:40 +08:00
|
|
|
<el-dropdown-item :command="['delete', scope.row, `sys/endpoint?ids=${scope.row.id}`]" :disabled="scope.row.id === 1"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('overall.delete')}}</span></el-dropdown-item>
|
2021-04-14 18:55:01 +08:00
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import table from '@/components/common/mixin/table'
|
|
|
|
|
export default {
|
2021-04-16 15:02:40 +08:00
|
|
|
name: 'endpointTable',
|
2021-04-14 18:55:01 +08:00
|
|
|
mixins: [table],
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
tableTitle: [ // 原始table列
|
|
|
|
|
{
|
|
|
|
|
label: 'ID',
|
|
|
|
|
prop: 'id',
|
|
|
|
|
show: true,
|
|
|
|
|
width: 80
|
|
|
|
|
}, {
|
2021-04-16 17:36:00 +08:00
|
|
|
label: this.$t('project.endpoint.name'),
|
2021-04-14 18:55:01 +08:00
|
|
|
prop: 'name',
|
2021-04-16 17:36:00 +08:00
|
|
|
show: true
|
2021-04-14 18:55:01 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('project.module.type'),
|
|
|
|
|
prop: 'type',
|
2021-04-16 17:36:00 +08:00
|
|
|
show: true
|
2021-04-14 18:55:01 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t('project.project.project'),
|
|
|
|
|
prop: 'project',
|
2021-04-16 17:36:00 +08:00
|
|
|
show: true
|
2021-04-14 18:55:01 +08:00
|
|
|
},
|
2021-04-21 16:35:48 +08:00
|
|
|
{
|
|
|
|
|
label: this.$t('project.endpoint.asset'),
|
|
|
|
|
prop: 'asset',
|
|
|
|
|
show: true
|
|
|
|
|
},
|
2021-04-14 18:55:01 +08:00
|
|
|
{
|
2021-04-16 17:36:00 +08:00
|
|
|
label: this.$t('project.module.module'),
|
|
|
|
|
prop: 'module',
|
|
|
|
|
show: true
|
2021-04-14 18:55:01 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-04-16 17:36:00 +08:00
|
|
|
label: this.$t('project.endpoint.configs'),
|
|
|
|
|
prop: 'configs',
|
2021-04-21 16:35:48 +08:00
|
|
|
show: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('project.endpoint.alerts'),
|
|
|
|
|
prop: 'alerts',
|
2021-04-16 17:36:00 +08:00
|
|
|
show: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('project.endpoint.state'),
|
|
|
|
|
prop: 'state',
|
|
|
|
|
show: true
|
2021-04-14 18:55:01 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-04-21 16:35:48 +08:00
|
|
|
copyValue (str) {
|
|
|
|
|
const domUrl = document.createElement('input')
|
|
|
|
|
domUrl.value = str
|
|
|
|
|
domUrl.id = 'creatDom'
|
|
|
|
|
document.body.appendChild(domUrl)
|
|
|
|
|
domUrl.select() // 选择对象
|
|
|
|
|
document.execCommand('Copy') // 执行浏览器复制命令
|
|
|
|
|
const creatDom = document.getElementById('creatDom')
|
|
|
|
|
creatDom.parentNode.removeChild(creatDom)
|
|
|
|
|
this.$message.success(this.$t('overall.copySuccess'))
|
|
|
|
|
}
|
2021-04-14 18:55:01 +08:00
|
|
|
},
|
2021-04-16 15:02:40 +08:00
|
|
|
computed: {}
|
2021-04-14 18:55:01 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
2021-04-16 17:36:00 +08:00
|
|
|
<style scoped>
|
|
|
|
|
.endpoint-num{
|
|
|
|
|
padding: 0 3px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
}
|
|
|
|
|
.bagEF7458{
|
|
|
|
|
background: #EF7458;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
.bag23BF9A{
|
|
|
|
|
background: #23BF9A;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
.configs-endpoint{
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
padding: 2px 7px;
|
2021-04-21 16:35:48 +08:00
|
|
|
color: #3C92F1;
|
|
|
|
|
}
|
|
|
|
|
.colorEF7458{
|
|
|
|
|
color: #EF7458;
|
|
|
|
|
}
|
|
|
|
|
.color23BF9A{
|
|
|
|
|
color: #23BF9A;
|
|
|
|
|
}
|
|
|
|
|
.endpoint-num, .alert-num{
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<style>
|
|
|
|
|
.endpointConfigsTips{
|
|
|
|
|
height: 200px;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
.copy-value-content{
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 1px;
|
|
|
|
|
top: 4px;
|
2021-04-16 17:36:00 +08:00
|
|
|
}
|
|
|
|
|
</style>
|