From 8199dd38b1c99ece329098cba6a81ec7df970983 Mon Sep 17 00:00:00 2001 From: wuzhen <52326163@qq.com> Date: Mon, 8 Sep 2025 12:45:01 +0800 Subject: [PATCH] wuzhen update --- web/src/views/cw/application/form.vue | 112 ++++++++++++----- web/src/views/cw/application/index.vue | 167 +------------------------ 2 files changed, 80 insertions(+), 199 deletions(-) diff --git a/web/src/views/cw/application/form.vue b/web/src/views/cw/application/form.vue index 9639b93d..dd1a5636 100644 --- a/web/src/views/cw/application/form.vue +++ b/web/src/views/cw/application/form.vue @@ -215,53 +215,56 @@ @@ -710,14 +713,13 @@ const rules = { startDate: [{ required: true, message: '请选择项目开始日期', trigger: 'change' }], endDate: [{ required: true, message: '请选择项目结束日期', trigger: 'change' }], totalInvestment: [ - { required: true, message: '请填写项目总投资', trigger: 'blur' }, { type: 'number' as const, min: 0.01, message: '投资金额必须大于0', trigger: 'blur' } ] }; // 计算属性 const canSubmit = computed(() => { - return form.projectName && form.principal && form.totalInvestment > 0; + return form.projectName && form.principal && totalInvestmentCalculated.value > 0; }); const hasBudgetData = computed(() => { @@ -734,6 +736,26 @@ const yearlyTotals = computed(() => { }; }); +// 市财政资金总额(基于分年度明细自动汇总) +const totalMunicipalFiscalCalculated = computed(() => { + return (form.currentYearMunicipal || 0) + (form.nextYearMunicipal || 0) + (form.futureYearMunicipal || 0); +}); + +// 单位自筹总额(基于分年度明细自动汇总) +const totalSelfFundingCalculated = computed(() => { + return (form.currentYearSelf || 0) + (form.nextYearSelf || 0) + (form.futureYearSelf || 0); +}); + +// 其他资金总额(基于分年度明细自动汇总) +const totalOtherFundingCalculated = computed(() => { + return (form.currentYearOther || 0) + (form.nextYearOther || 0) + (form.futureYearOther || 0); +}); + +// 项目总投资(基于三个汇总字段自动计算) +const totalInvestmentCalculated = computed(() => { + return totalMunicipalFiscalCalculated.value + totalSelfFundingCalculated.value + totalOtherFundingCalculated.value; +}); + // 分年度预算明细数据 const budgetBreakdownData = computed(() => { const currentYear = parseInt(form.year) || new Date().getFullYear(); @@ -784,30 +806,22 @@ const updateBudgetBreakdown = (index: number) => { recalculateTotalFromBreakdown(); }; -// 从分年度明细重新计算总投资 +// 从分年度明细重新计算总投资(使用计算属性) const recalculateTotalFromBreakdown = () => { - const totalMunicipal = (form.currentYearMunicipal || 0) + (form.nextYearMunicipal || 0) + (form.futureYearMunicipal || 0); - const totalSelf = (form.currentYearSelf || 0) + (form.nextYearSelf || 0) + (form.futureYearSelf || 0); - const totalOther = (form.currentYearOther || 0) + (form.nextYearOther || 0) + (form.futureYearOther || 0); - - form.totalMunicipalFiscal = totalMunicipal; - form.totalSelfFunding = totalSelf; - form.totalOtherFunding = totalOther; - form.totalInvestment = totalMunicipal + totalSelf + totalOther; + // 使用计算属性自动同步到表单字段 + form.totalMunicipalFiscal = totalMunicipalFiscalCalculated.value; + form.totalSelfFunding = totalSelfFundingCalculated.value; + form.totalOtherFunding = totalOtherFundingCalculated.value; + form.totalInvestment = totalInvestmentCalculated.value; }; -// 计算预算汇总 +// 计算预算汇总(使用计算属性) const calculateBudgetSummary = () => { - // 计算各类资金的总和 - const totalMunicipal = (form.currentYearMunicipal || 0) + (form.nextYearMunicipal || 0) + (form.futureYearMunicipal || 0); - const totalSelf = (form.currentYearSelf || 0) + (form.nextYearSelf || 0) + (form.futureYearSelf || 0); - const totalOther = (form.currentYearOther || 0) + (form.nextYearOther || 0) + (form.futureYearOther || 0); - - // 更新总投资字段 - form.totalMunicipalFiscal = totalMunicipal; - form.totalSelfFunding = totalSelf; - form.totalOtherFunding = totalOther; - form.totalInvestment = totalMunicipal + totalSelf + totalOther; + // 使用计算属性自动同步到表单字段 + form.totalMunicipalFiscal = totalMunicipalFiscalCalculated.value; + form.totalSelfFunding = totalSelfFundingCalculated.value; + form.totalOtherFunding = totalOtherFundingCalculated.value; + form.totalInvestment = totalInvestmentCalculated.value; // 更新图表 if (budgetChartInstance && hasBudgetData.value) { @@ -820,9 +834,13 @@ const formatAmount = (amount: number): string => { return amount ? amount.toFixed(2) : '0.00'; }; -// 计算总投资 -const calculateTotalInvestment = () => { - form.totalInvestment = (form.totalMunicipalFiscal || 0) + (form.totalSelfFunding || 0) + (form.totalOtherFunding || 0); +// 更新所有总投资相关字段(从分年度明细计算) +const updateTotalInvestmentFromSubItems = () => { + // 自动同步所有计算值到表单字段(用于后端提交) + form.totalMunicipalFiscal = totalMunicipalFiscalCalculated.value; + form.totalSelfFunding = totalSelfFundingCalculated.value; + form.totalOtherFunding = totalOtherFundingCalculated.value; + form.totalInvestment = totalInvestmentCalculated.value; // 更新图表 if (budgetChartInstance && hasBudgetData.value) { @@ -830,6 +848,26 @@ const calculateTotalInvestment = () => { } }; +// 保留原函数名以兼容其他调用 +const calculateTotalInvestment = updateTotalInvestmentFromSubItems; + +// 监听分年度字段变化,自动同步所有总计字段 +watch( + () => [ + form.currentYearMunicipal, form.nextYearMunicipal, form.futureYearMunicipal, + form.currentYearSelf, form.nextYearSelf, form.futureYearSelf, + form.currentYearOther, form.nextYearOther, form.futureYearOther + ], + () => { + // 同步计算值到表单字段(用于后端提交) + form.totalMunicipalFiscal = totalMunicipalFiscalCalculated.value; + form.totalSelfFunding = totalSelfFundingCalculated.value; + form.totalOtherFunding = totalOtherFundingCalculated.value; + form.totalInvestment = totalInvestmentCalculated.value; + }, + { immediate: true } +); + // 渲染预算图表 const renderBudgetChart = () => { if (!budgetChartInstance) return; @@ -999,6 +1037,9 @@ const handleSaveDraft = async () => { try { savingDraft.value = true; + // 同步计算的总投资到表单字段 + form.totalInvestment = totalInvestmentCalculated.value; + // 如果当前在绩效指标步骤(第3步),校验分值占比总和 if (currentStep.value === 3 && form.performanceIndicators && form.performanceIndicators.length > 0) { const validationResult = validatePerformanceIndicators(); @@ -1032,6 +1073,9 @@ const handleSubmit = async () => { try { submitting.value = true; + // 同步计算的总投资到表单字段 + form.totalInvestment = totalInvestmentCalculated.value; + console.log('开始提交申报流程,form.id:', form.id); // 先保存数据 diff --git a/web/src/views/cw/application/index.vue b/web/src/views/cw/application/index.vue index 8e09d93b..6ebbb91f 100644 --- a/web/src/views/cw/application/index.vue +++ b/web/src/views/cw/application/index.vue @@ -1,61 +1,5 @@