|
@@ -7,11 +7,11 @@ import { iModalCommonProps } from '@/types/contract'
|
|
|
import { apiContractSection } from '@/utils/common/api'
|
|
|
import { contractTreeBaseId } from '@/utils/common/constStatus'
|
|
|
import consts from '@/utils/consts'
|
|
|
-import { dayjsFormat, handleAutoCode } from '@/utils/util'
|
|
|
-import { Button, Form, Input, Modal, Select, Tree, TreeSelect } from 'antd'
|
|
|
+import { dayjsFormat, formatMoney, handleAutoCode } from '@/utils/util'
|
|
|
+import { Button, Form, Input, Modal, Select, TreeSelect } from 'antd'
|
|
|
import locale from 'antd/es/date-picker/locale/zh_CN'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import React, { useEffect, useState } from 'react'
|
|
|
+import React, { useEffect, useState, useMemo } from 'react'
|
|
|
import { apiGetReturnWay } from '../Tabs/Receivable/api'
|
|
|
import styles from './index.module.scss'
|
|
|
interface ContractSection {
|
|
@@ -123,12 +123,10 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
|
}
|
|
|
|
|
|
// 处理添加回款的金额不应该超出最大值
|
|
|
- const handleMaxPrice = () => {
|
|
|
- const maxPrice = parseFloat(contractStore.contract.price) - parseFloat(contractStore.contract.returned)
|
|
|
- return maxPrice
|
|
|
- }
|
|
|
+ const maxPrice = parseFloat(contractStore.contract.price) - parseFloat(contractStore.contract.returned)
|
|
|
|
|
|
|
|
|
+ const minPrice = parseFloat(contractType === ContractType.INCOME ? row.contractReturned : row.contractsPaid)
|
|
|
return (
|
|
|
<Modal
|
|
|
getContainer={false}
|
|
@@ -198,6 +196,7 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
|
<>
|
|
|
<Form.Item name="code" label="合同编号" rules={[ { required: true, message: '请输入合同编号' } ]} className={styles.contractFormItem}>
|
|
|
<Input
|
|
|
+ autoComplete='off'
|
|
|
addonAfter={
|
|
|
<span className="pi-pd-lr-11" onClick={() => autoCode()}>
|
|
|
自动编号
|
|
@@ -213,9 +212,9 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
|
<Option value={2}>收入合同</Option>
|
|
|
</Select>
|
|
|
</Form.Item> */}
|
|
|
- <Form.Item label="合同金额" >
|
|
|
+ <Form.Item label="合同金额" name="price" rules={[ { required: true, message: '请输入合同金额' } ]}>
|
|
|
{/* <Input type="number" placeholder="输入合同金额" addonAfter={<span>元</span>} /> */}
|
|
|
- <MoneyInput size="small" setValue={(val: string | null) => form.setFieldsValue({ price: val })}/>
|
|
|
+ <MoneyInput />
|
|
|
</Form.Item>
|
|
|
</>
|
|
|
) : (
|
|
@@ -229,8 +228,15 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
|
<Form.Item name="name" label="合同名称" rules={[ { required: true, message: '请输入项目内容' } ]}>
|
|
|
<Input />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="合同金额" >
|
|
|
- <MoneyInput size="small" setValue={(val: string | null) => form.setFieldsValue({ price: val })}/>
|
|
|
+ <Form.Item label="合同金额" name="price" rules={[ { required: true, message: '请输入合同金额' }, () => ({
|
|
|
+ validator(_, value) {
|
|
|
+ if (value && parseFloat(value) < minPrice) {
|
|
|
+ return Promise.reject(`当前金额不能低于${minPrice}`)
|
|
|
+ }
|
|
|
+ return Promise.resolve()
|
|
|
+ }
|
|
|
+ }) ]}>
|
|
|
+ <MoneyInput />
|
|
|
</Form.Item>
|
|
|
<Form.Item name="partyA" label="甲方" rules={[ { required: true, message: '请输入甲方' } ]}>
|
|
|
<Input />
|
|
@@ -308,9 +314,16 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
|
|
|
<Form.Item name="time" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}日期`} rules={[ { required: true, message: '请选择回款日期' } ]}>
|
|
|
<DatePicker allowClear locale={locale} className="pi-width-100P" />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label={`${contractType === ContractType.INCOME ? '回款' : '支付'}金额`} >
|
|
|
+ <Form.Item name="price" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}金额`} rules={[ { required: true, message: `请输入${contractType === ContractType.INCOME ? '回款' : '支付'}金额` }, () => ({
|
|
|
+ validator(_, value) {
|
|
|
+ if (value && parseFloat(value) > maxPrice) {
|
|
|
+ return Promise.reject(`当前金额不能大于${minPrice}`)
|
|
|
+ }
|
|
|
+ return Promise.resolve()
|
|
|
+ }
|
|
|
+ }) ]}>
|
|
|
{/* <Input onChange={handleReturnPrice}/> */}
|
|
|
- <MoneyInput size="small" maxPrice={handleMaxPrice()} setValue={(val: string | null) => form.setFieldsValue({ price: val })}/>
|
|
|
+ <MoneyInput />
|
|
|
</Form.Item>
|
|
|
<Form.Item name="way" label="支付方式" rules={[ { required: true, message: '请选择回款方式' } ]}>
|
|
|
<Select>{options}</Select>
|