Skip to content

Commit

Permalink
chore: type error fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Dec 12, 2024
1 parent 0a887d3 commit 2b846d2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/src/components/common-ui/vben-vxe-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,4 @@ useVbenVxeGrid 返回的第二个参数,是一个对象,包含了一些表
| gridOptions | grid组件的参数 | `VxeTableGridProps` |
| gridEvents | grid组件的触发的⌚️ | `VxeGridListeners` |
| formOptions | 表单参数 | `VbenFormProps` |
| isFormShow | 是否显示搜索表单 | `boolean` |
| showSearchForm | 是否显示搜索表单 | `boolean` |
12 changes: 3 additions & 9 deletions packages/effects/plugins/src/vxe-table/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getDefaultState(): VxeGridProps {
gridOptions: {},
gridEvents: {},
formOptions: undefined,
isFormShow: true,
showSearchForm: true,
};
}

Expand Down Expand Up @@ -82,12 +82,6 @@ export class VxeGridApi {
}
}

setFormVisible(isVisible: boolean) {
this.setState({
isFormShow: isVisible,
});
}

setGridOptions(options: Partial<VxeGridProps['gridOptions']>) {
this.setState({
gridOptions: options,
Expand Down Expand Up @@ -118,12 +112,12 @@ export class VxeGridApi {

toggleSearchForm(show?: boolean) {
this.setState({
isFormShow: isBoolean(show) ? show : !this.state?.isFormShow,
showSearchForm: isBoolean(show) ? show : !this.state?.showSearchForm,
});
// nextTick(() => {
// this.grid.recalculate();
// });
return this.state?.isFormShow;
return this.state?.showSearchForm;
}

unmount() {
Expand Down
5 changes: 3 additions & 2 deletions packages/effects/plugins/src/vxe-table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ interface ToolbarConfigOptions extends VxeGridPropTypes.ToolbarConfig {
}

export interface VxeTableGridOptions<T = any> extends VxeTableGridProps<T> {
toolbarConfig: ToolbarConfigOptions;
/** 工具栏配置 */
toolbarConfig?: ToolbarConfigOptions;
}

export interface VxeGridProps {
Expand Down Expand Up @@ -60,7 +61,7 @@ export interface VxeGridProps {
/**
* 显示搜索表单
*/
isFormShow?: boolean;
showSearchForm?: boolean;
}

export type ExtendedVxeGridApi = {
Expand Down
12 changes: 7 additions & 5 deletions packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { VbenFormProps } from '@vben-core/form-ui';
import type {
VxeGridDefines,
VxeGridInstance,
VxeGridListeners,
VxeGridPropTypes,
VxeGridProps as VxeTableGridProps,
} from 'vxe-table';
Expand Down Expand Up @@ -59,7 +60,7 @@ const {
formOptions,
tableTitle,
tableTitleHelp,
isFormShow,
showSearchForm,
} = usePriorityValues(props, state);
const { isMobile } = usePreferences();
Expand Down Expand Up @@ -114,7 +115,7 @@ const toolbarOptions = computed(() => {
code: 'search',
icon: 'vxe-icon--search',
circle: true,
status: isFormShow.value ? 'primary' : undefined,
status: showSearchForm.value ? 'primary' : undefined,
title: $t('common.search'),
},
]
Expand Down Expand Up @@ -196,8 +197,9 @@ function onToolbarToolClick(event: VxeGridDefines.ToolbarToolClickEventParams) {
if (event.code === 'search') {
props.api?.toggleSearchForm?.();
}
// @ts-ignore
gridEvents.value?.toolbarToolClick?.(event);
(
gridEvents.value?.toolbarToolClick as VxeGridListeners['toolbarToolClick']
)?.(event);
}
const events = computed(() => {
Expand Down Expand Up @@ -334,7 +336,7 @@ onUnmounted(() => {
<template #form>
<div
v-if="formOptions"
v-show="isFormShow !== false"
v-show="showSearchForm !== false"
class="relative rounded py-3 pb-4"
>
<slot name="form">
Expand Down

0 comments on commit 2b846d2

Please sign in to comment.