From 98277f07107ed5229bfdddafefc1cac896758f1d Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期一, 28 十一月 2022 16:58:12 +0800
Subject: [PATCH] Merge branch 'master' of http://42.193.1.25:9521/r/sccg_ui

---
 src/views/intelligentPatrol/trendAnalysis/index.vue |  170 +++++++++++++++++++++++---------------------------------
 1 files changed, 69 insertions(+), 101 deletions(-)

diff --git a/src/views/intelligentPatrol/trendAnalysis/index.vue b/src/views/intelligentPatrol/trendAnalysis/index.vue
index 8321844..1cadf21 100644
--- a/src/views/intelligentPatrol/trendAnalysis/index.vue
+++ b/src/views/intelligentPatrol/trendAnalysis/index.vue
@@ -7,10 +7,13 @@
         <span class="trend-title">瓒嬪娍鍒嗘瀽</span>
         <el-form ref="form" :model="search" label-width="6vw">
           <el-form-item label="绫诲瀷鏌ヨ">
-            <el-input v-model="search.type" placeholder="鍐呭淇℃伅"></el-input>
+            <el-select v-model="search.type" placeholder="鍐呭淇℃伅">
+              <el-option v-for="option in categoryOptions" :key="option.value" :value="option.value" :label="option.label" ></el-option>
+            </el-select>
           </el-form-item>
-          <el-form-item label="鏃堕棿鑼冨洿">
-            <el-input v-model="search.timeRange" suffix-icon="el-icon-date" placeholder="閫夋嫨鏃堕棿鑼冨洿"></el-input>
+          <el-form-item class="time-area" label="鏃堕棿鑼冨洿">
+            <el-date-picker v-model="search.timeRange" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss">
+            </el-date-picker>
           </el-form-item>
         </el-form>
       </div>
@@ -18,39 +21,21 @@
       <div class="trend-data-show">
         <!-- 鐐逛綅鍒囨崲 -->
         <div class="trend-data-header">
-          <el-button type="text" @click="highFlag = true">楂樺彂鐐逛綅</el-button>
-          <el-button type="text" @click="highFlag = false">棣栨杩濊鐐逛綅</el-button>
+          <el-button type="text" @click="tabChange(1)">楂樺彂鐐逛綅</el-button>
+          <el-button type="text" @click="tabChange(2)">棣栨杩濊鐐逛綅</el-button>
         </div>
         <!-- 瀵瑰簲鏁版嵁 -->
         <div class="trend-data-main">
-          <!--  -->
-          <div class="high-point" v-if="highFlag">
-            <div class="point-item" v-for="item in highList" :key="item.id">
-              <span>{{ item.pointName }}</span>
-              <span>{{ item.count }}</span>
-            </div>
-          </div>
-          <!-- 棣栨杩濊 -->
-          <div class="first-point" v-else>
-            <div class="point-item" v-for="item in fisrtList" :key="item.id">
-              <span>{{ item.pointName }}</span>
-              <span>{{ item.count }}</span>
-            </div>
+          <div class="point-item" v-for="item in trendAnalysisList" :key="item.id" @click="pointClick(item)">
+            <span>{{ item.name }}</span>
+            <span>{{ item.count }}</span>
           </div>
         </div>
       </div>
     </div>
     <div class="trend-main">
-      <div class="trend-main-echarts" id="myRef">
+      <div class="trend-main-echarts" id="echarts">
 
-      </div>
-    </div>
-    <div class="trend-footer" v-if="timeRangeFlag">
-      <!-- 閫夋嫨鏃堕棿鑼冨洿 -->
-      <div class="time-area">
-        <el-date-picker v-model="search.timeRange" type="datetimerange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�"
-          end-placeholder="缁撴潫鏃ユ湡">
-        </el-date-picker>
       </div>
     </div>
   </div>
@@ -58,78 +43,44 @@
 
 <script>
 import * as echarts from 'echarts'
