diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 193a48ea2257c16cbed9c27ddbc8f7064b6cc68a..7b61b702fcb3f0cc9169ebfcf637d01f8d206b74 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -334,6 +334,7 @@ const Cell = (props: CellProps) => { const value = setFormat(editConfig, columnConfig, changedValue, optionValue); emitChangeCellData(value, optionValue); }} + cellRenderProps={cellRenderProps} style={{ minHeight: cellStyle.height, borderRadius: 0, diff --git a/components/apolloTable/component/Table.tsx b/components/apolloTable/component/Table.tsx index ccd1e4345ca8a102be515398a9911acdc8340f76..409ab26371adf4fdbfb5386a8b00f41b59a28412 100644 --- a/components/apolloTable/component/Table.tsx +++ b/components/apolloTable/component/Table.tsx @@ -55,11 +55,9 @@ export default class AirTable extends Component { }; if (JSON.stringify(dataSource) !== JSON.stringify(nextProps.dataSource)) { nextState.dataSource = nextProps.dataSource; - nextState.selectedCell = null; } if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) { nextState.columns = nextProps.columns; - nextState.selectedCell = null; } return nextState; } @@ -72,7 +70,6 @@ export default class AirTable extends Component { dataSource, tableWidth: width, tableHeight: height, - selectedCell: null, }; this.config = { overscanColumnCount: 5, @@ -216,12 +213,6 @@ export default class AirTable extends Component { } }; - changeSelectedCell = (key) => { - this.setState({ - selectedCell: key, - }); - }; - // 列伸缩回调 onResizeWidth = (e) => { const originLeft = (this.tableContainer && this.tableContainer.getBoundingClientRect().x) || 0; @@ -312,10 +303,10 @@ export default class AirTable extends Component { } }; // 拖拽排序回调 - onDragSorted = (dragColumn:any, dropColumn:any) => { + onDragSorted = (dragColumn: any, dropColumn: any) => { const { onDragSorted } = this.props; const { columns } = this.state; - const newColumns:any[] = []; + const newColumns: any[] = []; columns.map((item) => { if (dragColumn.orderNo > dropColumn.orderNo) { if (item.orderNo >= dropColumn.orderNo && item.orderNo <= dragColumn.orderNo) { @@ -387,6 +378,7 @@ export default class AirTable extends Component { > { }: { showColumns: ColumnProps[]; showData: RowProps; position?: string }, { columnIndex, key, rowIndex, style }: any, ) => { - const { columns, dataSource, selectedCell } = this.state; + const { columns, dataSource } = this.state; const { emitChangeCell, paginationConfig, @@ -507,8 +499,6 @@ export default class AirTable extends Component { cellEditable={cellEditable} rowSelection={position === 'right' ? false : rowSelection} contentMenu={contentMenu} - selectedCell={selectedCell} - changeSelectedCell={this.changeSelectedCell} cellKey={key} position={position} /> diff --git a/components/apolloTable/component/base/detail/tag/index.tsx b/components/apolloTable/component/base/detail/tag/index.tsx index c45015b7e695d9cc851bd177289316c633aabe07..7a8ba6e926e51d2b42ef944ce82dc4278921f9ae 100644 --- a/components/apolloTable/component/base/detail/tag/index.tsx +++ b/components/apolloTable/component/base/detail/tag/index.tsx @@ -6,6 +6,9 @@ import s from './index.less'; export const Tags = (props: any) => { const { value, origin, componentAttr, columnConfig } = props; if (!Array.isArray(value) || value.length === 0) return null; + if (value.length === 1 && !value[0].text && !value[0].value) { + return null; + } const { options, mode } = componentAttr || {}; const outStyle: any = {}; const innerStyle: any = {}; @@ -18,9 +21,10 @@ export const Tags = (props: any) => { const getColor = (item: any) => { let color = ''; if (options && Array.isArray(options) && options.length > 0) { - const obj = options.find((ls) => { - return String(ls.id) === String(item.value); - }) || {}; + const obj = + options.find((ls) => { + return String(ls.id) === String(item.value); + }) || {}; color = obj.color || 'e9eef9'; } return color; diff --git a/components/apolloTable/component/base/edit/text-select/index.tsx b/components/apolloTable/component/base/edit/text-select/index.tsx index 8d723451efebfa2a437e6aa71be4403b6614333f..4cd551cef8f0e3937fa2627178f5d5af6756fc79 100644 --- a/components/apolloTable/component/base/edit/text-select/index.tsx +++ b/components/apolloTable/component/base/edit/text-select/index.tsx @@ -5,7 +5,7 @@ import { antiAssign } from '../../../../utils/utils'; import s from './index.less'; export const ApolloInputSearch = (props: ApolloInputSearchProps) => { - const { onChange, request, type } = props; + const { onChange, request } = props; const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'request']); const changeValue = (value) => { @@ -17,7 +17,7 @@ export const ApolloInputSearch = (props: ApolloInputSearchProps) => { return ( { return request({ name: val, fieldValueName: type }); }} + request={request} fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }} {...selfProps} onChange={changeValue} diff --git a/components/apolloTable/component/interface.tsx b/components/apolloTable/component/interface.tsx index f7f341db93a29794862c378cc7c417fc3de98c9e..58217f0c373d1d5ba9a58bbfd56413a7e37ee24e 100644 --- a/components/apolloTable/component/interface.tsx +++ b/components/apolloTable/component/interface.tsx @@ -83,7 +83,6 @@ export interface TableState { dataSource: RowProps[]; tableHeight?: number; tableWidth?: number; - selectedCell?: any; } export interface CommonProps extends TableProps { operateConfig?: OperateConfigProps; diff --git a/components/apolloTable/editFormV3/index.tsx b/components/apolloTable/editFormV3/index.tsx index 06bfc0c87a200da5ea113f3b70c7a3a5e5da78c6..4224d6e60a9e446ae305506fb880a4175caa0fe3 100644 --- a/components/apolloTable/editFormV3/index.tsx +++ b/components/apolloTable/editFormV3/index.tsx @@ -25,7 +25,7 @@ class FormWrap extends Component { handleSubmit = (e) => { e.preventDefault(); e.stopPropagation(); - const { rowId, form, handleSubmit, data, rowData } = this.props; + const { rowId, form, handleSubmit, data, rowData, detailType } = this.props; form.validateFieldsAndScroll((err, values) => { if (!err) { const newValues: any[] = []; @@ -33,7 +33,7 @@ class FormWrap extends Component { const item = data.find((temp: any) => { return temp.columnName === key; }); - const { columnType, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item; + const { columnType, columnAttrObj, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item; if (readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) { return; } @@ -44,13 +44,15 @@ class FormWrap extends Component { detailConfig = config[String(columnType)] || config['1']; } const cellValueList = setFormat(detailConfig, item, values[key]); - newValues.push({ + const newData: any = { columnCode: key, cellValueList, - }); + }; + newValues.push(newData); }); + if (typeof handleSubmit === 'function') { - handleSubmit({ data: { value: newValues } }); + handleSubmit({ data: { value: newValues }, formValues: values, detailType }); } } }); @@ -82,7 +84,7 @@ class FormWrap extends Component { renderEditForm = (item) => { const { getFieldDecorator } = this.props.form; - const { rowData } = this.props; + const { rowData, rowId } = this.props; const { columnType, columnName, @@ -94,6 +96,7 @@ class FormWrap extends Component { validateFirst = true, validateTrigger = 'onChange', dynamicCellConfigDTO, + cellRenderProps, } = item; let detailConfig: any; if (typeof renderEditForm === 'function') { @@ -114,13 +117,15 @@ class FormWrap extends Component { {getFieldDecorator(columnName, { validateFirst, validateTrigger, - rules: [{ required: !!item.requiredFlag, message: '必填项不能为空' }, ...rules], + // rules: [{ required: !!item.requiredFlag, message: '必填项不能为空' }, ...rules], initialValue: getFormat(detailConfig, item, value), })( ,