mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 18:40:22 +08:00
fix: 修复BasicForm使用componentProps函数返回valueFormat时DatePicker无法正确格式化的问题 (#3357)
* 修复BasicForm使用componentProps函数返回valueFormat时DatePicker无法正确格式化的问题 * chore: resolve prettier error --------- Co-authored-by: invalid w <wangjuesix@gmail.com>
This commit is contained in:
parent
b0e8154f9f
commit
beee35173b
@ -63,6 +63,7 @@
|
|||||||
import { basicProps } from './props';
|
import { basicProps } from './props';
|
||||||
import { useDesign } from '@/hooks/web/useDesign';
|
import { useDesign } from '@/hooks/web/useDesign';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
import { TableActionType } from '@/components/Table';
|
||||||
|
|
||||||
defineOptions({ name: 'BasicForm' });
|
defineOptions({ name: 'BasicForm' });
|
||||||
|
|
||||||
@ -124,7 +125,12 @@
|
|||||||
const getSchema = computed((): FormSchema[] => {
|
const getSchema = computed((): FormSchema[] => {
|
||||||
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
||||||
for (const schema of schemas) {
|
for (const schema of schemas) {
|
||||||
const { defaultValue, component, componentProps, isHandleDateDefaultValue = true } = schema;
|
const {
|
||||||
|
defaultValue,
|
||||||
|
component,
|
||||||
|
componentProps = {},
|
||||||
|
isHandleDateDefaultValue = true,
|
||||||
|
} = schema;
|
||||||
// handle date type
|
// handle date type
|
||||||
if (
|
if (
|
||||||
isHandleDateDefaultValue &&
|
isHandleDateDefaultValue &&
|
||||||
@ -132,7 +138,17 @@
|
|||||||
component &&
|
component &&
|
||||||
dateItemType.includes(component)
|
dateItemType.includes(component)
|
||||||
) {
|
) {
|
||||||
const valueFormat = componentProps ? componentProps['valueFormat'] : null;
|
const opt = {
|
||||||
|
schema,
|
||||||
|
tableAction: props.tableAction ?? ({} as TableActionType),
|
||||||
|
formModel,
|
||||||
|
formActionType: {} as FormActionType,
|
||||||
|
};
|
||||||
|
const valueFormat = componentProps
|
||||||
|
? typeof componentProps === 'function'
|
||||||
|
? componentProps(opt)['valueFormat']
|
||||||
|
: componentProps['valueFormat']
|
||||||
|
: null;
|
||||||
if (!Array.isArray(defaultValue)) {
|
if (!Array.isArray(defaultValue)) {
|
||||||
schema.defaultValue = valueFormat
|
schema.defaultValue = valueFormat
|
||||||
? dateUtil(defaultValue).format(valueFormat)
|
? dateUtil(defaultValue).format(valueFormat)
|
||||||
|
Loading…
Reference in New Issue
Block a user