瀏覽代碼

fix home2

scorpio 2 年之前
父節點
當前提交
74ea62cfe5
共有 2 個文件被更改,包括 25 次插入14 次删除
  1. 6 0
      src/views/invest/components/chart.vue
  2. 19 14
      src/views/invest/index.vue

+ 6 - 0
src/views/invest/components/chart.vue

@@ -170,8 +170,14 @@ export default {
           this.option.xAxis[0].data = res.data.map(res => res.month)
           this.option.series[0].data = res.data.map(res => res.sum_complete_amount)
           this.option.series[1].data = res.data.map(res => res.average)
+          const length = res.data.length
+          this.avg(this.option.series[0].data[0], this.option.series[1].data[0])
         }
       })
+    },
+    avg (lastComplete, lastAvg) {
+      console.log(lastComplete, lastAvg)
+      this.$emit('avg', lastComplete < lastAvg)
     }
   }
 }

+ 19 - 14
src/views/invest/index.vue

@@ -28,15 +28,16 @@
             <div class='flex-child-average full-width flex flex-col flex-justify-start'>
               <div class="flex flex-center flex-justify-between">
                 <span class='font-16 bold full-width text-left '>投资数据统计 单位(亿元)</span>
-                <div v-if="isAverage === false" class="flex flex-center red">
+                <div  class="flex flex-center" :class='isAverage ? "red" :"blue" '>
                   <el-icon>
                     <Warning/>
                   </el-icon>
-                  <span class='full-width text-right ml-5 nowrap mr-20'>上月未完成平均投资指标</span>
+                  <span class='full-width text-right ml-5 nowrap mr-20' v-if='isAverage'>上月未完成平均投资指标</span>
+                  <span class='full-width text-right  ml-5 nowrap mr-20' v-else>上月已完成平均投资指标</span>
                 </div>
               </div>
               <div class='full-width mt-10' style='background-color: #F7FAFD'>
-                <chart :dept-id='dept' :quarter='yearType.value === 0 ? "":yearType ' :year="year"/>
+                <chart :dept-id='dept' :quarter='yearType.value === 0 ? "":yearType ' :year="year" @avg='avg'/>
               </div>
 
               <span class='font-16 bold full-width text-left mt-20'>项目入库统计  单位(个)</span>
@@ -72,16 +73,16 @@ import amount from '@/views/invest/components/amount.vue'
 import chart from '@/views/invest/components/chart.vue'
 import chart2 from '@/views/invest/components/chart2.vue'
 import complete from '@/views/invest/components/complete.vue'
-import {useStore} from '@/store/user.js'
+import { useStore } from '@/store/user.js'
 
 export default {
   name: 'index',
-  components: {BasicContainer, left, years, amount, chart, chart2, complete},
-  setup() {
+  components: { BasicContainer, left, years, amount, chart, chart2, complete },
+  setup () {
     const user = useStore()
-    return {user}
+    return { user }
   },
-  data() {
+  data () {
     return {
       yearType: {
         value: 0
@@ -114,31 +115,35 @@ export default {
       isAverage: true
     }
   },
-  created() {
+  created () {
     this.year = new Date().getFullYear()
     this.isBelowAverage()
   },
   methods: {
-    changeDept(res) {
+    changeDept (res) {
       if (res === null) {
         this.dept = null
         return
       }
       this.dept = res.id
     },
-    change(index) {
+    change (index) {
       this.yearType = index
     },
-    yearSelect(res) {
+    yearSelect (res) {
       this.year = res
     },
-    isBelowAverage() {
+    isBelowAverage () {
       this.$api.invest.belowAverage().then(res => {
         if (res.code === 200) {
-          this.isAverage = res.data
+          // this.isAverage = res.data
         }
       })
     },
+    avg (res) {
+      console.log(res)
+      this.isAverage = res
+    }
   }
 }
 </script>