web-class-frontend/app/components/SuperTable.vue

39 lines
970 B
Vue
Raw Normal View History

2025-04-23 17:43:14 +08:00
<script setup lang="ts">
2025-05-03 19:34:43 +08:00
import type {
TableProps,
TableRowData,
RowEventContext,
} from 'tdesign-vue-next';
2025-04-23 17:43:14 +08:00
const emit = defineEmits(['pageChange', 'onRowClick']);
const data = defineModel<unknown>('data');
const columns = defineModel<TableProps['columns']>('columns');
const loading = defineModel<boolean>('loading');
const pagination = defineModel<TableProps['pagination']>('pagination');
async function onPageChange(pageInfo: { current: number; pageSize: number }) {
emit('pageChange', pageInfo);
}
2025-05-03 19:34:43 +08:00
function onRowClick(x: RowEventContext<TableRowData>) {
2025-04-23 17:43:14 +08:00
emit('onRowClick', x);
}
</script>
<template>
<t-table
row-key="index"
:data="data as TableRowData[]"
:columns="columns"
:pagination="pagination"
:table-layout="'auto'"
:bordered="true"
:stripe="true"
:lazy-load="true"
:loading="loading"
@page-change="onPageChange"
@row-click="onRowClick"
>
</t-table>
</template>