WholeProcessPlatform/frontend/src/modules/shuidianhuangjingjieruMod/DataTable.vue

297 lines
6.7 KiB
Vue
Raw Normal View History

<!-- DataTable.vue -->
<template>
<div class="data-table-container">
<a-table :columns="columns" :data-source="tableData" :pagination="false" size="middle" :customRow="customRow"
class="custom-table">
</a-table>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import type { ColumnsType } from 'ant-design-vue/es/table/interface';
// 定义组件名
defineOptions({
name: 'DataTable'
});
// 表格列配置
const columns: ColumnsType = [
{
title: '基地名称',
dataIndex: 'name',
key: 'name',
fixed: 'left',
// width: 65,
align: 'left'
},
{
title: '装机容量 (万 kW)',
key: 'capacity',
align: 'center',
children: [
{
title: '总计',
dataIndex: 'total',
key: 'total',
width: 65,
align: 'center'
},
{
title: '已建',
dataIndex: 'built',
key: 'built',
width: 65,
align: 'center'
},
{
title: '在建',
dataIndex: 'building',
key: 'building',
width: 65,
align: 'center'
},
{
title: '未建',
dataIndex: 'unbuilt',
key: 'unbuilt',
width: 65,
align: 'center'
},
]
}
];
// 表格数据
const tableData = ref([
{
key: '1',
name: '金沙江干流',
total: '7952.00',
built: '6370.00',
building: '902.00',
unbuilt: '680.00'
},
{
key: '2',
name: '雅砻江干流',
total: '2773.65',
built: '1920.00',
building: '492.00',
unbuilt: '361.65'
},
{
key: '3',
name: '大渡河干流',
total: '2689.65',
built: '1925.65',
building: '534.00',
unbuilt: '230.00'
},
{
key: '4',
name: '乌江干流',
total: '1181.36',
built: '1133.36',
building: '48.00',
unbuilt: '0.00'
},
{
key: '5',
name: '长江上游干流',
total: '3212.65',
built: '2523.65',
building: '0.00',
unbuilt: '689.00'
},
{
key: '6',
name: '湘西',
total: '1054.32',
built: '959.30',
building: '38.52',
unbuilt: '56.65'
},
{
key: '7',
name: '黄河上游干流',
total: '2794.59',
built: '1749.89',
building: '0.00',
unbuilt: '1044.65'
},
{
key: '8',
name: '黄河中游干流',
total: '835.65',
built: '401.65',
building: '0.00',
unbuilt: '434.00'
},
{
key: '9',
name: '南盘江 - 红水河',
total: '1271.00',
built: '1271.00',
building: '0.00',
unbuilt: '0.00'
},
{
key: '10',
name: '东北',
total: '1331.95',
built: '749.05',
building: '0.00',
unbuilt: '582.90'
},
{
key: '11',
name: '澜沧江干流',
total: '2535.00',
built: '2275.00',
building: '260.00',
unbuilt: '0.00'
},
{
key: '12',
name: '怒江干流',
total: '3138.00',
built: '0.00',
building: '102.00',
unbuilt: '3036.00'
},
{
key: '13',
name: '闽浙赣',
total: '962.08',
built: '920.68',
building: '0.00',
unbuilt: '41.40'
},
{
key: '14',
name: '其他',
total: '7460.57',
built: '7273.27',
building: '121.90',
unbuilt: '65.40'
},
{
key: '15',
name: '总计',
total: '7460.57',
built: '7273.27',
building: '121.90',
unbuilt: '65.40'
}
]);
// 自定义行样式
const customRow = (record: any, index: number) => {
return {
style: {
backgroundColor: index % 2 === 1 ? '#fafafa' : '#ffffff'
}
};
};
// 页面加载时执行的逻辑
onMounted(() => {
});
</script>
<style lang="scss" scoped>
.data-table-container {
padding: 0;
background: #fff;
margin-top: 10px;
}
.custom-table {
:deep(.ant-table) {
font-size: 14px;
border: 1px solid #e8e8e8;
.ant-table-thead {
>tr {
>th {
background-color: #e5eff8 !important;
color: #2f6b98;
// font-weight: 600;
border: 1px solid #e8e8e8 !important;
padding: 6px 8px;
text-align: center;
&:first-child {
background-color: #e5eff8 !important;
text-align: left;
}
}
&:first-child {
>th {
background-color: #e5eff8 !important;
&:first-child {
background-color: #e5eff8 !important;
}
}
}
}
}
.ant-table-tbody {
>tr {
>td {
border: 1px solid #e8e8e8;
padding: 6px 8px;
text-align: center;
&:first-child {
text-align: left;
// font-weight: 500;
}
}
&:hover {
background-color: #e6f7ff !important;
}
}
}
.ant-table-footer {
padding: 0;
background-color: #fafafa;
.table-footer {
.footer-row {
display: flex;
align-items: center;
padding: 12px 8px;
border-top: 1px solid #e8e8e8;
background-color: #fafafa;
.footer-item {
flex: 1;
text-align: center;
// font-weight: 600;
color: #333;
&:first-child {
flex: 0 0 140px;
text-align: center;
}
}
}
}
}
// 移除默认的 footer 单元格样式
.ant-table-footer::before {
display: none;
}
}
}
</style>