Bladeren bron

fix:页面图表完善

Cooklalala 6 maanden geleden
bovenliggende
commit
b75d1f7e33

+ 16 - 4
src/components/Customize/cake.vue

@@ -2,8 +2,8 @@
 <template>
   <div>
     <boxTop :title="title" />
-    <div class="cakeBox flex">
-      <div class="chartsdom" id="cake"></div>
+    <div class="cakeBox flex" :style="{ width: barWidth }">
+      <div class="chartsdom" :id="id"></div>
       <div class="panel">
         <div class="panelitem flex space_around">
           <div v-for="item in data.acrossList" :key="item.index">
@@ -43,8 +43,17 @@ export default {
     boxTop,
   },
   props: {
+    id: {
+      type: String,
+      default: ``,
+    },
+    barWidth: {
+      type: String,
+      default: `401px`,
+    },
     data: {
       type: Object,
+      default: new Object(),
     },
     title: {
       type: String,
@@ -60,16 +69,19 @@ export default {
   },
   watch: {
     data: {
-      handler(newVal) {
+      handler() {
         this.getEchart()
       },
       deep: true, // 深度监听
       immediate: true, // 立即执行
     },
+    // data() {
+    //   this.getEchart()
+    // },
   },
   methods: {
     getEchart() {
-      let myChart = echarts.init(document.getElementById(`cake`))
+      let myChart = echarts.init(document.getElementById(this.id))
       const title = this.data.title
       const value = this.data.value
       const splitLineLength = `19%`

+ 5 - 4
src/components/Customize/wavyLineChart.vue

@@ -3,7 +3,7 @@
 <template>
   <div>
     <boxTop :title="title" />
-    <div class="wavylineBox">
+    <div class="wavylineBox" :style="{ width: barWidth }">
       <div class="chartsdom" :id="id"></div>
     </div>
   </div>
@@ -31,7 +31,8 @@ export default {
       default: ``,
     },
     barWidth: {
-      type: Number,
+      type: String,
+      default: `401px`,
     },
     area: {
       type: Array,
@@ -52,7 +53,7 @@ export default {
     this.getEchart()
   },
   watch: {
-    area() {
+    dataArray() {
       this.getEchart()
     },
   },
@@ -221,7 +222,7 @@ export default {
 
 <style lang="less" scoped>
 .wavylineBox {
-  width: 401px;
+  width: 448px;
   height: 266px;
   .chartsdom {
     width: 100%;

+ 6 - 2
src/components/Customize/weatherForecast.vue

@@ -2,7 +2,7 @@
 <template>
   <div>
     <boxTop :title="title" />
-    <div class="weatherBox">
+    <div class="weatherBox" :style="{ width: barWidth }">
       <div class="chartsdom" id="weather"></div>
     </div>
   </div>
@@ -24,6 +24,10 @@ export default {
     dataArray: {
       type: Array,
     },
+    barWidth: {
+      type: String,
+      default: `401px`,
+    },
     title: {
       type: String,
       default: ``,
@@ -108,7 +112,7 @@ export default {
         xAxis: {
           type: `category`,
           axisLabel: {
-            formatter: `{value}ri`,
+            formatter: `{value}`,
             color: `#c7d6f2`,
             fontSize: `12px`,
             fontFamily: `Microsoft YaHei`,

+ 6 - 5
src/views/page1/index.vue

@@ -1,6 +1,7 @@
 <template>
   <bgBox :tabChange="tabChange" class="bgBox" :tabIndex="0">
     <cake
+      id="`实时统计`"
       style="position: absolute; top: 115px; left: 50px"
       title="实时统计"
       :data="statisticsData"
@@ -33,8 +34,8 @@
       class="animated fadeInRight"
       v-if="isWavyLine"
       title="各区域移栽面积"
-      :area.sync="wavyLineArea"
-      :dataArray.sync="wavyLinedataArray"
+      :area="wavyLineArea"
+      :dataArray="wavyLinedataArray"
       smooth="true"
     />
     <HorizontalHistogram
@@ -50,10 +51,10 @@
       id="`移栽趋势分析`"
       style="position: absolute; right: 50px; top: 760px"
       class="animated fadeInRight"
-      v-if="isWavyLine"
+      v-if="isTrend"
       title="移栽趋势分析"
-      :area.sync="trendarea"
-      :dataArray.sync="trendDataArray"
+      :area="trendarea"
+      :dataArray="trendDataArray"
     />
     <threeMap
       class="animated zoomIn"

+ 6 - 4
src/views/page2/index.vue

@@ -10,21 +10,24 @@
         title="各区域移栽面积"
         :area="HorizontalArea"
         :dataArray="HorizontalArray"
+        class="animated fadeInRight"
       />
       <wavyLineChart
         id="`本月移栽数量趋势`"
         style="position: absolute; right: 50px; top: 460px; z-index: 10"
-        v-if="isWavyLine"
+        v-if="isTrend"
         title="本月移栽数量趋势"
         :area.sync="trendarea"
         :dataArray.sync="trendDataArray"
+        class="animated fadeInRight"
       />
       <wavyLineChart
         id="`本年移栽数量趋势`"
         style="position: absolute; right: 50px; top: 760px; z-index: 10"
-        v-if="isWavyLine"
+        v-if="isTrend"
         title="本年移栽数量趋势"
         :area.sync="trendarea"
+        class="animated fadeInRight"
         :dataArray.sync="trendDataArray"
       />
     </bgBox>
@@ -38,7 +41,6 @@ import leftBox from './leftBox.vue'
 import HorizontalHistogram from '@/components/Customize/HorizontalHistogram'
 import wavyLineChart from '@/components/Customize/wavyLineChart'
 window.map = {}
-
 export default {
   components: {
     bgBox,
@@ -59,7 +61,7 @@ export default {
         LastYear: [],
         thisYear: [],
       },
-      isWavyLine: true,
+      isTrend: true,
     }
   },
   computed: {},

+ 160 - 2
src/views/page3/index.vue

@@ -34,13 +34,75 @@
       </div>
       <leftBox class="lefBox" />
       <leftBox2 class="lefBox2" />
+      <cake
+        id="`移栽数据`"
+        barWidth="448px"
+        style="position: absolute; top: 95px; right: 550px"
+        title="移栽数据"
+        :data="statisticsData"
+        class="animated fadeInRight"
+        v-if="isCake"
+      />
+      <weatherForecast
+        :unit="`摄氏度`"
+        barWidth="448px"
+        style="position: absolute; right: 50px; top: 95px"
+        class="animated fadeInRight"
+        v-if="isWeather"
+        title="天气预报"
+        :area="Weatherarea"
+        :dataArray="WeatherdataArray"
+        :alertValue="30"
+      />
+      <wavyLineChart
+        id="`月度移栽趋势`"
+        barWidth="448px"
+        style="position: absolute; right: 550px; top: 400px; z-index: 10"
+        v-if="isTrend"
+        title="月度移栽趋势"
+        :area.sync="trendarea"
+        class="animated fadeInRight"
+        :dataArray.sync="trendDataArray"
+      />
+      <wavyLineChart
+        id="`月度移栽面积分析`"
+        barWidth="448px"
+        style="position: absolute; right: 550px; top: 730px; z-index: 10"
+        v-if="isTrend"
+        title="月度移栽面积分析"
+        :area.sync="trendarea"
+        class="animated fadeInRight"
+        :dataArray.sync="trendDataArray"
+      />
+      <wavyLineChart
+        id="`年度移栽趋势`"
+        barWidth="448px"
+        style="position: absolute; right: 50px; top: 400px; z-index: 10"
+        v-if="isTrend"
+        title="年度移栽趋势"
+        :area.sync="trendarea"
+        class="animated fadeInRight"
+        :dataArray.sync="trendDataArray"
+      />
+      <wavyLineChart
+        id="`年度移栽面积分析`"
+        barWidth="448px"
+        style="position: absolute; right: 50px; top: 730px; z-index: 10"
+        v-if="isTrend"
+        title="年度移栽面积分析"
+        :area.sync="trendarea"
+        class="animated fadeInRight"
+        :dataArray.sync="trendDataArray"
+      />
     </div>
   </bgBox>
 </template>
 
 <script>
 import 'element-ui/lib/theme-chalk/index.css'
-
+import wavyLineChart from '@/components/Customize/wavyLineChart'
+import weatherForecast from '@/components/Customize/weatherForecast'
+import cake from '@/components/Customize/cake'
 import bgBox from '@/components/bgBox/index.vue'
 import leftBox from './leftBox.vue'
 import leftBox2 from './leftBox2.vue'
@@ -68,6 +130,9 @@ export default {
     leftBox,
     leftBox2,
     bgBox,
+    wavyLineChart,
+    weatherForecast,
+    cake,
   },
   data() {
     const vm = this
@@ -92,10 +157,47 @@ export default {
         radio: 6,
         date: [],
       },
+      trendarea: [],
+      trendDataArray: {
+        LastYear: [],
+        thisYear: [],
+      },
+      statisticsData: {
+        title: `处理率`,
+        value: 0,
+        acrossList: [{ name: `今日种植数`, value: undefined }],
+        verticalList: [
+          { name: `目标移栽数`, value: undefined },
+          { name: `累计移栽`, value: undefined },
+        ],
+      },
+      Weatherarea: [],
+      WeatherdataArray: [],
+      isCake: false,
+      isTrend: false,
+      isWeather: false,
     }
   },
   computed: {},
-  async created() {},
+  async created() {
+    this.$util.autoVueFn(
+      [
+        {
+          time: 1000 * 5,
+          fn: this.getTrendAnalysis,
+        },
+        {
+          time: 1000 * 5,
+          fn: this.getStatistics,
+        },
+        {
+          time: 1000 * 5,
+          fn: this.getWeatherForecast,
+        },
+      ],
+      this
+    )
+  },
   watch: {
     'query.radio': {
       handler(val) {
@@ -123,6 +225,62 @@ export default {
     getEchartData(start, end) {
       console.log(`start, end`, start, end)
     },
+    getWeatherForecast() {
+      return this.$http.get(`/api/weatherForecast`).then((res) => {
+        const area = []
+        const dataArray = []
+        res.forEach((element) => {
+          area.push(element.时间)
+          dataArray.push(element.温度)
+        })
+        this.Weatherarea = area
+        this.WeatherdataArray = dataArray
+        this.isWeather = true
+      })
+    },
+    getTrendAnalysis() {
+      this.$http.get(`/api/transplantTrendAnalysis`).then((res) => {
+        const area = []
+        const dataArray = {
+          LastYear: [],
+          thisYear: [],
+        }
+        res.forEach((element) => {
+          area.push(element.时间)
+          dataArray.LastYear.push(element.去年)
+          dataArray.thisYear.push(element.今年)
+        })
+        this.trendarea = area
+        this.trendDataArray = dataArray
+        this.isTrend = true
+      })
+    },
+    getStatistics() {
+      return this.$http.get(`/api/transplantData`).then((res) => {
+        const obj = this.statisticsData
+        // eslint-disable-next-line no-prototype-builtins
+        if (res.hasOwnProperty(obj.title)) {
+          obj.value = res[obj.title]
+        }
+        const list1 = this.statisticsData.acrossList
+        this.statisticsData.acrossList = list1.map((item) => {
+          // eslint-disable-next-line no-prototype-builtins
+          if (res.hasOwnProperty(item.name)) {
+            return { ...item, value: res[item.name] }
+          }
+          return item
+        })
+        const list2 = this.statisticsData.verticalList
+        this.statisticsData.verticalList = list2.map((item) => {
+          // eslint-disable-next-line no-prototype-builtins
+          if (res.hasOwnProperty(item.name)) {
+            return { ...item, value: res[item.name] }
+          }
+          return item
+        })
+        this.isCake = true
+      })
+    },
     backFn() {
       console.log(`backFn`)
     },