Files
hzdyjs/docs/变更管理/code-adjust-record-2025-08-01-performance-indicators-and-amount-fields-fix.md
T
2025-08-01 08:35:47 +08:00

7.0 KiB
Raw Blame History

项目申报绩效指标和金额字段修复记录

日期: 2025-08-01
操作人员: Assistant
修复类型: 前端表单功能增强和后端数据完整性修复

🚨 问题描述

  1. 绩效指标缺失问题: 新增项目申报时缺少绩效指标填写功能
  2. 金额字段未录入: 所有输入的金额数据没有录入数据库中

需要补充的绩效指标

  • 产出指标(必填):
    • 数量指标
    • 质量指标
    • 时效指标
    • 成本指标
  • 效益与效果指标(选填一项):
    • 经济效益指标
    • 社会效益指标
    • 环境效益指标
  • 满意度(选填):
    • 满意度指标

🔍 问题分析

1. 绩效指标问题

  • 前端: 现有绩效指标仅为简单的文本框,不符合实际业务需求
  • 后端: 已有绩效指标相关的Entity、Service和Controller,但未正确集成

2. 金额字段问题

  • 前端: 表单数据结构不完整,缺少多个金额字段
  • 后端: CwProjectApplicationBo已定义完整的金额字段,但前端未正确映射

缺失的金额字段

// 年度预计执行数
currentYearTotal: null,
currentYearMunicipal: null,
currentYearSelf: null,
currentYearOther: null,
// 下年度申请资金
nextYearTotal: null,
nextYearMunicipal: null,
nextYearSelf: null,
nextYearOther: null,
// 以后年度安排
futureYearTotal: null,
futureYearMunicipal: null,
futureYearSelf: null,
futureYearOther: null

🔧 修复方案

1. 前端绩效指标组件

新增文件: web/src/views/cw/application/components/PerformanceIndicators.vue

功能特点:

  • 分类管理:产出指标、效益指标、满意度指标
  • 动态添加/删除指标项
  • 分值占比验证(总分必须为100%)
  • 实时分值计算和提示
  • 支持必填验证和选填验证

核心功能:

// 验证绩效指标
validate() {
  // 验证必填的产出指标
  const requiredTypes = ['quantity', 'quality', 'timeliness', 'cost'];
  for (const type of requiredTypes) {
    const hasValid = this.outputIndicators[type].some(item => item.goalName && item.targetValue);
    if (!hasValid) {
      return { valid: false, message: `${this.getTypeName(type)}至少需要填写一项` };
    }
  }
  
  // 验证分值总和
  if (this.totalWeight !== 100) {
    return { valid: false, message: '绩效指标总分值占比必须等于100%' };
  }
  
  return { valid: true };
}

2. 前端API接口

新增文件: web/src/api/cw/performanceIndicator.ts

接口功能:

  • 查询绩效指标列表
  • 根据申报ID查询绩效指标
  • 批量保存绩效指标
  • 删除绩效指标

3. 前端表单数据结构修复

修改文件: web/src/views/cw/application/form.vue

主要修改:

// 表单数据结构增强
const form = reactive({
  // ... 基本字段
  // 项目总投资
  totalInvestment: 0,
  totalMunicipalFiscal: 0,
  totalSelfFunding: 0,
  totalOtherFunding: 0,
  // 年度预计执行数
  currentYearTotal: 0,
  currentYearMunicipal: 0,
  currentYearSelf: 0,
  currentYearOther: 0,
  // 下年度申请资金
  nextYearTotal: 0,
  nextYearMunicipal: 0,
  nextYearSelf: 0,
  nextYearOther: 0,
  // 以后年度安排
  futureYearTotal: 0,
  futureYearMunicipal: 0,
  futureYearSelf: 0,
  futureYearOther: 0,
  // 绩效指标
  performanceIndicators: []
})

4. 绩效指标集成方案

步骤1: 在表单中集成绩效指标组件

<template>
  <!-- 第四步:绩效指标 -->
  <el-card shadow="never" class="form-card" v-show="currentStep === 3">
    <template #header>
      <div class="card-header">
        <el-icon><TrendCharts /></el-icon>
        <span>绩效指标设置</span>
      </div>
    </template>
    
    <el-form ref="performanceFormRef" :model="form">
      <div class="performance-section">
        <PerformanceIndicators v-model="form.performanceIndicators" />
      </div>
    </el-form>
  </el-card>
</template>

步骤2: 更新保存逻辑

// 保存时同时保存绩效指标
const handleSaveDraft = async () => {
  try {
    // 保存申报基本信息
    const result = form.id 
      ? await updateProjectApplication(form)
      : await addProjectApplication(form)
    
    // 更新表单ID
    if (result && result.data) {
      form.id = result.data.id
      form.applicationNo = result.data.applicationNo
    }
    
    // 保存绩效指标
    if (form.id && form.performanceIndicators.length > 0) {
      await batchSavePerformanceIndicator(
        form.id, 
        form.applicationNo, 
        form.performanceIndicators
      )
    }
    
    ElMessage.success('保存成功')
  } catch (error) {
    ElMessage.error('保存失败:' + error.message)
  }
}

5. 后端集成(已就绪)

后端相关代码已完备,包括:

  • CwPerformanceIndicator 实体类
  • CwPerformanceIndicatorService 服务接口
  • CwPerformanceIndicatorController 控制器
  • 批量保存、验证分值等完整功能

📋 实施步骤

阶段1: 前端组件准备 ✅

  • 创建 PerformanceIndicators.vue 组件
  • 创建 performanceIndicator.ts API接口
  • 修复表单数据结构

阶段2: 表单集成(待完成)

  • 在项目申报表单中集成绩效指标组件
  • 修复表单保存逻辑,支持绩效指标保存
  • 修复金额字段在表单模板中的显示和绑定
  • 添加表单验证规则

阶段3: 测试和优化(待完成)

  • 测试绩效指标的添加、修改、删除功能
  • 测试金额字段的保存和加载
  • 验证绩效指标分值占比计算
  • 测试表单的完整提交流程

⚠️ 注意事项

1. 文件依赖关系

  • PerformanceIndicators.vue 依赖 Element Plus 组件
  • API接口需要正确的请求路径匹配后端Controller
  • 表单验证需要配合绩效指标组件的验证方法

2. 数据结构一致性

  • 前端绩效指标数据结构需与后端BO类一致
  • 金额字段命名需与后端实体字段严格匹配
  • 分值占比计算需要前后端一致的验证规则

3. 用户体验优化

  • 绩效指标组件支持实时分值计算提示
  • 表单步骤进度指示清晰
  • 错误提示信息明确具体

🔄 回滚方案

如修复过程中出现问题,可按以下步骤回滚:

  1. 恢复原有绩效指标的简单文本框实现
  2. 恢复表单数据结构为原始版本
  3. 移除新增的绩效指标组件和API文件

📊 预期效果

功能完善度

  • ✅ 绩效指标管理功能完整:产出指标、效益指标、满意度指标
  • ✅ 金额字段数据完整录入数据库
  • ✅ 表单验证规则完善
  • ✅ 用户操作体验优化

数据完整性

  • ✅ 所有申报数据正确保存到数据库
  • ✅ 绩效指标与申报记录正确关联
  • ✅ 分值占比验证确保数据合理性

业务流程

  • ✅ 支持草稿保存和正式提交
  • ✅ 支持申报信息的修改和查看
  • ✅ 审批流程可正常创建和处理

这次修复将完整解决项目申报的功能缺失问题,使系统能够满足实际的预算申报业务需求。