123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <template>
- <div>
- <el-card class="box-card">
- <div class="seachBox">
- <div class="conditionOne">
- <span>测风塔:</span>
- <el-select v-model="cftId" placeholder="请选择" @change="changeCft">
- <el-option
- v-for="item in startDateAndEndDate"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- <span style="float: left;">{{ item.label }}</span>
- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.date }}</span>
- </el-option>
- </el-select>
- </div>
- <div class="conditionTwo">
- <span>时间:</span>
- <el-date-picker
- v-model="dataTime"
- type="monthrange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- >
- </el-date-picker>
- </div>
- <div class="conditionTwo">
- <span>层高:</span>
- <el-select v-model="height" placeholder="请选择" clearable multiple>
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </div>
- <el-button class="seachBtu" type="primary" plain icon="el-icon-search" size="small" @click="getListShear" :loading="btuLoading">搜索
- </el-button>
- </div>
- <div class="mainBox">
- <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
- <el-tab-pane label="风切变曲线图" name="first">
- <div class="avgTextDiv">
- <div v-html="avgShearText"/>
- </div>
- <div id="shearChart"/>
- </el-tab-pane>
- </el-tabs>
- </div>
- </el-card>
- </div>
- </template>
- <script>
- import {listAllInfo, listEquipmentIdAndDataTime} from "@/api/biz/dataQuery/windTowerStatusInfo";
- import {listShear} from "@/api/biz/dataQuery/statistics";
- import defaultOption from "@/api/biz/dataQuery/defaultOption";
- export default {
- name: "index",
- data() {
- return {
- btuLoading:true,
- dataTime: [new Date(new Date().getFullYear(), new Date().getMonth() - 11, 1).getTime(), new Date(new Date().getFullYear(), new Date().getMonth(), 1)],
- // dateTime:new Date(new Date().getFullYear(),0).getTime(),
- cftId: '',
- value: '',
- allOptions: [],
- startDateAndEndDate: [],
- options: [],
- height: null,
- activeName: 'first',
- avgShearText: '',//平均值
- value2: '',
- }
- },
- mounted() {
- this.allOptions = defaultOption.allHeightOptions
- this.getlistEquipmentIdAndDataTime()
- },
- destroyed() {
- if (!this.shearChart) {
- return
- }
- this.shearChart.dispose()
- this.shearChart = null
- },
- methods: {
- /*获取所有的测风塔*/
- getlistEquipmentIdAndDataTime() {
- listEquipmentIdAndDataTime().then(res => {
- this.startDateAndEndDate = res.data
- this.cftId = res.data[0].value
- this.changeHeight(res.data[0])
- this.getListShear()
- })
- },
- async getListShear() {
- this.btuLoading = true
- const param = {
- startTime: new Date(this.dataTime[0]).getTime(),
- endTime: new Date(this.dataTime[1]).getTime(),
- eqId: this.cftId,
- height: this.height == null ? this.height : this.height.toString(),
- }
- if (!this.shearChart) {
- this.shearChart = this.$echarts.init(document.getElementById('shearChart'))
- }
- // 调用showLoading方法
- this.shearChart.showLoading({
- text: 'loading',
- color: '#c23531',
- textColor: '#000',
- maskColor: 'rgba(255, 255, 255, 0.2)',
- zlevel: 0,
- });
- await listShear(param).then(async res => {
- let data = res.rows[1]
- this.avgShearText = ''
- for (let i = 0; i < data.length; i++) {
- this.avgShearText += ' <span style="color: #1c84c6;font-weight: bold">' + data[i].height + '平均值:</span>' + '<span style="color: #1ab394">' + data[i].shearAve + '</span>' + ','
- }
- if (this.avgShearText != '') {
- this.avgShearText = this.avgShearText.slice(0, this.avgShearText.length - 1)
- }
- this.shearData = res.rows[0]
- this.drawShearInChart(this.shearData)
- this.btuLoading = false
- }).catch(err => {
- this.shearChart.hideLoading();
- this.btuLoading = false
- this.$message.error('获取风速数据异常')
- console.log('获取风速数据异常:' + err)
- })
- },
- //风速曲线图
- drawShearInChart(data) {
- this.shearChart = this.$echarts.init(document.getElementById('shearChart'))
- /*拼接曲线图的serise*/
- let serise = []
- let legend = []
- for (let i = 0; i < data.length; i++) {
- let seriseData = []
- legend.push(data[i].height + 'm')
- let arr = data[i].arr
- /*拼接serise Data*/
- for (let j = 0; j < data[i].arr.length; j++) {
- seriseData.push([data[i].arr[j].time, data[i].arr[j].shear])
- }
- serise.push({
- name: data[i].height,
- type: 'line',
- smooth: false,
- symbol: 'none', // 这句就是去掉点的
- data: seriseData
- })
- }
- var option = {
- title: {
- text: '年逐月风切变',
- },
- legend: {
- // data: ['风速']
- data: legend
- },
- grid: {
- left: '2%',
- right: '3%',
- // bottom: '8%',
- containLabel: true
- },
- tooltip: {
- trigger: 'axis',
- },
- // color: ['#1a9f00', '#2f4554', '#61a0a8','#d48265'],
- xAxis: {
- name: '时间',
- type: 'category',
- axisLine: {
- onZero: false,
- lineStyle: {
- color: '#666b8f',
- width: 4// 这里是为了突出显示加上的
- }
- },
- },
- dataZoom: [
- {
- startValue: ''
- },
- {
- type: 'inside'
- }
- ],
- yAxis: {
- type: 'value',
- name: '风切变指数',
- // min: 0,
- // interval: 5,
- axisLabel: {
- formatter: '{value}'
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: '#666b8f',
- width: 4// 这里是为了突出显示加上的
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: ['#315070'],
- width: 2,
- type: 'dotted'
- }
- }
- },
- series: serise
- }
- this.shearChart.setOption(option, true)
- this.shearChart.hideLoading();
- window.addEventListener('resize', () => {
- if (this.shearChart) {
- this.shearChart.resize()
- }
- })
- },
- /*切换测风塔时改变层高option*/
- changeHeight(data) {
- if (data.heights != null) {
- var option = []
- let str = data.heights.split(',')
- this.height = null
- for (let i = 0; i < str.length; i++) {
- let filter = this.allOptions.find(w => w.value == str[i])
- option.push(filter)
- }
- this.options = option
- } else {
- this.height = null
- this.options = this.allOptions
- }
- },
- /*切换测风塔找到它对应的层高*/
- changeCft() {
- let data = this.startDateAndEndDate.find(w => w.value == this.cftId)
- this.changeHeight(data)
- },
- handleClick() {
- if (this.activeName == 'first') {
- this.shearChart = null
- this.$nextTick(() => {
- this.drawShearInChart(this.shearData)
- this.shearChart.resize()
- })
- }
- }
- }
- }
- </script>
- <style scoped>
- .box-card {
- height: calc(90vh);
- }
- .seachBox {
- display: flex;
- margin: .5%;
- }
- .conditionOne, .conditionTwo, .conditionThree, .seachBtu {
- display: inline-block;
- }
- .conditionTwo, .conditionThree, .seachBtu {
- margin-left: .5%;
- }
- #shearChart {
- width: 100%;
- height: calc(72vh);
- }
- </style>
|