Table.vue 1.41 KB
<script lang="ts" setup>
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { callStatisticsPage } from '/@/api/application/record';
  import { columns } from '../config';
  import { PageEnum } from '/@/enums/pageEnum';
  import { useGo } from '/@/hooks/web/usePage';

  const { t } = useI18n();

  const go = useGo();

  const [registerTable] = useTable({
    immediate: true,
    api: callStatisticsPage,
    columns,
    showIndexColumn: false,
    clickToRowSelect: false,
    showTableSetting: false,
    useSearchForm: false,
    bordered: true,
    rowKey: 'name',
    actionColumn: {
      width: 200,
      title: t('common.actionText'),
      dataIndex: 'action',
      slots: { customRender: 'action' },
      fixed: 'right',
    },
  });

  const handleViewDetail = (record) => {
    if (!record.name) return;
    go(PageEnum.APPLICATION_RECORD + '?name=' + encodeURIComponent(String(record.name)));
  };
</script>

<template>
  <div>
    <BasicTable :clickToRowSelect="false" @register="registerTable">
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              label: t('common.viewText'),
              icon: 'ant-design:eye-outlined',
              onClick: handleViewDetail.bind(null, record),
            },
          ]"
        />
      </template>
    </BasicTable>
  </div>
</template>