feat(Form): 为fieldMapToTime的映射类型增加时间戳转换
parent
f1bc5e738a
commit
8030b54795
|
@ -107,14 +107,24 @@ export function useFormValues({ defaultValueRef, getSchema, formModel, getProps
|
|||
|
||||
const [startTimeFormat, endTimeFormat] = Array.isArray(format) ? format : [format, format]
|
||||
|
||||
values[startTimeKey] = dateUtil(startTime).format(startTimeFormat)
|
||||
values[endTimeKey] = dateUtil(endTime).format(endTimeFormat)
|
||||
values[startTimeKey] = formatTime(startTime, startTimeFormat)
|
||||
values[endTimeKey] = formatTime(endTime, endTimeFormat)
|
||||
Reflect.deleteProperty(values, field)
|
||||
}
|
||||
|
||||
return values
|
||||
}
|
||||
|
||||
function formatTime(time: string, format: string) {
|
||||
if (format === 'timestamp')
|
||||
return dateUtil(time).unix()
|
||||
|
||||
else if (format === 'timestampStartDay')
|
||||
return dateUtil(time).startOf('day').unix()
|
||||
|
||||
return dateUtil(time).format(format)
|
||||
}
|
||||
|
||||
function initDefault() {
|
||||
const schemas = unref(getSchema)
|
||||
const obj: Recordable = {}
|
||||
|
|
Loading…
Reference in New Issue