未验证 提交 bc499744 编写于 作者: S sevth 提交者: GitHub

feat(Form):...

feat(Form): 支持`filedMapToTime`分别格式化时间,支持配置时间相关组件默认值处理开关,当组件配置`valueFormat`时,默认值绑定不再是`moment`对象,此时应关闭默认值的转换处理 (#2305)

* fix: 修复使用 extendSlots 时插槽参数未传递的问题。

* feat(Form): `fieldMapToTime`additional time formatting support separately.

* fix(Form): Add `isHandleDateDefaultValue` property.
Co-authored-by: Nsevth <pengqiang@vastweb>
上级 c8b16949
......@@ -118,9 +118,9 @@
const getSchema = computed((): FormSchema[] => {
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
for (const schema of schemas) {
const { defaultValue, component } = schema;
const { defaultValue, component, isHandleDateDefaultValue = true } = schema;
// handle date type
if (defaultValue && dateItemType.includes(component)) {
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) {
if (!Array.isArray(defaultValue)) {
schema.defaultValue = dateUtil(defaultValue);
} else {
......
......@@ -108,8 +108,10 @@ export function useFormValues({
const [startTime, endTime]: string[] = values[field];
values[startTimeKey] = dateUtil(startTime).format(format);
values[endTimeKey] = dateUtil(endTime).format(format);
const [startTimeFormat, endTimeFormat] = Array.isArray(format) ? format : [format, format];
values[startTimeKey] = dateUtil(startTime).format(startTimeFormat);
values[endTimeKey] = dateUtil(endTime).format(endTimeFormat);
Reflect.deleteProperty(values, field);
}
......
......@@ -7,7 +7,7 @@ import type { TableActionType } from '/@/components/Table/src/types/table';
import type { CSSProperties } from 'vue';
import type { RowProps } from 'ant-design-vue/lib/grid/Row';
export type FieldMapToTime = [string, [string, string], string?][];
export type FieldMapToTime = [string, [string, string], (string | [string, string])?][];
export type Rule = RuleObject & {
trigger?: 'blur' | 'change' | ['change', 'blur'];
......@@ -175,6 +175,10 @@ export interface FormSchema {
// 默认值
defaultValue?: any;
// 是否自动处理与时间相关组件的默认值
isHandleDateDefaultValue?: boolean;
isAdvanced?: boolean;
// Matching details components
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册