profile.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="main-content-wrapper">
  3. <div class="main-content">
  4. <div class="content-row">
  5. <ProfileRadar :chartData="radarData" />
  6. <ProfileMembers :columns="teamColumns" :data="teamMembers" />
  7. </div>
  8. <div class="content-row">
  9. <ProfileBasicDistribution :chartData1="genderData" :chartData2="nationData" :chartData3="politicalData" />
  10. <ProfilePositionDistribution :chartData1="skillData" :chartData2="operateData" :chartData3="postData" />
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script setup>
  16. import { ref, watch } from 'vue'
  17. import ProfileRadar from '../../components/ProfileRadar.vue'
  18. import ProfileMembers from '../../components/ProfileMembers.vue'
  19. import ProfileBasicDistribution from '../../components/ProfileBasicDistribution.vue'
  20. import ProfilePositionDistribution from '../../components/ProfilePositionDistribution.vue'
  21. import { countStationTeamStats, getDeptMemberDistribution, getDeptPositionDistribution, getDimensionScoreOverview } from '@/api/portraitManagement/portraitManagement'
  22. const props = defineProps({
  23. queryParams: {
  24. type: Object,
  25. default: () => ({})
  26. }
  27. })
  28. const radarData = ref([
  29. ])
  30. const teamMembers = ref([])
  31. const teamColumns = [
  32. { label: '小组', prop: 'deptName' },
  33. { label: '员工数量', prop: 'employeeCount' },
  34. { label: '党员数量', prop: 'partyMemberCount' },
  35. { label: '平均年龄', prop: 'avgAge' },
  36. { label: '平均工龄', prop: 'avgWorkYears' },
  37. { label: '职业资格等级证书数量', prop: 'qualificationLevel' },
  38. { label: '平均开机年龄', prop: 'avgXrayOperatorYears' },
  39. { label: '综合得分', prop: 'totalScore' }
  40. ]
  41. const fetchTeamData = async (params) => {
  42. try {
  43. const res = await countStationTeamStats(params)
  44. if (res.code === 200 && res.data) {
  45. teamMembers.value = res.data
  46. }
  47. } catch (error) {
  48. console.error('获取部门成员列表失败', error)
  49. }
  50. }
  51. const genderData = ref([
  52. ])
  53. const nationData = ref([
  54. ])
  55. const politicalData = ref([
  56. ])
  57. const skillData = ref([
  58. ])
  59. const operateData = ref([
  60. ])
  61. const postData = ref([
  62. ])
  63. const fetchMemberDistribution = async (params) => {
  64. try {
  65. const res = await getDeptMemberDistribution(params)
  66. if (res.code === 200 && res.data) {
  67. genderData.value = res.data.sexDistribution.map(item => ({ value: item.count, name: item.name })) || []
  68. nationData.value = res.data.nationDistribution.map(item => ({ value: item.count, name: item.name })) || []
  69. politicalData.value = res.data.politicalDistribution.map(item => ({ value: item.count, name: item.name })) || []
  70. console.log('genderData', genderData.value)
  71. console.log('nationData', nationData.value)
  72. console.log('politicalData', politicalData.value)
  73. }
  74. } catch (error) {
  75. console.error('获取部门成员基本情况分布失败', error)
  76. }
  77. }
  78. const fetchPositionDistribution = async (params) => {
  79. try {
  80. const res = await getDeptPositionDistribution(params)
  81. if (res.code === 200 && res.data) {
  82. skillData.value = res.data.qualificationDistribution.map(item => ({ value: item.count, name: item.name })) || []
  83. operateData.value = res.data.xrayYearDistribution.map(item => ({ value: item.count, name: item.name })) || []
  84. postData.value = res.data.positionDistribution.map(item => ({ value: item.count, name: item.name })) || []
  85. }
  86. } catch (error) {
  87. console.error('获取部门成员职位情况分布失败', error)
  88. }
  89. }
  90. const fetchRadarData = async (params) => {
  91. try {
  92. const res = await getDimensionScoreOverview(params)
  93. if (res.code === 200 && res.data) {
  94. radarData.value = res.data.dimensions || [{ name: '', finalScore: 0, color: '#00e5ff' }]
  95. }
  96. } catch (error) {
  97. console.error('获取维度得分一览失败', error)
  98. }
  99. }
  100. const fetchData = (params) => {
  101. if (!params.deptId && !params.groupId && !params.teamId) {
  102. return
  103. }
  104. // console.log('params', params)
  105. // debugger
  106. fetchTeamData(params)
  107. fetchMemberDistribution(params)
  108. fetchPositionDistribution(params)
  109. fetchRadarData(params)
  110. }
  111. watch(() => props.queryParams, (newParams) => {
  112. fetchData(newParams)
  113. }, { deep: true })
  114. </script>
  115. <style lang="scss" scoped>
  116. .main-content-wrapper {
  117. .main-content {
  118. display: flex;
  119. flex-direction: column;
  120. gap: 20px;
  121. padding: 0 20px 40px;
  122. }
  123. .content-row {
  124. display: flex;
  125. gap: 20px;
  126. >.info-card {
  127. flex: 1;
  128. min-width: 0;
  129. }
  130. }
  131. }
  132. </style>