profile.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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="memberColumns" :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 { getDeptMembers, 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. const teamMembers = ref([
  30. // { deptName: '安检一队', employeeCount: 32, partyMemberCount: 8, avgAge: 28.5, avgServiceYear: 4.2, avgXrayYear: 3.1, totalScore: 92.5 },
  31. // { deptName: '安检二队', employeeCount: 28, partyMemberCount: 6, avgAge: 30.2, avgServiceYear: 5.8, avgXrayYear: 4.5, totalScore: 88.3 },
  32. // { deptName: '安检三队', employeeCount: 35, partyMemberCount: 10, avgAge: 27.8, avgServiceYear: 3.5, avgXrayYear: 2.8, totalScore: 90.1 },
  33. // { deptName: '安检四队', employeeCount: 30, partyMemberCount: 7, avgAge: 29.6, avgServiceYear: 4.8, avgXrayYear: 3.6, totalScore: 86.7 },
  34. // { deptName: '安检五队', employeeCount: 26, partyMemberCount: 5, avgAge: 31.0, avgServiceYear: 6.2, avgXrayYear: 5.0, totalScore: 85.9 },
  35. // { deptName: '安检六队', employeeCount: 33, partyMemberCount: 9, avgAge: 28.0, avgServiceYear: 3.8, avgXrayYear: 2.5, totalScore: 91.2 }
  36. ])
  37. const memberColumns = ref([
  38. { label: '姓名', prop: 'personName' },
  39. { label: '年龄', prop: 'age' },
  40. { label: '司龄', prop: 'workYears' },
  41. { label: '性别', prop: 'sex' },
  42. { label: '民族', prop: 'nation' },
  43. { label: '政治面貌', prop: 'politicalStatus' },
  44. { label: '职务', prop: 'roleNames' },
  45. { label: '职业技能等级', prop: 'qualificationLevel' },
  46. { label: '开机年限', prop: 'xrayOperatorYears' },
  47. { label: '综合得分', prop: 'totalScore' }
  48. ])
  49. const genderData = ref([
  50. ])
  51. const nationData = ref([
  52. ])
  53. const politicalData = ref([
  54. ])
  55. const skillData = ref([])
  56. const operateData = ref([])
  57. const postData = ref({
  58. categories: ['前传', '人身', '验证', '开包', '开机'],
  59. values: [4, 5, 6, 7, 8],
  60. colors: ['#ff6b6b', '#ee5a24']
  61. })
  62. const fetchTeamMembers = async (params) => {
  63. try {
  64. const res = await getDeptMembers(params)
  65. if (res.code === 200 && res.data) {
  66. teamMembers.value = res.data
  67. }
  68. } catch (error) {
  69. console.error('获取部门成员列表失败', error)
  70. }
  71. }
  72. const fetchMemberDistribution = async (params) => {
  73. try {
  74. const res = await getDeptMemberDistribution(params)
  75. if (res.code === 200 && res.data) {
  76. genderData.value = res.data.sexDistribution.map(item => ({ value: item.count, name: item.name })) || []
  77. nationData.value = res.data.nationDistribution.map(item => ({ value: item.count, name: item.name })) || []
  78. politicalData.value = res.data.politicalDistribution.map(item => ({ value: item.count, name: item.name })) || []
  79. console.log('genderData', genderData.value)
  80. console.log('nationData', nationData.value)
  81. console.log('politicalData', politicalData.value)
  82. }
  83. } catch (error) {
  84. console.error('获取部门成员基本情况分布失败', error)
  85. }
  86. }
  87. const fetchPositionDistribution = async (params) => {
  88. try {
  89. const res = await getDeptPositionDistribution(params)
  90. if (res.code === 200 && res.data) {
  91. skillData.value = res.data.qualificationDistribution.map(item => ({ value: item.count, name: item.name })) || []
  92. operateData.value = res.data.xrayYearDistribution.map(item => ({ value: item.count, name: item.name })) || []
  93. postData.value = res.data.positionDistribution.map(item => ({ value: item.count, name: item.name })) || []
  94. }
  95. } catch (error) {
  96. console.error('获取部门成员职位情况分布失败', error)
  97. }
  98. }
  99. const fetchRadarData = async (params) => {
  100. try {
  101. const res = await getDimensionScoreOverview(params)
  102. if (res.code === 200 && res.data) {
  103. radarData.value = res.data.dimensions || [{ name: '', finalScore: 0, color: '#00e5ff' }]
  104. }
  105. } catch (error) {
  106. console.error('获取维度得分一览失败', error)
  107. }
  108. }
  109. const fetchData = (params) => {
  110. if (!params.deptId && !params.groupId && !params.teamId) {
  111. return
  112. }
  113. // console.log('params', params)
  114. // debugger
  115. fetchTeamMembers(params)
  116. fetchMemberDistribution(params)
  117. fetchPositionDistribution(params)
  118. fetchRadarData(params)
  119. }
  120. watch(() => props.queryParams, (newParams) => {
  121. fetchData(newParams)
  122. }, { deep: true, immediate: true })
  123. </script>
  124. <style lang="scss" scoped>
  125. .main-content-wrapper {
  126. .main-content {
  127. display: flex;
  128. flex-direction: column;
  129. gap: 20px;
  130. padding: 0 20px 40px;
  131. }
  132. .content-row {
  133. display: flex;
  134. gap: 20px;
  135. >.info-card {
  136. flex: 1;
  137. min-width: 0;
  138. }
  139. }
  140. }
  141. </style>