table-column.vue 965 Bytes
<script setup lang="ts">
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { TableColumn, TableData, TableSortable } from '@arco-design/web-vue';

type PropType = { title?: string; dataIndex?: string; tooltip?: boolean; ellipsis?: boolean; hasSort?: boolean };

const sortable = { sortDirections: ['ascend', 'descend'], sorter: true, defaultSortOrder: '' } as TableSortable;

withDefaults(defineProps<PropType>(), { tooltip: true, hasSort: false });
</script>

<template>
  <TableColumn
    v-bind="$attrs"
    :title="title"
    :data-index="dataIndex"
    :tooltip="tooltip as boolean"
    :ellipsis="ellipsis || tooltip as boolean"
    :sortable="hasSort ? sortable : undefined as any"
  >
    <template v-if="$slots.default" #cell="{ record, rowIndex }: { record: TableData, rowIndex: number }">
      <slot name="default" :record="record" :index="rowIndex" />
    </template>
  </TableColumn>
</template>

<style scoped lang="less"></style>