diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 3f696e2347ef1958ad692639520f43e5350f6f24..d72be9c925079b526909480aaa382afb4a78d2e0 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -263,6 +263,7 @@ const Cell = (props: CellProps) => { {...newProps} columnConfig={columnConfig} onChange={changeCellData} + rowData={record} onEmitChange={(changedValue: any, optionValue: any) => { const value = setFormat(editConfig, columnConfig, changedValue, optionValue); emitChangeCellData(value, optionValue); diff --git a/components/apolloTable/component/base/edit/textarea/index.tsx b/components/apolloTable/component/base/edit/textarea/index.tsx index 4300e353aff8da7d041712892528ab31500e9b50..c9ec5048423e229493d90bc45bfd8c22b2e1648e 100644 --- a/components/apolloTable/component/base/edit/textarea/index.tsx +++ b/components/apolloTable/component/base/edit/textarea/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { Input } from 'antd'; import styles from './styles.less'; import { antiAssign } from '../../../../utils/utils'; @@ -6,8 +6,17 @@ import { ApolloTextAreaProps } from '../editInterface'; import { Consumer } from '../../../context'; export const ApolloTextArea = (props: ApolloTextAreaProps) => { - const { maxLength, onChange, value } = props; - const selfProps = antiAssign(props, ['columnConfig', 'onChange']); + const { maxLength, onChange, value, cutLength, getDetail, rowData } = props; + const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'value']); + const [curValue, setCurValue] = useState(value); + useEffect(() => { + setCurValue(value); + }, [value]); + useEffect(() => { + if (value.length === cutLength) { + getMore(); + } + }, []); const changeValue = (e) => { if (typeof onChange === 'function') { @@ -15,16 +24,29 @@ export const ApolloTextArea = (props: ApolloTextAreaProps) => { } }; + const getMore = async () => { + let newValue = await getDetail({ rowId: rowData.id }); + if (newValue) { + newValue = newValue[0] && newValue[0].value; + setCurValue(newValue); + } + }; + return ( {({ locale }) => { return (
- + {!!maxLength && ( - {`${locale.alreadyInput} ${ - (value || '').length - }/${maxLength}`} + + {`${locale.alreadyInput} ${(curValue || '').length}/${maxLength}`} + )}
); diff --git a/components/apolloTable/component/base/edit/textarea/styles.less b/components/apolloTable/component/base/edit/textarea/styles.less index 7d5d42a0e0dc16e689181e3fd1bf2cafff68cd17..0d50edcbc64a5aeefa7f98c94d002c7c73769236 100644 --- a/components/apolloTable/component/base/edit/textarea/styles.less +++ b/components/apolloTable/component/base/edit/textarea/styles.less @@ -4,6 +4,7 @@ left: 0; .input { padding-bottom: 18px; + max-height: 500px !important; } .wordNumber { position: absolute;