diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 10263123f687b2b69dd2f589d94c71416d703dfd..3f696e2347ef1958ad692639520f43e5350f6f24 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -250,7 +250,7 @@ const Cell = (props: CellProps) => { const EditComp: any = editConfig.cellComp; const transferColumn = transferAttr(columnType, { - ...(config.componentAttr || {}), + ...(editConfig.componentAttr || {}), ...(columnConfig.columnAttrObj || {}), }); const newProps = { diff --git a/components/apolloTable/component/base/_utils/getFormatter.tsx b/components/apolloTable/component/base/_utils/getFormatter.tsx index 930b71dcd47dc355e9fc7d6cef91f37a55ab6820..0415a2b5aa2a64f96a0b20f028910f93644cace8 100644 --- a/components/apolloTable/component/base/_utils/getFormatter.tsx +++ b/components/apolloTable/component/base/_utils/getFormatter.tsx @@ -47,8 +47,10 @@ export const GetFormatter = { }, MULTIPLE_SELECT: (val) => { // 处理成[{}]结构 - const obj = val[0] || {}; - return { key: obj.value, label: obj.text }; + if (!Array.isArray(val) || val.length === 0) return undefined; + return val.map((item) => { + return { key: item.value, label: item.text }; + }); }, TEXT_SELECT: (val) => { return GetFormatter.SELECT(val); diff --git a/components/apolloTable/component/base/detail/input/index.less b/components/apolloTable/component/base/detail/input/index.less index 28578af43409aafd6f3cddf0fc5691a87e481315..0e181bf40ce791b9b21eea085c2212e2caaf4048 100644 --- a/components/apolloTable/component/base/detail/input/index.less +++ b/components/apolloTable/component/base/detail/input/index.less @@ -6,15 +6,16 @@ width: 100%; height: 100%; align-items: center; - .text { - width: 100%; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } .itemBgTxt { position: absolute; z-index: -1; visibility: hidden; } } +.text { + width: 100%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + word-break: break-all; +} diff --git a/components/apolloTable/component/base/detail/input/index.tsx b/components/apolloTable/component/base/detail/input/index.tsx index e7ca55f2144b57990519e77d36f5b44ad6588a73..462666c278cf29c552d7f70d509010bf59518521 100644 --- a/components/apolloTable/component/base/detail/input/index.tsx +++ b/components/apolloTable/component/base/detail/input/index.tsx @@ -5,7 +5,7 @@ import styles from './index.less'; import { InputProps } from '../detailInterface'; export const ApolloInputDetail = (props: InputProps) => { - const { className } = props; + const { className, origin } = props; const value = props.formatter ? props.formatter(props.value) : props.value; if (!value) { return null; @@ -25,6 +25,10 @@ export const ApolloInputDetail = (props: InputProps) => { } }, [value]); + if (origin === 'detailForm') { + return
{value}
; + } + if (typeof value === 'string') { return (
diff --git a/components/apolloTable/component/base/edit/select/index.tsx b/components/apolloTable/component/base/edit/select/index.tsx index 6e5bf0982854f998d142b35ed18a6ecb2e783921..5312c432d61b18b966eb8c5d551bda00ec4d3065 100644 --- a/components/apolloTable/component/base/edit/select/index.tsx +++ b/components/apolloTable/component/base/edit/select/index.tsx @@ -5,9 +5,9 @@ import { antiAssign } from '../../../../utils/utils'; import styles from './styles.less'; export const ApolloSelect = (props: ApolloSelectProps) => { - const { options = [], onChange, isMultiple, isMobile } = props; + const { options = [], onChange, isMultiple } = props; const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'isMultiple', 'options']); - const changeValue = (value, option) => { + const changeValue = (value: any, option: any) => { if (typeof onChange === 'function') { onChange(value, option); } @@ -16,9 +16,12 @@ export const ApolloSelect = (props: ApolloSelectProps) => { if (isMultiple) { selfProps.mode = 'multiple'; } - return ( - {options.map((item) => { return ( diff --git a/components/apolloTable/editFormV3/index.tsx b/components/apolloTable/editFormV3/index.tsx index 7ee4b04e92db431bfb180c982caedac925d6a786..588129e0ba8e235e818059121f71471354c48da2 100644 --- a/components/apolloTable/editFormV3/index.tsx +++ b/components/apolloTable/editFormV3/index.tsx @@ -14,9 +14,10 @@ import { Form, Button } from 'antd'; import styles from './index.less'; import { config } from '../component/base/config'; import { transferAttr } from '../component/base/_utils/transferAttr'; -import { getFormat } from '../component/base'; +import { getFormat, setFormat } from '../component/base'; import { Provider } from '../component/context'; import { defaultLocale } from '@/submodule/components/apolloTable/locale'; +import _ from 'lodash'; const FormItem = Form.Item; @@ -24,17 +25,36 @@ class FormWrap extends Component { handleSubmit = (e) => { e.preventDefault(); e.stopPropagation(); - const { rowId, form, handleSubmit } = this.props; + const { rowId, form, handleSubmit, data, rowData } = this.props; form.validateFieldsAndScroll((err, values) => { if (!err) { - const result = []; - Object.keys(values).map((el) => { - result.push({ - columnCode: el, - cellValueList: values[el], + const newValues: any[] = []; + _.keys(values).map((key) => { + const item = data.find((temp: any) => { + return temp.columnName === key; + }); + const { columnType, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item; + if (readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) { + return; + } + let detailConfig: any; + if (typeof renderEditForm === 'function') { + detailConfig = renderEditForm({ cellData: values[key], rowData, columnConfig: item }); + } else { + detailConfig = config[String(columnType)] || config['1']; + } + // if(key==='contactList'){ + // debugger + // } + const cellValueList = setFormat(detailConfig, item, values[key]); + newValues.push({ + columnCode: key, + cellValueList, }); }); - handleSubmit({ data: { id: rowId, value: result } }); + if (typeof handleSubmit === 'function') { + handleSubmit({ data: { value: newValues } }); + } } }); }; @@ -98,7 +118,7 @@ class FormWrap extends Component { validateFirst, validateTrigger, rules: [{ required: !!item.requiredFlag }, ...rules], - // initialValue: getFormat(detailConfig, item, value), + initialValue: getFormat(detailConfig, item, value), })()} ); @@ -135,6 +155,7 @@ class FormWrap extends Component { {data.map((item: any, i: number) => { return (