|
@@ -1,5 +1,5 @@
|
|
|
-import { Form } from 'antd'
|
|
|
-import Input, { InputProps } from 'antd/lib/input'
|
|
|
+import Input from 'antd/lib/input'
|
|
|
+import BigNumber from 'bignumber.js'
|
|
|
import React, { ChangeEvent, useState, useEffect } from 'react'
|
|
|
import './index.scss'
|
|
|
|
|
@@ -53,10 +53,12 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
|
|
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
|
const val = e.target.value?.match(/^(\d*)\.?(\d{0,2})/)
|
|
|
|
|
|
- const newInputVal = val && val[0] || ''
|
|
|
-
|
|
|
+ let newInputVal = val && val[0] || ''
|
|
|
|
|
|
if (newInputVal) {
|
|
|
+ newInputVal = new BigNumber(newInputVal).toString()
|
|
|
+ }
|
|
|
+ if (newInputVal) {
|
|
|
// newInputVal = parseFloat(newInputVal).toString()
|
|
|
// if (maxPrice && parseFloat(newInputVal) > maxPrice) {
|
|
|
// newInputVal = maxPrice.toString()
|
|
@@ -67,7 +69,7 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
|
|
|
|
|
|
// newInputVal = minPrice.toString()
|
|
|
// }
|
|
|
- const len = val && parseFloat(val[1]) && parseFloat(val[1]).toString().length || null
|
|
|
+ const len = val && val[1] && new BigNumber(val[1]).toString().length || null
|
|
|
|
|
|
if (len && len > 12) {
|
|
|
return
|
|
@@ -89,7 +91,7 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
|
|
|
<div className='ant-input ant-input-sm'>
|
|
|
<div className="pi-flex-row">
|
|
|
<span className="pi-fz-14 pi-mg-right-5">¥</span>
|
|
|
- <Input bordered={false} value={inputVal || value} size="small" onChange={handleChange} autoComplete="off" />
|
|
|
+ <Input bordered={false} value={inputVal || (value && new BigNumber(value).toString())} size="small" onChange={handleChange} autoComplete="off" />
|
|
|
</div>
|
|
|
{
|
|
|
digit ?
|