66 lines
1.5 KiB
Vue
66 lines
1.5 KiB
Vue
![]() |
<script lang="ts" setup>
|
||
|
import type { VxeGridProps } from '#/adapter';
|
||
|
|
||
|
import { Page } from '@vben/common-ui';
|
||
|
|
||
|
import { Button } from 'ant-design-vue';
|
||
|
|
||
|
import { useVbenVxeGrid } from '#/adapter';
|
||
|
import { getExampleTableApi } from '#/api';
|
||
|
|
||
|
interface RowType {
|
||
|
category: string;
|
||
|
color: string;
|
||
|
id: string;
|
||
|
price: string;
|
||
|
productName: string;
|
||
|
releaseDate: string;
|
||
|
}
|
||
|
|
||
|
const gridOptions: VxeGridProps<RowType> = {
|
||
|
checkboxConfig: {
|
||
|
highlight: true,
|
||
|
labelField: 'name',
|
||
|
},
|
||
|
columns: [
|
||
|
{ title: '序号', type: 'seq', width: 50 },
|
||
|
{ align: 'left', title: 'Name', type: 'checkbox', width: 100 },
|
||
|
{ field: 'category', title: 'Category' },
|
||
|
{ field: 'color', title: 'Color' },
|
||
|
{ field: 'productName', title: 'Product Name' },
|
||
|
{ field: 'price', title: 'Price' },
|
||
|
{ field: 'releaseDate', title: 'Date' },
|
||
|
],
|
||
|
height: 'auto',
|
||
|
keepSource: true,
|
||
|
pagerConfig: {},
|
||
|
proxyConfig: {
|
||
|
ajax: {
|
||
|
query: async ({ page }) => {
|
||
|
return await getExampleTableApi({
|
||
|
page: page.currentPage,
|
||
|
pageSize: page.pageSize,
|
||
|
});
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
|
||
|
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions });
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<Page auto-content-height>
|
||
|
<Grid>
|
||
|
<template #toolbar-tools>
|
||
|
<Button class="mr-2" type="primary" @click="() => gridApi.query()">
|
||
|
刷新当前页面
|
||
|
</Button>
|
||
|
<Button type="primary" @click="() => gridApi.reload()">
|
||
|
刷新并返回第一页
|
||
|
</Button>
|
||
|
</template>
|
||
|
</Grid>
|
||
|
</Page>
|
||
|
</template>
|