left.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div>
  3. <CusModule title="光伏发电量">
  4. <div class="elec-top-bar">
  5. <span class="elec-content">
  6. 今日发电量<span class="elec-value">{{todayEnergy}}</span><span class="unit"> kW·h</span>
  7. </span>
  8. </div>
  9. <div class="elec-items-container">
  10. <div v-for="i in elecList" :key="i.name" class="elec-item" :style="{ backgroundImage: `url(${i.image})` }">
  11. <div class="elec-item-content">
  12. <div class="elec-item-value">{{ i.value }}</div>
  13. <div class="unit">{{ i.unit }}</div>
  14. </div>
  15. <div class="elec-item-label">
  16. {{ i.name }}
  17. </div>
  18. </div>
  19. </div>
  20. </CusModule>
  21. <CusModule class="module-top" title="光伏发电指标">
  22. <div class="elec-index">
  23. <div class="panel-content" v-for="item, index in elecIndexList" :key="index">
  24. <div class="image-container">
  25. <img :src="require(`@/assets/images/source/elec${index + 1}.svg`)" alt="">
  26. </div>
  27. <div class="whitespace-pre">
  28. <span class="value">{{ item.value }}</span>
  29. <span class="unit">{{ item.unit }}</span>
  30. <div class="label">{{ item.name }}</div>
  31. </div>
  32. </div>
  33. </div>
  34. </CusModule>
  35. <CusModule class="module-top" title="历史发电量">
  36. <BaseChart height="350px" width="100%" :option="lineOptions" />
  37. </CusModule>
  38. </div>
  39. </template>
  40. <script>
  41. import CusModule from '../components/CusModule.vue';
  42. import BaseChart from '@/components/BaseChart/index.vue'
  43. import {dateFormat} from '@/utils';
  44. import {mapState} from 'vuex';
  45. import * as echarts from 'echarts'
  46. export default {
  47. name: 'SourceLeft',
  48. data () {
  49. return {
  50. todayEnergy:'321',
  51. elecList: [
  52. {
  53. name: "本月发电量",
  54. value: 9431,
  55. unit: "kW·h",
  56. image: require("@/assets/images/source/l1-item1.png"),
  57. },
  58. {
  59. name: "今年发电量",
  60. value: 12034,
  61. unit: "kW·h",
  62. image: require("@/assets/images/source/l1-item2.png"),
  63. },
  64. {
  65. name: "累计发电量",
  66. value: 95312,
  67. unit: "kW·h",
  68. image: require("@/assets/images/source/l1-item3.png"),
  69. },
  70. ],
  71. elecIndexList: [
  72. {
  73. name: "逆变器输入电量",
  74. value: 120,
  75. unit: "kW",
  76. },
  77. {
  78. name: "逆变器转换效率",
  79. value: 86.3,
  80. unit: "%",
  81. },
  82. {
  83. name: "光电转换效率",
  84. value: 82.1,
  85. unit: "%",
  86. },
  87. {
  88. name: "电站性能比",
  89. value: 78.09,
  90. unit: "",
  91. },
  92. ],
  93. lineData:[]
  94. };
  95. },
  96. components: {
  97. CusModule,
  98. BaseChart
  99. },
  100. computed: {
  101. ...mapState('userState', ['areaType']),
  102. lineOptions () {
  103. return {
  104. legend: {
  105. show: false,
  106. },
  107. tooltip: {
  108. trigger: "axis",
  109. },
  110. yAxis: {
  111. name: "kW·h",
  112. splitLine: {
  113. show: true,
  114. lineStyle: {
  115. color: '#334E5E'
  116. }
  117. },
  118. },
  119. xAxis: {
  120. splitLine: {
  121. show: false,
  122. },
  123. data: this.lineData.map(item=>item.xData),
  124. },
  125. series: [
  126. {
  127. type: 'line',
  128. name: "发电量",
  129. smooth: true,
  130. lineStyle: {
  131. normal: {
  132. color: "#80DBE1", // 线条颜色
  133. },
  134. },
  135. itemStyle: {
  136. color: "#80DBE1",
  137. borderColor: "#fff",
  138. borderWidth: 3
  139. },
  140. areaStyle: { //区域填充样式
  141. normal: {
  142. //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
  143. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  144. offset: 0,
  145. color: "rgba(81, 139, 152,0.8)"
  146. },
  147. {
  148. offset: 1,
  149. color: "rgba(81, 139, 152, 0)"
  150. }
  151. ], false),
  152. shadowColor: 'rgba(81, 139, 152, 0.5)', //阴影颜色
  153. shadowBlur: 20 //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
  154. }
  155. },
  156. data: this.lineData.map(item=>item.yData),
  157. },
  158. ],
  159. }
  160. }
  161. },
  162. watch: {
  163. areaType () {
  164. this.getElecData()
  165. this.lineData = this.getDatesOfLastTenDays()
  166. }
  167. },
  168. mounted () {
  169. this.lineData = this.getDatesOfLastTenDays()
  170. this.getElecData()
  171. },
  172. methods: {
  173. getDatesOfLastTenDays () {
  174. var dates = [];
  175. var today = new Date();
  176. for (var i = 0; i < 10; i++) {
  177. var pastDate = new Date(today);
  178. pastDate.setDate(today.getDate() - i); // 减去i天
  179. var formattedDate = dateFormat(pastDate, 'MM-dd');
  180. dates.push(formattedDate);
  181. }
  182. return dates.reverse().map(item => ({
  183. xData: item,
  184. yData: parseFloat(((Math.random() * 100 + 100)).toFixed(1))
  185. }));
  186. },
  187. getElecData () {
  188. this.todayEnergy = Math.floor(Math.random() * 100 + 300)
  189. this.elecList = this.elecList.map((item,index) => ({
  190. ...item,
  191. value:Math.floor(Math.random() * 100 + 900*(index+1))
  192. }))
  193. this.elecIndexList = this.elecIndexList.map(item => ({
  194. ...item,
  195. value:parseFloat(Math.random() * 100).toFixed(1)
  196. }))
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang='scss' scoped>
  202. @import url("../index.scss");
  203. .elec-top-bar {
  204. width: 100%;
  205. height: 90px;
  206. background-image: url('~@/assets/images/source/l1-top.png');
  207. background-repeat: no-repeat;
  208. display: flex;
  209. align-items: center;
  210. padding-left: 14px;
  211. .elec-content {
  212. color: #B3E3E8;
  213. font-size: 14px;
  214. letter-spacing: 1px;
  215. white-space: pre;
  216. .elec-value {
  217. font-size: 20px;
  218. font-weight: bold;
  219. color: #06E3F9;
  220. }
  221. }
  222. }
  223. .elec-items-container {
  224. display: flex;
  225. justify-content: space-between;
  226. margin-top: 2px;
  227. .elec-item {
  228. width: 108px;
  229. height: 134px;
  230. position: relative;
  231. background-size: cover;
  232. .elec-item-content {
  233. text-align: center;
  234. margin-top: 1px;
  235. .elec-item-value {
  236. font-weight: bold;
  237. font-size: 20px;
  238. color: #06E3F9;
  239. }
  240. }
  241. .elec-item-label {
  242. position: absolute;
  243. bottom: 16px;
  244. width: 100%;
  245. color: #B3E3E8;
  246. font-size: 14px;
  247. text-align: center;
  248. }
  249. }
  250. }
  251. .elec-index {
  252. display: flex;
  253. flex-wrap: wrap;
  254. justify-content: space-between;
  255. padding: 10px 0 0;
  256. .panel-content {
  257. margin-top: 12px;
  258. flex-basis: 48%;
  259. height: 75px;
  260. color: #B3E3E8;
  261. background: url('~@/assets/images/home/l2_item_bg.png') no-repeat;
  262. background-size: 100% 100%;
  263. display: flex;
  264. .whitespace-pre {
  265. margin-top: 15px;
  266. margin-left: 10px;
  267. span.value {
  268. font-size: 18px;
  269. font-weight: bold;
  270. }
  271. }
  272. .label {
  273. margin-top: 5px;
  274. font-size: 14px;
  275. }
  276. .image-container {
  277. width: 60px;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. img {
  282. height: 24px;
  283. margin-bottom: 5px;
  284. }
  285. }
  286. }
  287. }
  288. </style>