Browse Source
From default value (#2913)
* feat: defaultValue赋值后不改动时间相关字段无法格式化问题
* feat: 更新处理方式
* feat: 去除未引用方法
---------
Co-authored-by: zhangshujun <zhangsj01@51cto.com>
pull/2917/head
zhangshujun
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
3 deletions
-
src/components/Form/src/BasicForm.vue
|
|
|
@ -117,15 +117,18 @@ |
|
|
|
const getSchema = computed((): FormSchema[] => { |
|
|
|
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any); |
|
|
|
for (const schema of schemas) { |
|
|
|
const { defaultValue, component, isHandleDateDefaultValue = true } = schema; |
|
|
|
const { defaultValue, component, componentProps,isHandleDateDefaultValue = true } = schema; |
|
|
|
// handle date type |
|
|
|
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) { |
|
|
|
const valueFormat =componentProps ? componentProps['valueFormat'] : null; |
|
|
|
if (!Array.isArray(defaultValue)) { |
|
|
|
schema.defaultValue = dateUtil(defaultValue); |
|
|
|
schema.defaultValue = valueFormat |
|
|
|
? dateUtil(defaultValue).format(valueFormat) |
|
|
|
: dateUtil(defaultValue); |
|
|
|
} else { |
|
|
|
const def: any[] = []; |
|
|
|
defaultValue.forEach((item) => { |
|
|
|
def.push(dateUtil(item)); |
|
|
|
def.push(valueFormat ? dateUtil(item).format(valueFormat) : dateUtil(item)); |
|
|
|
}); |
|
|
|
schema.defaultValue = def; |
|
|
|
} |
|
|
|
|