|
1
|
<template>
|
|
2
3
4
5
|
<BasicTable
@register="registerTable"
:rowSelection="{ type: 'checkbox', selectedRowKeys: checkedKeys, onChange: onSelectChange }"
>
|
vben
authored
|
6
|
<template #form-custom> custom-slot </template>
|
|
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<template #headerTop>
<a-alert type="info" show-icon>
<template #message>
<template v-if="checkedKeys.length > 0">
<span>已选中{{ checkedKeys.length }}条记录(可跨页)</span>
<a-button type="link" @click="checkedKeys = []" size="small">清空</a-button>
</template>
<template v-else>
<span>未选中任何项目</span>
</template>
</template>
</a-alert>
</template>
|
Vben
authored
|
20
21
22
|
<template #toolbar>
<a-button type="primary" @click="getFormValues">获取表单数据</a-button>
</template>
|
vben
authored
|
23
|
</BasicTable>
|
|
24
25
|
</template>
<script lang="ts">
|
|
26
|
import { defineComponent, ref } from 'vue';
|
|
27
28
|
import { BasicTable, useTable } from '/@/components/Table';
import { getBasicColumns, getFormConfig } from './tableData';
|
|
29
|
import { Alert } from 'ant-design-vue';
|
|
30
31
32
33
|
import { demoListApi } from '/@/api/demo/table';
export default defineComponent({
|
|
34
|
components: { BasicTable, AAlert: Alert },
|
|
35
|
setup() {
|
|
36
|
const checkedKeys = ref<Array<string | number>>([]);
|
Vben
authored
|
37
|
const [registerTable, { getForm }] = useTable({
|
|
38
39
40
41
42
|
title: '开启搜索区域',
api: demoListApi,
columns: getBasicColumns(),
useSearchForm: true,
formConfig: getFormConfig(),
|
vben
authored
|
43
|
showTableSetting: true,
|
|
44
45
|
showIndexColumn: false,
rowKey: 'id',
|
|
46
47
|
});
|
Vben
authored
|
48
49
50
51
|
function getFormValues() {
console.log(getForm().getFieldsValue());
}
|
|
52
53
54
55
56
|
function onSelectChange(selectedRowKeys: (string | number)[]) {
console.log(selectedRowKeys);
checkedKeys.value = selectedRowKeys;
}
|
|
57
58
|
return {
registerTable,
|
Vben
authored
|
59
|
getFormValues,
|
|
60
61
|
checkedKeys,
onSelectChange,
|
|
62
63
64
65
|
};
},
});
</script>
|