right.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div>
  3. <CusModule title="告警信息">
  4. <div class="seamless-header">
  5. <div>告警内容</div>
  6. <div>告警设备</div>
  7. <div>告警时间</div>
  8. </div>
  9. <vue-seamless-scroll :data="listData" class="seamless-warp" :class-option="classOption">
  10. <div class="seamless-item" v-for="(item, index) in listData" :key="index">
  11. <div>{{ item.name }}</div>
  12. <div>{{ item.type }}</div>
  13. <div>{{ item.createTime }}</div>
  14. </div>
  15. </vue-seamless-scroll>
  16. </CusModule>
  17. <CusModule class="module-top" title="节能减排(今年)">
  18. <div class="energy">
  19. <div class="energy-item">
  20. <div class="energy-item-value">{{reduce.coal}}</div>
  21. <div class="energy-item-name">标煤当量(吨)</div>
  22. </div>
  23. <div class="energy-item">
  24. <div class="energy-item-value">{{reduce.co2}}</div>
  25. <div class="energy-item-name">CO2当量(吨)</div>
  26. </div>
  27. <div class="energy-item">
  28. <div class="energy-item-value">{{reduce.tree}}</div>
  29. <div class="energy-item-name">植树当量(棵)</div>
  30. </div>
  31. </div>
  32. </CusModule>
  33. <CusModule class="module-top" title="发电趋势预测">
  34. <BaseChart height="350px" width="100%" :option="lineOptions" />
  35. </CusModule>
  36. </div>
  37. </template>
  38. <script>
  39. import CusModule from '../components/CusModule.vue';
  40. import BaseChart from '@/components/BaseChart/index.vue'
  41. import vueSeamlessScroll from 'vue-seamless-scroll'
  42. import {dateFormat} from '@/utils';
  43. import * as echarts from 'echarts'
  44. import {mapState} from 'vuex';
  45. export default {
  46. name: 'SourceRight',
  47. data () {
  48. return {
  49. lineData: [],
  50. reduce: {
  51. coal: '',
  52. co2: '',
  53. tree:''
  54. },
  55. classOption: {
  56. step: 0.3, // 数值越大速度滚动越快
  57. limitMoveNum: 4, // 开始无缝滚动的数据量 this.dataList.length
  58. hoverStop: true, // 是否开启鼠标悬停stop
  59. direction: 1, // 0向下 1向上 2向左 3向右
  60. openWatch: true, // 开启数据实时监控刷新dom
  61. singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
  62. singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
  63. waitTime: 1000 // 单步运动停止
  64. },
  65. listData: [
  66. {
  67. name: '光伏板故障',
  68. type: 'AF1001',
  69. createTime: '2024-10-07 12:15:46'
  70. },
  71. {
  72. name: '变电柜故障',
  73. type: 'AB1068',
  74. createTime: '2024-10-08 11:11:41'
  75. },
  76. {
  77. name: '光伏板故障',
  78. type: 'AF1066',
  79. createTime: '2024-10-09 15:15:46'
  80. },
  81. {
  82. name: '变电相故障',
  83. type: 'AC1061',
  84. createTime: '2024-10-08 11:11:41'
  85. },
  86. {
  87. name: '变电柜故障',
  88. type: 'AB1076',
  89. createTime: '2024-10-10 12:33:40'
  90. },
  91. {
  92. name: '光伏板故障',
  93. type: 'AF1008',
  94. createTime: '2024-10-10 12:35:40'
  95. }
  96. ]
  97. }
  98. },
  99. components: {
  100. CusModule,
  101. BaseChart,
  102. vueSeamlessScroll
  103. },
  104. computed: {
  105. ...mapState('userState', ['areaType']),
  106. lineOptions () {
  107. return {
  108. legend: {
  109. show: false,
  110. },
  111. tooltip: {
  112. trigger: "axis",
  113. },
  114. yAxis: {
  115. name: "kW·h",
  116. splitLine: {
  117. show: true,
  118. lineStyle: {
  119. color: '#334E5E'
  120. }
  121. },
  122. },
  123. xAxis: {
  124. splitLine: {
  125. show: false,
  126. },
  127. data: this.lineData.map(item=>item.xData),
  128. },
  129. series: [
  130. {
  131. type: 'line',
  132. name: "发电量",
  133. smooth: true,
  134. lineStyle: {
  135. normal: {
  136. color: "#80DBE1", // 线条颜色
  137. },
  138. },
  139. itemStyle: {
  140. color: "#80DBE1",
  141. borderColor: "#fff",
  142. borderWidth: 3
  143. },
  144. areaStyle: { //区域填充样式
  145. normal: {
  146. //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
  147. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  148. offset: 0,
  149. color: "rgba(81, 139, 152,0.8)"
  150. },
  151. {
  152. offset: 1,
  153. color: "rgba(81, 139, 152, 0)"
  154. }
  155. ], false),
  156. shadowColor: 'rgba(81, 139, 152, 0.5)', //阴影颜色
  157. shadowBlur: 20 //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
  158. }
  159. },
  160. data: this.lineData.map(item=>item.yData),
  161. },
  162. ],
  163. }
  164. }
  165. },
  166. watch: {
  167. areaType () {
  168. this.lineData = this.getDatesOfLastTenDays()
  169. this.getReduceData()
  170. }
  171. },
  172. mounted () {
  173. this.lineData = this.getDatesOfLastTenDays()
  174. this.getReduceData()
  175. },
  176. methods: {
  177. getDatesOfLastTenDays () {
  178. var dates = [];
  179. var today = new Date();
  180. for (var i = 1; i < 11; i++) {
  181. var pastDate = new Date(today);
  182. pastDate.setDate(today.getDate() + i); // 减去i天
  183. var formattedDate = dateFormat(pastDate, 'MM-dd');
  184. dates.push(formattedDate);
  185. }
  186. return dates.map(item => ({
  187. xData: item,
  188. yData: parseFloat(((Math.random() * 100 + 100)).toFixed(1))
  189. }));
  190. },
  191. getReduceData () {
  192. this.reduce.coal =parseFloat(((Math.random() * 100 + 500)).toFixed(1))
  193. this.reduce.co2 =parseFloat(((Math.random() * 100 + 600)).toFixed(1))
  194. this.reduce.tree =Math.floor(Math.random() * 100 + 1000)
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang='scss' scoped>
  200. @import url("../index.scss");
  201. .energy {
  202. display: flex;
  203. .energy-item {
  204. position: relative;
  205. flex: 1;
  206. flex-shrink: 0;
  207. height: 169px;
  208. background: url('~@/assets/images/net/r1-item_bg.png') no-repeat;
  209. background-size: cover;
  210. .energy-item-value {
  211. position: absolute;
  212. width: 100%;
  213. text-align: center;
  214. bottom: 100px;
  215. font-size: 14px;
  216. font-weight: bold;
  217. }
  218. .energy-item-name {
  219. position: absolute;
  220. width: 100%;
  221. text-align: center;
  222. bottom: 20px;
  223. font-size: 14px;
  224. }
  225. }
  226. }
  227. .seamless-header {
  228. margin-top: 20px;
  229. display: flex;
  230. align-items: center;
  231. justify-content: space-between;
  232. padding: 5px 10px;
  233. color: #7DBAFF;
  234. background: #1B4A64;
  235. font-size: 16px;
  236. >div:first-of-type,
  237. >div:last-of-type {
  238. flex-basis: 35%;
  239. }
  240. >div {
  241. text-align: center;
  242. }
  243. }
  244. .seamless-warp {
  245. overflow: hidden;
  246. height: 200px;
  247. .seamless-item {
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. padding: 5px 0;
  252. &:nth-child(odd) {
  253. background: #000;
  254. }
  255. >div:first-of-type,
  256. >div:last-of-type {
  257. flex-basis: 38%;
  258. }
  259. >div {
  260. text-align: center;
  261. font-size: 13px;
  262. }
  263. }
  264. }
  265. </style>