import { Col, Form, Input, Row } from 'antd'; import { useEffect, useState } from 'react'; import styles from './BackCardNumber.less'; import React from 'react'; import schema from "./schema" import { getItemProps } from "../../utils" import FormItem from '../FormItem/FormItem'; const BankCardNumber = (item: any) => { const data: any = getItemProps(schema, item) const { itemProps: { label, name }, BValue, innerStyle } = data const [inputIndex, setInputIndex] = useState(-1); const [valueText, setValueText] = useState(''); useEffect(() => { setValueText(BValue); }, []); const onChange = (e: any) => { const value = e.target.value; const FocusIndex = Math.floor((value?.length || 0) / 4) >= 3 ? 3 : Math.floor((value?.length || 0) / 4); setInputIndex(FocusIndex); setValueText(value); }; const onFocus = (e: any) => { const value = e.target.value; const FocusIndex = Math.floor((value?.length || 0) / 4) >= 3 ? 3 : Math.floor((value?.length || 0) / 4); setInputIndex(FocusIndex); }; const onBlur = () => { setInputIndex(-1); }; return (
{[0, 1, 2, 3].map((item) => { return (
{item !== 3 ? valueText?.substring(item * 4, (item + 1) * 4) : valueText?.substring(item * 4, valueText.length)}
); })}
); }; export default BankCardNumber;