Commit 34d576ab authored by 李晓静's avatar 李晓静

merge

parents 2fd4ccc6 14a11859
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Input, Modal } from 'antd'; import { Input, Modal } from 'antd';
import styles from './styles.less'; import styles from './styles.less';
import { onBlurFn } from '../onBlurFn';
import { antiAssign } from '../../../../utils/utils'; import { antiAssign } from '../../../../utils/utils';
import { ApolloTextAreaProps } from '../editInterface'; import { ApolloTextAreaProps } from '../editInterface';
import { Consumer } from '../../../context'; import { Consumer } from '../../../context';
export const ApolloTextLink = (props: ApolloTextAreaProps) => { export const ApolloTextLink = (props: ApolloTextAreaProps) => {
const { maxLength, onChange, value, cutLength, getDetail, rowData, onEmitChange, columnConfig, origin } = props; const { maxLength, onChange, value, onEmitChange, columnConfig, origin } = props;
const { columnChsName } = columnConfig; const { columnChsName } = columnConfig;
const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'value', 'cutLength', 'getDetail', 'rowData', 'onEmitChange']); const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'value', 'cutLength', 'getDetail', 'rowData', 'onEmitChange']);
const [curValue, setCurValue] = useState(value); const [curValue, setCurValue] = useState(value);
...@@ -17,12 +18,20 @@ export const ApolloTextLink = (props: ApolloTextAreaProps) => { ...@@ -17,12 +18,20 @@ export const ApolloTextLink = (props: ApolloTextAreaProps) => {
getMore(); getMore();
} }
}, [value]); }, [value]);
const [inputVal, setInputVal] = useState(value)
useEffect(() => {
setInputVal(value);
}, [value]);
// useEffect(() => { // useEffect(() => {
// if (value && value.length === cutLength) { // if (value && value.length === cutLength) {
// getMore(); // getMore();
// } // }
// }, []); // }, []);
const inputOnBlurFn = () => {
if (typeof onBlurFn === 'function') {
onBlurFn(props);
}
};
const changeValue = (e) => { const changeValue = (e) => {
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
onChange(e.target.value); onChange(e.target.value);
...@@ -62,8 +71,12 @@ export const ApolloTextLink = (props: ApolloTextAreaProps) => { ...@@ -62,8 +71,12 @@ export const ApolloTextLink = (props: ApolloTextAreaProps) => {
<Input.TextArea <Input.TextArea
className={styles.inputForm} className={styles.inputForm}
{...selfProps} {...selfProps}
value={value} value={inputVal}
onChange={changeValue} onBlur={inputOnBlurFn}
onChange={(e) => {
changeValue(e);
setInputVal(e.target.value)
}}
/> />
{!!maxLength && ( {!!maxLength && (
<span className={styles.wordNumberForm}> <span className={styles.wordNumberForm}>
......
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