Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table internal search collspaed configuration does not take effect #4585

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ watch(
</script>
<template>
<div
:class="cn('col-span-full w-full text-right', rootProps.actionWrapperClass)"
:class="
cn('col-span-full w-full pb-6 text-right', rootProps.actionWrapperClass)
"
:style="queryFormStyle"
>
<component
Expand Down
1 change: 1 addition & 0 deletions packages/@core/ui-kit/form-ui/src/use-vben-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function useVbenForm<
onBeforeUnmount(() => {
api.unmount();
});
api.setState({ ...props, ...attrs });
return () =>
h(VbenUseForm, { ...props, ...attrs, formApi: extendedApi }, slots);
},
Expand Down
13 changes: 1 addition & 12 deletions packages/@core/ui-kit/form-ui/src/vben-use-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,12 @@ props.formApi?.mount?.(form);
const handleUpdateCollapsed = (value: boolean) => {
props.formApi?.setState({ collapsed: !!value });
};
// if (isFunction(forward.value.handleValuesChange)) {
// watch(
// () => form.values,
// (val) => {
// forward.value.handleValuesChange?.(toRaw(val));
// },
// {
// deep: true,
// immediate: true,
// },
// );
// }
</script>

<template>
<Form
v-bind="forward"
:collapsed="state.collapsed"
:component-bind-event-map="COMPONENT_BIND_EVENT_MAP"
:component-map="COMPONENT_MAP"
:form="form"
Expand Down
1 change: 1 addition & 0 deletions packages/effects/plugins/src/vxe-table/use-vxe-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function useVbenVxeGrid(options: VxeGridProps) {
onBeforeUnmount(() => {
api.unmount();
});
api.setState({ ...props, ...attrs });
return () => h(VxeGrid, { ...props, ...attrs, api: extendedApi }, slots);
},
{
Expand Down
3 changes: 1 addition & 2 deletions packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ async function init() {
);
}
}
onMounted(() => {
props.api?.mount?.(gridRef.value, formApi);
init();
Expand Down Expand Up @@ -246,7 +245,7 @@ onMounted(() => {
<slot :name="slotName" v-bind="slotProps"></slot>
</template>
<template #form>
<div v-if="formOptions" class="relative rounded py-3 pb-6">
<div v-if="formOptions" class="relative rounded py-3 pb-4">
<slot name="form">
<Form v-bind="vbenFormOptions">
<template
Expand Down
23 changes: 20 additions & 3 deletions playground/src/views/examples/vxe-table/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { VbenFormProps, VxeGridProps } from '#/adapter';
import { Page } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { Button, message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter';
import { getExampleTableApi } from '#/api';
Expand Down Expand Up @@ -92,11 +92,28 @@ const gridOptions: VxeGridProps<RowType> = {
},
};
const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
function toggleFormCollspae() {
gridApi.formApi.resetForm();
gridApi.setState({
formOptions: {
showCollapseButton: !(
gridApi.state?.formOptions?.showCollapseButton ?? true
),
},
});
}
</script>

<template>
<Page auto-content-height>
<Grid />
<Grid>
<template #toolbar-tools>
<Button type="primary" @click="toggleFormCollspae">
切换表单折叠按钮
</Button>
</template>
</Grid>
</Page>
</template>