农经大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.1 KiB

  1. import Pannel from '@/components/pannel/index.vue';
  2. import PannelTabs from '@/components/pannel-tabs/index.vue';
  3. import LineCharts from '@/components/charts/line/index.vue';
  4. import PieCharts from '@/components/charts/pie/index.vue';
  5. import { mapGetters } from 'vuex';
  6. import { analysisOfCapitalExpenditureType, analysisOfCapitalExpenditureRend } from '../../../../api/index.js';
  7. export default {
  8. components: {
  9. LineCharts,
  10. PieCharts,
  11. PannelTabs,
  12. Pannel
  13. },
  14. data () {
  15. return {
  16. data: [], // 数据
  17. isLoad: false, // 是否加载完成
  18. tabIndex: '1'
  19. };
  20. },
  21. computed: {
  22. ...mapGetters(['year', 'deptId'])
  23. },
  24. created () {
  25. },
  26. mounted () {
  27. },
  28. watch: {
  29. year: {
  30. handler () {
  31. this.getData();
  32. },
  33. immediate: true, // 立即执行
  34. },
  35. deptId: {
  36. handler () {
  37. this.getData();
  38. },
  39. immediate: true, // 立即执行
  40. }
  41. },
  42. methods: {
  43. tabChange (info) {
  44. //console.log(info);
  45. this.tabIndex = info.id
  46. this.getData()
  47. },
  48. // 获取数据
  49. getData () {
  50. if (this.year || this.deptId) {
  51. this.isLoad = false;
  52. // 如果是趋势
  53. if (this.tabIndex == 1) {
  54. analysisOfCapitalExpenditureRend(this.deptId, this.year).then(res => {
  55. let data = res.data.map(item => {
  56. return {
  57. name: item.name + '月',
  58. value: item.value
  59. }
  60. })
  61. this.data = data;
  62. this.isLoad = true;
  63. })
  64. } else if (this.tabIndex == 2) {
  65. // 获取类型
  66. analysisOfCapitalExpenditureType(this.deptId, this.year).then(res => {
  67. let data = res.data.list.map(item => {
  68. return {
  69. name: item.name,
  70. value: item.value,
  71. unit: '万元'
  72. }
  73. })
  74. this.data = data
  75. this.isLoad = true;
  76. })
  77. }
  78. }
  79. },
  80. }
  81. };