Ben Lin
2024-07-02 2069d53e9be24adec3c8d6717fd7317555bd9a52
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
<template>
  <div class="p-4">
    <BasicTable @register="registerTable" />
  </div>
</template>
<script lang="ts" setup>
  import { BasicTable, useTable } from '@/components/Table';
  import { getBasicColumns } from './tableData';
 
  import { demoListApi } from '@/api/demo/table';
 
  function handleSummary(tableData: Recordable[]) {
    const totalNo = tableData.reduce((prev, next) => {
      prev += next.no;
      return prev;
    }, 0);
    return [
      {
        _row: '合计',
        _index: '平均值',
        no: totalNo,
      },
      {
        _row: '合计',
        _index: '平均值',
        no: totalNo,
      },
    ];
  }
  const [registerTable] = useTable({
    title: '表尾行合计示例',
    api: demoListApi,
    rowSelection: { type: 'checkbox' },
    columns: getBasicColumns(),
    showSummary: true,
    summaryFunc: handleSummary,
    scroll: { x: 2000 },
    canResize: false,
    showSelectionBar: true, // 显示多选状态栏
  });
</script>