Commit 4a225a0f by cwq0219

表格-滚动

1 parent 0c05d68c
td,
th {
padding: 0 !important;
background-color: rgba(42, 88, 173, .05);
}
table {
background-color: rgba(42, 88, 173, 0.2) !important;
}
tbody tr td:last-child,
tbody tr th:last-child {
padding-right: 10px !important;
}
.el-card__body {
padding: 5px;
}
......
......@@ -2,6 +2,10 @@
<template>
<div ref="tableCom">
<div class="table">
<!-- <el-scrollbar
:native="false"
class="table-scroll"
> -->
<el-table
:ref="tableParams.tableId + 'MutiTable' || 'mutiTable'"
v-loading="tableLoading"
......@@ -12,6 +16,7 @@
size="small"
:row-key="tableParams.uniqueKey || 'id'"
border
:max-height="tableMaxHeight"
v-if="tableParams.dropCol.length"
>
<el-table-column
......@@ -64,7 +69,7 @@
<el-button
v-show="item.showConf ? (scope.row[item.showConf.attr] == item.showConf.showVal) : true"
:type="item.type || 'primary'"
size="mini"
:size="btn_size"
plain
@click="item.handleClick(scope.row)"
>{{item.label}}</el-button>
......@@ -73,7 +78,7 @@
</el-table-column>
</transition>
</el-table>
<div>
<div class="sort-btns">
<el-tooltip
effect="dark"
content="重置表头顺序"
......@@ -90,16 +95,17 @@
<el-button
type="primary"
class="opt-btn"
size="mini"
:size="btn_size"
style="margin-left: 0;"
@click="handleOptShow"
>{{isShowOption ? '收起' : '展开'}}</el-button>
</div>
<!-- </el-scrollbar> -->
</div>
<div ref="page">
<el-pagination
v-if="hasPage"
small
:size="btn_size"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
......@@ -126,6 +132,7 @@ export default {
loading: false,
isShowOption: false,
isMove: false,
tableMaxHeight: 0,
timer: '',
data: [],
// 页码
......@@ -236,6 +243,9 @@ export default {
event.preventDefault()
event.stopPropagation()
}
this.row = 0
this.tableParams.isMuti && (++this.row)
this.hasNum && (++this.row)
this.handleGet()
const btn = document.getElementById(this.tableParams.btnId)
btn && btn.addEventListener('click', this.refreshEmit)
......@@ -249,8 +259,10 @@ export default {
// var parentHeight = document.querySelector('.table').parentElement.parentElement.clientHeight
var parentHeight = this.$refs.tableCom.parentElement.clientHeight
var pageHeight = this.hasPage ? this.$refs.page.clientHeight : 0
document.querySelector('.table').style.height = parentHeight - pageHeight - 50 + 'px'
this.loading = false
// console.log(parentHeight - pageHeight - 50 + 'px')
// document.querySelector('.table').style.height = parentHeight - pageHeight - 50 + 'px'
// this.loading = false
this.tableMaxHeight = parentHeight - pageHeight - 50
}, 400)
},
......@@ -304,8 +316,8 @@ export default {
if (this.hasNum && evt.newIndex === 0) {
this.handleGet()
} else {
var oldIndex = this.hasNum ? (evt.oldIndex - 1) : evt.oldIndex
var newIndex = this.hasNum ? (evt.newIndex - 1) : evt.newIndex
var oldIndex = this.row ? (evt.oldIndex - this.row) : evt.oldIndex
var newIndex = this.row ? (evt.newIndex - this.row) : evt.newIndex
const oldItem = this.tableParams.dropCol[oldIndex]
this.tableParams.dropCol.splice(oldIndex, 1)
this.tableParams.dropCol.splice(newIndex, 0, oldItem)
......@@ -394,11 +406,24 @@ export default {
</script>
<style>
.table {
display: flex;
/* display: flex; */
/* align-items: center; */
}
.el-table {
/* .el-table {
overflow-y: scroll;
} */
.el-scrollbar__wrap {
overflow-x: hidden;
}
.table-scroll {
height: 100%;
width: 100%;
/* display: flex; */
}
.sort-btns {
position: fixed;
top: 300px;
right: 36px;
}
.refresh-btn {
display: block;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!