This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/bottomBox/nzBottomDataList.vue

157 lines
4.2 KiB
Vue
Raw Normal View History

2021-04-14 18:35:42 +08:00
<template>
2021-08-29 21:35:04 +08:00
<div class="bottom-data-list">
2021-04-14 18:35:42 +08:00
<div class="top-tools top-tools--sub">
<div class="top-tool-left">
<div class="sub-list-title" v-if="showTitle">{{bottomHeaderTitle}}<slot name="title"></slot></div>
2021-04-14 18:35:42 +08:00
<div class="sub-list-tabs">
<div v-for="tab in tabs" :key="tab.prop" :class="{'sub-list-tab--active': tab.active || tab.prop == targetTab }" :title='tab.name' class="sub-list-tab" @click="changeTab(tab.prop)">{{tab.name}}</div>
2021-04-14 18:35:42 +08:00
</div>
</div>
2021-04-20 19:27:49 +08:00
<div class="top-tool-right" v-if="!customTool">
2021-04-14 18:35:42 +08:00
<div v-if="layout.indexOf('searchInput') > -1" class="top-tool-search margin-r-20">
<search-input v-if="searchInputShow" :searchMsg="searchMsg" :position="'bottom' + targetTab + obj.id" @search="search" :targetTab="targetTab"></search-input>
2021-04-14 18:35:42 +08:00
</div>
<slot name="top-tool-right"></slot>
<button v-if="layout.indexOf('elementSet') > -1" id="account-column-setting" class="top-tool-btn margin-r-20"
type="button" @click="tools.showCustomTableTitle = true" :title="$t('overall.selectColumns')">
2021-04-14 18:35:42 +08:00
<i class="nz-icon-gear nz-icon"></i>
</button>
</div>
<div v-else class="top-tool-right">
2021-04-20 19:27:49 +08:00
<slot name="top-tool-right"></slot>
</div>
2021-04-14 18:35:42 +08:00
</div>
<!-- 自定义table列 -->
<transition name="el-zoom-in-top">
2021-04-14 18:35:42 +08:00
<element-set
v-if="tools.showCustomTableTitle && layout.indexOf('elementSet') > -1"
2021-04-14 18:35:42 +08:00
ref="customTableTitle"
:custom-table-title="customTableTitle"
:original-table-title="tableTitle"
:tableId="tableId"
@close="tools.showCustomTableTitle = false"
@update="updateCustomTableTitle"
2021-09-26 14:50:22 +08:00
:table-class="true"
2021-04-14 18:35:42 +08:00
></element-set>
</transition>
<div class="sub-container">
2021-08-05 22:25:55 +08:00
<div :class="subContentClass">
2021-04-14 18:35:42 +08:00
<slot></slot>
</div>
2021-04-27 19:24:26 +08:00
<div class="pagination-bottom" v-if="showPagination">
2021-04-14 18:35:42 +08:00
<slot name="pagination"></slot>
</div>
</div>
</div>
</template>
<script>
import { fromRoute } from '@/components/common/js/constants'
2021-04-14 18:35:42 +08:00
export default {
name: 'nzBottomDataList',
props: {
from: {
type: String,
default: ''
},
tableTitle: {
type: Array
},
customTableTitle: {
type: Array
},
layout: {
type: Array,
default () { return [] }
},
searchMsg: {
type: Object
},
tableId: {
type: String,
default: ''
},
obj: { },
2021-04-14 18:35:42 +08:00
tabs: {
type: Array
2021-04-20 15:31:57 +08:00
},
2021-04-20 19:27:49 +08:00
targetTab: String,
customTool: {
type: Boolean,
default: false
2021-04-27 19:24:26 +08:00
},
showPagination: {
type: Boolean,
default: true
},
showTitle: {
type: Boolean,
default: true
},
title: {
type: String
}
},
computed: {
bottomHeaderTitle () {
return this.title || this.$t('overall.name')
2021-08-05 22:25:55 +08:00
},
subContentClass () {
const className = []
switch (this.targetTab) {
2022-05-26 10:25:32 +08:00
case 'panelTab':
className.push('nz-table-list bottom-panel')
2021-08-05 22:25:55 +08:00
break
case 'log': {
className.push('bottom-log')
break
}
default: {
className.push('nz-table-list')
2021-08-05 22:25:55 +08:00
break
}
}
this.from === fromRoute.chartTemp && className.push('chart-temp')
return className.join(' ')
2021-04-20 19:27:49 +08:00
}
2021-04-14 18:35:42 +08:00
},
data () {
return {
fromRoute: fromRoute,
searchInputShow: true,
2021-04-14 18:35:42 +08:00
tools: {
toTopBtnTop: this.$tableHeight.toTopBtnTop, // to-top按钮的top属性
tableHover: false, // 控制滚动条和top按钮同时出现
showCustomTableTitle: false // 自定义列弹框是否显示
}
}
},
watch: {
obj (n) {
this.searchInputShow = false
setTimeout(() => {
this.searchInputShow = true
}, 100)
},
targetTab (n) {
this.searchInputShow = false
setTimeout(() => {
this.searchInputShow = true
}, 100)
}
},
2021-04-14 18:35:42 +08:00
methods: {
updateCustomTableTitle (custom) {
this.$emit('update:customTableTitle', custom)
},
search (searchObj) {
this.$emit('search', searchObj)
},
// 切换tab
changeTab (tab) {
this.$emit('changeTab', tab)
}
}
}
</script>