2022-04-25 17:53:49 +08:00
|
|
|
<template>
|
2022-05-05 00:54:49 +08:00
|
|
|
<el-table-v2
|
|
|
|
:columns="columns"
|
|
|
|
:data="data"
|
|
|
|
:width="700"
|
|
|
|
:height="400"
|
|
|
|
fixed
|
|
|
|
/>
|
2022-04-25 17:53:49 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="tsx" setup>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
import dayjs from 'dayjs'
|
2022-05-05 00:54:49 +08:00
|
|
|
import {
|
|
|
|
ElButton,
|
|
|
|
ElIcon,
|
|
|
|
ElTag,
|
|
|
|
ElTooltip,
|
|
|
|
TableV2FixedDir,
|
|
|
|
} from 'element-plus'
|
2022-04-25 17:53:49 +08:00
|
|
|
import { Timer } from '@element-plus/icons-vue'
|
|
|
|
|
2022-05-05 00:54:49 +08:00
|
|
|
import type { Column } from 'element-plus'
|
2022-04-25 17:53:49 +08:00
|
|
|
|
|
|
|
let id = 0
|
|
|
|
|
|
|
|
const dataGenerator = () => ({
|
|
|
|
id: `random-id-${++id}`,
|
|
|
|
name: 'Tom',
|
|
|
|
date: '2020-10-1',
|
|
|
|
})
|
|
|
|
|
|
|
|
const columns: Column<any>[] = [
|
|
|
|
{
|
|
|
|
key: 'date',
|
|
|
|
title: 'Date',
|
|
|
|
dataKey: 'date',
|
|
|
|
width: 150,
|
2022-05-05 00:54:49 +08:00
|
|
|
fixed: TableV2FixedDir.LEFT,
|
2022-04-25 17:53:49 +08:00
|
|
|
cellRenderer: ({ cellData: date }) => (
|
|
|
|
<ElTooltip content={dayjs(date).format('YYYY/MM/DD')}>
|
|
|
|
{
|
|
|
|
<span class="flex items-center">
|
|
|
|
<ElIcon class="mr-3">
|
|
|
|
<Timer />
|
|
|
|
</ElIcon>
|
|
|
|
{dayjs(date).format('YYYY/MM/DD')}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
</ElTooltip>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'name',
|
|
|
|
title: 'Name',
|
|
|
|
dataKey: 'name',
|
|
|
|
width: 150,
|
|
|
|
align: 'center',
|
|
|
|
cellRenderer: ({ cellData: name }) => <ElTag>{name}</ElTag>,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'operations',
|
|
|
|
title: 'Operations',
|
|
|
|
cellRenderer: () => (
|
|
|
|
<>
|
|
|
|
<ElButton size="small">Edit</ElButton>
|
|
|
|
<ElButton size="small" type="danger">
|
|
|
|
Delete
|
|
|
|
</ElButton>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
width: 150,
|
|
|
|
align: 'center',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2022-05-05 00:54:49 +08:00
|
|
|
const data = ref(Array.from({ length: 200 }).map(dataGenerator))
|
2022-04-25 17:53:49 +08:00
|
|
|
</script>
|