|
@@ -14,6 +14,7 @@ import dayjs from 'dayjs'
|
|
import React, { useEffect, useState, useMemo } from 'react'
|
|
import React, { useEffect, useState, useMemo } from 'react'
|
|
import { apiGetReturnWay } from '../Tabs/Receivable/api'
|
|
import { apiGetReturnWay } from '../Tabs/Receivable/api'
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
|
|
+import { BigNumber } from "bignumber.js"
|
|
interface ContractSection {
|
|
interface ContractSection {
|
|
id: string;
|
|
id: string;
|
|
treeType: number;
|
|
treeType: number;
|
|
@@ -123,10 +124,10 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
}
|
|
}
|
|
|
|
|
|
// 处理添加回款的金额不应该超出最大值
|
|
// 处理添加回款的金额不应该超出最大值
|
|
- const maxPrice = parseFloat(contractStore.contract.price) - parseFloat(contractType === ContractType.INCOME ? contractStore.contract.returned : contractStore.contract.paid)
|
|
|
|
|
|
+ // const maxPrice = parseFloat(contractStore.contract.price) - parseFloat(contractType === ContractType.INCOME ? contractStore.contract.returned : contractStore.contract.paid)
|
|
|
|
+ const maxPrice = new BigNumber(contractStore.contract.price).minus(contractType === ContractType.INCOME ? contractStore.contract.returned : contractStore.contract.paid)
|
|
|
|
|
|
-
|
|
|
|
- const minPrice = parseFloat(contractType === ContractType.INCOME ? row.contractReturned : row.contractsPaid)
|
|
|
|
|
|
+ const minPrice = new BigNumber(contractType === ContractType.INCOME ? row.contractReturned : row.contractsPaid)
|
|
return (
|
|
return (
|
|
<Modal
|
|
<Modal
|
|
getContainer={false}
|
|
getContainer={false}
|
|
@@ -230,7 +231,7 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
</Form.Item>
|
|
</Form.Item>
|
|
<Form.Item label="合同金额" name="price" rules={[ { required: true, message: '请输入合同金额' }, () => ({
|
|
<Form.Item label="合同金额" name="price" rules={[ { required: true, message: '请输入合同金额' }, () => ({
|
|
validator(_, value) {
|
|
validator(_, value) {
|
|
- if (value && parseFloat(value) < minPrice) {
|
|
|
|
|
|
+ if (value && (new BigNumber(value).lt(minPrice))) {
|
|
return Promise.reject(`当前金额不能低于${minPrice}`)
|
|
return Promise.reject(`当前金额不能低于${minPrice}`)
|
|
}
|
|
}
|
|
return Promise.resolve()
|
|
return Promise.resolve()
|
|
@@ -316,7 +317,7 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
</Form.Item>
|
|
</Form.Item>
|
|
<Form.Item name="price" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}金额`} rules={[ { required: true, message: `请输入${contractType === ContractType.INCOME ? '回款' : '支付'}金额` }, () => ({
|
|
<Form.Item name="price" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}金额`} rules={[ { required: true, message: `请输入${contractType === ContractType.INCOME ? '回款' : '支付'}金额` }, () => ({
|
|
validator(_, value) {
|
|
validator(_, value) {
|
|
- if (value && parseFloat(value) > maxPrice) {
|
|
|
|
|
|
+ if (value && (new BigNumber(value).gt(maxPrice))) {
|
|
return Promise.reject(`当前金额不能大于${maxPrice}`)
|
|
return Promise.reject(`当前金额不能大于${maxPrice}`)
|
|
}
|
|
}
|
|
return Promise.resolve()
|
|
return Promise.resolve()
|