表格高度最大化自适应
由于担心引起代码冲突,就暂时只写了用户页面。如有需要,其他页面以及代码模板可以根据其进行修改。
This commit is contained in:
parent
5477ce3c39
commit
3c529b79ae
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container" :style="containerStyle">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<!--部门数据-->
|
<!--部门数据-->
|
||||||
<el-col :span="4" :xs="24">
|
<el-col :span="4" :xs="24">
|
||||||
@ -139,7 +139,7 @@
|
|||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="userList" :height="tableHeight" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="50" align="center" />
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
|
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
|
||||||
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
|
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
|
||||||
@ -392,6 +392,13 @@ export default {
|
|||||||
roleOptions: [],
|
roleOptions: [],
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
|
// 表格高度
|
||||||
|
tableHeight: 0,
|
||||||
|
// 页面样式
|
||||||
|
containerStyle: {
|
||||||
|
height: null,
|
||||||
|
'overflow-y': 'hidden'
|
||||||
|
},
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
children: "children",
|
children: "children",
|
||||||
label: "label"
|
label: "label"
|
||||||
@ -467,6 +474,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.loadTableHeight();
|
||||||
this.getList();
|
this.getList();
|
||||||
this.getTreeselect();
|
this.getTreeselect();
|
||||||
this.getConfigKey("sys.user.initPassword").then(response => {
|
this.getConfigKey("sys.user.initPassword").then(response => {
|
||||||
@ -474,6 +482,20 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/** 加载表格高度 */
|
||||||
|
loadTableHeight() {
|
||||||
|
const self = this
|
||||||
|
const windowHeight = window.document.documentElement.clientHeight
|
||||||
|
self.containerStyle.height = windowHeight - 85 + 'px' // 设置页面高度
|
||||||
|
// self.cardBodyStyle.height = windowHeight - 130 + 'px' // 卡片body高度
|
||||||
|
self.tableHeight = windowHeight - 330 // 设置表格高度
|
||||||
|
window.onresize = function () {
|
||||||
|
const wHeight = window.document.documentElement.clientHeight
|
||||||
|
self.containerStyle.height = wHeight - 85 + 'px' // 设置页面高度
|
||||||
|
// self.cardBodyStyle.height = wHeight - 130 + 'px' // 卡片高度
|
||||||
|
self.tableHeight = wHeight - 330 // 设置表格高度
|
||||||
|
}
|
||||||
|
},
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user