index.vue
3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!--
* 功能:表格
* 作者:闫李壮
* 日期:2024-06-04
-->
<template>
<div class="table-list-view">
<ul class="table-list-header" :style="tableCss.columns">
<li v-for="(item, index) in newColumns" :key="index"
:class="preview==2?'list-header-preview':'table-list-header-default'"
:style="{ width: item.title=='时间'? `calc(120% / ${columns.length})`:item.title=='事件'? `calc(220% / ${columns.length})`:item.title=='操作' ||item.title=='状态' ?`calc(70% / ${columns.length})` :`calc(100% / ${columns.length})` }">
<a-typography-paragraph :style="{ width: '100%', color: tableCss.columns.color }"
:ellipsis="{ rows: 1, showTooltip: true }" class="table-list-text">
{{ item.title }}
</a-typography-paragraph>
</li>
</ul>
<TransitionGroup name="list" tag="ul" class="table-list-body">
<li v-for="item in data" :key="item.id" :class="{ openHover: tableCss.data.background }">
<template v-for="(headItem, headIndex) in columns">
<a-typography-paragraph
v-if="headItem.dataIndex!='id'"
:ellipsis="{ rows: 1, showTooltip: true }"
:style="{ width: headItem.title=='时间'?`calc((120% / ${columns.length}))`:headItem.title=='事件'? `calc(220% / ${columns.length})`: headItem.title=='操作' ||headItem.title=='状态'?`calc(70% / ${columns.length})`: `calc(100% / ${columns.length})`, color: tableCss.data.color }"
class="table-list-text">
{{ item[headItem.dataIndex] }}
</a-typography-paragraph>
</template>
</li>
</TransitionGroup>
</div>
</template>
<script lang="ts" setup>
import {computed, watch, watchEffect} from "vue";
const props = defineProps({
data: {
type: Array,
default: () => []
},
columns: {
type: Array,
default: () => []
},
tableCss: {
type: Object,
default: () => ({
columns: {
color: 'var(--color-text-1)',
background: ''
},
data: {
color: 'var(--color-text-1)',
background: ''
}
})
},
preview: {
type: Number,
default: 0
}
})
const newColumns = computed(() => {
const result: any = [];
props.columns.filter((item: any) => {
if (item.title && item.title != '编号') {
result.push(item)
}
})
return result
})
</script>
<style lang="less" scoped>
.table-list-view {
height: 100%;
overflow: hidden;
ul {
list-style: none;
padding: 0;
margin: 0;
}
.table-list-header, .table-list-body li {
display: flex;
align-items: center;
justify-content: space-between;
text-align: left;
padding-right: 10px;
padding-left: 16px;
box-sizing: border-box;
}
}
.table-list-header-default {
font-weight: bold;
padding-top: 6px;
padding-bottom: 4px;
}
.list-header-preview {
font-weight: bold;
padding-top: 0;
padding-bottom: 0;
}
.table-list-text {
margin-bottom: 0;
}
.openHover:hover {
background: rgba(52, 144, 227, 0.05);
}
.list-move, /* 对移动中的元素应用的过渡 */
.list-enter-active,
.list-leave-active {
transition: all 0.5s ease;
}
.list-enter-from,
.list-leave-to {
opacity: 0;
transform: translateX(30px);
}
/* 确保将离开的元素从布局流中删除
以便能够正确地计算移动的动画。 */
.list-leave-active {
position: absolute;
}
.arco-empty {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
</style>