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
| <template>
| <div>
| <a-table
| :columns="columns"
| :data="data"
| row-key="id"
| :row-selection="{
| type: 'checkbox',
| showCheckedAll: true,
| }"
| :border="false"
| :pagination="false"
| />
| <a-typography-text type="secondary" class="data-statistic-list-tip">
| {{ $t('monitor.list.tip.rotations') }} {{ data.length }}
| {{ $t('monitor.list.tip.rest') }}
| </a-typography-text>
| </div>
| </template>
|
| <script lang="ts" setup>
| import { computed, h, compile } from 'vue';
| import { useI18n } from 'vue-i18n';
| import type {
| TableColumnData,
| TableData,
| } from '@arco-design/web-vue/es/table/interface.d';
|
| interface PreviewRecord {
| cover: string;
| name: string;
| duration: string;
| id: string;
| status: number;
| }
| const { t } = useI18n();
| const data: PreviewRecord[] = [
| {
| cover:
| 'http://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/c788fc704d32cf3b1136c7d45afc2669.png~tplv-uwbnlip3yd-webp.webp',
| name: '视频直播',
| duration: '00:05:19',
| id: '54e23ade',
| status: -1,
| },
| ];
| const renderTag = (status: number) => {
| if (status === -1) {
| return `<a-tag color="red" class='data-statistic-list-cover-tag'>
| ${t('monitor.list.tag.auditFailed')}
| </a-tag>`;
| }
| return '';
| };
| // Using the Render function is more flexible than using templates.
| // But, cannot bind context and local scopes are also lost
|
| const columns = computed(() => {
| return [
| {
| title: t('monitor.list.title.order'),
| render({
| rowIndex,
| }: {
| record: TableData;
| column: TableColumnData;
| rowIndex: number;
| }) {
| const tmp = `<span>${rowIndex + 1}</span>`;
| return h(compile(tmp));
| },
| },
| {
| title: t('monitor.list.title.cover'),
| render({
| record,
| }: {
| record: TableData;
| column: TableColumnData;
| rowIndex: number;
| }) {
| const tmp = `<div class='data-statistic-list-cover-wrapper'>
| <img src=${record.cover} />
| ${renderTag(record.status)}
| </div>`;
| return h(compile(tmp));
| },
| },
| {
| title: t('monitor.list.title.name'),
| dataIndex: 'name',
| },
| {
| dataIndex: 'duration',
| title: t('monitor.list.title.duration'),
| },
| {
| dataIndex: 'id',
| title: t('monitor.list.title.id'),
| },
| ];
| });
| </script>
|
| <style lang="less">
| // Warning: Here is the global style
| .data-statistic {
| &-list {
| &-cover {
| &-wrapper {
| position: relative;
| height: 68px;
|
| img {
| height: 100%;
| }
| }
|
| &-tag {
| position: absolute;
| top: 6px;
| left: 6px;
| }
| }
|
| &-tip {
| display: block;
| margin-top: 16px;
| text-align: center;
| }
| }
| }
| </style>
|
|