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-08-02 22:43:53 +08:00
|
|
|
|
<div class="main-list" :class="{'main-list-with-sub': bottomBox.showSubList}">
|
|
|
|
|
|
<div class="main-modal"></div>
|
|
|
|
|
|
<div class="top-tools" v-show="bottomBox.mainResizeShow">
|
|
|
|
|
|
<div class="top-tool-main-right" :class="{'top-tool-main-right-to-left': bottomBox.showSubList}">
|
|
|
|
|
|
<div class="top-tool-search">
|
|
|
|
|
|
<search-input ref="searchInput" :searchMsg="searchMsg" @search="search" :inTransform="bottomBox.inTransform"></search-input>
|
2020-03-27 18:44:59 +08:00
|
|
|
|
</div>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<button type="button" @click="add" :title="$t('overall.createPrometheusServer')"
|
|
|
|
|
|
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>
|
2020-10-29 19:11:46 +08:00
|
|
|
|
<delete-button :delete-objs="batchDeleteObjs" api="promServer" @after="getTableData"></delete-button>
|
2020-03-27 18:44:59 +08:00
|
|
|
|
</div>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
|
|
|
|
|
</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<!-- 自定义table列 -->
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<element-set
|
|
|
|
|
|
v-if="tools.showCustomTableTitle"
|
|
|
|
|
|
@close="tools.showCustomTableTitle = false"
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:original-table-title="tableTitle"
|
|
|
|
|
|
ref="customTableTitle"
|
|
|
|
|
|
></element-set>
|
|
|
|
|
|
</transition>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<el-table :data="tableData" border v-show="bottomBox.mainResizeShow" :height="mainTableHeight" style="width: 100%;"
|
|
|
|
|
|
v-loading="tools.loading" ref="promTable" class="nz-table" v-scrollBar:el-table="'large'"
|
2020-10-29 19:11:46 +08:00
|
|
|
|
@sort-change="tableDataSort"
|
|
|
|
|
|
@selection-change="(selection)=>{this.batchDeleteObjs=selection}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
type="selection"
|
|
|
|
|
|
width="40"
|
|
|
|
|
|
align="center">
|
|
|
|
|
|
</el-table-column>
|
2020-11-04 15:38:34 +08:00
|
|
|
|
<el-table-column :resizable="true" v-for="(item, index) in tools.customTableTitle"
|
2020-08-02 22:43:53 +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,'promServer')"
|
|
|
|
|
|
:prop="$tableSet.propTitle(item.prop,'promServer')"
|
2020-08-02 22:43:53 +08:00
|
|
|
|
:sort-orders="['ascending', 'descending']">
|
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
|
<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-08-02 22:43:53 +08:00
|
|
|
|
<span v-else-if="item.prop == 'type'">
|
2020-09-01 15:36:21 +08:00
|
|
|
|
<!--{{scope.row[item.prop] == '1' ? 'Global' : ''}}
|
|
|
|
|
|
{{scope.row[item.prop] == '2' ? 'Per-Datacenter' : ''}}-->
|
|
|
|
|
|
{{findServerType(scope.row[item.prop]).text}}
|
2020-08-02 22:43:53 +08:00
|
|
|
|
</span>
|
2020-10-16 19:26:50 +08:00
|
|
|
|
<span v-else-if="item.prop == 'checkTime'">{{utcTimeToTimezoneStr(scope.row[item.prop])}}</span>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<span v-else-if="item.prop == 'status'">
|
2020-10-16 19:26:50 +08:00
|
|
|
|
<el-popover placement="right" width="200" trigger="hover" :content="$t('asset.assetStatPre')+(scope.row.checkTime?utcTimeToTimezoneStr(scope.row.checkTime):$t('asset.assetStatDown'))">
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<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">
|
2020-09-24 11:38:13 +08:00
|
|
|
|
<!--<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-08-02 22:43:53 +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-09-10 17:00:32 +08:00
|
|
|
|
<span :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" :id="'prom-del-'+scope.row.id"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
</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">
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<span @mousedown.stop="!tools.showCustomTableTitle && (tools.showCustomTableTitle = true)" class="nz-table-gear">
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<i class="nz-icon nz-icon-gear"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot="scope">
|
|
|
|
|
|
<button v-if="scope.$index == 0" class="to-top" :style="{top: tools.toTopBtnTop}" :class="{'to-top-is-hover': tools.tableHover}" v-show="tools.showTopBtn && bottomBox.mainResizeShow" @click="$toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<div class="pagination-bottom" v-show="!bottomBox.showSubList">
|
|
|
|
|
|
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
2020-03-27 19:01:19 +08:00
|
|
|
|
</div>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
</div>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<transition name="el-zoom-in-bottom">
|
|
|
|
|
|
<bottom-box v-if="bottomBox.showSubList" :sub-resize-show="bottomBox.subResizeShow" :obj="bottomBox.promServer" :is-full-screen="bottomBox.isFullScreen" :from="'promServer'" :target-tab.sync="bottomBox.targetTab" :detail="bottomBox.promDetail"
|
|
|
|
|
|
@closeSubList="bottomBox.showSubList = false" @fullScreen="fullScreen" @exitFullScreen="exitFullScreen" @listResize="listResize" ></bottom-box>
|
|
|
|
|
|
</transition>
|
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>
|
|
|
|
|
|
</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-10-29 19:11:46 +08:00
|
|
|
|
import deleteButton from "../../common/deleteButton";
|
2020-02-03 21:30:07 +08:00
|
|
|
|
export default {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
name: "promServer",
|
|
|
|
|
|
components: {
|
2020-10-29 19:11:46 +08:00
|
|
|
|
'prom-server-box': promServerBox,
|
|
|
|
|
|
'delete-button':deleteButton,
|
2020-07-15 20:43:19 +08:00
|
|
|
|
},
|
2020-02-03 21:30:07 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
//侧滑
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
/*二级页面相关*/
|
|
|
|
|
|
bottomBox: {
|
|
|
|
|
|
promDetail: {},
|
|
|
|
|
|
promServer: {},
|
|
|
|
|
|
mainResizeShow: true, //dom高度改变时是否展示|隐藏
|
|
|
|
|
|
subResizeShow: true,
|
|
|
|
|
|
isFullScreen: false, //全屏状态
|
|
|
|
|
|
showSubList: false, //是否显示二级列表
|
|
|
|
|
|
targetTab: '', //显示二级列表中的哪个页签
|
|
|
|
|
|
inTransform: false, //搜索框相关,搜索条件下拉框是否在transform里
|
|
|
|
|
|
},
|
2020-03-27 18:44:59 +08:00
|
|
|
|
mainTableHeight: this.$tableHeight.normal, //主列表table高度
|
2020-07-24 19:22:52 +08:00
|
|
|
|
/*工具参数*/
|
|
|
|
|
|
tools: {
|
|
|
|
|
|
loading: false, //是否显示table加载动画
|
|
|
|
|
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
|
|
|
|
|
tableHover: false, //控制滚动条和top按钮同时出现
|
|
|
|
|
|
showTopBtn: false, //显示To top按钮
|
2020-08-04 21:53:06 +08:00
|
|
|
|
showCustomTableTitle: false, //自定义列弹框是否显示
|
|
|
|
|
|
customTableTitle: [], //自定义列工具的数据
|
2020-07-24 19:22:52 +08:00
|
|
|
|
},
|
2020-10-29 19:11:46 +08:00
|
|
|
|
batchDeleteObjs:[],
|
2020-03-13 12:20:02 +08:00
|
|
|
|
tableId: 'promTable', //需要分页的table的id,用于记录每页数量
|
2020-07-24 19:22:52 +08:00
|
|
|
|
promServer: {},
|
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
|
|
|
|
|
|
}, {
|
2020-10-23 10:52:02 +08:00
|
|
|
|
label: 'Data Center',
|
2020-02-03 21:30:07 +08:00
|
|
|
|
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
|
|
|
|
}, {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
label: this.$t('asset.state'),
|
2020-02-06 18:50:40 +08:00
|
|
|
|
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
|
|
|
|
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: {}, //搜索参数
|
2020-09-01 15:36:21 +08:00
|
|
|
|
promServerType:null,
|
2020-02-03 21:30:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
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-24 19:22:52 +08:00
|
|
|
|
for (let i = 0; i < this.$CONSTANTS.promServer.typeData.length; i++) {
|
2020-07-31 20:57:04 +08:00
|
|
|
|
if (obj.value == this.$CONSTANTS.promServer.typeData[i].type) {
|
|
|
|
|
|
type = this.$CONSTANTS.promServer.typeData[i].label;
|
2020-03-27 18:44:59 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
detail.push({label: this.$t('config.promServer.type'), value: type});
|
2020-03-28 20:44:29 +08:00
|
|
|
|
detail.push({
|
2020-07-24 19:22:52 +08:00
|
|
|
|
label: this.$t('asset.state'),
|
2020-03-28 20:44:29 +08:00
|
|
|
|
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-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) {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.bottomBox.promServer = JSON.parse(JSON.stringify(u));
|
|
|
|
|
|
this.bottomBox.targetTab = "detail";
|
|
|
|
|
|
this.bottomBox.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-11-17 09:05:43 +08:00
|
|
|
|
if(this.$refs.promTable&&this.$refs.promTable.bodyWrapper){
|
|
|
|
|
|
this.$refs.promTable.bodyWrapper.scrollTop = 0;
|
|
|
|
|
|
}
|
2020-02-03 21:30:07 +08:00
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
//获取dc数据
|
|
|
|
|
|
getDcData() {
|
|
|
|
|
|
return new Promise(resolve => {
|
2020-11-19 15:06:31 +08:00
|
|
|
|
this.$get('idc', {pageSize: -1}).then(response => {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
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
|
|
|
|
// 数据排序
|
|
|
|
|
|
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();
|
|
|
|
|
|
},
|
2020-09-01 15:36:21 +08:00
|
|
|
|
findServerType(type){
|
|
|
|
|
|
if(!this.promServerType){
|
|
|
|
|
|
this.promServerType=[];
|
|
|
|
|
|
this.$CONSTANTS.promServer.theData.forEach(item=>{
|
|
|
|
|
|
this.promServerType=this.promServerType.concat(item.children)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
return this.promServerType.find(item=>{
|
|
|
|
|
|
return item.value == type
|
|
|
|
|
|
})
|
2020-11-20 15:02:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
plpsscrolly(el,self){
|
|
|
|
|
|
if (el._ps_.scrollbarYTop > 50) {
|
|
|
|
|
|
self.tools.showTopBtn = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.tools.showTopBtn = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
plmouseenter(el,self){
|
|
|
|
|
|
self.tools.tableHover = true;
|
|
|
|
|
|
},
|
|
|
|
|
|
plmouseleave(el,self){
|
|
|
|
|
|
self.tools.tableHover = false;
|
2020-09-01 15:36:21 +08:00
|
|
|
|
}
|
2019-12-25 17:15:09 +08:00
|
|
|
|
},
|
2020-11-21 12:21:27 +08:00
|
|
|
|
created(){
|
|
|
|
|
|
//是否存在分页缓存
|
|
|
|
|
|
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
|
|
|
|
|
if (pageSize != 'undefined' && pageSize != null) {
|
|
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-08-04 21:53:06 +08:00
|
|
|
|
mounted() {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
//初始化数据
|
|
|
|
|
|
Promise.all([this.getDcData()]).then(response => {
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
});
|
2020-08-04 21:53:06 +08:00
|
|
|
|
//初始化表头
|
|
|
|
|
|
this.tools.customTableTitle = 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-10-30 15:54:47 +08:00
|
|
|
|
this.tableTitleReset(this.tableTitle,this.tools.customTableTitle);
|
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_) {
|
2020-11-20 15:02:36 +08:00
|
|
|
|
el.addEventListener("ps-scroll-y", this.plpsscrolly.bind('',el,this));
|
|
|
|
|
|
el.addEventListener("mouseenter", this.plmouseenter.bind('',el,this));
|
|
|
|
|
|
el.addEventListener("mouseleave", this.plmouseleave.bind('',el,this));
|
2020-03-05 21:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
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-07-24 19:22:52 +08:00
|
|
|
|
'bottomBox.promServer': {
|
2020-03-27 18:44:59 +08:00
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n) {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.bottomBox.promDetail = this.convertToDetail(n);
|
2020-03-27 18:44:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
'bottomBox.showSubList': function(n) {
|
2020-07-17 19:39:48 +08:00
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.showSubListWatch(vm, n);
|
2020-11-16 15:16:39 +08:00
|
|
|
|
},
|
2020-11-20 15:02:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy(){
|
|
|
|
|
|
let el = this.$refs.promTable.$el.querySelector(".el-table__body-wrapper");
|
|
|
|
|
|
if (el._ps_) {
|
|
|
|
|
|
el.removeEventListener("ps-scroll-y", this.plpsscrolly.bind('',el,this));
|
|
|
|
|
|
el.removeEventListener("mouseenter", this.plmouseenter.bind('',el,this));
|
|
|
|
|
|
el.removeEventListener("mouseleave", this.plmouseleave.bind('',el,this));
|
2020-11-20 16:55:21 +08:00
|
|
|
|
el._ps_.destroy();
|
2020-11-20 15:02:36 +08:00
|
|
|
|
}
|
2019-12-10 17:00:28 +08:00
|
|
|
|
}
|
2019-12-05 18:07:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|