scorpioyq 2 年 前
コミット
785d6ee695
2 ファイル変更38 行追加38 行削除
  1. 32 31
      src/views/invest/components/chart.vue
  2. 6 7
      src/views/invest/index.vue

+ 32 - 31
src/views/invest/components/chart.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <charts id="chart" height="255px" :option="option" />
+    <charts id="chart" height="255px" :option="option"/>
   </div>
 </template>
 
@@ -8,7 +8,7 @@
 import charts from '../../../components/echarts/index.vue'
 
 export default {
-  components: { charts },
+  components: {charts},
   props: {
     deptId: {
       type: String,
@@ -58,8 +58,8 @@ export default {
         xAxis: [
           {
             type: 'category',
-            axisTick: { show: false },
-            splitLine: { show: false },
+            axisTick: {show: false},
+            splitLine: {show: false},
             data: [],
             axisPointer: {
               type: 'shadow'
@@ -76,8 +76,8 @@ export default {
         yAxis: [
           {
             type: 'value',
-            axisTick: { show: false },
-            splitLine: { show: false },
+            axisTick: {show: false},
+            splitLine: {show: false},
             axisLine: {
               show: true,
               lineStyle: {
@@ -89,8 +89,8 @@ export default {
           {
             type: 'value',
             name: '',
-            axisTick: { show: true },
-            splitLine: { show: true },
+            axisTick: {show: true},
+            splitLine: {show: true},
             interval: 5,
             axisLabel: {
               formatter: '',
@@ -124,7 +124,7 @@ export default {
               show: true,
               position: 'top'
             },
-            lineStyle: { color: '#528BEC', type: 'solid', borderColor: 'red' },
+            lineStyle: {color: '#528BEC', type: 'solid', borderColor: 'red'},
             data: []
           },
           {
@@ -149,7 +149,7 @@ export default {
               show: true,
               position: 'top'
             },
-            lineStyle: { color: 'red', type: 'solid', borderColor: 'red' },
+            lineStyle: {color: 'red', type: 'solid', borderColor: 'red'},
             data: []
           }
         ]
@@ -157,32 +157,33 @@ export default {
       type: 1
     }
   },
-  created() {},
+  created() {
+  },
   methods: {
     init() {
       this.$api.invest
-        .count({
-          deptId: this.deptId === null ? '' : this.deptId,
-          year: this.year === null ? '' : this.year,
-          quarter: this.quarter.value === undefined ? '' : this.quarter.value
-        })
-        .then(res => {
-          if (res.code === 200) {
-            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 size = this.option.series[0].data.length
-            this.avg(
-              this.option.series[0].data[size - 1],
-              this.option.series[1].data[size - 1]
-            )
-          }
-        })
+          .count({
+            deptId: this.deptId === null ? '' : this.deptId,
+            year: this.year === null ? '' : this.year,
+            quarter: this.quarter.value === undefined ? '' : this.quarter.value
+          })
+          .then(res => {
+            if (res.code === 200) {
+              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 size = this.option.series[0].data.length
+              this.avg(
+                  this.option.series[0].data[size - 2],
+                  this.option.series[1].data[size - 2]
+              )
+            }
+          })
     },
     avg(lastComplete, lastAvg) {
-      this.$emit('avg', lastAvg === 0 ? true : lastComplete < lastAvg)
+      this.$emit('avg', lastAvg === 0 ? true : lastComplete > lastAvg)
     }
   }
 }

+ 6 - 7
src/views/invest/index.vue

@@ -38,7 +38,7 @@
                 >
                 <div
                     class="flex flex-center"
-                    :class="isAverage ? 'red' : 'blue'"
+                    :class="isAverage ? 'green' : 'red'"
                 >
                   <el-icon>
                     <Warning/>
@@ -46,10 +46,10 @@
                   <span
                       class="full-width text-right ml-5 nowrap mr-20"
                       v-if="isAverage"
-                  >上月完成平均投资指标</span
+                  >上月完成平均投资指标</span
                   >
                   <span class="full-width text-right ml-5 nowrap mr-20" v-else
-                  >上月完成平均投资指标</span
+                  >上月完成平均投资指标</span
                   >
                 </div>
               </div>
@@ -147,12 +147,12 @@ export default {
           value: 2017
         }
       ],
-      isAverage: true
+      isAverage: false
     }
   },
   created() {
     this.year = new Date().getFullYear()
-    this.isBelowAverage()
+    // this.isBelowAverage()
     this.deptDetail()
   },
   methods: {
@@ -182,12 +182,11 @@ export default {
     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
     }
   }