From 0a8e4f9371a403db92f2894a78363600e5583908 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期四, 15 十二月 2022 22:12:08 +0800 Subject: [PATCH] 优化 --- src/views/intelligentPatrol/trendAnalysis/index.vue | 216 +++++++++++++++++++++++++++++++---------------------- 1 files changed, 125 insertions(+), 91 deletions(-) diff --git a/src/views/intelligentPatrol/trendAnalysis/index.vue b/src/views/intelligentPatrol/trendAnalysis/index.vue index 5d5a93a..dc2095e 100644 --- a/src/views/intelligentPatrol/trendAnalysis/index.vue +++ b/src/views/intelligentPatrol/trendAnalysis/index.vue @@ -1,67 +1,83 @@ <template> - <div class="trend-analysis"> - <!-- 渚ц竟鏍� --> - <div class="trend-side"> - <!-- 杈撳叆鍖哄煙 --> - <div class="trend-input-area"> - <span class="trend-title">瓒嬪娍鍒嗘瀽</span> - <el-form ref="form" :model="search" label-width="6vw"> -<!-- <el-form-item label="绫诲瀷鏌ヨ">--> -<!-- <el-select v-model="search.type" @change="searchList" 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 class="time-area" label="鏃堕棿鑼冨洿"> - <el-date-picker @change="searchList" start-placeholder="寮�濮嬫椂闂�" end-placeholder="缁撴潫鏃堕棿" v-model="search.timeRange" - type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss"> - </el-date-picker> - </el-form-item> - </el-form> - </div> - <!-- 鏁版嵁灞曠ず --> - <div class="trend-data-show"> - <!-- 鐐逛綅鍒囨崲 --> - <div class="trend-data-header"> - <el-button type="text" @click="tabChange(1)">楂樺彂鐐逛綅</el-button> - <el-button type="text" @click="tabChange(2)">棣栨杩濊鐐逛綅</el-button> + <div style="height: 95%"> + <div class="trend-title">瓒嬪娍鍒嗘瀽</div> + <div class="trend-analysis"> + <div class="trend-side"> + <!-- 杈撳叆鍖哄煙 --> + <div class="trend-input-area"> + <el-form ref="form" :model="search" label-width="6vw"> + <!-- <el-form-item label="绫诲瀷鏌ヨ">--> + <!-- <el-select v-model="search.type" @change="searchList" 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 class="time-area" label="鏃堕棿鑼冨洿"> + <el-date-picker + @change="searchList" + start-placeholder="寮�濮嬫椂闂�" + end-placeholder="缁撴潫鏃堕棿" + v-model="search.timeRange" + type="datetimerange" + value-format="yyyy-MM-dd HH:mm:ss" + > + </el-date-picker> + </el-form-item> + </el-form> </div> - <!-- 瀵瑰簲鏁版嵁 --> - <div class="trend-data-main"> - <div class="point-item" v-for="item in trendAnalysisList" :key="item.id" @click="pointClick(item)"> - <span class="point-name">{{ item.name }}</span> - <span>{{ item.count }}</span> + <!-- 鏁版嵁灞曠ず --> + <div class="trend-data-show"> + <!-- 鐐逛綅鍒囨崲 --> + <div class="trend-data-header"> + <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="point-item" + v-for="item in trendAnalysisList" + :key="item.id" + @click="pointClick(item)" + > + <span class="point-name">{{ item.name }}</span> + <span>{{ item.count }}</span> + </div> </div> </div> </div> - </div> - <div class="trend-main"> - - <div class="map"> - <MyMap :point="point" :zoom="zoom" :mark="mark" @fatherMethod="fatherMethod"></MyMap> + <div class="trend-main"> + <div class="map"> + <MyMap + :point="point" + :zoom="zoom" + :mark="mark" + @fatherMethod="fatherMethod" + ></MyMap> + </div> </div> - - </div> - <el-dialog - title="鎻愮ず" + <el-dialog + title="瓒嬪娍鍥�" :visible.sync="echartsDialogVisible" - width="30%" - :before-close="handleClose"> - <div style="height: 500px;width: 500px;" id="echarts"> - </div> - </el-dialog> + :before-close="handleClose" + > + <div style="height: 500px; width: 500px" id="echarts"></div> + </el-dialog> + </div> </div> </template> <script> -import * as echarts from 'echarts' +import * as echarts from "echarts"; import basecase from "@/api/operate/basecase"; import { CATEGOTY } from "@/utils/helper"; import MyMap from "@/components/map"; export default { - components :{MyMap}, + components: { MyMap }, created() { - this.searchList() + this.searchList(); }, mounted() { @@ -71,16 +87,17 @@ computed: { categoryOptions() { return CATEGOTY; - } + }, }, data() { return { - echartsList:null, - echartsDialogVisible:false, + echartsDateList: [], + echartsDataList: null, + echartsDialogVisible: false, search: { type: null, - timeRange: null + timeRange: null, }, timeRangeFlag: false, trendAnalysisList: [], @@ -89,40 +106,39 @@ pointName: null, point: { x: "119.27179890", y: "28.59027084" }, mark: null, - zoom: 15, - } + zoom: 13, + }; }, methods: { - fatherMethod(){ - console.log('7777') - this.echartsDialogVisible=true - this.$nextTick(function (){ - this.renderEchart(this.echartsList); - - }) + fatherMethod() { + this.echartsDialogVisible = true; + this.$nextTick(function () { + this.renderEchart(this.echartsDateList, this.echartsDataList); + }); }, - handleClose(){ - this.echartsDialogVisible = false + handleClose() { + this.echartsDialogVisible = false; }, - renderEchart(dataList) { + renderEchart(dateTimeList, dataList) { if (!this.echarts) { - this.echarts = echarts.init(document.getElementById('echarts')); + this.echarts = echarts.init(document.getElementById("echarts")); } // 缁樺埗鍥捐〃 this.echarts.setOption({ xAxis: { - name: '鏃�/鍛�', + name: "鏃�/鍛�", + data: dateTimeList, }, yAxis: { - name: '鎶ヨ閲�(娆�)', + name: "鎶ヨ閲�(娆�)", }, series: [ { data: dataList, - type: 'line', - smooth: true - } - ] + type: "line", + smooth: true, + }, + ], }); }, async searchList() { @@ -130,10 +146,11 @@ const trendAnalysisParam = { startTime, endTime, - type: this.search.type - } - this.trendAnalysisList = this.highFlag ? await basecase.getTrendAnalysisData(trendAnalysisParam) - : await basecase.getFirstTrendAnalysisData(trendAnalysisParam); + type: this.search.type, + }; + this.trendAnalysisList = this.highFlag + ? await basecase.getTrendAnalysisData(trendAnalysisParam) + : await basecase.getFirstTrendAnalysisData(trendAnalysisParam); }, tabChange(params) { @@ -144,27 +161,43 @@ pointClick(data) { this.pointName = data.name; this.point = { - x: data.longitude, - y: data.latitude, - }; + x: data.longitude, + y: data.latitude, + }; this.zoom = 19; this.mark = { title: data.address }; - basecase.getPointTrendAnalysisData({ longitude: data.longitude,latitude: data.latitude }) - .then(res => { - // const countList = res.map(item => +item.count); - this.echartsList= res.map(item => +item.count); - // this.renderEchart(countList); - }) - .catch(err => this.$message.error(err)) - } + basecase + .getPointTrendAnalysisData({ + longitude: data.longitude, + latitude: data.latitude, + }) + .then((res) => { + // const countList = res.map(item => +item.count); + this.echartsDataList = []; + this.echartsDateList = []; + res.forEach((item) => { + this.echartsDataList.push(item.count); + this.echartsDateList.push(item.dateTime); + }); + // this.renderEchart(countList); + }) + .catch((err) => this.$message.error(err)); + }, }, -} +}; </script> <style lang="scss" scoped> +.trend-title { + color: #4b9bb7; + line-height: 40px; + font-size: 26px; + text-align: left; + margin-left: 20px; +} .trend-analysis { height: 100%; - padding: 10vh 0vw; + padding: 10px 0px; color: #4b9bb7; display: flex; @@ -179,7 +212,7 @@ flex-direction: column; padding: 0 2vw; - &>span { + & > span { line-height: 40px; } @@ -202,7 +235,7 @@ border: 2px solid #09152f; } - .el-button+.el-button { + .el-button + .el-button { margin: 0; } } @@ -212,7 +245,7 @@ display: flex; padding: 0 2vw; justify-content: space-between; - .point-name{ + .point-name { cursor: pointer; color: #66b1ff; } @@ -225,6 +258,7 @@ flex: 1; border: 1px solid #09152f; display: flex; + margin-left: 20px; .trend-main-echarts { width: 500px; height: 400px; @@ -239,6 +273,6 @@ } .map { height: 100%; - min-width: 80%; + width: 98%; } </style> -- Gitblit v1.8.0