调整table滚动兼顾使用滚动条

This commit is contained in:
2024-08-05 00:41:42 +08:00
parent 03079e442a
commit 5519ae42ea
4 changed files with 431 additions and 59 deletions

View File

@@ -1,124 +1,195 @@
#app {
font-weight: normal;
font-weight: normal;
}
a, .green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
.AppSelect .el-input__inner {
background: linear-gradient(180deg, rgba(12, 53, 111, 0) 0%, #0C356F 100%);
border: 1px solid #1760AE;
border-radius: 0;
color: #fff;
background: linear-gradient(180deg, rgba(12, 53, 111, 0) 0%, #0C356F 100%);
border: 1px solid #1760AE;
border-radius: 0;
color: #fff;
}
.el-table:before, .el-table:after {
background: transparent;
background: transparent;
}
.el-table .gutter {
background-color: transparent !important;
border-color: transparent !important;
background-color: transparent !important;
border-color: transparent !important;
}
.flex {
display: flex;
display: flex;
}
.fill {
flex: 1;
min-height: 0;
min-width: 0;
flex: 1;
min-height: 0;
min-width: 0;
}
.pointer {
cursor: pointer;
cursor: pointer;
}
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
display: grid;
grid-template-columns: repeat(4, 1fr);
}
.mb-8 {
margin-bottom: 8px;
margin-bottom: 8px;
}
.mr-8 {
margin-right: 8px;
margin-right: 8px;
}
.dv-scroll-board {
overflow: hidden;
overflow: hidden;
}
.dv-scroll-board .header {
align-items: center;
padding: 6px 0;
align-items: center;
padding: 6px 0;
}
.dv-scroll-board .header-item, .tableHead .item {
height: initial !important;
line-height: 17px !important;
font-weight: bold;
height: initial !important;
line-height: 17px !important;
font-weight: bold;
}
.dv-scroll-board .ceil {
padding: 6px 10px !important;
padding: 6px 10px !important;
}
.dv-scroll-board .row-item {
overflow: hidden;
overflow: hidden;
}
.dv-scroll-board .ceil, .dv-scroll-board .header-item {
text-wrap: unset !important;
word-break: break-all;
font-size: 12px;
line-height: 17px
text-wrap: unset !important;
word-break: break-all;
font-size: 12px;
line-height: 17px
}
.summary {
height: 30px;
align-items: center;
color: #66FFFF;
background-image: linear-gradient(90deg, rgba(1, 196, 236, 0.5) 0%, rgba(1, 196, 236, 0.01) 100%);
height: 30px;
align-items: center;
color: #66FFFF;
background-image: linear-gradient(90deg, rgba(1, 196, 236, 0.5) 0%, rgba(1, 196, 236, 0.01) 100%);
}
.tableHead {
height: 30px;
align-items: center;
background-color: rgba(13, 48, 99, 0.6);
height: 30px;
align-items: center;
background-color: rgba(13, 48, 99, 0.6);
}
.summary .item, .tableHead .item {
font-size: 12px;
font-weight: bold;
padding: 0 10px;
align-items: center;
box-sizing: border-box;
line-height: 17px;
flex-shrink: 0;
font-size: 12px;
font-weight: bold;
padding: 0 10px;
align-items: center;
box-sizing: border-box;
line-height: 17px;
flex-shrink: 0;
}
.dialogTable {
position: fixed !important;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 600px!important;
height: 300px;
z-index: 9999;
background-color: #07193D;
box-shadow: #66FFFF 0 0 20px;
position: fixed !important;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 600px !important;
height: 300px;
z-index: 9999;
background-color: #07193D;
box-shadow: #66FFFF 0 0 20px;
}
.scrollTable {
color: #fff;
box-sizing: border-box;
background: transparent !important;
border-color: transparent;
}
.scrollTable .tableHeader {
background: rgba(13, 48, 99, 0.6) !important;
color: #fff;
border-color: transparent !important;
}
.scrollTable tr {
background-color: transparent !important;
}
.scrollTable .el-table__footer-wrapper tr {
background: linear-gradient(90deg, rgba(1, 196, 236, 0.5) 0%, rgba(1, 196, 236, 0.01) 100%);
}
.scrollTable .el-table__footer-wrapper .is-leaf {
color: #66FFFF;
background: transparent;
border-color: transparent;
}
.scrollTable:before {
background: transparent !important;
}
.scrollTable .el-table__cell.gutter, .scrollTable [name=gutter] {
display: none;
}
.scrollTable .simplebar-scrollbar:before {
background: #ddd;
}
.scrollTable .el-table__body {
width: 100% !important;
}
.scrollTable .tableCell {
color: #fff;
border-color: transparent !important;
}
.scrollTable .el-table__cell {
padding: 3px 0 !important;
}
.scrollTable tr.el-table__row--striped {
--odd-bg: #09265B;
background-color: #081F48;
background-image: linear-gradient(
-45deg, var(--odd-bg) 0, var(--odd-bg) 10%, transparent 10%, transparent 50%,
var(--odd-bg) 50%, var(--odd-bg) 60%, transparent 60%, transparent);
background-size: 10px 10px;
}
.scrollTable tr.el-table__row--striped .tableCell {
background-color: transparent !important;
}
.scrollTable tr:hover > .tableCell {
background-color: rgba(255, 255, 255, .1) !important;
}

View File

@@ -12,8 +12,11 @@ const libs = [
`${KENGEE_CDN_BASE}/js/d3-array.min.js`,
`${KENGEE_CDN_BASE}/js/d3-geo.min.js`,
'/presource/datascreen/js/ezuikit-flv/ezuikit.js',
// '/presource/datascreen/js/ezuikit.js',
'/presource/datascreen/js/clappr.min.js',
'/presource/datascreen/js/simplebar/simplebar.min.js',
]
const css = [
"/presource/datascreen/js/simplebar/simplebar.css"
]
window.$loadScript = (type = 'js', url, dom = "body") => {
let flag = false;
@@ -131,6 +134,63 @@ Vue.component("HlsPlayer", {
this.player?.destroy()
}
})
Vue.component("scrollTable", {
props: {
tableData: {default: () => []},
columns: {default: () => []},
config: {default: () => ({})}
},
data() {
return {
timer: null,
scroll: null
}
},
render(h) {
const {config, tableData, columns} = this.$props
return h('el-table', {
props: {
headerCellClassName: 'tableHeader', cellClassName: 'tableCell', stripe: !0,
...config, data: tableData, height: '100%'
}, class: 'scrollTable'
},
columns.map(col => h("tableColumn", {props: {column: col}}))
)
},
methods: {
initScroll() {
const {SimpleBar} = window
const dom = this.$el.querySelector('.el-table__body-wrapper')
this.scroll = new SimpleBar(dom)
dom.addEventListener('mouseover', this.stopAutoScroll)
dom.addEventListener('mouseout', this.autoScroll)
// this.scroll.refresh();
},
autoScroll() {
if (this.timer) clearInterval(this.timer)
this.timer = setInterval(() => {
const dom = this.$el.querySelector('.simplebar-content-wrapper')
const max = dom.scrollHeight - dom.clientHeight
if (dom.scrollTop + 30 >= max) dom.scrollTop = 0
else dom.scrollTop += 30
}, 1000)
},
stopAutoScroll() {
if (this.timer) clearInterval(this.timer)
}
},
mounted() {
this.initScroll()
this.autoScroll()
},
beforeDestroy() {
this.stopAutoScroll()
this.scroll?.destroy()
const dom = this.$el.querySelector('.el-table__body-wrapper')
dom.removeEventListener("mouseover", this.stopAutoScroll)
dom.removeEventListener("mouseout", this.autoScroll)
}
})
Vue.component("tableColumn", {
props: {
column: {default: () => ({})}
@@ -153,4 +213,5 @@ Vue.component("tableColumn", {
export default Promise.all([
import("./fetch"),
...libs.map(url => $loadScript('js', url)),
...css.map(url => $loadScript('css', url))
])