diff --git a/frontend/src/pages/projects/ProjectDetail.tsx b/frontend/src/pages/projects/ProjectDetail.tsx
index e3f7220..b684410 100644
--- a/frontend/src/pages/projects/ProjectDetail.tsx
+++ b/frontend/src/pages/projects/ProjectDetail.tsx
@@ -540,7 +540,41 @@ const ProjectDetail: React.FC = () => {
const latestContract = contracts.length > 0 ? contracts[0] : null;
return (
- } onClick={() => setContractEditModalVisible(true)}>合同细节录入}>
+ } onClick={() => {
+ const latestContract = contracts.length > 0 ? contracts[0] : null;
+ const savedSettlement = latestContract?.settlement_method || 'lump_sum';
+ const savedTotal = parseFloat(latestContract?.contract_amount || project?.contract_amount || '0');
+ setSettlementType(savedSettlement);
+ setContractTotal(savedTotal);
+ setContractFile(latestContract?.contract_file || '');
+ if (milestones.length > 0) {
+ setPaymentNodes(milestones.map((m: any) => ({
+ key: String(m.id),
+ name: m.milestone_name || '',
+ condition: m.condition || '',
+ percentage: m.percentage || 0,
+ amount: m.amount || 0,
+ status: m.status || 'pending'
+ })));
+ } else {
+ setPaymentNodes([
+ { key: '1', name: '预付款', condition: '合同签订后7天内', percentage: 40, amount: Math.round(savedTotal * 0.4), status: 'pending' },
+ { key: '2', name: '进度款', condition: '所有设备材料达到现场', percentage: 30, amount: Math.round(savedTotal * 0.3), status: 'pending' },
+ { key: '3', name: '尾款', condition: '通电完工7天内', percentage: 27, amount: Math.round(savedTotal * 0.27), status: 'pending' },
+ { key: '4', name: '质保金', condition: '', percentage: 3, amount: Math.round(savedTotal * 0.03), status: 'pending' }
+ ]);
+ }
+ setContractEditModalVisible(true);
+ setTimeout(() => {
+ contractForm.setFieldsValue({
+ project_overview: project?.project_situation || project?.description || '',
+ settlement_type: savedSettlement,
+ contract_total: savedTotal,
+ tax_included: latestContract?.tax_included || false,
+ other_info: latestContract?.other_info || ''
+ });
+ }, 100);
+ }}>合同细节录入}>
{project.currency} {parseFloat(latestContract?.contract_amount || project.contract_amount || '0').toLocaleString()}
@@ -1527,11 +1561,12 @@ const ProjectDetail: React.FC = () => {
}
const values = await contractForm.validateFields();
- const finalContractTotal = settlementType === 'unit_price' ? contractTotal : (values.contract_total || 0);
+ const actualSettlementType = values.settlement_type || settlementType;
+ const finalContractTotal = actualSettlementType === 'unit_price' ? contractTotal : (values.contract_total || 0);
const saveData = {
project_id: id,
project_overview: values.project_overview,
- settlement_type: values.settlement_type,
+ settlement_type: actualSettlementType,
contract_total: finalContractTotal,
tax_included: values.tax_included || false,
unit_price_items: unitPriceItems,
@@ -1584,6 +1619,13 @@ const ProjectDetail: React.FC = () => {
{ value: 'lump_sum', label: '总价包干' },
{ value: 'unit_price', label: '单价结算' }
]}
+ onChange={(val) => {
+ setSettlementType(val);
+ if (val === 'lump_sum') {
+ const formTotal = contractForm.getFieldValue('contract_total') || 0;
+ setContractTotal(formTotal);
+ }
+ }}
/>