优化表格滚动设置,调整样式以提升用户体验

This commit is contained in:
zhangtao
2025-01-08 21:50:12 +08:00
parent d72cc6ddfb
commit 0b4d68b3cc
17 changed files with 62 additions and 43 deletions
+9 -3
View File
@@ -37,9 +37,15 @@
</a-space>
</template>
<a-table :rowKey="record => record.id" :columns="columns" :data-source="dataSource"
:loading="tableLoading" :scroll="{ x: 500, y: 'calc(100vh - 500px)' }" :row-selection="rowSelection"
:pagination="false" :style="{ minHeight: '500px' }">
<!-- 树形表格 -->
<a-table :rowKey="record => record.id"
:columns="columns"
:data-source="dataSource"
:loading="tableLoading"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }"
:row-selection="rowSelection"
:pagination="false"
:style="{ minHeight: '500px' }">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
@@ -38,7 +38,8 @@
<a-card title="用户列表" :bordered="true" :headStyle="{ borderBottom: 'none', padding: '20px 24px' }"
:bodyStyle="{ padding: '0 24px' }">
<a-table :rowKey="record => record.id" :columns="columns" :data-source="dataSource" :loading="tableLoading"
:row-selection="rowSelection" @change="handleTableChange" :scroll="{ x: 500, y: 'calc(100vh - 500px)' }"
:row-selection="rowSelection" @change="handleTableChange"
:scroll="{ x: 500 }"
:pagination="pagination">
<template v-slot:bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
@@ -60,7 +61,7 @@
import { ref, reactive, computed, unref } from 'vue';
import type { TableColumnsType } from 'ant-design-vue';
import { getUserList } from '@/api/system/user'
import type { searchCreatorDataType, creatorTableDataType } from './types'
import type { searchCreatorDataType, creatorType } from './types'
const openModal = ref<boolean>(false);
@@ -97,7 +98,7 @@ const columns: TableColumnsType = [
width: 500
}
]
const dataSource = ref<creatorTableDataType[]>([]);
const dataSource = ref<creatorType[]>([]);
const loadingData = () => {
tableLoading.value = true;
@@ -154,10 +155,10 @@ const handleTableChange = (values: any) => {
loadingData();
}
const selectedRowKeys = ref<creatorTableDataType['id'][]>([]);
const selectedRowName = ref<creatorTableDataType['name']>('');
const selectedRowKeys = ref<creatorType['id'][]>([]);
const selectedRowName = ref<creatorType['name']>('');
const onSelectChange = (selectingRowKeys: creatorTableDataType['id'][], selectingRows: creatorTableDataType[]) => {
const onSelectChange = (selectingRowKeys: creatorType['id'][], selectingRows: creatorType[]) => {
selectedRowKeys.value = selectingRowKeys;
selectedRowName.value = selectingRows[0].name;
}
+1 -1
View File
@@ -55,7 +55,7 @@
:data-source="dataSource"
:loading="tableLoading"
@change="handleTableChange"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }"
:scroll="{ x: 500 }"
:pagination="pagination"
:style="{ minHeight: '500px' }">
<template #bodyCell="{ column, record, index }">
+3 -2
View File
@@ -57,12 +57,13 @@
</a-button>
</a-dropdown>
</template>
<a-table :rowKey="record => record.id"
<a-table
:rowKey="record => record.id"
:columns="columns"
:data-source="dataSource"
:row-selection="rowSelection"
:loading="tableLoading"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }"
:row-selection="rowSelection"
:pagination="false"
:style="{ minHeight: '500px' }"
>
+8 -3
View File
@@ -60,9 +60,14 @@
</a-dropdown>
</template>
<a-table :rowKey="record => record.id" :columns="columns" :data-source="dataSource"
:row-selection="rowSelection" :loading="tableLoading" @change="handleTableChange"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }" :pagination="pagination"
<a-table :rowKey="record => record.id"
:columns="columns"
:data-source="dataSource"
:row-selection="rowSelection"
:loading="tableLoading"
@change="handleTableChange"
:scroll="{ x: 500 }"
:pagination="pagination"
:style="{ minHeight: '500px' }">
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
+1 -1
View File
@@ -71,7 +71,7 @@
:row-selection="rowSelection"
:loading="tableLoading"
@change="handleTableChange"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }"
:scroll="{ x: 500 }"
:pagination="pagination"
:style="{ minHeight: '500px' }">
<template #bodyCell="{ column, record, index }">
@@ -60,7 +60,7 @@
:data-source="menuTreeData"
:row-selection="menuRowSelection"
:loading="tableLoading"
:scroll="{ x: 500, y: 'calc(100vh - 270px)' }"
:scroll="{ x: 500 }"
:pagination="false"
:style="{ minHeight: '700px' }"
:expandAll="true">
+1 -1
View File
@@ -69,7 +69,7 @@
:row-selection="rowSelection"
:loading="tableLoading"
@change="handleTableChange"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }"
:scroll="{ x: 500 }"
:pagination="pagination"
:style="{ minHeight: '500px' }">
<template #bodyCell="{ column, record, index }">
@@ -34,8 +34,14 @@
</div>
<div>
<a-table :rowKey="record => record.id" :columns="columns" :data-source="dataSource" :row-selection="rowSelection"
:loading="tableLoading" @change="handleTableChange" :scroll="{ x: 500, y: 330 }" :pagination="pagination"
<a-table :rowKey="record => record.id"
:columns="columns"
:data-source="dataSource"
:row-selection="rowSelection"
:loading="tableLoading"
@change="handleTableChange"
:scroll="{ x: 500 }"
:pagination="pagination"
:style="{ minHeight: '330px' }">
<template v-slot:bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
+9 -3
View File
@@ -67,9 +67,15 @@
</a-button>
</a-dropdown>
</template>
<a-table :rowKey="record => record.id" :columns="columns" :data-source="dataSource"
:row-selection="rowSelection" :loading="tableLoading" @change="handleTableChange"
:scroll="{ x: 500, y: 'calc(100vh - 500px)' }" :pagination="pagination" :style="{ minHeight: '500px' }">
<a-table :rowKey="record => record.id"
:columns="columns"
:data-source="dataSource"
:row-selection="rowSelection"
:loading="tableLoading"
@change="handleTableChange"
:scroll="{ x: 500 }"
:pagination="pagination"
:style="{ minHeight: '500px' }">
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
<span>{{ (pagination.current - 1) * pagination.pageSize + index + 1 }}</span>