feat: 表单 Schema 支持组件 Props 映射泛型,同步适配VxeGrid

This commit is contained in:
dullathanol
2026-04-04 23:40:27 +08:00
committed by allen
parent cb5e7e00f1
commit 064a6a20f0
29 changed files with 516 additions and 662 deletions

View File

@@ -41,6 +41,7 @@ export interface SeparatorOptions {
export interface VxeGridProps<
T extends Record<string, any> = any,
D extends BaseFormComponentType = BaseFormComponentType,
P extends Record<string, any> = Record<never, never>,
> {
/**
* 数据
@@ -73,7 +74,7 @@ export interface VxeGridProps<
/**
* 表单配置
*/
formOptions?: VbenFormProps<D>;
formOptions?: VbenFormProps<D, P>;
/**
* 显示搜索表单
*/
@@ -87,10 +88,11 @@ export interface VxeGridProps<
export type ExtendedVxeGridApi<
D extends Record<string, any> = any,
F extends BaseFormComponentType = BaseFormComponentType,
P extends Record<string, any> = Record<never, never>,
> = VxeGridApi<D> & {
useStore: <T = NoInfer<VxeGridProps<D, F>>>(
selector?: (state: NoInfer<VxeGridProps<any, any>>) => T,
) => Readonly<Ref<T>>;
useStore: <S = NoInfer<VxeGridProps<D, F, P>>>(
selector?: (state: NoInfer<VxeGridProps<any, any, any>>) => S,
) => Readonly<Ref<S>>;
};
export interface SetupVxeTable {

View File

@@ -22,10 +22,15 @@ type FilteredSlots<T> = {
export function useVbenVxeGrid<
T extends Record<string, any> = any,
D extends BaseFormComponentType = BaseFormComponentType,
>(options: VxeGridProps<T, D>) {
P extends Record<string, any> = Record<never, never>,
>(options: VxeGridProps<T, D, P>) {
// const IS_REACTIVE = isReactive(options);
const api = new VxeGridApi(options);
const extendedApi: ExtendedVxeGridApi<T, D> = api as ExtendedVxeGridApi<T, D>;
const api = new VxeGridApi(options as VxeGridProps);
const extendedApi: ExtendedVxeGridApi<T, D, P> = api as ExtendedVxeGridApi<
T,
D,
P
>;
extendedApi.useStore = (selector) => {
return useStore(api.store, selector);
};