diff --git a/components/apolloTable/component/base/extra/dataEntry/textSelect/index.tsx b/components/apolloTable/component/base/extra/dataEntry/textSelect/index.tsx index 946f99b492699e21c368cfc72121b66f9dd406de..d7bbb798747c750af14fa63d67a1177a6b929687 100644 --- a/components/apolloTable/component/base/extra/dataEntry/textSelect/index.tsx +++ b/components/apolloTable/component/base/extra/dataEntry/textSelect/index.tsx @@ -137,11 +137,7 @@ class TextSelect extends React.Component { onChange = (obj) => { const { onChange } = this.props; if (typeof onChange === 'function') { - if (!obj || (!obj.label && !obj.value)) { - onChange(undefined); - } else { - onChange(obj); - } + onChange(obj); } }; @@ -158,7 +154,11 @@ class TextSelect extends React.Component { }; onVisibleChange = (tempVisible) => { + const { onDropdownVisibleChange } = this.props; this.setState({ tempVisible }); + if (onDropdownVisibleChange) { + onDropdownVisibleChange(tempVisible); + } }; renderList = () => { diff --git a/components/apolloTable/editFormV3/index.tsx b/components/apolloTable/editFormV3/index.tsx index 1192ea5c04cbfd963b8089a9232b57e29f83f717..f9c795ac33a055d17113dac02e4b19c422131145 100644 --- a/components/apolloTable/editFormV3/index.tsx +++ b/components/apolloTable/editFormV3/index.tsx @@ -89,6 +89,30 @@ class FormWrap extends Component { ); }; + validateRequired = (item, rule, value, callback) => { + if (!item.requiredFlag) { + return callback(); + } + if (!value) { + return callback('必填项不能为空'); + } + if (Array.isArray(value)) { + if (value.length === 0) { + return callback('必填项不能为空'); + } + const [first] = value; + if (!first.text && first.text !== 0 && !first.value && first.value !== 0) { + return callback('必填项不能为空'); + } + } + if (typeof value === 'object') { + if (!value.text && value.text !== 0 && !value.value && value.value !== 0) { + return callback('必填项不能为空'); + } + } + return callback(); + }; + renderEditForm = (item) => { const { getFieldDecorator } = this.props.form; const { rowData, rowId, getInstanceDetail, onBlurFn } = this.props; @@ -141,7 +165,11 @@ class FormWrap extends Component { {getFieldDecorator(columnName, { validateFirst, validateTrigger, - rules: [{ required: !!item.requiredFlag, message: '必填项不能为空' }, ...rules], + rules: [ + { required: !!item.requiredFlag, message: '必填项不能为空' }, + { validator: this.validateRequired.bind(this, item) }, + ...rules, + ], initialValue: getFormat(detailConfig, item, value), })(