Commit 5efdec64 authored by zhangwenshuai's avatar zhangwenshuai

update

parent 1885c41c
...@@ -263,6 +263,7 @@ const Cell = (props: CellProps) => { ...@@ -263,6 +263,7 @@ const Cell = (props: CellProps) => {
{...newProps} {...newProps}
columnConfig={columnConfig} columnConfig={columnConfig}
onChange={changeCellData} onChange={changeCellData}
rowData={record}
onEmitChange={(changedValue: any, optionValue: any) => { onEmitChange={(changedValue: any, optionValue: any) => {
const value = setFormat(editConfig, columnConfig, changedValue, optionValue); const value = setFormat(editConfig, columnConfig, changedValue, optionValue);
emitChangeCellData(value, optionValue); emitChangeCellData(value, optionValue);
......
import React from 'react'; import React, { useEffect, useState } from 'react';
import { Input } from 'antd'; import { Input } from 'antd';
import styles from './styles.less'; import styles from './styles.less';
import { antiAssign } from '../../../../utils/utils'; import { antiAssign } from '../../../../utils/utils';
...@@ -6,8 +6,17 @@ import { ApolloTextAreaProps } from '../editInterface'; ...@@ -6,8 +6,17 @@ import { ApolloTextAreaProps } from '../editInterface';
import { Consumer } from '../../../context'; import { Consumer } from '../../../context';
export const ApolloTextArea = (props: ApolloTextAreaProps) => { export const ApolloTextArea = (props: ApolloTextAreaProps) => {
const { maxLength, onChange, value } = props; const { maxLength, onChange, value, cutLength, getDetail, rowData } = props;
const selfProps = antiAssign(props, ['columnConfig', 'onChange']); 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) => { const changeValue = (e) => {
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
...@@ -15,16 +24,29 @@ export const ApolloTextArea = (props: ApolloTextAreaProps) => { ...@@ -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 ( return (
<Consumer> <Consumer>
{({ locale }) => { {({ locale }) => {
return ( return (
<div className={styles.container}> <div className={styles.container}>
<Input.TextArea className={styles.input} {...selfProps} onChange={changeValue} /> <Input.TextArea
className={styles.input}
{...selfProps}
value={curValue}
onChange={changeValue}
/>
{!!maxLength && ( {!!maxLength && (
<span className={styles.wordNumber}>{`${locale.alreadyInput} ${ <span className={styles.wordNumber}>
(value || '').length {`${locale.alreadyInput} ${(curValue || '').length}/${maxLength}`}
}/${maxLength}`}</span> </span>
)} )}
</div> </div>
); );
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
left: 0; left: 0;
.input { .input {
padding-bottom: 18px; padding-bottom: 18px;
max-height: 500px !important;
} }
.wordNumber { .wordNumber {
position: absolute; position: absolute;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment