left.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <div>
  3. <CusModule title="抄表采集率">
  4. <div class="soc-container">
  5. <div class="soc-data-point soc-left-data">
  6. <div>
  7. <span class="soc-value">{{ meterReading.actual }}</span>
  8. <span class="unit">个</span>
  9. </div>
  10. <div class="soc-description">实采数据</div>
  11. </div>
  12. <div class="soc-central-data">
  13. <span class="soc-value">{{ meterReading.rate }}</span>
  14. <span class="unit">%</span>
  15. </div>
  16. <div class="soc-data-point soc-right-data">
  17. <div>
  18. <span class="soc-failure">{{ meterReading.fail }}</span>
  19. <span class="soc-failure unit">个</span>
  20. </div>
  21. <div class="soc-description">失败数据</div>
  22. </div>
  23. <div class="soc-bottom-data">
  24. <div>
  25. <span class="soc-value">{{ meterReading.total }}</span>
  26. <span class="unit">个</span>
  27. </div>
  28. <div class="soc-description">应采数据</div>
  29. </div>
  30. </div>
  31. </CusModule>
  32. <CusModule class="module-top" title="用能情况">
  33. <div class="soc-pie-chart-container">
  34. <BaseChart width="100%" height="100%" :option="pieOptions"></BaseChart>
  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. import {mapState} from 'vuex';
  48. import {cntDevice} from "@/api/device/meterDevice";
  49. import { listFacsMeterHourSta } from '@/api/device/energyConsumption'
  50. import {DateTool} from "@/utils/DateTool";
  51. import {pgSupplyDayTotalPv} from "@/api/screen";
  52. export default {
  53. name: 'SocLeft',
  54. data() {
  55. return {
  56. lineData: [],
  57. meterReading: {},
  58. energyUse: []
  59. };
  60. },
  61. components: {
  62. CusModule,
  63. BaseChart
  64. },
  65. computed: {
  66. ...mapState('userState', ['areaType']),
  67. pieOptions() {
  68. return {
  69. legend: {
  70. show: false,
  71. },
  72. color: ["#3FA7FD", "#8AC540", "#F9AF39", "#82D8F9"],
  73. grid: {
  74. top: '20%'
  75. },
  76. series: [
  77. {
  78. name: "类别统计",
  79. type: "pie",
  80. radius: ["40%", "55%"],
  81. center: ["50%", "50%"],
  82. data: this.energyUse,
  83. label: {
  84. normal: {
  85. show: true,
  86. formatter: [
  87. '{b|{b}}',
  88. '{c|{c}}{b|kW·h}',
  89. '{d|{d}%}'
  90. ].join('\n'), // 用\n来换行
  91. rich: {
  92. b: {
  93. color: '#fff',
  94. fontSize: 13,
  95. lineHeight: 20,
  96. align: 'left'
  97. },
  98. c: {
  99. fontSize: 18,
  100. fontWeight: 'bold',
  101. color: '#06E3F9',
  102. textShadowColor: '#1c90a6',
  103. textShadowOffsetX: 0,
  104. textShadowOffsetY: 2,
  105. textShadowBlur: 5
  106. },
  107. d: {
  108. color: '#fff',
  109. align: 'left',
  110. fontSize: 12
  111. }
  112. }
  113. }
  114. },
  115. labelLine: {
  116. normal: {
  117. length: 10,
  118. length2: 30,
  119. smooth: true,
  120. lineStyle: {
  121. width: 1,
  122. color: 'rgba(255,255,255,0.7)'
  123. }
  124. }
  125. }
  126. },
  127. ],
  128. }
  129. },
  130. lineOptions() {
  131. return {
  132. legend: {
  133. show: false,
  134. },
  135. tooltip: {
  136. trigger: "axis",
  137. },
  138. yAxis: {
  139. name: "kW·h",
  140. splitLine: {
  141. show: true,
  142. lineStyle: {
  143. color: '#334E5E'
  144. }
  145. },
  146. },
  147. xAxis: {
  148. splitLine: {
  149. show: false,
  150. },
  151. data: this.lineData.map(item => item.xData),
  152. },
  153. series: [
  154. {
  155. type: 'line',
  156. name: "",
  157. smooth: true,
  158. lineStyle: {
  159. normal: {
  160. color: "#80DBE1", // 线条颜色
  161. },
  162. },
  163. itemStyle: {
  164. color: "#80DBE1",
  165. borderColor: "#fff",
  166. borderWidth: 3
  167. },
  168. areaStyle: { //区域填充样式
  169. normal: {
  170. //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
  171. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  172. offset: 0,
  173. color: "rgba(81, 139, 152,0.8)"
  174. },
  175. {
  176. offset: 1,
  177. color: "rgba(81, 139, 152, 0)"
  178. }
  179. ], false),
  180. shadowColor: 'rgba(81, 139, 152, 0.5)', //阴影颜色
  181. shadowBlur: 20 //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
  182. }
  183. },
  184. data: this.lineData.map(item => item.yData),
  185. },
  186. ],
  187. }
  188. }
  189. },
  190. watch: {
  191. areaType() {
  192. this.qryPageDatas()
  193. }
  194. },
  195. mounted() {
  196. this.qryPageDatas()
  197. this.timer && clearInterval(this.timer)
  198. this.timer = setInterval(() => {
  199. this.qryPageDatas()
  200. }, 60000 * 3)
  201. },
  202. beforeDestroy() {
  203. this.timer && clearInterval(this.timer)
  204. },
  205. methods: {
  206. getDatesOfLastTenDays() {
  207. var dates = [];
  208. var today = new Date();
  209. for (var i = 0; i < 10; i++) {
  210. var pastDate = new Date(today);
  211. pastDate.setDate(today.getDate() - i); // 减去i天
  212. var formattedDate = dateFormat(pastDate, 'MM-dd');
  213. dates.push(formattedDate);
  214. }
  215. return dates.reverse().map(item => ({
  216. xData: item,
  217. yData: parseFloat(((Math.random() * 100 + 100)).toFixed(1))
  218. }));
  219. },
  220. qryPageDatas() {
  221. this.getCntDevice()
  222. this.getDeviceElecMeter()
  223. this.getPgSupplyDayTotalPv()
  224. },
  225. async getCntDevice() {
  226. const {data} = await cntDevice({
  227. areaCode: this.areaType
  228. })
  229. const {
  230. totalDevice,
  231. onlineDevice
  232. } = data
  233. this.meterReading = {
  234. total: totalDevice,
  235. actual: onlineDevice,
  236. fail: totalDevice - onlineDevice,
  237. rate: (onlineDevice / totalDevice * 100).toFixed(1)
  238. }
  239. },
  240. async getDeviceElecMeter() {
  241. const params = {
  242. startRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
  243. endRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
  244. meterCls: 45,
  245. areaCode: this.areaType || -1,
  246. facsCategory: 'Z',
  247. };
  248. listFacsMeterHourSta(params).then(response => {
  249. this.energyUse = response.data.map(item => ({
  250. name: item.objName,
  251. value: item.totalElecQuantity || 0,
  252. }));
  253. })
  254. },
  255. async getPgSupplyDayTotalPv() {
  256. const {data: pgPvHisSupply} = await pgSupplyDayTotalPv({
  257. areaCode: this.areaType,
  258. startRecTime: DateTool.lastXDay(30),
  259. endRecTime: DateTool.now(),
  260. })
  261. if (!pgPvHisSupply) {
  262. return
  263. }
  264. const dateTips = DateTool.getDayOfRange(DateTool.lastXDay(30), DateTool.now());
  265. const dateIndexMap = {}
  266. pgPvHisSupply.forEach(item => {
  267. dateIndexMap[item.date] = item
  268. })
  269. const lineData = []
  270. dateTips.forEach((item, index) => {
  271. if (dateIndexMap[item]) {
  272. lineData.push({
  273. xData: item,
  274. yData: dateIndexMap[item].useElecQuantity
  275. })
  276. } else {
  277. lineData.push({
  278. xData: item,
  279. yData: 0
  280. })
  281. }
  282. })
  283. this.lineData = lineData
  284. },
  285. }
  286. }
  287. </script>
  288. <style lang='scss' scoped>
  289. @import url("../index.scss");
  290. .soc-container {
  291. margin-top: 20px;
  292. width: 100%;
  293. height: 203px;
  294. background-image: url('~@/assets/images/soc/l1_bg.png');
  295. background-repeat: no-repeat;
  296. background-position: center;
  297. position: relative;
  298. text-align: center;
  299. .soc-data-point {
  300. position: absolute;
  301. top: 60px;
  302. .soc-value {
  303. color: #06E3F9;
  304. font-size: 18px;
  305. }
  306. .soc-description {
  307. color: #B3E3E8;
  308. font-size: 14px;
  309. }
  310. }
  311. .soc-left-data {
  312. left: 45px;
  313. }
  314. .soc-right-data {
  315. right: 35px;
  316. }
  317. .soc-central-data {
  318. position: absolute;
  319. left: 50%;
  320. top: 20px;
  321. transform: translateX(-50%);
  322. .soc-value {
  323. color: #06E3F9;
  324. font-size: 32px;
  325. }
  326. }
  327. .soc-bottom-data {
  328. position: absolute;
  329. left: 50%;
  330. bottom: 62px;
  331. transform: translateX(-50%);
  332. .soc-value {
  333. color: #06E3F9;
  334. font-size: 18px;
  335. }
  336. .soc-description {
  337. color: #B3E3E8;
  338. font-size: 14px;
  339. }
  340. }
  341. .soc-failure {
  342. color: #F05050;
  343. font-size: 18px;
  344. &.unit {
  345. font-size: 14px;
  346. }
  347. }
  348. }
  349. .soc-pie-chart-container {
  350. margin-top: 20px;
  351. width: 369px;
  352. height: 178px;
  353. padding-bottom: 2px;
  354. padding-right: 17px;
  355. position: relative;
  356. background-image: url('~@/assets/images/soc/l2-pie_bg.png');
  357. .soc-chart-label {
  358. position: absolute;
  359. text-align: center;
  360. .soc-chart-label-text {
  361. color: #B3E3E8;
  362. font-size: 14px;
  363. }
  364. .soc-chart-value {
  365. font-size: 18px;
  366. font-weight: bold;
  367. color: #06E3F9;
  368. }
  369. }
  370. .soc-top-left {
  371. top: 12px;
  372. left: 20px;
  373. }
  374. .soc-top-right {
  375. top: 12px;
  376. right: 35px;
  377. }
  378. .soc-bottom-left {
  379. bottom: 32px;
  380. left: 20px;
  381. }
  382. .soc-bottom-right {
  383. bottom: 32px;
  384. right: 35px;
  385. }
  386. }
  387. .storage-grid {
  388. display: flex;
  389. flex-wrap: wrap;
  390. }
  391. .grid-item {
  392. flex-basis: 50%;
  393. height: 62px;
  394. display: flex;
  395. background: url('~@/assets/images/home/l2_item_bg.png') no-repeat;
  396. &:nth-child(n+3) {
  397. margin-top: 10px;
  398. }
  399. .image-container {
  400. width: 90px;
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. }
  405. .item-details {
  406. width: calc(100% - 22px);
  407. display: flex;
  408. flex-direction: column;
  409. justify-content: center;
  410. margin-left: 5px;
  411. color: #B3E3E8;
  412. .item-value {
  413. span.value {
  414. font-size: 20px;
  415. font-weight: bold;
  416. }
  417. span.unit {
  418. color: #768f95;
  419. font-size: 12px;
  420. margin-left: 2px;
  421. }
  422. }
  423. .item-name {
  424. font-size: 12px;
  425. }
  426. }
  427. }
  428. </style>