left.vue 6.8 KB

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