feat: useVxeTable returns formApi instance (#4582)

This commit is contained in:
Vben
2024-10-07 13:32:37 +08:00
committed by GitHub
parent 60c615ce8a
commit f8ce3fdf1f
5 changed files with 67 additions and 62 deletions

View File

@@ -1,3 +1,4 @@
import type { ExtendedFormApi } from '@vben-core/form-ui';
import type { VxeGridInstance } from 'vxe-table';
import type { VxeGridProps } from './types';
@@ -23,14 +24,16 @@ function getDefaultState(): VxeGridProps {
}
export class VxeGridApi {
private isMounted = false;
private stateHandler: StateHandler;
public formApi = {} as ExtendedFormApi;
// private prevState: null | VxeGridProps = null;
public grid = {} as VxeGridInstance;
isMounted = false;
public state: null | VxeGridProps = null;
stateHandler: StateHandler;
public store: Store<VxeGridProps>;
constructor(options: VxeGridProps = {}) {
@@ -52,9 +55,10 @@ export class VxeGridApi {
bindMethods(this);
}
mount(instance: null | VxeGridInstance) {
mount(instance: null | VxeGridInstance, formApi: ExtendedFormApi) {
if (!this.isMounted && instance) {
this.grid = instance;
this.formApi = formApi;
this.stateHandler.setConditionTrue();
this.isMounted = true;
}

View File

@@ -217,7 +217,7 @@ async function init() {
}
onMounted(() => {
props.api?.mount?.(gridRef.value);
props.api?.mount?.(gridRef.value, formApi);
init();
});
</script>