DepartmentalTaskCompletionRank.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <ChartsContainer name="班组完成排行(Top10)">
  3. <div ref="content" style="height: 100%;">
  4. </div>
  5. </ChartsContainer>
  6. </template>
  7. <script setup>
  8. import { onMounted, computed } from 'vue';
  9. import ChartsContainer from '../ChartsContainer.vue';
  10. import { useECharts } from '@/hooks/useEcharts.js';
  11. import { deptRanking } from '@/api/item/items'
  12. import { useTimeOut } from './useTimeOut'
  13. const content = ref(null)
  14. const datalist = ref([])
  15. const setChartsOptions = computed(() =>{
  16. return {
  17. backgroundColor: 'transparent',
  18. grid: {
  19. top: 50,
  20. right: 20,
  21. bottom: 30,
  22. left: 40
  23. },
  24. legend: {
  25. data: [ '已完成', '总任务数' ],
  26. right: 'center',
  27. top: 10,
  28. textStyle: { color: '#fff' }
  29. },
  30. xAxis: {
  31. type: 'category',
  32. data: datalist.value.map(item => item.deptName),
  33. axisLine: { lineStyle: { color: '#fff' } },
  34. axisLabel: { color: '#fff' }
  35. },
  36. yAxis: {
  37. type: 'value',
  38. min: 0,
  39. interval: 10,
  40. max: Math.ceil(Math.max(datalist.value.map(item => item.totalTasks)) / 0.8),
  41. axisLine: { lineStyle: { color: '#fff' } },
  42. axisLabel: { color: '#fff' },
  43. splitLine: { lineStyle: { color: '#fff' } }
  44. },
  45. tooltip: {
  46. trigger: 'axis'
  47. },
  48. series: [
  49. {
  50. name: '已完成',
  51. type: 'bar',
  52. data: datalist.value.map(item => item.completedTasks),
  53. itemStyle: { color: '#4CAF50' },
  54. label: { show: true, position: 'top', color: '#fff' }
  55. },
  56. {
  57. name: '总任务数',
  58. type: 'bar',
  59. data: datalist.value.map(item => item.totalTasks),
  60. itemStyle: { color: '#2196F3' },
  61. label: { show: true, position: 'top', color: '#fff' }
  62. }
  63. ]
  64. }
  65. })
  66. useECharts(content, setChartsOptions);
  67. useTimeOut(() => {
  68. deptRanking().then(res => {
  69. datalist.value = res.data
  70. })
  71. })
  72. </script>
  73. <style lang="scss" scoped></style>