mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
120 lines
3.0 KiB
Vue
120 lines
3.0 KiB
Vue
<template>
|
||
<PageWrapper
|
||
title="可展开表格"
|
||
content="不可与scroll共用。TableAction组件可配置stopButtonPropagation来阻止操作按钮的点击事件冒泡,以便配合Table组件的expandRowByClick"
|
||
>
|
||
<BasicTable @register="registerTable">
|
||
<template #expandedRowRender="{ record }">
|
||
<span>No: {{ record.no }} </span>
|
||
</template>
|
||
<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>
|
||
</BasicTable>
|
||
</PageWrapper>
|
||
</template>
|
||
<script lang="ts">
|
||
import { defineComponent } from 'vue';
|
||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||
import { PageWrapper } from '/@/components/Page';
|
||
import { demoListApi } from '/@/api/demo/table';
|
||
import { useListPage } from '/@/hooks/system/useListPage';
|
||
const columns: BasicColumn[] = [
|
||
{
|
||
title: 'ID',
|
||
dataIndex: 'id',
|
||
fixed: 'left',
|
||
width: 200,
|
||
},
|
||
{
|
||
title: '姓名',
|
||
dataIndex: 'name',
|
||
width: 150,
|
||
filters: [
|
||
{ text: 'Male', value: 'male' },
|
||
{ text: 'Female', value: 'female' },
|
||
],
|
||
},
|
||
{
|
||
title: '地址',
|
||
dataIndex: 'address',
|
||
width: 300,
|
||
},
|
||
{
|
||
title: '编号',
|
||
dataIndex: 'no',
|
||
width: 150,
|
||
sorter: true,
|
||
defaultHidden: true,
|
||
},
|
||
{
|
||
title: '开始时间',
|
||
width: 150,
|
||
sorter: true,
|
||
dataIndex: 'beginTime',
|
||
},
|
||
{
|
||
title: '结束时间',
|
||
width: 150,
|
||
sorter: true,
|
||
dataIndex: 'endTime',
|
||
},
|
||
];
|
||
export default defineComponent({
|
||
components: { BasicTable, TableAction, PageWrapper },
|
||
setup() {
|
||
const { tableContext } = useListPage({
|
||
designScope: 'basic-table-demo',
|
||
tableProps: {
|
||
api: demoListApi,
|
||
title: '可展开表格演示',
|
||
titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
|
||
columns: columns,
|
||
rowKey: 'id',
|
||
canResize: false,
|
||
expandRowByClick: true,
|
||
actionColumn: {
|
||
width: 160,
|
||
title: 'Action',
|
||
dataIndex: 'action',
|
||
},
|
||
useSearchForm: false,
|
||
},
|
||
});
|
||
//注册table数据
|
||
const [registerTable] = tableContext;
|
||
|
||
function handleDelete(record: Recordable) {
|
||
console.log('点击了删除', record);
|
||
}
|
||
function handleOpen(record: Recordable) {
|
||
console.log('点击了启用', record);
|
||
}
|
||
|
||
return {
|
||
registerTable,
|
||
handleDelete,
|
||
handleOpen,
|
||
};
|
||
},
|
||
});
|
||
</script>
|