Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin
This commit is contained in:
@@ -96,9 +96,13 @@ function createRequestClient(baseURL: string) {
|
||||
|
||||
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
||||
client.addResponseInterceptor(
|
||||
errorMessageResponseInterceptor((msg: string, _error) => {
|
||||
errorMessageResponseInterceptor((msg: string, error) => {
|
||||
// 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
|
||||
message.error(msg);
|
||||
// 当前mock接口返回的错误字段是 error 或者 message
|
||||
const responseData = error?.response?.data ?? {};
|
||||
const errorMessage = responseData?.error ?? responseData?.message ?? '';
|
||||
// 如果没有错误信息,则会根据状态码进行提示
|
||||
message.error(errorMessage || msg);
|
||||
}),
|
||||
);
|
||||
|
||||
|
@@ -29,6 +29,9 @@ const gridOptions: VxeGridProps<RowType> = {
|
||||
{ field: 'address', showOverflow: true, title: 'Address' },
|
||||
],
|
||||
data: MOCK_TABLE_DATA,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
sortConfig: {
|
||||
multiple: true,
|
||||
},
|
||||
|
@@ -30,12 +30,6 @@ const gridOptions: VxeGridProps<RowType> = {
|
||||
title: 'DateTime',
|
||||
width: 500,
|
||||
},
|
||||
{
|
||||
field: 'releaseDate',
|
||||
formatter: 'formatDate',
|
||||
title: 'Date',
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
|
@@ -3,7 +3,7 @@ import type { VbenFormProps, VxeGridProps } from '#/adapter';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter';
|
||||
import { getExampleTableApi } from '#/api';
|
||||
@@ -60,6 +60,8 @@ const formOptions: VbenFormProps = {
|
||||
label: 'Date',
|
||||
},
|
||||
],
|
||||
// 控制表单是否显示折叠按钮
|
||||
showCollapseButton: true,
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps<RowType> = {
|
||||
@@ -93,26 +95,11 @@ const gridOptions: VxeGridProps<RowType> = {
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
|
||||
|
||||
function toggleFormCollspae() {
|
||||
gridApi.formApi.setState((prev) => {
|
||||
return {
|
||||
...prev,
|
||||
showCollapseButton: !prev.showCollapseButton,
|
||||
};
|
||||
});
|
||||
}
|
||||
const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #toolbar-tools>
|
||||
<Button type="primary" @click="toggleFormCollspae">
|
||||
切换表单折叠按钮
|
||||
</Button>
|
||||
</template>
|
||||
</Grid>
|
||||
<Grid />
|
||||
</Page>
|
||||
</template>
|
||||
|
@@ -30,7 +30,6 @@ const gridOptions: VxeGridProps<RowType> = {
|
||||
{ field: 'productName', title: 'Product Name' },
|
||||
{ field: 'price', title: 'Price' },
|
||||
{ field: 'releaseDate', formatter: 'formatDateTime', title: 'DateTime' },
|
||||
{ field: 'releaseDate', formatter: 'formatDate', title: 'Date' },
|
||||
],
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
|
Reference in New Issue
Block a user