|
1
|
<template>
|
|
2
3
4
5
|
<PageWrapper
title="可展开表格"
content="不可与scroll共用。TableAction组件可配置stopButtonPropagation来阻止操作按钮的点击事件冒泡,以便配合Table组件的expandRowByClick"
>
|
|
6
7
8
9
|
<BasicTable @register="registerTable">
<template #expandedRowRender="{ record }">
<span>No: {{ record.no }} </span>
</template>
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<template #action="{ record }">
<TableAction
stopButtonPropagation
:actions="[
{
label: '删除',
icon: 'ic:outline-delete-outline',
onClick: handleDelete.bind(null, record),
},
]"
:dropDownActions="[
{
label: '启用',
popConfirm: {
title: '是否启用?',
confirm: handleOpen.bind(null, record),
},
},
]"
/>
</template>
|
|
31
|
</BasicTable>
|
|
32
|
</PageWrapper>
|
|
33
34
35
|
</template>
<script lang="ts">
import { defineComponent } from 'vue';
|
|
36
37
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { PageWrapper } from '/@/components/Page';
|
|
38
39
40
41
42
|
import { getBasicColumns } from './tableData';
import { demoListApi } from '/@/api/demo/table';
export default defineComponent({
|
|
43
|
components: { BasicTable, TableAction, PageWrapper },
|
|
44
45
46
|
setup() {
const [registerTable] = useTable({
api: demoListApi,
|
|
47
48
|
title: '可展开表格演示',
titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
|
|
49
50
51
|
columns: getBasicColumns(),
rowKey: 'id',
canResize: false,
|
|
52
53
54
55
56
57
|
expandRowByClick: true,
actionColumn: {
width: 160,
title: 'Action',
slots: { customRender: 'action' },
},
|
|
58
|
});
|
|
59
60
61
62
63
64
|
function handleDelete(record: Recordable) {
console.log('点击了删除', record);
}
function handleOpen(record: Recordable) {
console.log('点击了启用', record);
}
|
|
65
66
67
|
return {
registerTable,
|
|
68
69
|
handleDelete,
handleOpen,
|
|
70
71
72
73
|
};
},
});
</script>
|