-import { transform } from 'echarts-stat';
+import basecase from "@/api/operate/basecase";
+import { CATEGOTY } from "@/utils/helper";
+
 export default {
+  created() {
+    this.searchList()
+  },
+
+  mounted() {
+    this.renderEchart();
+  },
+
+  computed: {
+    categoryOptions() {
+      return CATEGOTY;
+    }
+  },
+
   data() {
     return {
       search: {
-        type: '',
-        timeRange: ''
+        type: null,
+        timeRange: null
       },
       timeRangeFlag: false,
-      highList: [
-        {
-          id: 1,
-          pointName: '鍚庡簡璺�200鍙�-鐞�',
-          count: '100娆�',
-        },
-        {
-          id: 2,
-          pointName: '鍚庡簡璺�200鍙�-鐞�',
-          count: '100娆�',
-        },
-        {
-          id: 3,
-          pointName: '鍚庡簡璺�200鍙�-鐞�',
-          count: '100娆�',
-        },
-        {
-          id: 4,
-          pointName: '鍚庡簡璺�200鍙�-鐞�',
-          count: '100娆�',
-        },
-        {
-          id: 5,
-          pointName: '鍚庡簡璺�200鍙�-鐞�',
-          count: '100娆�',
-        },
-      ],
-      fisrtList: [
-        {
-          id: 1,
-          pointName: '鍚庡簡璺�205鍙�-鐞�',
-          count: '1娆�',
-        },
-        {
-          id: 2,
-          pointName: '鍚庡簡璺�204鍙�-鐞�',
-          count: '1娆�',
-        },
-        {
-          id: 3,
-          pointName: '鍚庡簡璺�203鍙�-鐞�',
-          count: '1娆�',
-        },
-        {
-          id: 4,
-          pointName: '鍚庡簡璺�202鍙�-鐞�',
-          count: '1娆�',
-        },
-        {
-          id: 5,
-          pointName: '鍚庡簡璺�201鍙�-鐞�',
-          count: '1娆�',
-        },
-      ],
+      trendAnalysisList: [],
       highFlag: true,
+      echarts: null,
+      pointName: null
     }
   },
   methods: {
-    renderEchart() {
-      // echarts.registerTransform(transform.regression);
-      const myChart = echarts.init(document.getElementById('myRef'));
+    renderEchart(dataList) {
+      if (!this.echarts) {
+        this.echarts = echarts.init(document.getElementById('echarts'));
+      }
       // 缁樺埗鍥捐〃
-      myChart.setOption({
+      this.echarts.setOption({
         xAxis: {
           name: '鏃�/鍛�',
         },
@@ -138,17 +89,38 @@
         },
         series: [
           {
-            data: [10, 22, 28, 23, 19],
+            data: dataList,
             type: 'line',
             smooth: true
           }
         ]
       });
+    },
+    async searchList() {
+      const [startTime, endTime] = this.search.timeRange ?? [null, null];
+      const trendAnalysisParam = {
+        startTime,
+        endTime,
+        type: this.search.type
+      }
+      this.trendAnalysisList = this.highFlag ? await basecase.getTrendAnalysisData(trendAnalysisParam)
+          : await basecase.getFirstTrendAnalysisData(trendAnalysisParam);
+    },
+    tabChange(params) {
+      this.highFlag = params === 1;
+      this.searchList();
+    },
+
+    pointClick(data) {
+      this.pointName = data.name;
+      basecase.getPointTrendAnalysisData({ id: data.id })
+          .then(res => {
+            const countList = res.map(item => +item.count);
+            this.renderEchart(countList);
+          })
+          .catch(err => this.$message.error(err))
     }
   },
-  mounted() {
-    this.renderEchart()
-  }
 }
 </script>
 
@@ -160,7 +132,7 @@
   display: flex;
 
   .trend-side {
-    width: 20vw;
+    width: 30vw;
     text-align: left;
     height: 100%;
     border: 1px solid #09152f;
@@ -199,14 +171,10 @@
       }
 
       .trend-data-main {
-
-        .high-point,
-        .first-point {
-          .point-item {
-            display: flex;
-            padding: 0 2vw;
-            justify-content: space-between;
-          }
+        .point-item {
+          display: flex;
+          padding: 0 2vw;
+          justify-content: space-between;
         }
       }
     }

--
Gitblit v1.8.0