From 5efdec649cb88240d5b48a257cc6a25af13988fe Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Tue, 9 Jun 2020 03:03:23 +0800 Subject: [PATCH] update --- components/apolloTable/component/Cell.tsx | 1 + .../component/base/edit/textarea/index.tsx | 36 +++++++++++++++---- .../component/base/edit/textarea/styles.less | 1 + 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 3f696e2..d72be9c 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 4300e35..c9ec504 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 7d5d42a..0d50edc 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; -- 2.21.0