Commit 0414865f by ym

table

1 parent 1056858b
<!-- 表格+分页 v-show="tableShow"-->
<template> <template>
<div class="glsx-table" :class="{'hasTableContent':showClass}"> <div class="glsx-table" :class="{'hasTableContent':showClass}">
<el-table id="initTable" :ref="tableParams.mutiSelectName + 'MutiTable' || 'MutiTable'" :data="getListApi ? data : tableData" :row-key="tableParams.mutiSelectUniqueKey || ''" v-loading="loading" :border="border" :height="height" :highlight-current-row="true" :stripe="true" @sort-change="sortChange" @selection-change="handleSelect" :size="size" :header-cell-style="headerStyle"> <el-table id="initTable" :ref="tableParams.mutiSelectName + 'MutiTable' || 'MutiTable'" :data="getListApi ? data : tableData" :row-key="tableParams.mutiSelectUniqueKey || ''" v-loading="loading" :border="border" :highlight-current-row="true" :stripe="true" @sort-change="sortChange" @selection-change="handleSelect" :size="size" :header-cell-style="headerStyle">
<el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName" type="selection" width="55" :selectable="checkSelectable" :reserve-selection="true"></el-table-column> <el-table-column v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName" type="selection" width="55" :selectable="checkSelectable" :reserve-selection="true"></el-table-column>
<el-table-column v-if="hasNum" align="center" width="60px" label="序号" type="index" :index="index => index + (page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1"></el-table-column> <el-table-column v-if="hasNum" align="center" width="60px" label="序号" type="index" :index="index => index + (page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1"></el-table-column>
<el-table-column v-for="(item, index) in tableColumns" :key="index" :label="item.label" :prop="item.prop" :width="item.width" :min-width="item.minWidth" :align="item.align || 'center'" :sortable="item.sortable"> <el-table-column v-for="(item, index) in tableColumns" :key="index" :label="item.label" :prop="item.prop" :width="item.width" :min-width="item.minWidth" :align="item.align || 'center'" :sortable="item.sortable">
...@@ -37,21 +36,14 @@ ...@@ -37,21 +36,14 @@
</template> </template>
<script> <script>
import { Table, TableColumn, Pagination } from 'element-ui'
export default { export default {
name: 'glsx-table', name: 'GLTable',
data() {
return { components: {
loading: false, [Table.name]: Table,
data: [], [TableColumn.name]: TableColumn,
// 页码 [Pagination.name]: Pagination
page: {},
total: 10,
// 多选数组
mutiSelectArr: {},
tableColumns: [],
showClass:false
}
}, },
props: { props: {
...@@ -184,6 +176,21 @@ export default { ...@@ -184,6 +176,21 @@ export default {
} }
}, },
data() {
return {
loading: false,
data: [],
// 页码
page: {},
total: 10,
// 多选数组
mutiSelectArr: {},
tableColumns: [],
showClass:false
}
},
watch: { watch: {
customHeadShowList(val) { customHeadShowList(val) {
this.isCustomHead && this.findShowHeadCol() this.isCustomHead && this.findShowHeadCol()
...@@ -197,33 +204,6 @@ export default { ...@@ -197,33 +204,6 @@ export default {
} }
}, },
mounted() {
this.isCustomHead ? this.findShowHeadCol() : (this.tableColumns = this.tableParams.tableColumns)
this.page = {}
this.page[this.pageConf.pageSize] = 10
this.page[this.pageConf.pageNum] = 1
this.getListApi && this.refreshTable()
this.$nextTick(() => {
var _this=this
setTimeout(() => {
// 使用getListApi获取和返回数组为空时算高度 !(_this.getListApi && _this.data.length==0)
if(_this.getListApi ){
let offsettop = document.getElementById('initTable').offsetTop
console.log('表格距离顶部', offsettop)
let clientHeight = document.body.clientHeight
console.log(clientHeight)
// _this.height=(clientHeight - offsettop - 101)+''
document.getElementById('initTable').style.height= (clientHeight - offsettop - 231)+'px';
}
}, 200)
})
},
methods: { methods: {
findShowHeadCol() { findShowHeadCol() {
this.tableColumns = [] this.tableColumns = []
...@@ -257,6 +237,25 @@ export default { ...@@ -257,6 +237,25 @@ export default {
this.mutiSelectArr[this.tableParams.mutiSelectName] = [] this.mutiSelectArr[this.tableParams.mutiSelectName] = []
this.$refs[this.tableParams.mutiSelectName + 'MutiTable'].clearSelection() this.$refs[this.tableParams.mutiSelectName + 'MutiTable'].clearSelection()
}, },
//设置表格高度
setTableHeightFun(){
let offsettop = document.getElementById('initTable').offsetTop
console.log('表格距离顶部', offsettop)
let clientHeight = document.body.clientHeight
console.log('页面整体高度',clientHeight)
console.log(document.getElementsByClassName('scrm-base-nav').length)
if(document.getElementsByClassName('scrm-base-nav').length && document.getElementsByClassName('scrm-base-nav').length){
var baseNavHeight=document.getElementsByClassName('scrm-base-nav')[0].clientHeight;
var subNavHeight=document.getElementsByClassName('scrm-base-sub-nav')[0].clientHeight
document.getElementById('initTable').style.height= (clientHeight - offsettop - 121-baseNavHeight-subNavHeight)+'px';
}else{
document.getElementById('initTable').style.height= (clientHeight - offsettop - 121)+'px';
}
},
refreshTable(isResetPageNum = true, isClearMuti = true) { refreshTable(isResetPageNum = true, isClearMuti = true) {
this.beforeSearchFn().then(res => { this.beforeSearchFn().then(res => {
...@@ -304,9 +303,31 @@ export default { ...@@ -304,9 +303,31 @@ export default {
this.page[this.pageConf.pageNum] = value this.page[this.pageConf.pageNum] = value
this.getListApi ? this.refreshTable(false, false) : this.$emit('refreshTable', this.page) this.getListApi ? this.refreshTable(false, false) : this.$emit('refreshTable', this.page)
} }
},
mounted() {
this.isCustomHead ? this.findShowHeadCol() : (this.tableColumns = this.tableParams.tableColumns)
this.page = {}
this.page[this.pageConf.pageSize] = 10
this.page[this.pageConf.pageNum] = 1
this.getListApi && this.refreshTable()
// this.$nextTick(() => {
// var _this=this
// setTimeout(() => {
// // 使用getListApi获取和返回数组为空时算高度 !(_this.getListApi && _this.data.length==0)
// if(_this.getListApi ){
// }
// }, 200)
// })
} }
} };
</script> </script>
<style> <style>
.a-click { .a-click {
cursor: pointer; cursor: pointer;
...@@ -331,7 +352,7 @@ export default { ...@@ -331,7 +352,7 @@ export default {
} }
.glsx-table .emptyBg { .glsx-table .emptyBg {
display: inline-block; display: inline-block;
margin-top: 150px; /* margin-top: 150px; */
height: 100%; height: 100%;
} }
.glsx-table .emptyBg div { .glsx-table .emptyBg div {
...@@ -344,4 +365,4 @@ export default { ...@@ -344,4 +365,4 @@ export default {
/* .hasTableContent .el-table__body-wrapper{ /* .hasTableContent .el-table__body-wrapper{
height: 100%; height: 100%;
} */ } */
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -329,6 +329,12 @@ $dackColor: #4f48e6; ...@@ -329,6 +329,12 @@ $dackColor: #4f48e6;
color: $defaultColor; color: $defaultColor;
} }
.el-pagination {
display: flex;
margin-top: 10px;
align-items: center;
}
.el-pagination button:hover { .el-pagination button:hover {
color: $defaultColor; color: $defaultColor;
} }
...@@ -341,6 +347,14 @@ $dackColor: #4f48e6; ...@@ -341,6 +347,14 @@ $dackColor: #4f48e6;
border-color: $defaultColor; border-color: $defaultColor;
} }
.el-pagination__jump {
margin-left: 5px;
}
.el-pagination .el-select .el-input {
margin-left: 10px;
}
.el-form-item__label { .el-form-item__label {
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!