2020-03-30 19:46:03 +08:00
|
|
|
|
<template>
|
2021-03-25 14:14:45 +08:00
|
|
|
|
<div style="height: 100%">
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<div class="sub-top-tools">
|
2021-04-20 14:38:24 +08:00
|
|
|
|
<div class="sub-list-tabs" v-if="from===fromRoute.asset">
|
|
|
|
|
|
<div class="sub-list-tab-title">{{obj.host}}</div>
|
|
|
|
|
|
<div class="sub-list-tab" @click="changeTab('panel')" id="endpoint-tab-change-panel">{{$t("overall.detail")}}</div>
|
2021-04-25 16:28:09 +08:00
|
|
|
|
<div @click="changeTab('alertMessage')" class="sub-list-tab" v-has="'asset_alerts_view'" id="endpoint-tab-change-alertmsg">{{$t("asset.alerts")}}</div>
|
|
|
|
|
|
<div class="sub-list-tab sub-list-tab-active">{{$t("asset.modules")}}</div>
|
2021-04-20 14:38:24 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="sub-list-tabs" v-if="from===fromRoute.module">
|
|
|
|
|
|
<div class="sub-list-tab-title">{{obj.name}}</div>
|
2021-04-25 16:28:09 +08:00
|
|
|
|
<div class="sub-list-tab sub-list-tab-active">{{$t("asset.modules")}}</div>
|
|
|
|
|
|
<div @click="changeTab('alertMessage')" class="sub-list-tab" id="endpoint-tab-change-alertmsg">{{$t("asset.alerts")}}</div>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="top-tool-right">
|
|
|
|
|
|
<div class="top-tool-search">
|
2020-10-14 10:25:56 +08:00
|
|
|
|
<search-input :searchMsg="searchMsg" @search="search" position="endpoint-bottom"></search-input>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</div>
|
2020-03-31 17:22:15 +08:00
|
|
|
|
<export-excel
|
2021-02-04 11:21:00 +08:00
|
|
|
|
id="endpoint-sub-list"
|
2020-03-31 17:22:15 +08:00
|
|
|
|
export-file-name="endpoint"
|
|
|
|
|
|
export-url="/endpoint/export"
|
2020-07-31 20:57:04 +08:00
|
|
|
|
import-url="/endpoint/import"
|
2020-10-29 16:05:19 +08:00
|
|
|
|
:params="endpointSearchLabel"
|
2020-12-08 21:53:37 +08:00
|
|
|
|
:permissions="{import: 'asset_endpoint_import', export: 'asset_endpoint_export'}"
|
2020-03-31 17:22:15 +08:00
|
|
|
|
@afterImport="getTableData"
|
|
|
|
|
|
class="margin-l-20"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template slot="optionZone">
|
2020-12-08 21:53:37 +08:00
|
|
|
|
<button :title="$t('overall.createEndpoint')" @click.stop="add" class="nz-btn nz-btn-size-normal nz-btn-style-light" id="project-create-project" v-has="'asset_endpoint_toAdd'">
|
2020-05-15 17:52:17 +08:00
|
|
|
|
<i class="nz-icon nz-icon-create-square"></i>
|
|
|
|
|
|
</button>
|
2020-03-31 17:22:15 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</export-excel>
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<delete-button :delete-objs="batchDeleteObjs" @after="getTableData" api="endpoint" v-has="'asset_endpoint_delete'" id="endpoint-tab-batch-delete"></delete-button>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<!-- 自定义table列 -->
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<element-set
|
2021-02-04 11:21:00 +08:00
|
|
|
|
id="endpoint-sub-list"
|
2020-08-04 21:53:06 +08:00
|
|
|
|
v-if="tools.showCustomTableTitle"
|
|
|
|
|
|
@close="tools.showCustomTableTitle = false"
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:original-table-title="tableTitle"
|
|
|
|
|
|
ref="customTableTitle"
|
2020-08-24 15:17:47 +08:00
|
|
|
|
:path="'/projectBottom'"
|
2020-08-04 21:53:06 +08:00
|
|
|
|
></element-set>
|
|
|
|
|
|
</transition>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<el-table
|
2021-02-04 11:21:00 +08:00
|
|
|
|
id="endpoint-sub-list-table"
|
2020-03-30 19:46:03 +08:00
|
|
|
|
:data="tableData"
|
|
|
|
|
|
border
|
2020-08-04 21:53:06 +08:00
|
|
|
|
v-loading="tools.loading"
|
2021-10-22 19:39:49 +08:00
|
|
|
|
:loading="tools.loading"
|
2020-03-30 19:46:03 +08:00
|
|
|
|
class="nz-table endpoint-table"
|
|
|
|
|
|
:height="$tableHeight.noPagination"
|
2020-09-27 17:08:58 +08:00
|
|
|
|
:cell-class-name="messageStyle"
|
2020-03-30 19:46:03 +08:00
|
|
|
|
ref="endpointTable"
|
2021-03-25 14:14:45 +08:00
|
|
|
|
style="width: 100%;height: 100%"
|
2020-07-21 10:03:31 +08:00
|
|
|
|
@sort-change="tableDataSort"
|
2020-10-29 19:11:46 +08:00
|
|
|
|
@selection-change="(selection)=>{this.batchDeleteObjs=selection}"
|
2020-07-21 10:03:31 +08:00
|
|
|
|
>
|
2020-10-29 19:11:46 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
type="selection"
|
|
|
|
|
|
width="40"
|
|
|
|
|
|
align="center">
|
|
|
|
|
|
</el-table-column>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<el-table-column
|
2020-11-04 15:38:34 +08:00
|
|
|
|
:resizable="true"
|
2020-08-04 21:53:06 +08:00
|
|
|
|
v-for="(item, index) in tools.customTableTitle"
|
2020-03-30 19:46:03 +08:00
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
|
:label="item.label"
|
2020-08-07 11:11:43 +08:00
|
|
|
|
:sortable="$tableSet.sortableShow(item.prop,'endpointTab')"
|
|
|
|
|
|
:prop="$tableSet.propTitle(item.prop,'endpointTab')"
|
2020-07-28 10:19:00 +08:00
|
|
|
|
:sort-orders="['ascending', 'descending']"
|
2020-11-12 10:11:18 +08:00
|
|
|
|
:min-width="item.minWidth || item.width"
|
2020-03-30 19:46:03 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-if="item.prop === 'asset' && scope.row[item.prop]" class="link">
|
2020-10-29 16:05:19 +08:00
|
|
|
|
{{scope.row[item.prop].sn}} :
|
|
|
|
|
|
({{scope.row[item.prop].host}})
|
|
|
|
|
|
</span>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-else-if="item.prop === 'project' && scope.row[item.prop]">{{scope.row.project.name}}</span>
|
|
|
|
|
|
<span v-else-if="item.prop === 'module' && scope.row[item.prop]">{{scope.row.module.name}}</span>
|
|
|
|
|
|
<span v-else-if="item.prop === 'param'">
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<template v-if="scope.row.paramObj">
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-for="(p, i) in scope.row.paramObj" :key="i">{{p.key}}={{p.value}}<span v-if="i < scope.row.paramObj.length-1">,</span></span>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</span>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-else-if="item.prop === 'labels'">
|
2020-11-10 14:11:29 +08:00
|
|
|
|
<template v-if="scope.row.labelModule">
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-for="(p, i) in scope.row.labelModule" :key="i">{{p.key}}={{p.value}}<span v-if="i < scope.row.labelModule.length-1">,</span></span>
|
2020-11-10 14:11:29 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</span>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'type'">{{scope.row.module.type}}</template>
|
|
|
|
|
|
<div v-else-if="item.prop === 'option'">
|
2020-12-08 21:53:37 +08:00
|
|
|
|
<span
|
|
|
|
|
|
:id="'edp-edit-'+scope.row.id"
|
|
|
|
|
|
:title="$t('overall.edit')"
|
|
|
|
|
|
@click="editEndpoint(scope.row)"
|
|
|
|
|
|
class="content-right-option"
|
|
|
|
|
|
v-has="'asset_endpoint_toEdit'">
|
|
|
|
|
|
<i class="nz-icon nz-icon-edit"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span :id="'asset-del-'+scope.row.id" :title="$t('overall.delete')" @click.stop="delEndpoint(scope.row)" class="content-right-option" v-has="'asset_endpoint_delete'"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-08-05 14:57:14 +08:00
|
|
|
|
</div>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-else-if="item.prop === 'lastUpdate'">{{dateFormat(scope.row.lastUpdate)}}</span>
|
|
|
|
|
|
<span v-else-if="item.prop === 'state'" >
|
2021-10-25 17:16:40 +08:00
|
|
|
|
<el-popover placement="right" trigger="click" :content="getStateContent(scope.row)" popper-class="small-pop">
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<div slot="reference" style="width: 20px">
|
2020-11-22 18:26:12 +08:00
|
|
|
|
<div :class="{'active-icon green':scope.row.state == '1','active-icon red':scope.row.state == '0', 'active-icon gray':scope.row.state == '2'}"></div>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</span>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'alerts'">
|
2020-09-27 17:08:58 +08:00
|
|
|
|
<el-tooltip :content="scope.row.alertNum+' '+$t('overall.active')" placement="top" effect="light" :disabled=" scope.row.alertNum < 99">
|
|
|
|
|
|
<span :id="'endpoint-alerts-'+scope.row.id" >
|
|
|
|
|
|
{{(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>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column width="28" :resizable="false">
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template slot="header">
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<span @mousedown.stop="!tools.showCustomTableTitle && (tools.showCustomTableTitle = true)" class="nz-table-gear">
|
2020-03-30 19:46:03 +08:00
|
|
|
|
<i class="nz-icon nz-icon-gear"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
2020-04-21 18:00:21 +08:00
|
|
|
|
<template v-slot="scope">
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<button v-if="scope.$index == 0" class="to-top" :style="{top: tools.toTopBtnTop}" :class="{'to-top-is-hover': tools.tableHover}" v-show="tools.showTopBtn" @click="$toTop('ps', 1)"><i class="nz-icon nz-icon-top"></i></button>
|
2020-04-21 18:00:21 +08:00
|
|
|
|
</template>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
2020-07-31 20:57:04 +08:00
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<add-endpoint-box v-if="rightBox.add.show" :current-project="currentProject" :current-module="currentModule" @close="closeRightBox" ref="addEndpointBox"></add-endpoint-box>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<edit-endpoint-box v-if="rightBox.edit.show" :current-project="currentProject" :current-module="currentModule" :endpoint="endpoint" @close="closeRightBox" ref="editEndpointBox"></edit-endpoint-box>
|
|
|
|
|
|
</transition>
|
2020-08-05 14:57:14 +08:00
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<edit-endpoint-box v-if="rightBox.editEndpoint.show" :project="currentProject" :module="currentModule" :endpoint="endpoint" @close="closeEditEndpointRightBox" ref="editEndpointBox"></edit-endpoint-box>
|
|
|
|
|
|
</transition>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
</div>
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
import exportXLSX from '../../exportXLSX'
|
|
|
|
|
|
import bus from '@/libs/bus'
|
|
|
|
|
|
import deleteButton from '../../deleteButton'
|
2021-04-20 14:38:24 +08:00
|
|
|
|
import { fromRoute } from '@/components/common/js/constants'
|
2021-10-11 14:05:07 +08:00
|
|
|
|
import detailViewRightMixin from '@/components/common/mixin/detailViewRightMixin'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'endpointTab',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
'export-excel': exportXLSX,
|
|
|
|
|
|
'delete-button': deleteButton
|
|
|
|
|
|
},
|
|
|
|
|
|
props: {
|
2021-04-20 14:38:24 +08:00
|
|
|
|
obj: Object, // 关联的实体对象
|
|
|
|
|
|
from: { type: String }
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-10-11 14:05:07 +08:00
|
|
|
|
mixin: [detailViewRightMixin],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2021-04-20 14:38:24 +08:00
|
|
|
|
fromRoute: fromRoute,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
rightBox: {
|
|
|
|
|
|
add: { show: false },
|
|
|
|
|
|
edit: { show: false },
|
|
|
|
|
|
editEndpoint: { show: false }
|
|
|
|
|
|
},
|
|
|
|
|
|
/* 工具参数 */
|
|
|
|
|
|
tools: {
|
|
|
|
|
|
loading: false, // 是否显示table加载动画
|
|
|
|
|
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, // to-top按钮的top属性
|
|
|
|
|
|
tableHover: false, // 控制滚动条和top按钮同时出现
|
|
|
|
|
|
showTopBtn: false, // 显示To top按钮
|
|
|
|
|
|
showCustomTableTitle: false, // 自定义列弹框是否显示
|
|
|
|
|
|
customTableTitle: [] // 自定义列工具的数据
|
|
|
|
|
|
},
|
|
|
|
|
|
batchDeleteObjs: [],
|
|
|
|
|
|
endpoint: {}, // 用来查看详情和编辑的对象
|
|
|
|
|
|
tableTitle: [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: this.$t('project.endpoint.endpointId'),
|
|
|
|
|
|
prop: 'id',
|
|
|
|
|
|
show: true
|
|
|
|
|
|
}, {
|
2021-05-14 15:24:32 +08:00
|
|
|
|
label: this.$t('project.project.projectName'),
|
2021-03-19 18:52:19 +08:00
|
|
|
|
prop: 'project',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: '120'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.module.module'),
|
|
|
|
|
|
prop: 'module',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: '120'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.asset'),
|
|
|
|
|
|
prop: 'asset',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
minWidth: '400'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.host'),
|
|
|
|
|
|
prop: 'host',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 120
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.port'),
|
|
|
|
|
|
prop: 'port',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: '120'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('overall.type'),
|
|
|
|
|
|
prop: 'type',
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
width: 120
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.labels'),
|
|
|
|
|
|
prop: 'labels',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 200
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.param'),
|
|
|
|
|
|
prop: 'param',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 200
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.path'),
|
|
|
|
|
|
prop: 'path',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 200
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.list.state'),
|
|
|
|
|
|
prop: 'state',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: '80'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('project.endpoint.alerts'),
|
|
|
|
|
|
prop: 'alerts',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 150
|
2020-07-21 10:03:31 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* {
|
2020-03-30 19:46:03 +08:00
|
|
|
|
label: this.$t("project.endpoint.lastUpdate"),
|
|
|
|
|
|
prop: 'lastUpdate',
|
|
|
|
|
|
show: true,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, */
|
|
|
|
|
|
{
|
|
|
|
|
|
label: this.$t('config.account.option'),
|
|
|
|
|
|
prop: 'option',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 120
|
2020-07-31 20:57:04 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
tablelable: [],
|
|
|
|
|
|
dropCol: [],
|
|
|
|
|
|
currentProject: { id: '', name: '', remark: '' }, // endpoint弹框、module列表用来回显project
|
|
|
|
|
|
currentModule: { id: '', name: '', project: {}, port: '', path: '', param: '', paramObj: [] }, // endpoint弹框用来回显module
|
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'id',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 11,
|
|
|
|
|
|
name: this.$t('asset.asset'),
|
|
|
|
|
|
type: 'query',
|
|
|
|
|
|
label: 'query',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 33,
|
|
|
|
|
|
name: this.$t('asset.state'),
|
|
|
|
|
|
// name: this.$t('asset.asset'),
|
|
|
|
|
|
type: 'select',
|
|
|
|
|
|
label: 'endpointState',
|
|
|
|
|
|
disabled: false,
|
|
|
|
|
|
readonly: true
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 34,
|
2021-05-14 15:24:32 +08:00
|
|
|
|
name: this.$t('project.project.projectName'),
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// name: this.$t('asset.asset'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'projectName',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 35,
|
|
|
|
|
|
name: this.$t('project.module.module'),
|
|
|
|
|
|
// name: this.$t('asset.asset'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'moduleName',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}]
|
2020-03-30 19:46:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
endpointSearchLabel: { // 搜索参数
|
2020-08-05 14:57:14 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
tableData: []
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 切换tab
|
|
|
|
|
|
changeTab (tab) {
|
|
|
|
|
|
this.$emit('changeTab', tab)
|
|
|
|
|
|
},
|
|
|
|
|
|
getTableData () {
|
|
|
|
|
|
this.tools.loading = true
|
2021-04-20 14:38:24 +08:00
|
|
|
|
if (this.from === fromRoute.asset) {
|
|
|
|
|
|
this.$set(this.endpointSearchLabel, 'assetId', this.asset.id)
|
|
|
|
|
|
} else if (this.from === fromRoute.module) {
|
|
|
|
|
|
this.$set(this.endpointSearchLabel, 'moduleIds', this.module.id)
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$set(this.endpointSearchLabel, 'pageSize', '-1')
|
2021-05-19 11:32:41 +08:00
|
|
|
|
this.tools.loading = true
|
2021-04-20 14:38:24 +08:00
|
|
|
|
this.$get('monitor/endpoint', this.endpointSearchLabel).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.tools.loading = false
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
for (let i = 0; i < response.data.list.length; i++) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const param = response.data.list[i].param || '{}'
|
|
|
|
|
|
const tempObj = JSON.parse(param)
|
|
|
|
|
|
response.data.list[i].paramObj = []
|
|
|
|
|
|
const labels = response.data.list[i].labels || '{}'
|
|
|
|
|
|
const tempObj1 = JSON.parse(labels)
|
|
|
|
|
|
response.data.list[i].labelModule = []
|
|
|
|
|
|
for (const k in tempObj) {
|
|
|
|
|
|
response.data.list[i].paramObj.push({ key: k, value: tempObj[k] })
|
|
|
|
|
|
}
|
|
|
|
|
|
for (const k in tempObj1) {
|
|
|
|
|
|
response.data.list[i].labelModule.push({ key: k, value: tempObj1[k] })
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
// console.error(response.data.list[i], err);
|
2020-11-22 19:24:24 +08:00
|
|
|
|
}
|
2020-07-21 10:03:31 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
|
this.$emit('reload')
|
2020-07-21 10:03:31 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
closeRightBox (refresh) {
|
|
|
|
|
|
this.rightBox.add.show = false
|
|
|
|
|
|
this.rightBox.edit.show = false
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
delEndpoint (endpoint) {
|
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete('endpoint?ids=' + endpoint.id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
2020-03-30 19:46:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
toEdit (endpoint) {
|
|
|
|
|
|
this.endpoint = JSON.parse(JSON.stringify(endpoint))
|
|
|
|
|
|
if (!this.endpoint.paramObj) {
|
|
|
|
|
|
this.$set(this.endpoint, 'paramObj', [])
|
|
|
|
|
|
}
|
|
|
|
|
|
this.rightBox.edit = true
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.editEndpointBox.show(true)
|
|
|
|
|
|
this.$refs.editEndpointBox.toEdit(true, this.endpoint.id)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
editEndpoint (endpoint) {
|
|
|
|
|
|
this.endpoint = JSON.parse(JSON.stringify(endpoint))
|
|
|
|
|
|
this.$set(this.endpoint, 'projectId', this.endpoint.project.id)
|
|
|
|
|
|
this.$set(this.endpoint, 'moduleId', this.endpoint.moduleId)
|
2020-03-30 19:46:03 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.rightBox.editEndpoint.show = true
|
|
|
|
|
|
if (!this.endpoint.paramObj) {
|
|
|
|
|
|
this.$set(this.endpoint, 'paramObj', [])
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!this.endpoint.labelModule) {
|
|
|
|
|
|
this.$set(this.endpoint, 'labelModule', [])
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
closeEditEndpointRightBox (refresh) {
|
|
|
|
|
|
this.rightBox.editEndpoint.show = false
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
add () {
|
|
|
|
|
|
this.rightBox.add.show = true
|
|
|
|
|
|
},
|
|
|
|
|
|
search (searchObj) {
|
|
|
|
|
|
let orderBy = ''
|
|
|
|
|
|
if (this.endpointSearchLabel.orderBy) {
|
|
|
|
|
|
orderBy = this.endpointSearchLabel.orderBy
|
|
|
|
|
|
}
|
|
|
|
|
|
this.endpointSearchLabel = {}
|
|
|
|
|
|
// this.pageObj.pageNo = 1;
|
|
|
|
|
|
for (const item in searchObj) {
|
|
|
|
|
|
if (searchObj[item] || searchObj[item] === 0) {
|
|
|
|
|
|
if (item === 'endpointState') {
|
|
|
|
|
|
this.$set(this.endpointSearchLabel, 'state', searchObj[item])
|
2020-09-27 17:08:58 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$set(this.endpointSearchLabel, item, searchObj[item])
|
2020-09-27 17:08:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (orderBy) {
|
|
|
|
|
|
this.$set(this.endpointSearchLabel, 'orderBy', orderBy)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.$refs.endpointTable && this.$refs.endpointTable.bodyWrapper) {
|
|
|
|
|
|
this.$refs.endpointTable.bodyWrapper.scrollTop = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
this.getTableData()
|
2020-03-30 19:46:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
dateFormat (time) {
|
|
|
|
|
|
if (!time) {
|
|
|
|
|
|
return '-'
|
|
|
|
|
|
}
|
|
|
|
|
|
const date = new Date(time * 1000)
|
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
|
const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
|
|
|
|
|
const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
|
|
|
|
|
const hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
|
|
|
|
|
const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
|
|
|
|
|
const seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
|
|
|
|
|
|
|
|
|
|
|
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
|
|
|
|
|
},
|
|
|
|
|
|
getStateContent: function (row) {
|
|
|
|
|
|
if (row) {
|
|
|
|
|
|
if (row.state == 1) {
|
|
|
|
|
|
return 'up'
|
|
|
|
|
|
} else if (row.state == 0) {
|
|
|
|
|
|
return 'down'
|
|
|
|
|
|
} else if (row.state == 2) {
|
|
|
|
|
|
return 'suspended'
|
2020-03-30 19:46:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-03-30 19:46:03 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
formatUpdateTime: function (date) {
|
|
|
|
|
|
const time = new Date(date)
|
|
|
|
|
|
const hours = time.getHours() > 9 ? time.getHours() : '0' + time.getHours()
|
|
|
|
|
|
const minutes = time.getMinutes() > 9 ? time.getMinutes() : '0' + time.getMinutes()
|
|
|
|
|
|
|
|
|
|
|
|
return hours + ':' + minutes
|
2020-11-20 10:15:17 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
getStateErrorMsg: function (row) {
|
|
|
|
|
|
const errCodes = [230009, 230010, 230011]
|
|
|
|
|
|
if (row) {
|
|
|
|
|
|
if (row.state == 0) {
|
|
|
|
|
|
if (errCodes.find((item) => { return row.stateInfo.code == item })) {
|
|
|
|
|
|
return this.$t('project.endpoint.stateInfo_' + row.stateInfo.code)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error('state code error')
|
|
|
|
|
|
return row.stateInfo.msg
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
initEvent () {
|
|
|
|
|
|
bus.$on('current-project-change', project => {
|
|
|
|
|
|
this.currentProject = project
|
|
|
|
|
|
})
|
|
|
|
|
|
bus.$on('current-module-change', module => {
|
|
|
|
|
|
this.currentModule = module
|
|
|
|
|
|
})
|
2020-11-20 10:15:17 +08:00
|
|
|
|
// bus.$on("endpoint-list-change", menu => {
|
|
|
|
|
|
// this.getEndpointTableData();
|
|
|
|
|
|
// });
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 数据排序
|
|
|
|
|
|
tableDataSort (item) {
|
|
|
|
|
|
let orderBy = ''
|
|
|
|
|
|
if (item.order === 'ascending') {
|
|
|
|
|
|
orderBy = item.prop
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item.order === 'descending') {
|
|
|
|
|
|
orderBy = '-' + item.prop
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$set(this.endpointSearchLabel, 'orderBy', orderBy)
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
},
|
|
|
|
|
|
messageStyle (e) {
|
|
|
|
|
|
if (e.column.label == 'Alerts' || e.column.label == this.$t('project.endpoint.alerts')) {
|
|
|
|
|
|
if (e.row.alertNum > 0) {
|
|
|
|
|
|
return 'danger'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 'success'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
obj: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n) {
|
2021-04-20 14:38:24 +08:00
|
|
|
|
if (this.from === fromRoute.asset) {
|
|
|
|
|
|
this.asset = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
})
|
|
|
|
|
|
} else if (this.from === fromRoute.module) {
|
|
|
|
|
|
this.module = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-30 19:46:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
// 初始化表头
|
|
|
|
|
|
this.tools.customTableTitle = localStorage.getItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-/projectBottom')
|
|
|
|
|
|
? JSON.parse(localStorage.getItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-/projectBottom'))
|
|
|
|
|
|
: this.tableTitle
|
|
|
|
|
|
this.tableTitleReset(this.tableTitle, this.tools.customTableTitle)
|
|
|
|
|
|
this.initEvent()
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
|
bus.$off('current-project-change', project => {
|
|
|
|
|
|
this.currentProject = project
|
|
|
|
|
|
})
|
|
|
|
|
|
bus.$on('current-module-change', module => {
|
|
|
|
|
|
this.currentModule = module
|
|
|
|
|
|
})
|
|
|
|
|
|
// bus.$on("endpoint-list-change", menu => {
|
|
|
|
|
|
// this.getEndpointTableData();
|
|
|
|
|
|
// });
|
2020-03-30 19:46:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-03-30 19:46:03 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|