profile.vue 3.9 KB

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