left.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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 {listByFacs} from "@/api/device/elecMeterH";
  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. },
  198. methods: {
  199. getDatesOfLastTenDays() {
  200. var dates = [];
  201. var today = new Date();
  202. for (var i = 0; i < 10; i++) {
  203. var pastDate = new Date(today);
  204. pastDate.setDate(today.getDate() - i); // 减去i天
  205. var formattedDate = dateFormat(pastDate, 'MM-dd');
  206. dates.push(formattedDate);
  207. }
  208. return dates.reverse().map(item => ({
  209. xData: item,
  210. yData: parseFloat(((Math.random() * 100 + 100)).toFixed(1))
  211. }));
  212. },
  213. qryPageDatas() {
  214. this.getCntDevice()
  215. this.getDeviceElecMeter()
  216. this.getPgSupplyDayTotalPv()
  217. },
  218. async getCntDevice() {
  219. const {data} = await cntDevice({
  220. areaCode: this.areaType
  221. })
  222. const {
  223. totalDevice,
  224. onlineDevice
  225. } = data
  226. this.meterReading = {
  227. total: totalDevice,
  228. actual: onlineDevice,
  229. fail: totalDevice - onlineDevice,
  230. rate: (onlineDevice / totalDevice * 100).toFixed(1)
  231. }
  232. },
  233. async getDeviceElecMeter() {
  234. const params = {
  235. startRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
  236. endRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
  237. meterCls: 45,
  238. areaCode: this.areaType || -1,
  239. facsCategory: 'Z',
  240. };
  241. listByFacs(params).then(response => {
  242. this.energyUse = response.data.map(item => ({
  243. name: item.objName,
  244. value: item.quantity || 0,
  245. }));
  246. })
  247. },
  248. async getPgSupplyDayTotalPv() {
  249. const {data: pgPvHisSupply} = await pgSupplyDayTotalPv({
  250. areaCode: this.areaType,
  251. startRecTime: DateTool.lastXDay(30),
  252. endRecTime: DateTool.now(),
  253. })
  254. if (!pgPvHisSupply) {
  255. return
  256. }
  257. const dateTips = DateTool.getDayOfRange(DateTool.lastXDay(30), DateTool.now());
  258. const dateIndexMap = {}
  259. pgPvHisSupply.forEach(item => {
  260. dateIndexMap[item.date] = item
  261. })
  262. const lineData = []
  263. dateTips.forEach((item, index) => {
  264. if (dateIndexMap[item]) {
  265. lineData.push({
  266. xData: item,
  267. yData: dateIndexMap[item].useElecQuantity
  268. })
  269. } else {
  270. lineData.push({
  271. xData: item,
  272. yData: 0
  273. })
  274. }
  275. })
  276. this.lineData = lineData
  277. },
  278. }
  279. }
  280. </script>
  281. <style lang='scss' scoped>
  282. @import url("../index.scss");
  283. .soc-container {
  284. margin-top: 20px;
  285. width: 100%;
  286. height: 203px;
  287. background-image: url('~@/assets/images/soc/l1_bg.png');
  288. background-repeat: no-repeat;
  289. background-position: center;
  290. position: relative;
  291. text-align: center;
  292. .soc-data-point {
  293. position: absolute;
  294. top: 60px;
  295. .soc-value {
  296. color: #06E3F9;
  297. font-size: 18px;
  298. }
  299. .soc-description {
  300. color: #B3E3E8;
  301. font-size: 14px;
  302. }
  303. }
  304. .soc-left-data {
  305. left: 45px;
  306. }
  307. .soc-right-data {
  308. right: 35px;
  309. }
  310. .soc-central-data {
  311. position: absolute;
  312. left: 50%;
  313. top: 20px;
  314. transform: translateX(-50%);
  315. .soc-value {
  316. color: #06E3F9;
  317. font-size: 32px;
  318. }
  319. }
  320. .soc-bottom-data {
  321. position: absolute;
  322. left: 50%;
  323. bottom: 62px;
  324. transform: translateX(-50%);
  325. .soc-value {
  326. color: #06E3F9;
  327. font-size: 18px;
  328. }
  329. .soc-description {
  330. color: #B3E3E8;
  331. font-size: 14px;
  332. }
  333. }
  334. .soc-failure {
  335. color: #F05050;
  336. font-size: 18px;
  337. &.unit {
  338. font-size: 14px;
  339. }
  340. }
  341. }
  342. .soc-pie-chart-container {
  343. margin-top: 20px;
  344. width: 369px;
  345. height: 178px;
  346. padding-bottom: 2px;
  347. padding-right: 17px;
  348. position: relative;
  349. background-image: url('~@/assets/images/soc/l2-pie_bg.png');
  350. .soc-chart-label {
  351. position: absolute;
  352. text-align: center;
  353. .soc-chart-label-text {
  354. color: #B3E3E8;
  355. font-size: 14px;
  356. }
  357. .soc-chart-value {
  358. font-size: 18px;
  359. font-weight: bold;
  360. color: #06E3F9;
  361. }
  362. }
  363. .soc-top-left {
  364. top: 12px;
  365. left: 20px;
  366. }
  367. .soc-top-right {
  368. top: 12px;
  369. right: 35px;
  370. }
  371. .soc-bottom-left {
  372. bottom: 32px;
  373. left: 20px;
  374. }
  375. .soc-bottom-right {
  376. bottom: 32px;
  377. right: 35px;
  378. }
  379. }
  380. .storage-grid {
  381. display: flex;
  382. flex-wrap: wrap;
  383. }
  384. .grid-item {
  385. flex-basis: 50%;
  386. height: 62px;
  387. display: flex;
  388. background: url('~@/assets/images/home/l2_item_bg.png') no-repeat;
  389. &:nth-child(n+3) {
  390. margin-top: 10px;
  391. }
  392. .image-container {
  393. width: 90px;
  394. display: flex;
  395. align-items: center;
  396. justify-content: center;
  397. }
  398. .item-details {
  399. width: calc(100% - 22px);
  400. display: flex;
  401. flex-direction: column;
  402. justify-content: center;
  403. margin-left: 5px;
  404. color: #B3E3E8;
  405. .item-value {
  406. span.value {
  407. font-size: 20px;
  408. font-weight: bold;
  409. }
  410. span.unit {
  411. color: #768f95;
  412. font-size: 12px;
  413. margin-left: 2px;
  414. }
  415. }
  416. .item-name {
  417. font-size: 12px;
  418. }
  419. }
  420. }
  421. </style>