Przeglądaj źródła

fix(monthlyAssess): 修复指标id绑定错误并添加奖惩金额计算逻辑

1. 修正transformIndicatorTree和表单初始化时的id为indicator.id而非code
2. 新增calculateRewardPenaltyTotal函数计算奖惩总金额
3. 在增删指标、加载详情后调用该函数更新汇总金额
huoyi 1 miesiąc temu
rodzic
commit
d6c12f6447
1 zmienionych plików z 36 dodań i 3 usunięć
  1. 36 3
      src/views/performanceManage/monthlyAssess/index.vue

+ 36 - 3
src/views/performanceManage/monthlyAssess/index.vue

@@ -787,7 +787,7 @@ function transformIndicatorTree(treeData) {
787 787
 
788 788
         if (child.indicatorList && child.indicatorList.length > 0) {
789 789
           transformedChild.indicatorList = child.indicatorList.map(indicator => ({
790
-            ...indicator, name: indicator.name, id: indicator.code, indicatorId: indicator.id, indicatorName: indicator.name, occurCount: 1, personnelMonthlyAssessmentIndicatorRewardPunishmentDetailList: []
790
+            ...indicator, name: indicator.name, id: indicator.id, indicatorId: indicator.id, indicatorName: indicator.name, occurCount: 1, personnelMonthlyAssessmentIndicatorRewardPunishmentDetailList: []
791 791
           }))
792 792
         }
793 793
 
@@ -797,7 +797,7 @@ function transformIndicatorTree(treeData) {
797 797
 
798 798
     if (node.indicatorList && node.indicatorList.length > 0) {
799 799
       transformed.indicatorList = node.indicatorList.map(indicator => ({
800
-        ...indicator, name: indicator.name, id: indicator.code, indicatorId: indicator.id, indicatorName: indicator.name, occurCount: 1, personnelMonthlyAssessmentIndicatorRewardPunishmentDetailList: []
800
+        ...indicator, name: indicator.name, id: indicator.id, indicatorId: indicator.id, indicatorName: indicator.name, occurCount: 1, personnelMonthlyAssessmentIndicatorRewardPunishmentDetailList: []
801 801
       }))
802 802
     }
803 803
 
@@ -811,7 +811,7 @@ function onIndicatorCascaderChange(value) {
811 811
     indicatorDialog.form = {
812 812
       ...selected,
813 813
       name: selected.name,
814
-      id: selected.code,
814
+      id: selected.id,
815 815
       indicatorId: selected.id,
816 816
       indicatorName: selected.name,
817 817
       occurCount: 1,
@@ -1022,6 +1022,7 @@ async function loadAssessmentDetail(id) {
1022 1022
       }
1023 1023
     })
1024 1024
     nonCadreForm.indicatorGroups = indicatorGroups
1025
+    calculateRewardPenaltyTotal()
1025 1026
   } catch (error) {
1026 1027
     console.error('获取考核详情失败:', error)
1027 1028
     ElMessage.error('获取考核详情失败')
@@ -1327,6 +1328,7 @@ const deleteIndicator = (groupIndex, itemIndex) => {
1327 1328
     type: 'warning'
1328 1329
   }).then(() => {
1329 1330
     nonCadreForm.indicatorGroups[groupIndex].items.splice(itemIndex, 1)
1331
+    calculateRewardPenaltyTotal()
1330 1332
     ElMessage.success('删除成功')
1331 1333
   }).catch(() => { })
1332 1334
 }
@@ -1391,6 +1393,37 @@ const saveIndicator = () => {
1391 1393
     }
1392 1394
   }
1393 1395
   indicatorDialog.visible = false
1396
+  calculateRewardPenaltyTotal()
1397
+}
1398
+
1399
+// 计算奖励和扣罚汇总
1400
+const calculateRewardPenaltyTotal = () => {
1401
+  let rewardTotal = 0
1402
+  let penaltyTotal = 0
1403
+
1404
+  if (!nonCadreForm.indicatorGroups) {
1405
+    nonCadreForm.rewardAmount = 0
1406
+    nonCadreForm.penaltyAmount = 0
1407
+    return
1408
+  }
1409
+
1410
+  nonCadreForm.indicatorGroups.forEach(group => {
1411
+    if (group.items && Array.isArray(group.items)) {
1412
+      group.items.forEach(item => {
1413
+        const detailList = item.personnelMonthlyAssessmentIndicatorRewardPunishmentDetailList || []
1414
+        detailList.forEach(detail => {
1415
+          if (detail.rewardPunishmentType === 'PUNISHMENT') {
1416
+            penaltyTotal += Number(detail.amount) || 0
1417
+          } else {
1418
+            rewardTotal += Number(detail.amount) || 0
1419
+          }
1420
+        })
1421
+      })
1422
+    }
1423
+  })
1424
+
1425
+  nonCadreForm.rewardAmount = rewardTotal
1426
+  nonCadreForm.penaltyAmount = penaltyTotal
1394 1427
 }
1395 1428
 
1396 1429
 // 删除奖励/惩罚明细