Sfoglia il codice sorgente

perf(monthlyAssessSum): 格式化考核月份参数统一处理接口请求

统一格式化考核月份参数,将YYYY-MM格式转为YYYYMM格式后再发起所有接口请求,减少重复代码并统一参数处理逻辑
huoyi 4 settimane fa
parent
commit
6caed1edd2
1 ha cambiato i file con 23 aggiunte e 13 eliminazioni
  1. 23 13
      src/views/performanceManage/monthlyAssessSum/index.vue

+ 23 - 13
src/views/performanceManage/monthlyAssessSum/index.vue

@@ -483,30 +483,40 @@ const handleResize = () => {
483 483
 const getList = async () => {
484 484
   loading.value = true
485 485
   try {
486
+    // 格式化参数:YYYY-MM -> YYYYMM
487
+    const formatParams = (params) => {
488
+      const formatted = { ...params }
489
+      if (formatted.assessmentMonth) {
490
+        formatted.assessmentMonth = formatted.assessmentMonth.replace('-', '')
491
+      }
492
+      return formatted
493
+    }
494
+    
486 495
     // 获取大队列表
487 496
     const brigadeListRes = await listDept()
488 497
     const brigadeList = (brigadeListRes.data || []).filter(item => item.deptType === 'BRIGADE' && item.isFunctionalDept == 0)
489
-
498
+    
490 499
     // 其他接口调用
500
+    const formattedQueryParams = formatParams(queryParams)
491 501
     const results = await Promise.allSettled([
492
-      getScoreDistribution(queryParams),
493
-      getDeptParticipation(queryParams),
494
-      getDeptScoreDistribution(queryParams),
495
-      getAssessmentSummary(queryParams),
496
-      getActualImprovementDistribution(queryParams),
497
-      getActualIncompetentDistribution(queryParams),
498
-      getAssessmentTeamImprovementDistribution(queryParams),
499
-      getAssessmentTeamIncompetentDistribution(queryParams),
500
-      getFunctionalDeptSummary(queryParams),
501
-      getFunctionalDeptPersonnelDistribution(queryParams),
502
-      getFunctionalDeptDistributionPie(queryParams)
502
+      getScoreDistribution(formattedQueryParams),
503
+      getDeptParticipation(formattedQueryParams),
504
+      getDeptScoreDistribution(formattedQueryParams),
505
+      getAssessmentSummary(formattedQueryParams),
506
+      getActualImprovementDistribution(formattedQueryParams),
507
+      getActualIncompetentDistribution(formattedQueryParams),
508
+      getAssessmentTeamImprovementDistribution(formattedQueryParams),
509
+      getAssessmentTeamIncompetentDistribution(formattedQueryParams),
510
+      getFunctionalDeptSummary(formattedQueryParams),
511
+      getFunctionalDeptPersonnelDistribution(formattedQueryParams),
512
+      getFunctionalDeptDistributionPie(formattedQueryParams)
503 513
     ])
504 514
 
505 515
     const [scoreDistRes, deptPartRes, deptScoreRes, assessmentSumRes, actualImproveRes, actualIncompRes, teamImproveRes, teamIncompRes, functionalDeptRes, functionalDeptPersonnelRes, functionalDeptPieRes] = results
506 516
 
507 517
     // 对每个大队调用三个接口
508 518
     const brigadeDataPromises = brigadeList.map(async (brigade) => {
509
-      const brigadeParams = { ...queryParams, deptId: brigade.deptId }
519
+      const brigadeParams = formatParams({ ...queryParams, deptId: brigade.deptId })
510 520
       const brigadeResults = await Promise.allSettled([
511 521
         getDeptAssessmentTeamStatistics(brigadeParams),
512 522
         getBrigadeImprovementDistribution(brigadeParams),