feat: 表格区域独立滚动,表头固定

- 修改 common.less:
  - 新增 .page-wrapper 类,使用 flex 纵向布局占满父容器
  - 修改 .table-container 为 flex 布局,让表格自适应高度
  - .el-table 使用 flex:1 实现内容区域滚动、表头固定

- 7个列表页面添加 page-wrapper 类:
  - SystemUser.vue, SystemRole.vue
  - Hitokoto.vue, PhotoWall.vue, Music.vue, SourceImage.vue
  - Article.vue(特殊处理:左右分栏布局适配)

现在设置 100 条数据时,表格内容独立滚动,分页始终可见,不会触发整页滚动。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
灌糖包子 2026-03-20 22:16:49 +08:00
parent 5b9dc0ccb9
commit 1e7748db64
Signed by: sookie
GPG Key ID: 0599BECB75C1E68D
8 changed files with 29 additions and 16 deletions

View File

@ -91,9 +91,21 @@ html, body, #app, .layout {
}
}
/* ===== 页面布局(用于带分页的表格页面)===== */
.page-wrapper {
display: flex;
flex-direction: column;
height: 100%;
}
/* ===== 表格美化 ===== */
.table-container {
position: relative;
flex: 1;
overflow: hidden;
margin-bottom: 12px;
display: flex;
flex-direction: column;
.el-table {
// CSS 变量覆盖:表头背景/文字色、行悬停色、边框色、正文色
@ -103,7 +115,8 @@ html, body, #app, .layout {
--el-table-border-color: var(--el-border-color-lighter);
--el-table-text-color: var(--el-text-color-primary);
// 圆角/外边框/溢出裁剪无对应 CSS 变量,保留直接样式
// 固定高度让表头固定tbody滚动
flex: 1;
border-radius: var(--el-border-radius-base);
overflow: hidden;
border: 1px solid var(--el-border-color-lighter);

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<el-form inline :model="search">
<el-form-item label="内容">
<el-input v-model="search.content" />

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<el-form inline :model="search">
<el-form-item label="名称">
<el-input v-model="search.name" />

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<el-alert type="info" show-icon :closable="false" style="margin-bottom: 10px" >
<template #title>上传要求</template>
图片格式为{{allowUploadExt.join('、')}}文件大小不超过10MB

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<el-alert type="info" show-icon :closable="false" >
<template #title>上传要求</template>
图片格式为{{allowUploadExt.join('、')}}文件大小不超过10MB

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<div class="search-panel">
<el-form inline :model="search">
<el-form-item label="标题">
@ -52,13 +52,13 @@
<el-button @click="reset" icon="RefreshLeft">重置</el-button>
</div>
</div>
<el-row>
<el-col :span="4" style="height: 520px;overflow: auto;">
<el-row style="flex: 1; overflow: hidden;">
<el-col :span="4" style="height: 100%; overflow: auto;">
<el-tree :props="treeProps" :load="loadTreeData" lazy highlight-current @node-click="articlePreview" />
</el-col>
<el-col :span="20">
<div class="table-container">
<el-table :data="articleData" v-loading="loading" stripe @selection-change="dataSelect">
<el-col :span="20" style="height: 100%; display: flex; flex-direction: column;">
<div class="table-container" style="margin-bottom: 0;">
<el-table :data="articleData" v-loading="loading" stripe @selection-change="dataSelect" height="100%">
<el-table-column type="selection" width="55" />
<el-table-column prop="title" label="标题" />
<el-table-column prop="path" label="路径" >
@ -91,7 +91,7 @@
</template>
</el-table-column>
</el-table>
<div class="page-container">
<div class="page-container" style="margin-top: 12px; padding: 0;">
<el-pagination background
:page-sizes="store.state.pageSizeOpts"
:layout="store.state.pageLayout"

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<el-form inline :model="search" @submit.prevent>
<el-form-item label="角色名称/描述">
<el-input v-model="search.name" />

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="page-wrapper">
<el-form inline :model="search" @submit.prevent>
<el-form-item label="用户名/昵称">
<el-input v-model="search.username" />