mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
feat: useVxeTable returns formApi instance (#4582)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -217,7 +217,7 @@ async function init() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.api?.mount?.(gridRef.value);
|
||||
props.api?.mount?.(gridRef.value, formApi);
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user