赵士淞
2023-03-21 92e50a5a1bfc81ce40f8073f181459e82a45c07c
项目区分营业额与目标金额对比
2 files added
2 files modified
195 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/impl/ProjectServiceImpl.java 1 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/project/project.js 10 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/project/chart/subgroupTurnover.vue 126 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/project/index.vue 58 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/impl/ProjectServiceImpl.java
@@ -475,6 +475,7 @@
                if (dictDetail.getValue().equals(sysGoalSettingDtoList.get(j).getProjectDistinguish())) {
                    // 返回集合
                    returnMap.put("targetAmount", sysGoalSettingDtoList.get(j).getTargetAmount());
                    break;
                }
                // 判断循环是否结束
                if (j == sysGoalSettingDtoList.size() - 1) {
eladmin-web-master/src/api/project/project.js
@@ -64,4 +64,12 @@
  })
}
export default { getAll, add, edit, del, editAdmit, editDisavow, getPartake, getRelevant }
export function getSubgroupTurnover(params) {
  return request({
    url: 'api/project/subgroupTurnover',
    method: 'get',
    params
  })
}
export default { getAll, add, edit, del, editAdmit, editDisavow, getPartake, getRelevant, getSubgroupTurnover }
eladmin-web-master/src/views/project/chart/subgroupTurnover.vue
New file
@@ -0,0 +1,126 @@
<template>
  <div :class="className" :style="{ height: height, width: width }" />
</template>
<script>
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import { debounce } from '@/utils'
import crudProject from '@/api/project/project'
export default {
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '400px'
    },
    targetYear: {
      type: String,
      default: '2023'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.initChart()
    this.__resizeHandler = debounce(() => {
      if (this.chart) {
        this.chart.resize()
      }
    }, 100)
    window.addEventListener('resize', this.__resizeHandler)
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    window.removeEventListener('resize', this.__resizeHandler)
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')
      crudProject.getSubgroupTurnover({ targetYear: this.targetYear }).then(res => {
        console.log(res)
        // 图表项目区分类目
        const projectDistinguishData = []
        // 图表营业额类目
        const contractPriceData = []
        // 图表目标金额类目
        const targetAmountData = []
        // 遍历资产收入数据
        for (let i = 0; i < res.length; i++) {
          // 图表项目区分类目
          projectDistinguishData.push(res[i].projectDistinguish)
          // 图表营业额类目
          contractPriceData.push(res[i].contractPrice)
          // 图表目标金额类目
          targetAmountData.push(res[i].targetAmount)
        }
        this.chart.setOption({
          title: {
            text: '项目区分营业额与目标金额对比',
            subtext: '',
            left: 'center'
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          legend: {
            data: ['营业额', '目标金额'],
            right: '10%'
          },
          xAxis: [
            {
              type: 'category',
              axisTick: { show: false },
              data: projectDistinguishData
            }
          ],
          yAxis: [
            {
              type: 'value'
            }
          ],
          series: [
            {
              name: '营业额',
              type: 'bar',
              barGap: 0,
              emphasis: {
                focus: 'series'
              },
              data: contractPriceData
            },
            {
              name: '目标金额',
              type: 'bar',
              emphasis: {
                focus: 'series'
              },
              data: targetAmountData
            }
          ]
        })
      })
    }
  }
}
</script>
eladmin-web-master/src/views/project/index.vue
New file
@@ -0,0 +1,58 @@
<template>
  <div class="dashboard-container">
    <div class="dashboard-editor-container">
      <subgroup-turnover />
    </div>
  </div>
</template>
<script>
import SubgroupTurnover from './chart/subgroupTurnover.vue'
export default {
  name: 'ProjectChart',
  components: { SubgroupTurnover },
  data() {
    return {
    }
  },
  created() {
  },
  methods: {
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    position: relative;
    .github-corner {
      position: absolute;
      top: 0;
      border: 0;
      right: 0;
    }
    .search-wrapper {
      text-align: right;
    }
    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
      overflow: auto;
    }
  }
  @media (max-width:1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
</style>