index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <div class="seachBox">
  5. <div class="conditionOne">
  6. <span>测风塔:</span>
  7. <el-select v-model="cftId" placeholder="请选择" @change="changeCft">
  8. <el-option
  9. v-for="item in startDateAndEndDate"
  10. :key="item.value"
  11. :label="item.label"
  12. :value="item.value">
  13. <span style="float: left;">{{ item.label }}</span>
  14. <span style="float: right; color: #8492a6; font-size: 13px">{{ item.date }}</span>
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <div class="conditionTwo">
  19. <span>时间:</span>
  20. <el-date-picker
  21. v-model="dataTime"
  22. type="monthrange"
  23. range-separator="至"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期"
  26. >
  27. </el-date-picker>
  28. </div>
  29. <div class="conditionTwo">
  30. <span>层高:</span>
  31. <el-select v-model="height" placeholder="请选择" clearable multiple>
  32. <el-option
  33. v-for="item in options"
  34. :key="item.value"
  35. :label="item.label"
  36. :value="item.value">
  37. </el-option>
  38. </el-select>
  39. </div>
  40. <el-button class="seachBtu" type="primary" plain icon="el-icon-search" size="small" @click="getListShear" :loading="btuLoading">搜索
  41. </el-button>
  42. </div>
  43. <div class="mainBox">
  44. <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
  45. <el-tab-pane label="风切变曲线图" name="first">
  46. <div class="avgTextDiv">
  47. <div v-html="avgShearText"/>
  48. </div>
  49. <div id="shearChart"/>
  50. </el-tab-pane>
  51. </el-tabs>
  52. </div>
  53. </el-card>
  54. </div>
  55. </template>
  56. <script>
  57. import {listAllInfo, listEquipmentIdAndDataTime} from "@/api/biz/dataQuery/windTowerStatusInfo";
  58. import {listShear} from "@/api/biz/dataQuery/statistics";
  59. import defaultOption from "@/api/biz/dataQuery/defaultOption";
  60. export default {
  61. name: "index",
  62. data() {
  63. return {
  64. btuLoading:true,
  65. dataTime: [new Date(new Date().getFullYear(), new Date().getMonth() - 11, 1).getTime(), new Date(new Date().getFullYear(), new Date().getMonth(), 1)],
  66. // dateTime:new Date(new Date().getFullYear(),0).getTime(),
  67. cftId: '',
  68. value: '',
  69. allOptions: [],
  70. startDateAndEndDate: [],
  71. options: [],
  72. height: null,
  73. activeName: 'first',
  74. avgShearText: '',//平均值
  75. value2: '',
  76. }
  77. },
  78. mounted() {
  79. this.allOptions = defaultOption.allHeightOptions
  80. this.getlistEquipmentIdAndDataTime()
  81. },
  82. destroyed() {
  83. if (!this.shearChart) {
  84. return
  85. }
  86. this.shearChart.dispose()
  87. this.shearChart = null
  88. },
  89. methods: {
  90. /*获取所有的测风塔*/
  91. getlistEquipmentIdAndDataTime() {
  92. listEquipmentIdAndDataTime().then(res => {
  93. this.startDateAndEndDate = res.data
  94. this.cftId = res.data[0].value
  95. this.changeHeight(res.data[0])
  96. this.getListShear()
  97. })
  98. },
  99. async getListShear() {
  100. this.btuLoading = true
  101. const param = {
  102. startTime: new Date(this.dataTime[0]).getTime(),
  103. endTime: new Date(this.dataTime[1]).getTime(),
  104. eqId: this.cftId,
  105. height: this.height == null ? this.height : this.height.toString(),
  106. }
  107. if (!this.shearChart) {
  108. this.shearChart = this.$echarts.init(document.getElementById('shearChart'))
  109. }
  110. // 调用showLoading方法
  111. this.shearChart.showLoading({
  112. text: 'loading',
  113. color: '#c23531',
  114. textColor: '#000',
  115. maskColor: 'rgba(255, 255, 255, 0.2)',
  116. zlevel: 0,
  117. });
  118. await listShear(param).then(async res => {
  119. let data = res.rows[1]
  120. this.avgShearText = ''
  121. for (let i = 0; i < data.length; i++) {
  122. this.avgShearText += ' <span style="color: #1c84c6;font-weight: bold">' + data[i].height + '平均值:</span>' + '<span style="color: #1ab394">' + data[i].shearAve + '</span>' + ','
  123. }
  124. if (this.avgShearText != '') {
  125. this.avgShearText = this.avgShearText.slice(0, this.avgShearText.length - 1)
  126. }
  127. this.shearData = res.rows[0]
  128. this.drawShearInChart(this.shearData)
  129. this.btuLoading = false
  130. }).catch(err => {
  131. this.shearChart.hideLoading();
  132. this.btuLoading = false
  133. this.$message.error('获取风速数据异常')
  134. console.log('获取风速数据异常:' + err)
  135. })
  136. },
  137. //风速曲线图
  138. drawShearInChart(data) {
  139. this.shearChart = this.$echarts.init(document.getElementById('shearChart'))
  140. /*拼接曲线图的serise*/
  141. let serise = []
  142. let legend = []
  143. for (let i = 0; i < data.length; i++) {
  144. let seriseData = []
  145. legend.push(data[i].height + 'm')
  146. let arr = data[i].arr
  147. /*拼接serise Data*/
  148. for (let j = 0; j < data[i].arr.length; j++) {
  149. seriseData.push([data[i].arr[j].time, data[i].arr[j].shear])
  150. }
  151. serise.push({
  152. name: data[i].height,
  153. type: 'line',
  154. smooth: false,
  155. symbol: 'none', // 这句就是去掉点的
  156. data: seriseData
  157. })
  158. }
  159. var option = {
  160. title: {
  161. text: '年逐月风切变',
  162. },
  163. legend: {
  164. // data: ['风速']
  165. data: legend
  166. },
  167. grid: {
  168. left: '2%',
  169. right: '3%',
  170. // bottom: '8%',
  171. containLabel: true
  172. },
  173. tooltip: {
  174. trigger: 'axis',
  175. },
  176. // color: ['#1a9f00', '#2f4554', '#61a0a8','#d48265'],
  177. xAxis: {
  178. name: '时间',
  179. type: 'category',
  180. axisLine: {
  181. onZero: false,
  182. lineStyle: {
  183. color: '#666b8f',
  184. width: 4// 这里是为了突出显示加上的
  185. }
  186. },
  187. },
  188. dataZoom: [
  189. {
  190. startValue: ''
  191. },
  192. {
  193. type: 'inside'
  194. }
  195. ],
  196. yAxis: {
  197. type: 'value',
  198. name: '风切变指数',
  199. // min: 0,
  200. // interval: 5,
  201. axisLabel: {
  202. formatter: '{value}'
  203. },
  204. axisLine: {
  205. show: true,
  206. lineStyle: {
  207. color: '#666b8f',
  208. width: 4// 这里是为了突出显示加上的
  209. }
  210. },
  211. splitLine: {
  212. show: true,
  213. lineStyle: {
  214. color: ['#315070'],
  215. width: 2,
  216. type: 'dotted'
  217. }
  218. }
  219. },
  220. series: serise
  221. }
  222. this.shearChart.setOption(option, true)
  223. this.shearChart.hideLoading();
  224. window.addEventListener('resize', () => {
  225. if (this.shearChart) {
  226. this.shearChart.resize()
  227. }
  228. })
  229. },
  230. /*切换测风塔时改变层高option*/
  231. changeHeight(data) {
  232. if (data.heights != null) {
  233. var option = []
  234. let str = data.heights.split(',')
  235. this.height = null
  236. for (let i = 0; i < str.length; i++) {
  237. let filter = this.allOptions.find(w => w.value == str[i])
  238. option.push(filter)
  239. }
  240. this.options = option
  241. } else {
  242. this.height = null
  243. this.options = this.allOptions
  244. }
  245. },
  246. /*切换测风塔找到它对应的层高*/
  247. changeCft() {
  248. let data = this.startDateAndEndDate.find(w => w.value == this.cftId)
  249. this.changeHeight(data)
  250. },
  251. handleClick() {
  252. if (this.activeName == 'first') {
  253. this.shearChart = null
  254. this.$nextTick(() => {
  255. this.drawShearInChart(this.shearData)
  256. this.shearChart.resize()
  257. })
  258. }
  259. }
  260. }
  261. }
  262. </script>
  263. <style scoped>
  264. .box-card {
  265. height: calc(90vh);
  266. }
  267. .seachBox {
  268. display: flex;
  269. margin: .5%;
  270. }
  271. .conditionOne, .conditionTwo, .conditionThree, .seachBtu {
  272. display: inline-block;
  273. }
  274. .conditionTwo, .conditionThree, .seachBtu {
  275. margin-left: .5%;
  276. }
  277. #shearChart {
  278. width: 100%;
  279. height: calc(72vh);
  280. }
  281. </style>