perf: improve fieldMappingTime to support format function (#5392)

This commit is contained in:
Netfan
2025-01-14 18:15:00 +08:00
committed by GitHub
parent 76c4aa2c55
commit fb0ec05ff8
3 changed files with 12 additions and 4 deletions

View File

@@ -371,6 +371,9 @@ export class FormApi {
if (format === null) {
values[startTimeKey] = startTime;
values[endTimeKey] = endTime;
} else if (isFunction(format)) {
values[startTimeKey] = format(startTime, startTimeKey);
values[endTimeKey] = format(endTime, endTimeKey);
} else {
const [startTimeFormat, endTimeFormat] = Array.isArray(format)
? format

View File

@@ -4,7 +4,7 @@ import type { ZodTypeAny } from 'zod';
import type { Component, HtmlHTMLAttributes, Ref } from 'vue';
import type { VbenButtonProps } from '@vben-core/shadcn-ui';
import type { ClassType, MaybeComputedRef, Nullable } from '@vben-core/typings';
import type { ClassType, MaybeComputedRef } from '@vben-core/typings';
import type { FormApi } from './form-api';
@@ -224,7 +224,12 @@ export type HandleResetFn = (
export type FieldMappingTime = [
string,
[string, string],
([string, string] | Nullable<string>)?,
(
| ((value: any, fieldName: string) => any)
| [string, string]
| null
| string
)?,
][];
export interface FormSchema<