Commit 5efdec64 authored by zhangwenshuai's avatar zhangwenshuai

update

parent 1885c41c
......@@ -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);
......
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 (
<Consumer>
{({ locale }) => {
return (
<div className={styles.container}>
<Input.TextArea className={styles.input} {...selfProps} onChange={changeValue} />
<Input.TextArea
className={styles.input}
{...selfProps}
value={curValue}
onChange={changeValue}
/>
{!!maxLength && (
<span className={styles.wordNumber}>{`${locale.alreadyInput} ${
(value || '').length
}/${maxLength}`}</span>
<span className={styles.wordNumber}>
{`${locale.alreadyInput} ${(curValue || '').length}/${maxLength}`}
</span>
)}
</div>
);
......
......@@ -4,6 +4,7 @@
left: 0;
.input {
padding-bottom: 18px;
max-height: 500px !important;
}
.wordNumber {
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