diff --git a/src/components/formFields/common.less b/src/components/formFields/common.less new file mode 100644 index 0000000000000000000000000000000000000000..6fe10b8d81cb6cf081a173bd2b64c8d21f0729f2 --- /dev/null +++ b/src/components/formFields/common.less @@ -0,0 +1,7 @@ +.ccms-antd-label-vertical-flex-start { + :global { + .ant-form-item-label > label { + align-items: flex-start!important; + } + } +} \ No newline at end of file diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index 77d2fb1d45cdd5cefd38bf719025e7abe24c79df..d43b418d685ab3c39a574379c3a5864ea79de833 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -5,6 +5,7 @@ import { PlusOutlined, MinusCircleOutlined, ArrowUpOutlined, ArrowDownOutlined, import { IFormField, IFormFieldItem, IFormFieldItemField } from 'ccms/dist/src/components/formFields/form' import getALLComponents from '../' import { formItemLayout } from '../common' +import commonStyles from '../common.less' export default class FormFieldComponent extends FormField { getALLComponents = (type: any) => getALLComponents[type] @@ -14,6 +15,7 @@ export default class FormFieldComponent extends FormField { renderItemFieldComponent = (props: IFormFieldItemField) => { const { label, + subLabel, status, message, extra, @@ -30,7 +32,9 @@ export default class FormFieldComponent extends FormField { validateStatus={ status === 'normal' ? undefined : status === 'error' ? 'error' : 'validating' } help={ message === '' ? null : message} {...formItemLayout(layout, fieldType, label)} + // className={ layout === 'horizontal' && subLabel ? commonStyles['ccms-antd-label-vertical-flex-start']: null } > + {subLabel || null} {children} ) diff --git a/src/components/formFields/group/index.tsx b/src/components/formFields/group/index.tsx index aa638cc9826b77a66986c3860caae7c628a8cf4c..54baad6e90e3389cc7efd66bba34ac06b1cdd7d6 100644 --- a/src/components/formFields/group/index.tsx +++ b/src/components/formFields/group/index.tsx @@ -4,6 +4,7 @@ import { IGroupField, GroupFieldConfig } from "ccms/dist/src/components/formFiel import { IFormItem } from "ccms/dist/src/steps/form"; import { Form } from "antd" import getALLComponents from '../' +import commonStyles from '../common.less' import styles from './index.less' import { formItemLayout, computedItemStyle, computedGapStyle } from "../common"; @@ -37,6 +38,7 @@ export default class GroupFieldComponent extends GroupField { layout, columns, label, + subLabel, visitable, status, message, @@ -72,8 +74,10 @@ export default class GroupFieldComponent extends GroupField { validateStatus={status === 'normal' ? undefined : status === 'error' ? 'error' : 'validating'} help={fieldType === 'import_subform' || fieldType === 'group' || message === '' ? null : message} className={styles[`ccms-antd-mini-form-${fieldType}`]} + // className={ [styles[`ccms-antd-mini-form-${fieldType}`], layout === 'horizontal' && subLabel ? commonStyles['ccms-antd-label-vertical-flex-start']: null].join(' ') } style={itemStyle} > + {subLabel || null} {children} diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index 3187024f2f27d7a787c3e916f8409de096cd2b82..7c86ad81d0d3da106e9fdc5d20c319c490b23c48 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -5,6 +5,7 @@ import { IFormItem } from "ccms/dist/src/steps/form"; import { Form } from "antd" import { FormItemProps } from "antd/lib/form"; import getALLComponents from '../' +import commonStyles from '../common.less' import styles from './index.less' import { computedItemStyle, computedGapStyle } from "../common"; import InterfaceHelper from "../../../util/interface"; @@ -41,6 +42,7 @@ export default class ImportSubformFieldComponent extends ImportSubformField { layout, columns, label, + subLabel, visitable, status, message, @@ -75,8 +77,10 @@ export default class ImportSubformFieldComponent extends ImportSubformField { validateStatus={status === 'normal' ? undefined : status === 'error' ? 'error' : 'validating'} help={fieldType === 'group' || fieldType === 'import_subform' || message === '' ? null : message} className={styles[`ccms-antd-mini-form-${fieldType}`]} + // className={ [styles[`ccms-antd-mini-form-${fieldType}`], layout === 'horizontal' && subLabel ? commonStyles['ccms-antd-label-vertical-flex-start']: null].join(' ') } style={itemStyle} > + {subLabel || null} {children} diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index 99a684f6c936279da921d6dccf46091e14e2a8ff..eeb4772a745eee7030c5ffbc44de54b2467706bf 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -5,6 +5,7 @@ import { ITabsField, ITabsFieldItem, ITabsFieldItemField } from 'ccms/dist/src/c import getALLComponents from '../' import { Field } from 'ccms/dist/src/components/formFields/common' import { formItemLayout } from '../common' +import commonStyles from '../common.less' export default class TabsFieldComponent extends TabsField<{}> { // 各表单项对应的类型所使用的UI组件的类 @@ -13,6 +14,7 @@ export default class TabsFieldComponent extends TabsField<{}> { renderItemFieldComponent = (props: ITabsFieldItemField) => { const { label, + subLabel, status, message, extra, @@ -30,7 +32,9 @@ export default class TabsFieldComponent extends TabsField<{}> { validateStatus={ status === 'normal' ? undefined : status === 'error' ? 'error' : 'validating' } help={ message === '' ? null : message} {...formItemLayout(layout, fieldType, label)} + // className={ layout === 'horizontal' && subLabel ? commonStyles['ccms-antd-label-vertical-flex-start']: null } > + {subLabel || null} {children} ) diff --git a/src/steps/form/index.less b/src/steps/form/index.less index 05534b25084855dd65e50d94e116b54b0f45dee8..b7acf1a472f7185d4214a990faaf23e8b9b29d0f 100644 --- a/src/steps/form/index.less +++ b/src/steps/form/index.less @@ -79,3 +79,10 @@ border-bottom: 1px solid #f1f1f1; } } +.ccms-antd-label-vertical-flex-start { + :global { + .ant-form-item-label > label { + align-items: flex-start!important; + } + } +} \ No newline at end of file diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index 6a1d50215aa8a546b944c533d558dc56f7313dc2..bfc738ec86ec8bccce211574e35b330e675f5293 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -57,7 +57,8 @@ export default class FormStepComponent extends FormStep {
+ {subLabel || null} {children} }