index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="demand-analysis" :loading="loading">
  3. <!-- <commonSearch ref="commonSearch" type="daterange" @search="handleSearch"></commonSearch> -->
  4. <div class="item-echarts" ref="echarts" :style="{ height: echartsHeight + 'px' }"></div>
  5. </div>
  6. </template>
  7. <script>
  8. import * as echarts from 'echarts'
  9. import commonSearch from '../components/commonSearch.vue'
  10. import { httpAction, getAction } from '@/api/manage'
  11. import { emsdata } from '../emsdata'
  12. export default {
  13. name: 'moniparamData',
  14. components: {
  15. commonSearch,
  16. },
  17. data() {
  18. return {
  19. description: '参数历史查询',
  20. loading: true,
  21. echartsHeight: window.innerHeight - 84 - 60 - 30,
  22. myChart: null,
  23. url: {
  24. list: '/ems/statistics/demandanalysis',
  25. },
  26. moniparamData: {},
  27. }
  28. },
  29. created() {},
  30. mounted() {
  31. this.$nextTick(() => {
  32. setTimeout(() => {
  33. this.getTest()
  34. }, 1000)
  35. // this.getDemandanalysis()
  36. })
  37. },
  38. methods: {
  39. // 后端好了需要删掉
  40. getTest() {
  41. this.moniparamData = emsdata.moniparamData
  42. this.initEcharts()
  43. },
  44. async getDemandanalysis() {
  45. this.loading = true
  46. var data = this.$refs.commonSearch.queryParams
  47. getAction(this.url.list, data).then((response) => {
  48. console.log(response)
  49. this.monthsplit = response.data.monthsplit
  50. this.mubiao = response.data.mubiao
  51. this.shiji = response.data.shiji
  52. this.loading = false
  53. })
  54. this.initEcharts()
  55. },
  56. initEcharts() {
  57. var _this = this
  58. var chartDom = _this.$refs.echarts
  59. _this.myChart = echarts.init(chartDom)
  60. var option = {
  61. tooltip: {
  62. trigger: 'axis',
  63. position: function (pt) {
  64. return [pt[0], '20%']
  65. },
  66. },
  67. title: {
  68. left: 'left',
  69. text: '参数历史数据',
  70. },
  71. legend: {
  72. data: ['Pa', 'Pb', 'Pc', 'P'],
  73. },
  74. xAxis: {
  75. type: 'category',
  76. boundaryGap: false,
  77. data: _this.moniparamData.times,
  78. },
  79. yAxis: {
  80. type: 'value',
  81. boundaryGap: [0, '100%'],
  82. },
  83. dataZoom: [
  84. {
  85. type: 'inside',
  86. start: 0,
  87. end: 100,
  88. xAxisIndex: 0,
  89. },
  90. {
  91. start: 0,
  92. end: 10,
  93. },
  94. {
  95. show: true,
  96. yAxisIndex: 0,
  97. filterMode: "empty",
  98. width: 30,
  99. height: "80%",
  100. right: "7%",
  101. },
  102. ],
  103. series: [
  104. {
  105. name: 'Pa',
  106. type: 'line',
  107. symbol: 'none',
  108. sampling: 'lttb',
  109. itemStyle: {
  110. color: '#91CC75',
  111. },
  112. markPoint: {
  113. data: [
  114. { type: 'max', name: 'Max' },
  115. { type: 'min', name: 'Min' },
  116. ],
  117. },
  118. data: _this.moniparamData.result.Pa,
  119. },
  120. {
  121. name: 'Pb',
  122. type: 'line',
  123. symbol: 'none',
  124. sampling: 'lttb',
  125. itemStyle: {
  126. color: '#EE6666',
  127. },
  128. markPoint: {
  129. data: [
  130. { type: 'max', name: 'Max' },
  131. { type: 'min', name: 'Min' },
  132. ],
  133. },
  134. data: _this.moniparamData.result.Pb,
  135. },
  136. {
  137. name: 'Pc',
  138. type: 'line',
  139. symbol: 'none',
  140. sampling: 'lttb',
  141. itemStyle: {
  142. color: '#FAAD14',
  143. },
  144. markPoint: {
  145. data: [
  146. { type: 'max', name: 'Max' },
  147. { type: 'min', name: 'Min' },
  148. ],
  149. },
  150. data: _this.moniparamData.result.Pc,
  151. },
  152. {
  153. name: 'P',
  154. type: 'line',
  155. symbol: 'none',
  156. sampling: 'lttb',
  157. itemStyle: {
  158. color: '#5470C6',
  159. },
  160. markPoint: {
  161. data: [
  162. { type: 'max', name: 'Max' },
  163. { type: 'min', name: 'Min' },
  164. ],
  165. },
  166. data: _this.moniparamData.result.P,
  167. },
  168. ],
  169. }
  170. option && _this.myChart.setOption(option)
  171. window.addEventListener('resize', function () {
  172. _this.myChart.resize()
  173. })
  174. },
  175. /** 搜索按钮操作 */
  176. handleSearch(param) {
  177. this.getTest()
  178. // this.getDemandanalysis()
  179. },
  180. },
  181. }
  182. </script>
  183. <style lang="less" scoped>
  184. @import '~@/assets/less/uStyle.less';
  185. </style>
  186. <style lang="less" scoped>
  187. .demand-analysis {
  188. min-height: calc(100vh - 84px);
  189. padding: 10px;
  190. .search-container {
  191. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  192. padding-top: 12px;
  193. margin-bottom: 10px;
  194. .el-form-item--small.el-form-item {
  195. margin-bottom: 14px;
  196. }
  197. }
  198. .item-echarts {
  199. // min-height: calc(100vh - 174px);
  200. padding: 10px;
  201. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  202. background-color: white;
  203. }
  204. }
  205. </style>