2019-12-05 18:07:58 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.prom {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
<div class="prom">
|
2020-04-14 19:33:57 +08:00
|
|
|
|
<left-menu >
|
|
|
|
|
|
<div slot="content-left" class="slot-content">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<div class="sidebar-title">{{$t('overall.config')}}</div>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
<div class="sidebar-info">
|
|
|
|
|
|
<div class="sidebar-info-item sidebar-info-top" @click="jumpTo('account')" id="prom-jump-account">
|
|
|
|
|
|
{{$t('config.account.account')}}
|
2019-12-06 17:36:33 +08:00
|
|
|
|
</div>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
<div class="sidebar-info-item sidebar-info-item-active">{{$t('config.promServer.promServerList')}}</div>
|
2020-03-30 21:09:34 +08:00
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('dc')" id="prom-jump-dc">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
{{$t('config.dc.dc')}}
|
|
|
|
|
|
</div>
|
2020-03-30 21:09:34 +08:00
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('model')" id="prom-jump-model">
|
2020-03-11 12:27:00 +08:00
|
|
|
|
{{$t('config.model.model')}}
|
|
|
|
|
|
</div>
|
2020-03-30 21:09:34 +08:00
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('mib')" id="prom-jump-mib">
|
2020-03-26 19:58:09 +08:00
|
|
|
|
{{$t('config.mib.mib')}}
|
|
|
|
|
|
</div>
|
2020-03-30 21:09:34 +08:00
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('system')" id="prom-jump-system">
|
|
|
|
|
|
{{$t('config.system.system')}}
|
|
|
|
|
|
</div>
|
2020-04-01 20:47:19 +08:00
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('terminallog')" id="prom-jump-terminallog">
|
|
|
|
|
|
{{$t('config.terminallog.terminallog')}}
|
|
|
|
|
|
</div>
|
2020-04-08 22:31:07 +08:00
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('operationlog')" id="account-jump-operation">
|
|
|
|
|
|
{{$t('config.operationlog.operationlog')}}
|
|
|
|
|
|
</div>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-04-14 19:33:57 +08:00
|
|
|
|
<div slot="content-right"class="slot-content">
|
2020-03-30 14:14:09 +08:00
|
|
|
|
<div class="main-list main-and-sub-transition" :class="{'main-list-with-sub': showSubList}">
|
2020-03-27 18:44:59 +08:00
|
|
|
|
<div class="top-tools" v-show="mainResizeShow">
|
|
|
|
|
|
<div class="top-tool-main-right" :class="{'top-tool-main-right-to-left': showSubList}">
|
|
|
|
|
|
<div class="top-tool-search">
|
|
|
|
|
|
<search-input ref="searchInput" :searchMsg="searchMsg" @search="search" :inTransform="inTransform"></search-input>
|
|
|
|
|
|
</div>
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<button type="button" @click="add" :title="$t('overall.createPrometheusServer')"
|
2020-03-27 18:44:59 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20" id="prom-add">
|
|
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
|
|
|
|
|
</div>
|
2020-04-19 21:48:03 +08:00
|
|
|
|
<el-table :data="tableData" border v-show="mainResizeShow" :height="mainTableHeight" style="width: 100%;"
|
2020-07-15 18:32:25 +08:00
|
|
|
|
v-loading="loading" ref="promTable" class="nz-table" v-scrollBar:el-table="'large'"
|
|
|
|
|
|
@sort-change="tableDataSort">
|
|
|
|
|
|
<el-table-column :resizable="false" v-for="(item, index) in tablelable"
|
|
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:width="item.width"
|
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:sortable="sortableShow(item.prop)"
|
|
|
|
|
|
:prop="propTitle(item.prop)">
|
2020-03-27 18:44:59 +08:00
|
|
|
|
<template slot-scope="scope" :column="item">
|
2020-04-21 18:48:09 +08:00
|
|
|
|
<span v-if="item.prop == 'idc'" >{{scope.row[item.prop]?scope.row[item.prop].name:'-'}}</span>
|
2020-01-10 18:16:25 +08:00
|
|
|
|
|
2020-03-27 19:01:19 +08:00
|
|
|
|
<span v-else-if="item.prop == 'type'">
|
|
|
|
|
|
{{scope.row[item.prop] == '1' ? 'Global' : ''}}
|
|
|
|
|
|
{{scope.row[item.prop] == '2' ? 'Per-Datacenter' : ''}}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span v-else-if="item.prop == 'status'">
|
|
|
|
|
|
<el-popover placement="right" width="200" trigger="hover" :content="$t('asset.assetStatPre')+(scope.row.checkTime?scope.row.checkTime:$t('asset.assetStatDown'))">
|
|
|
|
|
|
<div slot="reference" style="width: 20px">
|
|
|
|
|
|
<div :class="{'active-icon green':scope.row[item.prop] == '1','active-icon red':scope.row[item.prop] == '0' || scope.row[item.prop] == '-1' || scope.row[item.prop] == '-2'}"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<div v-else-if="item.prop == 'option'" class="content-right-options">
|
|
|
|
|
|
<span :title="$t('overall.view')" @click="detail(scope.row)" class="content-right-option" :id="'prom-detail-'+scope.row.id"><i class="nz-icon nz-icon-view"></i></span>
|
|
|
|
|
|
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<span :title="$t('overall.edit')" @click="edit(scope.row)" class="content-right-option" :id="'prom-edit-'+scope.row.id"><i class="nz-icon nz-icon-edit"></i></span>
|
2020-03-27 19:01:19 +08:00
|
|
|
|
|
|
|
|
|
|
<span :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" :id="'prom-del-'+scope.row.id"><i class="el-icon-delete"></i></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<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">
|
|
|
|
|
|
<template slot="header" slot-scope="scope">
|
|
|
|
|
|
<span @click.stop="elementsetShow('shezhi',$event)" class="nz-table-gear">
|
|
|
|
|
|
<i class="nz-icon nz-icon-gear"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
2020-04-21 18:00:21 +08:00
|
|
|
|
<template v-slot="scope">
|
|
|
|
|
|
<button v-if="scope.$index == 0" class="to-top" :style="{top: toTopBtnTop}" :class="{'to-top-is-hover': tableHover}" v-show="showTopBtn && mainResizeShow" @click="$toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button>
|
|
|
|
|
|
</template>
|
2020-03-27 19:01:19 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<div class="pagination-bottom" v-show="!showSubList">
|
|
|
|
|
|
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-04-19 22:03:18 +08:00
|
|
|
|
<bottom-box v-if="showSubList" :show-sub-list="showSubList" :subResizeShow="subResizeShow" :obj="promServer" :isFullScreen="isFullScreen" :from="'promServer'" :targetTab.sync="targetTab" :detail="promDetail"
|
2020-03-27 19:01:19 +08:00
|
|
|
|
@closeSubList="showSubList = false" @fullScreen="fullScreen" @exitFullScreen="exitFullScreen" @listResize="listResize" ></bottom-box>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
</div>
|
2020-04-14 19:33:57 +08:00
|
|
|
|
</left-menu>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
<transition name="right-box">
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<prom-server-box v-if="rightBox.show" :prom-server="promServer" @close="closeRightBox"></prom-server-box>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
<element-set
|
|
|
|
|
|
v-clickoutside="elementsetHide"
|
|
|
|
|
|
:table-title="tableTitle"
|
|
|
|
|
|
:dropCol="dropCol"
|
|
|
|
|
|
@tablelable="tablelabelEmit"
|
|
|
|
|
|
ref="elementset"
|
|
|
|
|
|
></element-set>
|
|
|
|
|
|
</div>
|
2019-12-05 18:07:58 +08:00
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2020-04-06 22:11:25 +08:00
|
|
|
|
import bus from '../../../libs/bus';
|
2020-07-15 20:43:19 +08:00
|
|
|
|
import promServerBox from '../../common/rightBox/promServerBox';
|
|
|
|
|
|
|
2020-02-03 21:30:07 +08:00
|
|
|
|
export default {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
name: "promServer",
|
|
|
|
|
|
components: {
|
|
|
|
|
|
'prom-server-box': promServerBox
|
|
|
|
|
|
},
|
2020-02-03 21:30:07 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-03-27 18:44:59 +08:00
|
|
|
|
//底部上滑框相关
|
|
|
|
|
|
mainTableHeight: this.$tableHeight.normal, //主列表table高度
|
|
|
|
|
|
showSubList: false, //是否展示二级列表
|
|
|
|
|
|
targetTab: '', //展示二级列表中的哪个页签
|
|
|
|
|
|
showElementSet: false, //控制自定义列的弹框
|
|
|
|
|
|
inTransform: false, //搜索框相关,搜索条件下拉框是否在transform里
|
|
|
|
|
|
mainResizeShow: true, //dom高度改变时部分内容是否展示
|
|
|
|
|
|
subResizeShow: true,
|
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
|
promDetail: [],
|
|
|
|
|
|
//底部上滑框相关end
|
|
|
|
|
|
|
2020-04-21 18:00:21 +08:00
|
|
|
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
|
|
|
|
|
tableHover: false, //控制滚动条和top按钮同时出现
|
|
|
|
|
|
|
2020-03-13 12:20:02 +08:00
|
|
|
|
tableId: 'promTable', //需要分页的table的id,用于记录每页数量
|
2020-03-05 21:30:45 +08:00
|
|
|
|
showTopBtn: false,
|
2020-02-03 21:30:07 +08:00
|
|
|
|
rightBox: { //弹出框相关
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
},
|
2020-04-19 21:48:03 +08:00
|
|
|
|
loading: false,
|
2020-02-03 21:30:07 +08:00
|
|
|
|
promServer: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
host: '',
|
|
|
|
|
|
port: 9090,
|
|
|
|
|
|
idc: {id: '', name: '', location: ''}
|
|
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
blankPromServer: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
host: '',
|
|
|
|
|
|
port: 9090,
|
|
|
|
|
|
idc: {id: '', name: '', location: ''}
|
2020-02-03 21:30:07 +08:00
|
|
|
|
},
|
|
|
|
|
|
pageObj: {
|
|
|
|
|
|
pageNo: 1,
|
2020-07-13 17:26:06 +08:00
|
|
|
|
pageSize: 50,
|
2020-02-03 21:30:07 +08:00
|
|
|
|
total: 0
|
|
|
|
|
|
},
|
|
|
|
|
|
tableTitle: [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'ID',
|
|
|
|
|
|
prop: 'id',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 80
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: 'DC',
|
|
|
|
|
|
prop: 'idc',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: 'Host',
|
|
|
|
|
|
prop: 'host',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: 'Port',
|
|
|
|
|
|
prop: 'port',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("config.promServer.type"),
|
|
|
|
|
|
prop: 'type',
|
|
|
|
|
|
show: true,
|
2020-02-06 18:50:40 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('asset.createAssetTab.state'),
|
|
|
|
|
|
prop: 'status',
|
|
|
|
|
|
show: true
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('config.promServer.checkTime'),
|
|
|
|
|
|
prop: 'checkTime',
|
2020-02-14 18:07:21 +08:00
|
|
|
|
show: false
|
2020-02-03 21:30:07 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('config.account.option'),
|
|
|
|
|
|
prop: 'option',
|
|
|
|
|
|
show: true,
|
2020-02-18 11:05:57 +08:00
|
|
|
|
width: 120
|
2020-02-03 21:30:07 +08:00
|
|
|
|
}
|
2020-01-02 18:10:24 +08:00
|
|
|
|
],
|
2020-02-03 21:30:07 +08:00
|
|
|
|
tablelable: [],
|
|
|
|
|
|
dropCol: [],
|
|
|
|
|
|
tableData: [],
|
2020-07-15 20:43:19 +08:00
|
|
|
|
dcData: [],
|
2020-02-03 21:30:07 +08:00
|
|
|
|
searchMsg: { //给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'id',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 5,
|
|
|
|
|
|
name: 'DC',
|
|
|
|
|
|
type: 'dc',
|
|
|
|
|
|
label: 'dc',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 6,
|
|
|
|
|
|
name: this.$t('config.promServer.type'),
|
|
|
|
|
|
type: 'select',
|
|
|
|
|
|
label: 'promType',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 8,
|
|
|
|
|
|
name: this.$t('project.endpoint.host'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'host',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
id: 9,
|
|
|
|
|
|
name: this.$t('project.endpoint.port'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'port',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}],
|
|
|
|
|
|
},
|
|
|
|
|
|
searchLabel: {}, //搜索参数
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2020-03-30 14:14:09 +08:00
|
|
|
|
// 全屏
|
|
|
|
|
|
fullScreen() {
|
2020-07-15 20:47:17 +08:00
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.fullScreen(vm);
|
2020-03-27 18:44:59 +08:00
|
|
|
|
},
|
2020-03-30 14:14:09 +08:00
|
|
|
|
// 退出全屏
|
2020-03-27 18:44:59 +08:00
|
|
|
|
exitFullScreen() {
|
2020-07-15 20:47:17 +08:00
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.exitFullScreen(vm);
|
2020-03-27 18:44:59 +08:00
|
|
|
|
},
|
2020-03-30 14:14:09 +08:00
|
|
|
|
// 鼠标拖动二级列表
|
|
|
|
|
|
listResize(e) {
|
2020-07-15 20:47:17 +08:00
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.listResize(vm, e);
|
2020-03-27 18:44:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
convertToDetail(obj) {
|
|
|
|
|
|
let detail = [];
|
|
|
|
|
|
detail.push({label: this.$t("config.dc.dc"), value: obj.idc.name});
|
|
|
|
|
|
detail.push({label: "Host", value: obj.host});
|
|
|
|
|
|
detail.push({label: "Port", value: obj.port});
|
|
|
|
|
|
let type = "";
|
2020-07-15 20:43:19 +08:00
|
|
|
|
for (let i = 0; i < this.$CONSTANTS.promServer.typeOption.length; i++) {
|
2020-03-27 18:44:59 +08:00
|
|
|
|
if (obj.key == this.typeData[i].type) {
|
|
|
|
|
|
type = this.typeData[i].value;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
detail.push({label: this.$t('config.promServer.type'), value: type});
|
2020-03-28 20:44:29 +08:00
|
|
|
|
detail.push({
|
|
|
|
|
|
label: this.$t('asset.createAssetTab.state'),
|
|
|
|
|
|
value: obj.status,
|
|
|
|
|
|
type: 'status',
|
|
|
|
|
|
msg: this.$t('asset.assetStatPre')+(obj.checkTime ? obj.checkTime : this.$t('asset.assetStatDown'))
|
|
|
|
|
|
});
|
2020-03-27 18:44:59 +08:00
|
|
|
|
return detail;
|
|
|
|
|
|
},
|
2020-02-03 21:30:07 +08:00
|
|
|
|
elementsetShow(s, e) {
|
|
|
|
|
|
var eventfixed = {
|
|
|
|
|
|
shezhi: 0,
|
|
|
|
|
|
screen: 0
|
|
|
|
|
|
};
|
|
|
|
|
|
eventfixed[s] = 1;
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
this.$store.commit('setHeaderTable', this.tablelable);
|
|
|
|
|
|
this.$store.commit('setEventfixed', eventfixed);
|
|
|
|
|
|
const h = document.documentElement.clientHeight;
|
|
|
|
|
|
const w = document.documentElement.clientWidth;
|
|
|
|
|
|
const dw = this.$refs.elementset.$el.offsetWidth;
|
|
|
|
|
|
const dh = this.$refs.elementset.$el.offsetHeight;
|
|
|
|
|
|
let positionx =
|
2020-02-18 11:05:57 +08:00
|
|
|
|
e.clientX + dw <= w - 10 ? e.clientX + 14 : e.clientX + 14 - dw;
|
2020-02-03 21:30:07 +08:00
|
|
|
|
let positiony =
|
|
|
|
|
|
e.clientY + dh <= h - 10
|
2020-02-18 11:05:57 +08:00
|
|
|
|
? e.clientY + 20
|
|
|
|
|
|
: e.clientY + 20 - (e.clientY + dh - h);
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.$store.commit('setPosition', {positionx, positiony});
|
2020-01-02 18:10:24 +08:00
|
|
|
|
},
|
2020-02-03 21:30:07 +08:00
|
|
|
|
elementsetHide() {
|
|
|
|
|
|
//悬浮点击空白隐藏
|
|
|
|
|
|
this.$refs.elementset.elementsetHide();
|
2019-12-05 18:07:58 +08:00
|
|
|
|
},
|
2020-02-03 21:30:07 +08:00
|
|
|
|
tablelabelEmit(data) {
|
|
|
|
|
|
//获取子组件传过来的参数
|
|
|
|
|
|
this.$store.commit('setHeaderTable', data);
|
|
|
|
|
|
this.tablelable = data;
|
2019-12-17 17:17:30 +08:00
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
edit(u) {
|
|
|
|
|
|
this.promServer = JSON.parse(JSON.stringify(u));
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.rightBox.show = true;
|
2019-12-25 17:15:09 +08:00
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
/*删除*/
|
|
|
|
|
|
del(u) {
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete("promServer?ids=" + u.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-07-15 20:43:19 +08:00
|
|
|
|
});
|
2020-02-03 21:30:07 +08:00
|
|
|
|
});
|
2019-12-25 17:15:09 +08:00
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
detail(u) {
|
|
|
|
|
|
this.promServer = JSON.parse(JSON.stringify(u));
|
2020-03-27 18:44:59 +08:00
|
|
|
|
this.targetTab = "detail";
|
|
|
|
|
|
this.showSubList = true;
|
2019-12-25 17:15:09 +08:00
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
add() {
|
2020-07-15 22:11:33 +08:00
|
|
|
|
this.promServer = this.newPromServer();
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.rightBox.show = true;
|
|
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
closeRightBox(refresh) {
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.getTableData();
|
2020-02-03 21:30:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
jumpTo(data, id) {
|
2020-04-06 22:11:25 +08:00
|
|
|
|
bus.$emit("menu-change", data);
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.$router.push({
|
|
|
|
|
|
path: "/" + data,
|
|
|
|
|
|
query: {
|
|
|
|
|
|
t: +new Date()
|
2019-12-19 17:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-02-03 21:30:07 +08:00
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
getTableData() {
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.tableData = [];
|
|
|
|
|
|
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
|
|
|
|
|
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
2020-04-19 21:48:03 +08:00
|
|
|
|
this.loading = true;
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.$get('promServer', this.searchLabel).then(response => {
|
2020-04-19 21:48:03 +08:00
|
|
|
|
this.loading = false;
|
2020-02-03 21:30:07 +08:00
|
|
|
|
if (response.code === 200) {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
for (let i = 0; i < response.data.list.length; i++) {
|
|
|
|
|
|
for (let j = 0; j < this.dcData.length; j++) {
|
|
|
|
|
|
if (response.data.list[i].idcId == this.dcData[j].id) {
|
|
|
|
|
|
response.data.list[i].idc = this.dcData[j];
|
2020-02-03 21:30:07 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.tableData = response.data.list;
|
|
|
|
|
|
this.pageObj.total = response.data.total
|
2019-12-13 17:08:35 +08:00
|
|
|
|
}
|
2020-02-03 21:30:07 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2020-07-15 22:11:33 +08:00
|
|
|
|
newPromServer() {
|
|
|
|
|
|
return JSON.parse(JSON.stringify(this.blankPromServer));
|
2020-02-03 21:30:07 +08:00
|
|
|
|
},
|
|
|
|
|
|
pageNo(val) {
|
|
|
|
|
|
this.pageObj.pageNo = val;
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
pageSize(val) {
|
|
|
|
|
|
this.pageObj.pageSize = val;
|
2020-03-13 12:20:02 +08:00
|
|
|
|
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val);
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
search(searchObj) {
|
2020-07-15 18:32:25 +08:00
|
|
|
|
let orderBy='';
|
|
|
|
|
|
if(this.searchLabel.orderBy){
|
|
|
|
|
|
orderBy=this.searchLabel.orderBy
|
|
|
|
|
|
}
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.pageObj.pageNo = 1;
|
|
|
|
|
|
this.searchLabel = {};
|
|
|
|
|
|
for (let item in searchObj) {
|
|
|
|
|
|
if (searchObj[item]) {
|
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item]);
|
|
|
|
|
|
}
|
2019-12-10 17:00:28 +08:00
|
|
|
|
}
|
2020-07-15 18:32:25 +08:00
|
|
|
|
if(orderBy){
|
|
|
|
|
|
this.$set(this.searchLabel, 'orderBy', orderBy);
|
|
|
|
|
|
}
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
//获取dc数据
|
|
|
|
|
|
getDcData() {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('idc').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.dcData = response.data.list;
|
2020-02-03 21:30:07 +08:00
|
|
|
|
}
|
2020-07-15 20:43:19 +08:00
|
|
|
|
resolve();
|
2020-02-03 21:30:07 +08:00
|
|
|
|
});
|
2020-07-15 20:43:19 +08:00
|
|
|
|
});
|
2020-02-03 21:30:07 +08:00
|
|
|
|
},
|
2020-07-15 18:32:25 +08:00
|
|
|
|
//是否需要排序
|
|
|
|
|
|
sortableShow(prop){
|
|
|
|
|
|
switch(prop){
|
|
|
|
|
|
case 'id':
|
|
|
|
|
|
case 'idc':
|
|
|
|
|
|
case 'host':
|
|
|
|
|
|
case 'port':
|
|
|
|
|
|
case 'type':
|
|
|
|
|
|
return'custom';
|
|
|
|
|
|
default : return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// prop字段
|
|
|
|
|
|
propTitle(prop){
|
|
|
|
|
|
switch(prop){
|
|
|
|
|
|
case 'id': return'id';
|
|
|
|
|
|
case 'idc': return'idc_id';
|
|
|
|
|
|
case 'host': return'host';
|
|
|
|
|
|
case 'port': return'port';
|
|
|
|
|
|
case 'type': return'type';
|
|
|
|
|
|
default : return prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 数据排序
|
|
|
|
|
|
tableDataSort(item){
|
2020-07-15 22:11:33 +08:00
|
|
|
|
let orderBy = '';
|
|
|
|
|
|
if(item.order === 'ascending') {
|
|
|
|
|
|
orderBy = item.prop;
|
2020-07-15 18:32:25 +08:00
|
|
|
|
}
|
2020-07-15 22:11:33 +08:00
|
|
|
|
if(item.order === 'descending') {
|
|
|
|
|
|
orderBy = '-' + item.prop;
|
2020-07-15 18:32:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$set(this.searchLabel, "orderBy", orderBy);
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2019-12-25 17:15:09 +08:00
|
|
|
|
},
|
2020-02-03 21:30:07 +08:00
|
|
|
|
mounted: function () {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
//初始化数据
|
|
|
|
|
|
Promise.all([this.getDcData()]).then(response => {
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
});
|
2020-03-13 12:20:02 +08:00
|
|
|
|
//是否存在分页缓存
|
|
|
|
|
|
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
2020-03-20 18:22:44 +08:00
|
|
|
|
if (pageSize != 'undefined' && pageSize != null) {
|
2020-03-13 12:20:02 +08:00
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 21:30:45 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
//绑定滚动条事件,控制top按钮
|
|
|
|
|
|
let el = this.$refs.promTable.$el.querySelector(".el-table__body-wrapper");
|
|
|
|
|
|
if (el._ps_) {
|
|
|
|
|
|
el.addEventListener("ps-scroll-y", () => {
|
2020-03-06 17:53:36 +08:00
|
|
|
|
if (el._ps_.scrollbarYTop > 50) {
|
2020-03-05 21:30:45 +08:00
|
|
|
|
this.showTopBtn = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.showTopBtn = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-04-21 18:00:21 +08:00
|
|
|
|
el.addEventListener("mouseenter", () => {
|
|
|
|
|
|
this.tableHover = true;
|
|
|
|
|
|
});
|
|
|
|
|
|
el.addEventListener("mouseleave", () => {
|
|
|
|
|
|
this.tableHover = false;
|
|
|
|
|
|
});
|
2020-03-05 21:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path)
|
|
|
|
|
|
? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
|
|
|
|
|
|
: this.tableTitle;
|
|
|
|
|
|
this.dropCol = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path)
|
|
|
|
|
|
? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
|
|
|
|
|
|
: this.tableTitle;
|
2020-01-10 18:16:25 +08:00
|
|
|
|
},
|
2020-03-27 18:44:59 +08:00
|
|
|
|
|
2020-02-03 21:30:07 +08:00
|
|
|
|
watch: {
|
2020-03-27 18:44:59 +08:00
|
|
|
|
promServer: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.promDetail = this.convertToDetail(n);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
showSubList(n) {
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.showSubListWatch(vm, n);
|
2020-02-03 21:30:07 +08:00
|
|
|
|
}
|
2019-12-10 17:00:28 +08:00
|
|
|
|
}
|
2019-12-05 18:07:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|