1.修改合同问题

2.项目建档
3.增加进行中的项目
This commit is contained in:
32503
2025-07-02 09:56:11 +08:00
parent 9eb6d1cd10
commit 6e1b1c8653
17 changed files with 1687 additions and 619 deletions

View File

@ -1,4 +1,4 @@
import React, {useState, useRef, useCallback} from 'react';
import React, {useState, useRef} from 'react';
import { history } from 'umi';
import {Input, Button, Modal, Form, Select, message, DatePicker} from 'antd';
import { SearchOutlined , UndoOutlined} from '@ant-design/icons';
@ -43,7 +43,7 @@ const ContractList: React.FC = () => {
createDate: undefined
});
const actionRef = useRef<ActionType>();
const handleEdit = useCallback((selectedRecord: any, opt: string) => {
const handleEdit = (selectedRecord: any, opt: string) => {
getContract(selectedRecord.id).then((res) => {
history.push({
pathname: '/stepOne',
@ -53,7 +53,7 @@ const ContractList: React.FC = () => {
}
});
});
},[]);
}
// 选择合同类型
const handleChoose = () => {
@ -77,17 +77,25 @@ const ContractList: React.FC = () => {
};
// 处理搜索
const handleSearch = useCallback(() => {
if (searchParams.createDate) {
searchParams.createDate = saveDateTimeFormatter(moment(searchParams.createDate))
setSearchParams({
...searchParams
})
}
const handleSearch = () => {
actionRef.current?.reload()
}, []);
}
const goPerformance = useCallback((selectedRecord: any) => {
const goNegotiate = (selectedRecord: any) => {
getContract(selectedRecord.id).then((res) => {
if(res?.code === 200){
history.push({
pathname: '/negotiate',
state: {
contractInfo: res.data,
opt: 'edit'
}
});
}
});
}
const goPerformance = (selectedRecord: any) => {
getContract(selectedRecord.id).then((res) => {
if(res?.code === 200){
history.push({
@ -99,9 +107,9 @@ const ContractList: React.FC = () => {
});
}
});
},[])
}
const handleUpdate = useCallback((optRecord: any) => {
const handleUpdate = (optRecord: any) => {
updateContract(optRecord).then((r: any) => {
if (r?.code == 200) {
message.success('操作成功');
@ -109,9 +117,9 @@ const ContractList: React.FC = () => {
message.error('操作失败');
}
}).finally(() => actionRef.current?.reload());
},[])
}
const handleOperation = useCallback((optRecord: any, status: string) => {
const handleOperation = (optRecord: any, status: string) => {
optRecord.status = status;
const operation = status == '2' ? '中止' : status == '3' ? '终止' : '';
Modal.confirm({
@ -120,9 +128,9 @@ const ContractList: React.FC = () => {
await handleUpdate(optRecord);
}
})
},[])
}
const handleDelete = useCallback((id: string) => {
const handleDelete = (id: string) => {
Modal.confirm({
title: '确认删除该合同?',
onOk: async () => {
@ -136,7 +144,7 @@ const ContractList: React.FC = () => {
.finally(() => actionRef.current?.reload());
},
});
},[])
}
// 处理重置
const handleReset = () => {
@ -215,7 +223,13 @@ const ContractList: React.FC = () => {
<>
{optRecord.status === '0' && (<Button type="link" danger onClick={() => handleDelete(optRecord.id)}></Button>)}
{(optRecord.status === '0'|| optRecord.status === '2' )&& (<Button type="link" danger onClick={() => handleEdit(optRecord, 'edit')}></Button>)}
{optRecord.status === '1' && (<Button type="link" danger onClick={() => goPerformance(optRecord)}></Button>)}
{ optRecord.status === '1' && ((optRecord.contractType === '1' && Number(optRecord.step) >= 2 ) || (optRecord.contractType === '0' && Number(optRecord.step) >= 1))
&& (<Button type="link" danger onClick={() => goPerformance(optRecord)}></Button>)
}
{
optRecord.status === '1' && optRecord.contractType === '1' && optRecord.step === '1'
&& (<Button type="link" danger onClick={() => goNegotiate(optRecord)}></Button>)
}
{optRecord.status === '1' && (<Button type="link" danger onClick={() => handleOperation(optRecord, '2')}></Button>)}
{optRecord.status === '1' && (<Button type="link" danger onClick={() => handleOperation(optRecord, '3')}></Button>)}
{(<Button type="link" onClick={() => handleEdit(optRecord, 'detail')}></Button>)}
@ -227,6 +241,9 @@ const ContractList: React.FC = () => {
// 定义ProTable的请求函数
const request = async (params: any, sorter: any) => {
try {
if(searchParams.createDate){
searchParams.createDate = saveDateTimeFormatter(moment(searchParams.createDate))
}
// 构建请求参数,合并搜索参数
const requestParams = {
...params,
@ -330,7 +347,7 @@ const ContractList: React.FC = () => {
onChange={(e) => setSearchParams({...searchParams, biddingName: e.target.value})}
style={{ width: 200, marginRight: 16 }}
/>
<DatePicker placeholder="请选择创建时间" inputReadOnly={true} onChange={ (date, dateString) => {
<DatePicker placeholder="请选择创建时间" value={searchParams.createDate} inputReadOnly={true} onChange={ (date, dateString) => {
// @ts-ignore
setSearchParams({...searchParams, createDate: date})}
} style={{ width: 200, marginRight: 16 }}/>

View File

@ -1,8 +1,8 @@
import React, {useEffect, useState} from 'react';
import {Table, Button, Upload, message, Form} from 'antd';
import {Table, Button, Upload, message} from 'antd';
import {PlusOutlined, DeleteOutlined, SendOutlined, CheckOutlined} from '@ant-design/icons';
import moment, {Moment} from "moment";
import {createNegotiate, listNegotiate} from "@/pages/Contract/ContractService";
import {createNegotiate, listNegotiate,updateContract} from "@/pages/Contract/ContractService";
import {useLocation} from "umi";
import {saveDateTimeFormatter} from "@/utils/DateUtils";
import TextArea from "antd/es/input/TextArea";
@ -31,8 +31,10 @@ const tableData: any[] | (() => any[]) = [
// },
];
const Negotiate: React.FC = () => {
const step = '2';
const location = useLocation();
const contractInfo = location.state?.contractInfo;
const [isShow,setIsShow] = useState(false);
const opt = location.state?.opt;
let readOnly = false;
if (opt === 'detail') {
@ -128,7 +130,7 @@ const Negotiate: React.FC = () => {
message.success('文件上传成功');
}}
>
<Button type="primary"></Button>
<Button type="primary" hidden={readOnly}></Button>
</Upload>
)}
</span>
@ -145,6 +147,11 @@ const Negotiate: React.FC = () => {
key: 'createDate',
render: (value: Moment, record: any) => value ? moment(value).format('yyyy-MM-DD') : null
},
{
title: '版本号',
dataIndex: 'version',
key: 'version'
},
{
title: '备注',
dataIndex: 'note',
@ -154,7 +161,7 @@ const Negotiate: React.FC = () => {
<TextArea
placeholder="请输入备注"
value={text}
readOnly={readOnly}
disabled={readOnly}
onChange={(e) => handleNoteChange(e, record.key)}
/>
)
@ -177,7 +184,7 @@ const Negotiate: React.FC = () => {
hidden={readOnly || record.id}>
</Button>
<Button type="link" icon={<SendOutlined/>} disabled={readOnly}>
<Button type="link" icon={<SendOutlined/>} hidden={readOnly}>
</Button>
</div>
@ -199,9 +206,47 @@ const Negotiate: React.FC = () => {
setTableDataState(newTableData);
};
const saveAndCommit = async () => {
if(Number(contractInfo.step) <= Number(step)){
contractInfo.step = step;
}
contractInfo.status = '1';
await updateContract(contractInfo).then( (res: any) => {
if(res.code === 200){
message.success("当前数据更新成功").then(() => {
history.push({
pathname: '/contract',
});
}).then( () => {
})
}else {
message.error('合同信息更新失败');
}
});
}
const goPerformancePage = async () => {
// if(opt ==='detail'){
// history.push({
// pathname: '/performance',
// state: {
// contractInfo: contractInfo,
// opt: opt
// }
// });
// }else{
history.push({
pathname: '/performance',
state: {
contractInfo: contractInfo,
opt: opt
}
});
// }
}
const handleNegotiationEnd = () => {
console.log('磋商结束操作触发');
message.success('磋商结束');
setIsShow(true);
};
return (
@ -219,29 +264,57 @@ const Negotiate: React.FC = () => {
dataSource={tableDataState}/>
{/* 增加行按钮 */}
<Button type="primary" onClick={addRow} icon={<PlusOutlined/>} hidden={readOnly}>
<Button type="primary" onClick={addRow} icon={<PlusOutlined/>} hidden={readOnly || isShow}>
</Button>
<div hidden={readOnly || !isShow} style={{
borderLeft: '4px solid #0066cc',
paddingLeft: 16,
marginBottom: 16,
position: 'relative'
}}>
<span style={{ fontSize: 16, fontWeight: 'bold' }}></span>
</div>
<div hidden={!isShow} style={{ display: 'flex',marginLeft:30}}>
<Upload
name="file"
disabled={readOnly}
// listType="simple"
onChange={(info) => {
console.log('Uploaded file info:', info);
message.success('文件上传成功');
}}
>
<label style={{left: 40, marginRight: 20}}>: </label><Button type="primary"></Button>
<p></p>
<label style={{color: 'red'}}>.rar .zip .doc .docx .pdf 100MB</label>
</Upload>
</div>
{/* 居中的磋商结束按钮 */}
<div style={{textAlign: 'center', marginTop: 24}}>
<Button
type="primary"
onClick={handleNegotiationEnd}
style={{width: 160}}
hidden={readOnly}
style={{width: 120,marginRight:15}}
hidden={readOnly || isShow}
>
</Button>
<Form.Item label="">
<Button type="primary" hidden={!readOnly} onClick={() => {
history.push({
pathname: '/contract'
})
}}>
</Button>
</Form.Item>
<Button type="primary" style={{width: 120}} hidden={!isShow && readOnly} onClick={saveAndCommit}>
</Button>
<Button type="primary" style={{ marginLeft: 24 }} onClick={goPerformancePage} hidden={!isShow}>
</Button>
{/*<Form.Item label="">*/}
{/* <Button type="primary" hidden={!readOnly} onClick={() => {*/}
{/* goPerformancePage().then()*/}
{/* }}>*/}
{/* 查看履约信息*/}
{/* </Button>*/}
{/*</Form.Item>*/}
</div>
</div>
);

View File

@ -2,7 +2,6 @@ import React, {useEffect, useState} from 'react';
import {Form, Select, Input, Table, Button, message, DatePicker} from 'antd';
import {useLocation} from "umi";
const {Option} = Select;
import {
createPerformance,
updateContract,
@ -13,6 +12,7 @@ import {history} from "@@/core/history";
import {saveDateTimeFormatter} from "@/utils/DateUtils";
import moment, {Moment} from "moment";
const {Option} = Select;
const createDate = moment()
// 模拟合同履约状态选项
@ -49,10 +49,10 @@ const performanceStageDescOptions = [
];
// 模拟金额单位选项
const amountUnitOptions = [
{label: '元', value: '0'},
{label: '万元', value: '1'},
];
// const amountUnitOptions = [
// {label: '元', value: '0'},
// {label: '万元', value: '1'},
// ];
const initTableData = [
{
@ -60,14 +60,13 @@ const initTableData = [
id: '',
contractPerformanceId: '',
invoiceAmountItem: 0,
invoiceUnit: '0',
payAmountItem: 0,
payUnit: '0',
createDate: createDate
}
];
// @ts-ignore
const Performance: React.FC = () => {
const step = '3';
const [form] = Form.useForm();
const location = useLocation();
const contractInfo = location.state?.contractInfo;
@ -85,13 +84,10 @@ const Performance: React.FC = () => {
const [invoiceAmount, setInvoiceAmount] = useState(0);
// @ts-ignore
const [payAmount, setPayAmount] = useState(0);
let status0 = true;
let status1 = true;
let changeType0 = true;
let phaseDescriptionText0 = true;
// const [status0, setStatus0] = useState(true);
// const [status1, setStatus1] = useState(true);
// const [changeType0,setChangeType0] = useState(true);
const [status0, setStatus0] = useState(true);
const [status1, setStatus1] = useState(true);
const [changeType0,setChangeType0] = useState(true);
const [phaseDescriptionText0, setPhaseDescriptionText0] = useState(true);
// 计算总发票金额
const calculateTotalInvoiceAmount = (data: any) => {
return data.reduce((sum: number, row: { invoiceAmountItem: any; }) => sum + Number(row.invoiceAmountItem || 0), 0);
@ -125,13 +121,16 @@ const Performance: React.FC = () => {
changeDate: moment(contractInfo.performance.changeDate)
});
setStatus0(contractInfo.performance.status==='2'?false:true)
setStatus1(contractInfo.performance.status==='1'?false:true)
setChangeType0(contractInfo.performance.changeType=== '0'?false: true)
setPhaseDescriptionText0(contractInfo.performance.phase==='5'?false:true)
// 处理表格数据
if(contractInfo.performance.list){
const newTableData = contractInfo.performance.list.map((amountItem: any, index: number) => ({
...amountItem,
key: index + '',
invoiceUnit: '0',
payUnit: '0'
key: index + ''
}));
setTableData(newTableData);
@ -182,67 +181,67 @@ const Performance: React.FC = () => {
render: (_: any, record: any, index: number) => index + 1,
},
{
title: '发票金额(CNY)',
title: '发票金额(CNY) / 元',
dataIndex: 'invoiceAmountItem',
key: 'invoiceAmountItem',
render: (text: any, record: any) => (
<Input
readOnly={readOnly}
disabled={readOnly}
placeholder="请输入金额"
value={text}
onChange={(e) => handleInvoiceAmountItemChange(record.key, e.target.value)}
/>
),
},
// {
// title: '',
// dataIndex: 'invoiceUnit',
// key: 'invoiceUnit',
// render: (text: any, record: any) => (
// <Select
// defaultValue={'0'}
// disabled
// value={text}
// >
// {amountUnitOptions.map(({label, value}) => (
// <Option key={value} value={value}>
// {label}
// </Option>
// ))}
// </Select>
// ),
// },
{
title: '',
dataIndex: 'invoiceUnit',
key: 'invoiceUnit',
render: (text: any, record: any) => (
<Select
defaultValue={'0'}
disabled
value={text}
>
{amountUnitOptions.map(({label, value}) => (
<Option key={value} value={value}>
{label}
</Option>
))}
</Select>
),
},
{
title: '支付金额(CNY)',
title: '支付金额(CNY) / 元',
dataIndex: 'payAmountItem',
key: 'payAmountItem',
render: (text: any, record: any) => (
<Input
readOnly={readOnly}
disabled={readOnly}
placeholder="请输入金额"
value={text}
onChange={(e) => handlePayAmountItemChange(record.key, e.target.value)}
/>
),
},
{
title: '',
dataIndex: 'payUnit',
key: 'payUnit',
render: (text: any, record: any) => (
<Select
defaultValue={'0'}
disabled
value={text}
>
{amountUnitOptions.map(({label, value}) => (
<Option key={value} value={value}>
{label}
</Option>
))}
</Select>
),
},
// {
// title: '',
// dataIndex: 'payUnit',
// key: 'payUnit',
// render: (text: any, record: any) => (
// <Select
// defaultValue={'0'}
// disabled
// value={text}
// >
// {amountUnitOptions.map(({label, value}) => (
// <Option key={value} value={value}>
// {label}
// </Option>
// ))}
// </Select>
// ),
// },
{
title: '录入时间',
dataIndex: 'createDate',
@ -289,9 +288,9 @@ const Performance: React.FC = () => {
}
const statusChange = (value: any) => {
status0 = (value==='2'?false:true)
status1 = (value==='1'?false:true)
phaseDescriptionText0 = (true);
setStatus0(value==='2'?false:true)
setStatus1(value==='1'?false:true)
setPhaseDescriptionText0(true);
}
const onFinish = (values: any) => {
@ -299,11 +298,15 @@ const Performance: React.FC = () => {
values.contractId = contractInfo.id;
values.contractCode = contractInfo.contractCod;
values.contractName = contractInfo.contractName;
values.step = contractInfo.step;
const newValues = {
...values,
actualAmount: values.actualAmount?Number(values.actualAmount):0,
changeDate: saveDateTimeFormatter(values.changeDate)
}
if(Number(contractInfo.step) <= Number(step)){
newValues.step = step;
}
updatePerformance(newValues).then((res) => {
const performanceId = res.data.id;
if(performanceId){
@ -332,8 +335,10 @@ const Performance: React.FC = () => {
values.changeDate = saveDateTimeFormatter(values.changeDate)
try {
//修改合同信息状态为 进行中
contractInfo.status = 1;
updateContract(contractInfo);//更新合同状态
if(Number(contractInfo.step) <= Number(step)){
contractInfo.step = step;
}
updateContract(contractInfo).then();//更新合同状态
createPerformance(values).then((res: any) => {
const performanceId = res.data.id;
if (performanceId) {
@ -412,7 +417,7 @@ const Performance: React.FC = () => {
style={{width: '50%'}}
>
<Select placeholder="请选择" disabled={readOnly} onChange={ (value) => {
phaseDescriptionText0 = (value==='5'? false: true)
setPhaseDescriptionText0(value==='5'? false: true)
}}>
{performanceStageOptions.map(({label, value}) => (
<Option key={value} value={value}>
@ -429,7 +434,7 @@ const Performance: React.FC = () => {
style={{width: '50%'}}
>
<Select placeholder="请选择" disabled={readOnly} onChange={(value) => {
phaseDescriptionText0 = (value==='6'? false: true)
setPhaseDescriptionText0(value==='6'? false: true)
}}>
{performanceStageDescOptions.map(({label, value}) => (
<Option key={value} value={value}>
@ -447,7 +452,7 @@ const Performance: React.FC = () => {
>
<Input
placeholder="请输入合同履约阶段说明"
readOnly={readOnly}
disabled={readOnly}
/>
</Form.Item>
</div>
@ -460,7 +465,7 @@ const Performance: React.FC = () => {
style={{width: '50%', marginRight: 16}}
>
<Select placeholder="请选择" disabled={readOnly} onChange={ (value) => {
changeType0 = (value === '0'?false: true);
setChangeType0(value === '0'?false: true);
}}>
{yesOrNo.map(({label, value}) => (
<Option key={value} value={value}>
@ -472,21 +477,22 @@ const Performance: React.FC = () => {
</div>
<div style={{display: 'flex', flexWrap: 'wrap'}}>
{/* 合同实际金额 */}
<Form.Item
{!changeType0 && <Form.Item
name="amount"
label="合同金额(CNY) / 元"
hidden={changeType0}
style={{width: '50%'}}
rules={[{ pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确的金额格式,最多保留两位小数' },
{ validator: (_, value) => value > 0 ? Promise.resolve() : Promise.reject('金额必须大于0') }]}
rules={[
{required: false, pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确的金额格式,最多保留两位小数' },
{required: false,validator: (_, value) => value > 0 ? Promise.resolve() : Promise.reject('金额必须大于111110') }
]}
>
<Input
placeholder="请输入合同金额"
// value={actualAmount}
// onChange={handleActualAmountChange}
readOnly={readOnly}
disabled={readOnly}
/>
</Form.Item>
</Form.Item>}
{/* 合同是否有扣款 */}
<Form.Item
name="changeDate"
@ -503,14 +509,16 @@ const Performance: React.FC = () => {
name="actualAmount"
label="合同实际金额 / 元"
style={{width: '50%'}}
rules={[{ required: true ,pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确的金额格式,最多保留两位小数' },
{ validator: (_, value) => value > 0 ? Promise.resolve() : Promise.reject('金额必须大于0') }]}
rules={[
{ required: true ,pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确的金额格式,最多保留两位小数' },
{ validator: (_, value) => value > 0 ? Promise.resolve() : Promise.reject('金额必须大于0') }]
}
>
<Input
placeholder="请输入合同实际金额"
// value={actualAmount}
// onChange={handleActualAmountChange}
readOnly={readOnly}
disabled={readOnly}
/>
</Form.Item>
{/* 合同是否有扣款 */}
@ -542,7 +550,7 @@ const Performance: React.FC = () => {
>
<Input
value={invoiceAmount}
readOnly={totalReadOnly}
disabled={totalReadOnly}
placeholder="请输入金额"
/>
</Form.Item>
@ -555,7 +563,7 @@ const Performance: React.FC = () => {
>
<Input
value={payAmount}
readOnly={totalReadOnly}
disabled={totalReadOnly}
placeholder="请输入金额"
/>
</Form.Item>

View File

@ -14,6 +14,7 @@ const industryOptions = [
];
const StepOne: React.FC = () => {
const step = '0';
const [form] = Form.useForm();
let readOnly = false;
const location = useLocation();
@ -47,6 +48,9 @@ const StepOne: React.FC = () => {
try {
if (values.id) {
setLoading(true)
if(Number(values.step) <= Number(step)){
values.step = step;
}
updateContract(values).then((res: any) => {
if(res.code === 200){
// message.success("当前数据更新成功").then(() => {
@ -65,6 +69,7 @@ const StepOne: React.FC = () => {
}
})
} else {
values.step = step;
createContract(values).then( (res: any) => {
if(res.code === 200){
history.push({
@ -167,6 +172,7 @@ const StepOne: React.FC = () => {
</div>
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
<Form.Item hidden={true} name="id"></Form.Item>
<Form.Item hidden={true} name="step"></Form.Item>
<Form.Item
name="status"
label="合同状态"
@ -180,7 +186,7 @@ const StepOne: React.FC = () => {
rules={[{ required: true, message: '请输入项目名称' }]}
style={{ width: '50%', marginRight: 16 }}
>
<Input placeholder="请输入项目名称" readOnly={readOnly}/>
<Input placeholder="请输入项目名称" disabled={readOnly}/>
</Form.Item>
<Form.Item name="projectSelect" label="" style={{ width: '80%' }}>
<Button type="primary" hidden={readOnly}></Button>
@ -193,7 +199,7 @@ const StepOne: React.FC = () => {
rules={[{ required: true, message: '请输入标段名称' }]}
style={{ width: '50%', marginRight: 16 }}
>
<Input placeholder="请输入标段名称" readOnly={readOnly}/>
<Input placeholder="请输入标段名称" disabled={readOnly}/>
</Form.Item>
<Form.Item
name="biddingCode"
@ -201,7 +207,7 @@ const StepOne: React.FC = () => {
rules={[{ required: true, message: '请输入标段编号' }]}
style={{ width: '45%' }}
>
<Input placeholder="请输入标段编号" readOnly={readOnly} />
<Input placeholder="请输入标段编号" disabled={readOnly} />
</Form.Item>
</div>
<Form.Item name="sectionSelect" label="" style={{ width: '20%' }}>
@ -219,7 +225,7 @@ const StepOne: React.FC = () => {
rules={[{ required: true, message: '请输入采购单位' }]}
style={{ width: '50%', marginRight: 16 }}
>
<Input placeholder="请输入采购单位" readOnly={readOnly} />
<Input placeholder="请输入采购单位" disabled={readOnly} />
</Form.Item>
<Form.Item
name="purchaserCode"
@ -237,7 +243,7 @@ const StepOne: React.FC = () => {
]}
style={{ width: '50%', marginRight: 16 }}
>
<Input placeholder="请输入统一社会信用代码" readOnly={readOnly} />
<Input placeholder="请输入统一社会信用代码" disabled={readOnly} />
</Form.Item>
<Form.Item
name="industryCode"
@ -266,7 +272,7 @@ const StepOne: React.FC = () => {
rules={[{ required: true, message: '请输入供应商公司名称' }]}
style={{ width: '50%', marginRight: 16 }}
>
<Input placeholder="请输入供应商公司名称" readOnly={readOnly} />
<Input placeholder="请输入供应商公司名称" disabled={readOnly} />
</Form.Item>
<Form.Item
name="supplierCode"
@ -285,7 +291,7 @@ const StepOne: React.FC = () => {
]}
style={{ width: '45%' }}
>
<Input placeholder="请输入统一社会信用代码" readOnly={readOnly} />
<Input placeholder="请输入统一社会信用代码" disabled={readOnly} />
</Form.Item>
</div>
@ -312,7 +318,7 @@ const StepOne: React.FC = () => {
{ max: 20, message: '姓名长度不能超过20个字符' },
{ pattern: /^[\u4e00-\u9fa5a-zA-Z\s·]{2,20}$/, message: '请输入正确的姓名' }]}
>
<Input placeholder="" readOnly={readOnly}/>
<Input placeholder="" disabled={readOnly}/>
</Form.Item>
<Form.Item
name="signerContact"
@ -320,7 +326,7 @@ const StepOne: React.FC = () => {
style={{ width: '50%' }}
rules={ [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }]}
>
<Input placeholder="" readOnly={readOnly} />
<Input placeholder="" disabled={readOnly} />
</Form.Item>
</div>

View File

@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import {Form, Input, Select, DatePicker, Button, message, Spin, Upload} from 'antd';
import {useLocation} from "umi";
import {updateContract} from "@/pages/Contract/ContractService";
@ -45,34 +45,35 @@ const guaranteeOptions = [
];
const StepTwo: React.FC = () => {
const step = '1';
const [loading, setLoading] = useState<boolean>(false);
// const [payType0,setPayType0] = useState(true);
let payType0 = true;
let valuationType0 = true;
// const [valuationType0,setValuationType0] = useState(true);
const [payType0,setPayType0] = useState(true);
const [valuationType0,setValuationType0] = useState(true);
const [form] = Form.useForm();
const location = useLocation();
const contractInfo = location.state?.contractInfo;
const opt = location.state?.opt;
const isShow = contractInfo? contractInfo.contractType=='0'? false: true: true;
let readOnly = false;
if(opt){
form.setFieldsValue({
...contractInfo,
endDatetime: contractInfo.endDatetime ? moment(contractInfo.endDatetime) : null,
startDatetime: contractInfo.startDatetime ? moment(contractInfo.startDatetime) : null,
signedDatetime: contractInfo.signedDatetime ? moment(contractInfo.signedDatetime) : null,
performancePlace: contractInfo.performancePlace ? contractInfo.performancePlace.split(",") : [],
mainType: contractInfo.mainType ? contractInfo.mainType.split(","): []
})
if(opt === 'detail'){
readOnly = true
}else if(opt ==='edit'){
readOnly = false
useEffect(() => {
if(opt && contractInfo){
form.setFieldsValue({
...contractInfo,
endDatetime: contractInfo.endDatetime ? moment(contractInfo.endDatetime) : null,
startDatetime: contractInfo.startDatetime ? moment(contractInfo.startDatetime) : null,
signedDatetime: contractInfo.signedDatetime ? moment(contractInfo.signedDatetime) : null,
performancePlace: contractInfo.performancePlace ? contractInfo.performancePlace.split(",") : [],
mainType: contractInfo.mainType ? contractInfo.mainType.split(","): []
})
setPayType0(form.getFieldValue("payType") === '2' ? false: true);
setValuationType0(form.getFieldValue("valuationType") === '3' ? false: true);
}
}, [opt, contractInfo, form]);
if(opt === 'detail'){
readOnly = true
}else if(opt ==='edit'){
readOnly = false
}
payType0 = (form.getFieldValue("payType") === '2' ? false: true);
valuationType0 = (form.getFieldValue("valuationType") === '3' ? false: true);
function assignMatchingProperties<T>(original: T, updates: Partial<T>): T {
const result: T = { ...original };
@ -89,21 +90,30 @@ const StepTwo: React.FC = () => {
return result;
}
const processContract = (contract: any) => {
contract.performancePlace = contract.performancePlace.join(',');
contract.mainType = contract.mainType.join(',');
contract.signedDatetime = saveDateTimeFormatter(contract.signedDatetime);
contract.startDatetime = saveDateTimeFormatter(contract.startDatetime);
contract.endDatetime = saveDateTimeFormatter(contract.endDatetime);
}
// 表单提交处理函数
const onFinish = (values: any) => {
let newContract = null;
if(opt){
newContract = values;
newContract.step = contractInfo.step;
}else{
const updatedContract = assignMatchingProperties(contractInfo, values);
newContract = updatedContract;
}
newContract.performancePlace = newContract.performancePlace.join(',');
newContract.mainType = newContract.mainType.join(',');
newContract.signedDatetime = saveDateTimeFormatter(newContract.signedDatetime);
newContract.startDatetime = saveDateTimeFormatter(newContract.startDatetime);
newContract.endDatetime = saveDateTimeFormatter(newContract.endDatetime);
newContract.status = '1';//项目进行中
processContract(newContract)
setLoading(true)
if(Number(newContract.step) <= Number(step)){
newContract.step = step;
}
updateContract(newContract).then( (res: any) => {
if(res?.code === 200){
setLoading(false)
@ -131,12 +141,11 @@ const StepTwo: React.FC = () => {
}else{
const values = await form.validateFields();
const updatedContract = assignMatchingProperties(contractInfo, values);
updatedContract.performancePlace = updatedContract.performancePlace.join(',')
updatedContract.mainType = updatedContract.mainType.join(',');
updatedContract.signedDatetime = saveDateTimeFormatter(updatedContract.signedDatetime);
updatedContract.startDatetime = saveDateTimeFormatter(updatedContract.startDatetime);
updatedContract.endDatetime = saveDateTimeFormatter(updatedContract.endDatetime);
processContract(updatedContract);
setLoading(true);
if(Number(updatedContract.step) <= Number(step)){
updatedContract.step = step;
}
updateContract(updatedContract).then( (res: any) => {
if(res.code === 200){
// message.success("当前数据更新成功").then(() => {
@ -169,12 +178,11 @@ const StepTwo: React.FC = () => {
}else{
const values = await form.validateFields();
const updatedContract = assignMatchingProperties(contractInfo, values);
updatedContract.performancePlace = updatedContract.performancePlace.join(',')
updatedContract.mainType = updatedContract.mainType.join(',');
updatedContract.signedDatetime = saveDateTimeFormatter(updatedContract.signedDatetime);
updatedContract.startDatetime = saveDateTimeFormatter(updatedContract.startDatetime);
updatedContract.endDatetime = saveDateTimeFormatter(updatedContract.endDatetime);
processContract(updatedContract);
setLoading(true);
if(Number(updatedContract.step) <= Number(step)){
updatedContract.step = step;
}
updateContract(updatedContract).then( (res: any) => {
if(res.code === 200){
message.success("当前数据更新成功").then(() => {
@ -196,10 +204,10 @@ const StepTwo: React.FC = () => {
}
const payTypeOnChange = (value: any) => {
payType0 = (value === '2' ? false: true);
setPayType0(value === '2' ? false: true);
};
const onValuationTypeChange = (value: any) => {
valuationType0 = (value === '3' ? false: true);
setValuationType0(value === '3' ? false: true);
};
return (
@ -245,7 +253,7 @@ const StepTwo: React.FC = () => {
label="框架协议编号"
style={{ width: '45%', marginRight: 16 }}
>
<Input placeholder="当合同为执行框架协议或执行统谈分签协议时,须填写对应的框架协议或统谈分签协议的编号。" readOnly={readOnly}/>
<Input placeholder="当合同为执行框架协议或执行统谈分签协议时,须填写对应的框架协议或统谈分签协议的编号。" disabled={readOnly}/>
</Form.Item>
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
{/* 合同编号和合同名称 */}
@ -255,7 +263,7 @@ const StepTwo: React.FC = () => {
rules={[{ required: true, message: '请输入合同编号' }]}
style={{ width: '45%', marginRight: 16 }}
>
<Input readOnly={readOnly}/>
<Input disabled={readOnly}/>
</Form.Item>
<Form.Item
name="contractName"
@ -263,7 +271,7 @@ const StepTwo: React.FC = () => {
rules={[{ required: true, message: '请输入合同名称' }]}
style={{ width: '45%' }}
>
<Input readOnly={readOnly}/>
<Input disabled={readOnly}/>
</Form.Item>
</div>
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
@ -314,7 +322,7 @@ const StepTwo: React.FC = () => {
hidden={valuationType0}
rules={[{ required: !valuationType0, message: '请填写备注' }]}
>
<Input placeholder="请输入备注" readOnly={readOnly}/>
<Input placeholder="请输入备注" disabled={readOnly}/>
</Form.Item>
</div>
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
@ -328,7 +336,7 @@ const StepTwo: React.FC = () => {
rules={[{ pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确的金额格式,最多保留两位小数' },
{ validator: (_, value) => value > 0 ? Promise.resolve() : Promise.reject('金额必须大于0') }]}
>
<Input placeholder="" readOnly={readOnly}/>
<Input placeholder="" disabled={readOnly}/>
</Form.Item>
{/*<Form.Item name="amountUnit" rules={[{ required: true, message: '请选合同金额单位' }]} initialValue={'0'} style={{ width: '5%',marginLeft:'20px'}}>*/}
{/* <Select placeholder="请选择" disabled={readOnly}>*/}
@ -363,7 +371,7 @@ const StepTwo: React.FC = () => {
hidden={payType0}
rules={[{ required: !payType0, message: '请填写备注' }]}
>
<Input placeholder="请输入备注" readOnly={readOnly}/>
<Input placeholder="请输入备注" disabled={readOnly}/>
</Form.Item>
</div>
<div style={{ display: 'flex', flexWrap: 'wrap' }}>