优化L1、L4数据展示界面样式

This commit is contained in:
tao
2025-09-30 15:47:41 +08:00
parent 5d0d653b11
commit 4fd2c32cd7
2 changed files with 63 additions and 138 deletions

View File

@@ -9,7 +9,7 @@
<a-form layout="inline" :model="formData"> <a-form layout="inline" :model="formData">
<a-form-item label="日期范围"> <a-form-item label="日期范围">
<a-range-picker v-model:value="formData.dateRange" :placeholder="['开始日期', '结束日期']" <a-range-picker v-model:value="formData.dateRange" :placeholder="['开始日期', '结束日期']"
format="YYYY-MM-DD hh:mm:ss" class="date-range-picker" show-time /> format="YYYY-MM-DD hh:mm:ss" show-time />
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-space> <a-space>
@@ -237,111 +237,54 @@ onMounted(() => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@use "@/assets/styles/variables" as *; .l1-data-container {
padding: 20px;
.wrapper { background: #f5f5f5;
width: 100%; min-height: 100vh;
height: 100%;
overflow: hidden;
} }
.l1-data-container {
display: flex;
flex-direction: column;
height: 100vh;
padding: $spacing-lg;
.page-header { .page-header {
margin-bottom: $spacing-lg; margin-bottom: 20px;
flex-shrink: 0;
.page-title { .page-title {
font-size: $title-font-size; font-size: 24px;
color: $text-dark;
margin: 0;
font-weight: 600; font-weight: 600;
color: #1f2937;
margin: 0;
} }
} }
.filter-section { .filter-section {
background: $bg-light; background: white;
padding: $spacing-lg; padding: 20px;
border-radius: $border-radius-lg; border-radius: 8px;
margin-bottom: $spacing-lg; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
flex-shrink: 0; margin-bottom: 20px;
.filter-label {
font-weight: 500;
color: $text-dark;
font-size: $content-font-size;
}
} }
.table-section { .table-section {
overflow: hidden; background: white;
display: flex; padding: 20px;
flex-direction: column; border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
:deep(.ant-table-wrapper) {
height: 100%;
display: flex;
flex-direction: column;
.ant-spin-container,
.ant-table {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.ant-table-container {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.ant-table-body {
overflow-y: auto !important;
}
}
} }
.detail-content { .detail-content {
.ant-descriptions { max-height: 500px;
margin-top: $spacing-md; overflow-y: auto;
}
}
} }
:deep(.ant-btn-primary) { :deep(.ant-table-thead > tr > th) {
background: $primary-color; background: #f8fafc;
border-color: $primary-color; font-weight: 600;
&:hover {
background: $primary-light;
border-color: $primary-light;
}
} }
@media (max-width: 768px) { :deep(.ant-table-tbody > tr:hover > td) {
.l1-data-container { background: #f0f9ff;
padding: $spacing-md;
.filter-section {
.ant-row {
flex-direction: column;
gap: $spacing-md;
.ant-col {
width: 100% !important;
}
} }
.date-range-picker { :deep(.ant-descriptions-item-label) {
width: 100%; font-weight: 600;
} background: #f8fafc;
}
}
} }
</style> </style>

View File

@@ -8,13 +8,8 @@
<div class="filter-section"> <div class="filter-section">
<a-form layout="inline" :model="formData"> <a-form layout="inline" :model="formData">
<a-form-item label="日期范围"> <a-form-item label="日期范围">
<a-range-picker <a-range-picker v-model:value="formData.dateRange" :placeholder="['开始日期', '结束日期']"
v-model:value="formData.dateRange" format="YYYY-MM-DD hh:mm:ss" show-time />
:placeholder="['开始日期', '结束日期']"
format="YYYY-MM-DD hh:mm:ss"
class="date-range-picker"
show-time
/>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-space> <a-space>
@@ -37,17 +32,10 @@
<!-- 数据表格 --> <!-- 数据表格 -->
<div class="table-section"> <div class="table-section">
<a-table <a-table :columns="columns" :data-source="tableData" :loading="loading" :pagination="pagination"
:columns="columns" @change="handleTableChange" row-key="id" size="middle" :scroll="{ x: 1200 }">
:data-source="tableData" <template #bodyCell="{ column, record, index }">
:loading="loading" <template v-if="column.key === 'index'">{{ index + 1 }}</template>
:pagination="pagination"
@change="handleTableChange"
row-key="id"
size="middle"
:scroll="{ x: 1200 }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'createTime'"> <template v-if="column.key === 'createTime'">
{{ formatDateTime(record.createTime) }} {{ formatDateTime(record.createTime) }}
</template> </template>
@@ -86,24 +74,19 @@
查看详情 查看详情
</a-button> </a-button>
</template> </template>
<template v-else>
{{ record[column.key as string] }}
</template>
</template> </template>
</a-table> </a-table>
</div> </div>
<!-- 详情弹窗 --> <!-- 详情弹窗 -->
<a-modal <a-modal v-model:open="detailModalVisible" title="L4数据详情" width="800px" :footer="null">
v-model:open="detailModalVisible"
title="L4数据详情"
width="800px"
:footer="null"
>
<div v-if="selectedRecord" class="detail-content"> <div v-if="selectedRecord" class="detail-content">
<a-descriptions :column="2" bordered> <a-descriptions :column="2" bordered>
<a-descriptions-item <a-descriptions-item v-for="(value, key) in selectedRecord" :key="key"
v-for="(value, key) in selectedRecord" :label="columns.find((col) => col.key === key)?.title || key">
:key="key"
:label="columns.find((col) => col.key === key)?.title || key"
>
<template v-if="key === 'createTime'"> <template v-if="key === 'createTime'">
{{ formatDateTime(value) }} {{ formatDateTime(value) }}
</template> </template>
@@ -148,13 +131,14 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'; import { ref, reactive, onMounted } from 'vue';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { getL4Data } from '@/api/data'; import { getL4Data } from '@/api/data';
import { columns } from './data'; import { columns } from './data';
import type { QueryParams } from '@/api/data/model'; import type { QueryParams } from '@/api/data/model';
import type { L4Data } from './types'; import type { L4Data } from './types';
import type { Dayjs } from 'dayjs'; import type { Dayjs } from 'dayjs';
import { idText } from 'typescript';
type DateRangeType = [Dayjs, Dayjs] | undefined; type DateRangeType = [Dayjs, Dayjs] | undefined;
@@ -209,6 +193,8 @@ const fetchData = async () => {
const params: QueryParams = { const params: QueryParams = {
pageNum: pagination.current, pageNum: pagination.current,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
orderByColumn: 'id',
isAsc: 'desc'
}; };
// 添加日期范围筛选 // 添加日期范围筛选
@@ -278,7 +264,7 @@ onMounted(() => {
}); });
</script> </script>
<style scoped> <style scoped lang="scss">
.l4-data-container { .l4-data-container {
padding: 20px; padding: 20px;
background: #f5f5f5; background: #f5f5f5;
@@ -287,7 +273,6 @@ onMounted(() => {
.page-header { .page-header {
margin-bottom: 20px; margin-bottom: 20px;
}
.page-title { .page-title {
font-size: 24px; font-size: 24px;
@@ -295,6 +280,7 @@ onMounted(() => {
color: #1f2937; color: #1f2937;
margin: 0; margin: 0;
} }
}
.filter-section { .filter-section {
background: white; background: white;
@@ -304,10 +290,6 @@ onMounted(() => {
margin-bottom: 20px; margin-bottom: 20px;
} }
.date-range-picker {
width: 300px;
}
.table-section { .table-section {
background: white; background: white;
padding: 20px; padding: 20px;