feat:增加年选择组件 (#1288)

This commit is contained in:
吴多益 2020-12-30 16:44:33 +08:00 committed by GitHub
parent 968364f87f
commit 9350067327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,27 @@
---
title: Year 年
description:
type: 0
group: null
menuName: Year 年
icon:
order: 61
---
## 基本用法
```schema:height="400" scope="body"
{
"type": "form",
"api": "https://houtai.baidu.com/api/mock2/form/saveForm",
"controls": [
{
"type": "year",
"name": "year",
"label": "年"
}
]
}
```
更多用法和配置可以参考 [Date 日期](date)year 就是 data 的特定配置,所以 data 的所有配置都能使用。

View File

@ -692,6 +692,15 @@ export const docs = [
import('../../docs/components/form/treeselect.md').then(
makeMarkdownRenderer
)
},
{
label: 'Year 年',
path: '/docs/components/form/year',
getComponent: () =>
// @ts-ignore
import('../../docs/components/form/year.md').then(
makeMarkdownRenderer
)
}
]
},

View File

@ -343,3 +343,18 @@ export class MonthControlRenderer extends DateControl {
closeOnSelect: true
};
}
@FormItem({
type: 'year'
})
export class YearControlRenderer extends DateControl {
static defaultProps = {
...DateControl.defaultProps,
placeholder: '请选择年',
inputFormat: 'YYYY',
dateFormat: 'YYYY',
timeFormat: '',
viewMode: 'years',
closeOnSelect: true
};
}