From 93500673275ee86eeac83bb34a61ce59682848d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=A4=9A=E7=9B=8A?= Date: Wed, 30 Dec 2020 16:44:33 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=E5=B9=B4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6=20(#1288)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/form/year.md | 27 +++++++++++++++++++++++++++ examples/components/Doc.tsx | 9 +++++++++ src/renderers/Form/Date.tsx | 15 +++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 docs/components/form/year.md diff --git a/docs/components/form/year.md b/docs/components/form/year.md new file mode 100644 index 000000000..f1a460c57 --- /dev/null +++ b/docs/components/form/year.md @@ -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 的所有配置都能使用。 diff --git a/examples/components/Doc.tsx b/examples/components/Doc.tsx index e667703ec..3b5e8cb38 100644 --- a/examples/components/Doc.tsx +++ b/examples/components/Doc.tsx @@ -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 + ) } ] }, diff --git a/src/renderers/Form/Date.tsx b/src/renderers/Form/Date.tsx index 47e5de787..fe11f92e7 100644 --- a/src/renderers/Form/Date.tsx +++ b/src/renderers/Form/Date.tsx @@ -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 + }; +}