diff --git a/.eslintrc b/.eslintrc index f574bbc264e3ce7a35f8589473d31448b0769b94..cff24b5cdfa882623d223bf0db74816e1315a989 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,15 +39,27 @@ ] }, "rules": { - "import/no-unresolved": 1, - "import/no-cycle": 1, - "import/no-extraneous-dependencies": 1, - "@typescript-eslint/no-empty-function": 1, - "typescript-eslint/no-explicit-any": 0, "react/jsx-props-no-spreading": 0, - "no-use-before-define": "off", + "no-use-before-define": 0, "react/display-name": 0, "import/extensions": 0, + "import/no-cycle": 0, + "consistent-return": 0, + "no-restricted-syntax": 0, + "import/no-extraneous-dependencies": 1, + "@typescript-eslint/no-empty-function": 1, + "typescript-eslint/no-explicit-any": 0, + "no-underscore-dangle": 0, + "no-unused-expressions": 0, + "no-plusplus": 0, + "no-continue": 0, + "react/no-array-index-key": 1, + "no-return-await": 1, + "import/no-unresolved": 1, + "no-await-in-loop": 1, + "no-nested-ternary": 1, + "react/jsx-no-useless-fragment": 1, + "no-shadow": 1, "comma-dangle": [ "error", "never" diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index bfc738ec86ec8bccce211574e35b330e675f5293..e18e9af3fc607b6b8b2c017ff0eb9f783ad568a2 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -1,18 +1,20 @@ import React from 'react' import { FormStep } from 'ccms' import { IForm, IFormItem, IFormStepModal, FormConfig, IButtonProps } from 'ccms/dist/src/steps/form' -import { Button, Form, Space, Modal, Collapse } from 'antd' -const { Panel } = Collapse; +import { Button, Form, Space, Modal, Collapse, Row } from 'antd' import { FormProps } from 'antd/lib/form' import getALLComponents from '../../components/formFields' import OperationHelper from '../../util/operation' -import styles from "./index.less" +import styles from './index.less' import { formItemLayout, computedItemStyle, computedGapStyle } from '../../components/formFields/common' -import newstyles from "../../main.less" +import newstyles from '../../main.less' + +const { Panel } = Collapse export default class FormStepComponent extends FormStep { getALLComponents = (type: any) => getALLComponents[type] + OperationHelper = OperationHelper renderModalComponent = (props: IFormStepModal) => { @@ -31,24 +33,15 @@ export default class FormStepComponent extends FormStep { } renderComponent = (props: IForm) => { - const { - layout, - columns, - actions, - onSubmit, - onCancel, - submitText, - cancelText, - children - } = props + const { layout, columns, actions, rightTopActions, onSubmit, onCancel, submitText, cancelText, children } = props const formItemLayout: FormProps | null = layout === 'horizontal' ? { - labelAlign: 'left', - labelCol: { span: 6 }, - wrapperCol: { span: 18 } - } + labelAlign: 'left', + labelCol: { span: 6 }, + wrapperCol: { span: 18 } + } : null const gapStyle = computedGapStyle(columns, 'row') @@ -57,57 +50,41 @@ export default class FormStepComponent extends FormStep {
-
+ {Array.isArray(rightTopActions) && rightTopActions.length > 0 && ( + + + {rightTopActions} + + + )} +
{children}
- { - (Array.isArray(actions) ? actions.length > 0 : (onSubmit || onCancel)) && - - {Array.isArray(actions) - ? actions - : - {onSubmit && } - {onCancel && } - - } - + {Array.isArray(actions) && actions.length > 0 && ( + + {actions} - } + )} ) } renderButtonComponent = (props: IButtonProps) => { - const { - mode, - label, - onClick - } = props - return + const { mode, label, onClick } = props + return ( + + ) } renderItemComponent = (props: IFormItem) => { - const { - key, - visitable, - layout, - columns, - label, - subLabel, - status, - message, - extra, - required, - fieldType, - children - } = props + const { key, visitable, layout, columns, label, subLabel, status, message, extra, required, fieldType, children } = + props const colStyle = computedItemStyle(columns, layout, visitable) const itemStyle = visitable ? {} : { overflow: 'hidden', width: 0, height: 0, margin: 0, padding: 0 } if (columns?.type === 'width' && columns?.value && columns.wrap) { @@ -118,48 +95,48 @@ export default class FormStepComponent extends FormStep {
- { - fieldType === 'group' ? this.renderGroupUI(label, children, 'header') : - - {subLabel || null} - {children} - } + {fieldType === 'group' ? ( + this.renderGroupUI(label, children, 'header') + ) : ( + + {subLabel || null} + {children} + + )}
) } // group UI renderGroupUI = (label: string, children: any, collapsible?: 'header' | 'disabled') => { - return - -
- {children} -
-
-
+ return ( + + +
{children}
+
+
+ ) } } // -export const PropsType = (props: IForm) => { }; +export const PropsType = (props: IForm) => {} -export const PropsTypeFormConfig = (props: FormConfig) => { }; -export const PropsTypeStep = (props: FormStep) => { }; \ No newline at end of file +export const PropsTypeFormConfig = (props: FormConfig) => {} +export const PropsTypeStep = (props: FormStep) => {}