Explorar el Código

feat(qualityControl): 优化图表显示和资质等级分析逻辑

添加饼图标签显示和x轴标签旋转功能
重构资质等级分析逻辑以动态计算最高等级科室
调整资质等级描述生成逻辑以使用实际数据
huoyi hace 2 días
padre
commit
5a7bf0b3e3

+ 42 - 40
src/pages/qualityControlAnalysisReport/components/dutyOrganization.vue

@@ -533,7 +533,7 @@ export default {
533 533
     },
534 534
     processQueryParams(queryParams) {
535 535
       const processedParams = { ...queryParams }
536
-     
536
+
537 537
       if (processedParams.dateRangeQueryType === 'YEAR') {
538 538
         processedParams.yearOnYear = true
539 539
       } else {
@@ -541,9 +541,9 @@ export default {
541 541
         processedParams.yearOnYear = true
542 542
       }
543 543
 
544
-    
545
-      
546
-      processedParams.deptId = ['TEAMS', 'DEPARTMENT', 'BRIGADE','MANAGER'].includes(processedParams.scopedType) ? processedParams.scopedId : '';
544
+
545
+
546
+      processedParams.deptId = ['TEAMS', 'DEPARTMENT', 'BRIGADE', 'MANAGER'].includes(processedParams.scopedType) ? processedParams.scopedId : '';
547 547
       if (processedParams.scopedType == 'TEAMS') {
548 548
         delete processedParams.userId;
549 549
       }
@@ -566,6 +566,30 @@ export default {
566 566
 
567 567
 
568 568
       try {
569
+        // 加载资质等级柱状图数据(如果是STATION类型)
570
+        if (this.isStationType) {
571
+          const barResponse = await getQualificationBarChart(processedParams)
572
+          if (barResponse.code === 200) {
573
+            this.qualificationBarData = barResponse.data?.brigades || []
574
+          }
575
+        }
576
+
577
+        // 加载班组人员资质等级数据(如果是TEAMS类型)
578
+        if (this.isTeamsType) {
579
+          const barResponse = await getQualificationBarChart(processedParams)
580
+
581
+          if (barResponse.code === 200) {
582
+            this.teamsQualificationData = barResponse.data?.brigades || []
583
+          }
584
+        }
585
+
586
+        if (this.isUserType) {
587
+          // 获取资质等级分布柱状图数据
588
+          const barResponse = await getQualificationBarChart(processedParams)
589
+          console.log('资质等级分布柱状图数据:', barResponse.data.brigades)
590
+          this.user = barResponse?.data?.brigades[0]
591
+        }
592
+
569 593
         // 加载出勤人次分析数据
570 594
         const attendanceResponse = await getCalculate(processedParams)
571 595
 
@@ -592,29 +616,6 @@ export default {
592 616
         }
593 617
 
594 618
 
595
-        // 加载资质等级柱状图数据(如果是STATION类型)
596
-        if (this.isStationType) {
597
-          const barResponse = await getQualificationBarChart(processedParams)
598
-          if (barResponse.code === 200) {
599
-            this.qualificationBarData = barResponse.data?.brigades || []
600
-          }
601
-        }
602
-
603
-        // 加载班组人员资质等级数据(如果是TEAMS类型)
604
-        if (this.isTeamsType) {
605
-          const barResponse = await getQualificationBarChart(processedParams)
606
-
607
-          if (barResponse.code === 200) {
608
-            this.teamsQualificationData = barResponse.data?.brigades || []
609
-          }
610
-        }
611
-
612
-        if (this.isUserType) {
613
-          // 获取资质等级分布柱状图数据
614
-          const barResponse = await getQualificationBarChart(processedParams)
615
-          console.log('资质等级分布柱状图数据:', barResponse.data.brigades)
616
-          this.user = barResponse?.data?.brigades[0]
617
-        }
618 619
 
619 620
         // 检查是否为用户类型
620 621
         this.checkUserType()
@@ -901,31 +902,32 @@ export default {
901 902
 
902 903
     // 格式化资质等级描述第二部分
903 904
     formatQualificationDescriptionPart2(data) {
904
-      if (!Array.isArray(data)) {
905
+      if (this.qualificationBarData.length == 0) {
905 906
         return ''
906 907
       }
907 908
 
908
-      // 从资质柱状图数据中找出"一级"人员最多的主管
909
-      let topDeptForLevel1 = '旅检三科'
910
-      let level1Count = 25
911
-      let totalDeptCount = 395
909
+      // 从资质柱状图数据中找出"一级"人员最多的科室
910
+      let topDeptForLevel1 = ''
911
+      let level1Count = 0
912
+      let totalDeptCount = 0
913
+      let allDeptNames = []
912 914
 
913 915
       if (this.qualificationBarData && Array.isArray(this.qualificationBarData)) {
914
-        const barData = this.qualificationBarData
915
-
916
-        // 找出"一级"人员最多的主管
916
+        // 找出"一级"人员最多的科室
917 917
         let maxLevel1Count = 0
918
-        let maxDeptName = '旅检三科'
919
-        let totalCountForDept = 395
918
+        let maxDeptName = ''
919
+        let totalCountForDept = 0
920 920
 
921
-        barData.forEach(dept => {
921
+
922
+        this.qualificationBarData.forEach(dept => {
923
+          allDeptNames.push(dept.deptName)
922 924
           if (dept.levelCounts && Array.isArray(dept.levelCounts)) {
923 925
             const level1Data = dept.levelCounts.find(level => level.levelName === '高级')
924 926
             const deptTotalCount = dept.levelCounts.reduce((sum, level) => sum + (level.count || 0), 0)
925 927
 
926 928
             if (level1Data && level1Data.count > maxLevel1Count) {
927 929
               maxLevel1Count = level1Data.count
928
-              maxDeptName = dept.deptName || '未知主管'
930
+              maxDeptName = dept.deptName || ''
929 931
               totalCountForDept = deptTotalCount
930 932
             }
931 933
           }
@@ -937,7 +939,7 @@ export default {
937 939
       }
938 940
 
939 941
       // 生成第二部分描述文字
940
-      return `全站资质等级为"高级"的人员集中在${topDeptForLevel1}(${level1Count}人)${topDeptForLevel1}的人员规模(共${totalDeptCount}人)高于一科、二科`
942
+      return `全站资质等级为"高级"的人员集中在${topDeptForLevel1}(${level1Count}人)${topDeptForLevel1}的人员规模(共${totalDeptCount}人)高于${allDeptNames.filter(name => name !== topDeptForLevel1).join(', ')}`
941 943
     },
942 944
 
943 945
     // 检查是否为用户类型(已废弃,使用computed属性替代)

+ 13 - 2
src/pages/qualityControlAnalysisReport/components/qualityControl.vue

@@ -562,6 +562,11 @@ export default {
562 562
             type: 'pie',
563 563
             radius: '50%',
564 564
             data: [],
565
+            label: {
566
+              show: true,
567
+              formatter: '{b}: {c}个',
568
+              fontSize: 12
569
+            },
565 570
             emphasis: {
566 571
               itemStyle: {
567 572
                 shadowBlur: 10,
@@ -595,6 +600,12 @@ export default {
595 600
         xAxis: {
596 601
           type: 'category',
597 602
           data: [],
603
+          axisLabel: {
604
+            rotate: 45, // 倾斜45度
605
+            interval: 0, // 显示所有标签
606
+            fontSize: 12,
607
+            margin: 10
608
+          }
598 609
         },
599 610
         yAxis: {
600 611
           type: 'value',
@@ -696,9 +707,9 @@ export default {
696 707
         let params = {
697 708
           ...this.queryForm,
698 709
           userId: this.queryForm.scopedType == 'USER' ? this.queryForm.scopedId : "",
699
-          deptId: ["DEPARTMENT", "TEAMS", "MANAGER","BRIGADE"].includes(this.queryForm.scopedType) ? this.queryForm.scopedId : ""
710
+          deptId: ["DEPARTMENT", "TEAMS", "MANAGER", "BRIGADE"].includes(this.queryForm.scopedType) ? this.queryForm.scopedId : ""
700 711
         }
701
-       
712
+
702 713
 
703 714
 
704 715
         // 加载质控活动分析数据