scorpio 2 lat temu
rodzic
commit
57d518ecaf
3 zmienionych plików z 94 dodań i 102 usunięć
  1. 26 34
      src/views/invest/components/chart.vue
  2. 11 11
      src/views/invest/index.vue
  3. 57 57
      vite.config.js

+ 26 - 34
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,33 +157,25 @@ 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 - 2],
-                  this.option.series[1].data[size - 2]
-              )
-            }
-          })
-    },
-    avg(lastComplete, lastAvg) {
-      this.$emit('avg', lastAvg === 0 ? true : lastComplete > lastAvg)
+        .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
+          }
+        })
     }
   }
 }

+ 11 - 11
src/views/invest/index.vue

@@ -58,7 +58,6 @@
                   :dept-id="dept"
                   :quarter="yearType.value === 0 ? '' : yearType"
                   :year="year"
-                  @avg="avg"
                 />
               </div>
 
@@ -153,6 +152,7 @@ export default {
   created() {
     this.year = new Date().getFullYear()
     this.deptDetail()
+    this.getAvg()
   },
   methods: {
     deptDetail() {
@@ -171,22 +171,22 @@ export default {
         return
       }
       this.dept = res.id
+      this.getAvg()
+    },
+    getAvg() {
+      this.$api.invest
+        .belowAverage({ deptId: this.dept ? this.dept : '' })
+        .then(res => {
+          if (res.code === 200) {
+            this.isAverage = res.data
+          }
+        })
     },
     change(index) {
       this.yearType = index
     },
     yearSelect(res) {
       this.year = res
-    },
-    isBelowAverage() {
-      this.$api.invest.belowAverage().then(res => {
-        if (res.code === 200) {
-          this.isAverage = res.data
-        }
-      })
-    },
-    avg(res) {
-      this.isAverage = res
     }
   }
 }

+ 57 - 57
vite.config.js

@@ -1,4 +1,4 @@
-import {defineConfig} from 'vite'
+import { defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import Pages from 'vite-plugin-pages'
 import Layouts from 'vite-plugin-vue-layouts'
@@ -6,63 +6,63 @@ import path from 'path'
 
 // https://vitejs.dev/config/
 export default defineConfig({
-    plugins: [
-        vue(),
-        Pages({
-            dirs: [
-                {
-                    dir: 'src/page',
-                    baseRoute: ''
-                },
-                {
-                    dir: 'src/views',
-                    baseRoute: ''
-                }
-            ],
-            exclude: [
-                '**/components/*.vue',
-                '**/component/*.vue',
-                '**/component/**/*'
-            ]
-        }),
-        Layouts({
-            layoutsDirs: 'src/layout',
-            defaultLayout: 'index'
-        })
-    ],
-    resolve: {
-        alias: {
-            '@': path.resolve(path.resolve(), 'src')
+  plugins: [
+    vue(),
+    Pages({
+      dirs: [
+        {
+          dir: 'src/page',
+          baseRoute: ''
+        },
+        {
+          dir: 'src/views',
+          baseRoute: ''
         }
-    },
-    minify: 'terser',
-    build: {
-        chunkSizeWarningLimit: 1500,
-        rollupOptions: {
-            output: {
-                manualChunks(id) {
-                    if (id.includes('node_modules')) {
-                        return id
-                            .toString()
-                            .split('node_modules/')[1]
-                            .split('/')[0]
-                            .toString()
-                    }
-                }
-            }
-        }
-    },
-    server: {
-        open: true,
-        proxy: {
-            '/api': {
-                // 正式环境地址
-                target: 'https://dev.wutongresearch.club/api',
-                // target: 'https://prod.wutongshucloud.com/api',
-                // target: 'http://192.168.31.181:8110',
-                changeOrigin: true,
-                rewrite: path => path.replace(/^\/api/, '')
-            }
+      ],
+      exclude: [
+        '**/components/*.vue',
+        '**/component/*.vue',
+        '**/component/**/*'
+      ]
+    }),
+    Layouts({
+      layoutsDirs: 'src/layout',
+      defaultLayout: 'index'
+    })
+  ],
+  resolve: {
+    alias: {
+      '@': path.resolve(path.resolve(), 'src')
+    }
+  },
+  minify: 'terser',
+  build: {
+    chunkSizeWarningLimit: 1500,
+    rollupOptions: {
+      output: {
+        manualChunks(id) {
+          if (id.includes('node_modules')) {
+            return id
+              .toString()
+              .split('node_modules/')[1]
+              .split('/')[0]
+              .toString()
+          }
         }
+      }
+    }
+  },
+  server: {
+    open: true,
+    proxy: {
+      '/api': {
+        // 正式环境地址
+        target: 'https://dev.wutongresearch.club/api',
+        // target: 'https://prod.wutongshucloud.com/api',
+        // target: 'http://192.168.31.181:8110',
+        changeOrigin: true,
+        rewrite: path => path.replace(/^\/api/, '')
+      }
     }
+  }
 })