Commit 5daafbc9 authored by zhangwenshuai's avatar zhangwenshuai

remove number edit reg

parent a0f638f3
...@@ -3,34 +3,15 @@ import { InputNumber } from 'antd'; ...@@ -3,34 +3,15 @@ import { InputNumber } from 'antd';
import styles from './styles.less'; import styles from './styles.less';
import { ApolloNumberProps } from '../editInterface'; import { ApolloNumberProps } from '../editInterface';
import { antiAssign } from '../../../../utils/utils'; import { antiAssign } from '../../../../utils/utils';
import { floatNumberReg, intNumberReg } from '../../../../utils/reg';
export const ApolloNumber = (props: ApolloNumberProps) => { export const ApolloNumber = (props: ApolloNumberProps) => {
const { onChange, columnConfig }: any = props; const { onChange }: any = props;
const { columnAttrObj = {} } = columnConfig;
const { dataType } = columnAttrObj;
const selfProps = antiAssign(props, ['columnConfig', 'onChange']); const selfProps = antiAssign(props, ['columnConfig', 'onChange']);
const changeValue = (newValue: any) => { const changeValue = (newValue: any) => {
if (dataType === 'INT') {
if (!intNumberReg.test(newValue)) {
return false;
}
}
if (dataType === 'DECIMAL') {
if (!floatNumberReg.test(newValue)) {
return false;
}
}
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
onChange(newValue); onChange(newValue);
} }
}; };
const { onEmitChange, ...o } = selfProps; const { onEmitChange, ...o } = selfProps;
return ( return <InputNumber className={styles.number} {...o} onChange={changeValue} />;
<InputNumber
className={styles.number}
{...o}
onChange={changeValue}
/>
);
}; };
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