fix: table search form slot not working as expected
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import type { VxeGridProps } from 'vxe-table';
|
||||
import type { VxeGridProps, VxeUIExport } from 'vxe-table';
|
||||
|
||||
import type { VxeGridApi } from './api';
|
||||
|
||||
import { isFunction } from '@vben/utils';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export function extendProxyOptions(
|
||||
api: VxeGridApi,
|
||||
options: VxeGridProps,
|
||||
@@ -48,3 +50,17 @@ function extendProxyOption(
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function extendsDefaultFormatter(vxeUI: VxeUIExport) {
|
||||
vxeUI.formats.add('formatDate', {
|
||||
tableCellFormatMethod({ cellValue }) {
|
||||
return dayjs(cellValue).format('YYYY-MM-DD');
|
||||
},
|
||||
});
|
||||
|
||||
vxeUI.formats.add('formatDateTime', {
|
||||
tableCellFormatMethod({ cellValue }) {
|
||||
return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@@ -1,17 +0,0 @@
|
||||
import type { VxeUIExport } from 'vxe-table';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export function initDefaultFormatter(vxeUI: VxeUIExport) {
|
||||
vxeUI.formats.add('formatDate', {
|
||||
tableCellFormatMethod({ cellValue }) {
|
||||
return dayjs(cellValue).format('YYYY-MM-DD');
|
||||
},
|
||||
});
|
||||
|
||||
vxeUI.formats.add('formatDateTime', {
|
||||
tableCellFormatMethod({ cellValue }) {
|
||||
return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss');
|
||||
},
|
||||
});
|
||||
}
|
@@ -41,7 +41,7 @@ import {
|
||||
VxeToolbar,
|
||||
} from 'vxe-table';
|
||||
|
||||
import { initDefaultFormatter } from './formatter';
|
||||
import { extendsDefaultFormatter } from './extends';
|
||||
|
||||
// 是否加载过
|
||||
let isInit = false;
|
||||
@@ -120,6 +120,7 @@ export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
|
||||
},
|
||||
);
|
||||
|
||||
initDefaultFormatter(VxeUI);
|
||||
extendsDefaultFormatter(VxeUI);
|
||||
|
||||
configVxeTable(VxeUI);
|
||||
}
|
||||
|
@@ -204,7 +204,7 @@ async function init() {
|
||||
'[Vben Vxe Table]: The formConfig in the grid is not supported, please use the `formOptions` props',
|
||||
);
|
||||
}
|
||||
|
||||
props.api?.setState?.({ gridOptions: defaultGridOptions });
|
||||
// form 由 vben-form 代替,所以需要保证query相关事件可以拿到参数
|
||||
extendProxyOptions(props.api, defaultGridOptions, () => formApi.form.values);
|
||||
}
|
||||
@@ -267,7 +267,10 @@ onMounted(() => {
|
||||
:key="slotName"
|
||||
#[slotName]="slotProps"
|
||||
>
|
||||
<slot :name="slotName" v-bind="slotProps"></slot>
|
||||
<slot
|
||||
:name="`${FORM_SLOT_PREFIX}${slotName}`"
|
||||
v-bind="slotProps"
|
||||
></slot>
|
||||
</template>
|
||||
</Form>
|
||||
</slot>
|
||||
|
Reference in New Issue
Block a user