123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <script lang="ts" setup>
- import type { VbenFormProps } from '#/adapter/form';
- import type { VxeGridProps } from '#/adapter/vxe-table';
- import { Page } from '@vben/common-ui';
- import { message } from 'ant-design-vue';
- import { useVbenVxeGrid } from '#/adapter/vxe-table';
- import { getExampleTableApi } from '#/api';
- interface RowType {
- category: string;
- color: string;
- id: string;
- price: string;
- productName: string;
- releaseDate: string;
- }
- const formOptions: VbenFormProps = {
- // 默认展开
- collapsed: false,
- schema: [
- {
- component: 'Input',
- defaultValue: '1',
- fieldName: 'category',
- label: 'Category',
- },
- {
- component: 'Input',
- fieldName: 'productName',
- label: 'ProductName',
- },
- {
- component: 'Input',
- fieldName: 'price',
- label: 'Price',
- },
- {
- component: 'Select',
- componentProps: {
- allowClear: true,
- options: [
- {
- label: 'Color1',
- value: '1',
- },
- {
- label: 'Color2',
- value: '2',
- },
- ],
- placeholder: '请选择',
- },
- fieldName: 'color',
- label: 'Color',
- },
- {
- component: 'DatePicker',
- fieldName: 'datePicker',
- label: 'Date',
- },
- ],
- // 控制表单是否显示折叠按钮
- showCollapseButton: true,
- // 按下回车时是否提交表单
- submitOnEnter: false,
- };
- 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', formatter: 'formatDateTime', title: 'Date' },
- ],
- height: 'auto',
- keepSource: true,
- pagerConfig: {},
- proxyConfig: {
- ajax: {
- query: async ({ page }, formValues) => {
- message.success(`Query params: ${JSON.stringify(formValues)}`);
- return await getExampleTableApi({
- page: page.currentPage,
- pageSize: page.pageSize,
- ...formValues,
- });
- },
- },
- },
- };
- const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
- </script>
- <template>
- <Page auto-content-height>
- <Grid />
- </Page>
- </template>
|