powerstore.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" @tab-click="tabClick">
  4. <el-tab-pane label="总览" name="summary">
  5. <div class="chartGroup">
  6. <Block title="当日充电量【单位:kW·h】">
  7. <div class="block-area" slot="main">
  8. <div class="center-label">
  9. <div>总充电量</div>
  10. <div>{{ daySum.chargeElecQuantity }}kW·h</div>
  11. </div>
  12. <BaseChart width="100%" height="500px" :option="chargePieOptions" />
  13. </div>
  14. </Block>
  15. <Block title="当日放电量【单位:kW·h】">
  16. <div class="block-area" slot="main">
  17. <div class="center-label">
  18. <div>总放电量</div>
  19. <div>{{ daySum.dischargeElecQuantity }}kW·h</div>
  20. </div>
  21. <BaseChart width="100%" height="500px" :option="disChargePieOptions" />
  22. </div>
  23. </Block>
  24. </div>
  25. </el-tab-pane>
  26. <el-tab-pane label="区块储能" name="area">
  27. <el-col :span="4" :xs="24">
  28. <div class="head-container">
  29. <el-input v-model="areaName" placeholder="请输入区域名称" clearable size="small" prefix-icon="el-icon-search"
  30. style="margin-bottom: 20px" />
  31. </div>
  32. <div class="head-container" style="height: 100vh; overflow: hidden; position: relative;">
  33. <el-tree :data="areaOptions" :props="defaultProps" :expand-on-click-node="false"
  34. :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
  35. @node-click="handleNodeClick" style="height: calc(100vh - 50px); overflow-y: auto;" />
  36. </div>
  37. </el-col>
  38. <el-col :span="20" :xs="24">
  39. <div class="container-block">
  40. <SubTitle :title="`时段储能数据【${selectedLabel}】`" />
  41. <BaseChart width="100%" height="300px" :option="elecOptions" />
  42. </div>
  43. <div class="container-block">
  44. <div class="ctl-container">
  45. <el-date-picker v-model="dateRange" type="datetimerange" @change="getList" :picker-options="pickerOptions"
  46. value-format="yyyy-MM-dd hh:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
  47. align="right">
  48. </el-date-picker>
  49. </div>
  50. <el-table v-loading="loading" :data="elecStoreHList" max-height="400px">
  51. <el-table-column label="日期" align="center" prop="date" width="180">
  52. </el-table-column>
  53. <el-table-column label="时间" align="center" prop="time">
  54. </el-table-column>
  55. <el-table-column label="充电电量(kW·h)" align="center" prop="chargeElecQuantity" />
  56. <el-table-column label="放电电量(kW·h)" align="center" prop="dischargeElecQuantity" />
  57. </el-table>
  58. </div>
  59. </el-col>
  60. </el-tab-pane>
  61. </el-tabs>
  62. </div>
  63. </template>
  64. <script>
  65. import {listElecStoreH, dayStatistics} from '@/api/mgr/elecStoreH'
  66. import {areaWithFacsCategoryAsTree} from '@/api/basecfg/area'
  67. import {dateFormat} from '@/utils/index.js'
  68. import dayjs from 'dayjs'
  69. import {DateTool} from '@/utils/DateTool'
  70. import BaseChart from '@/components/BaseChart'
  71. import SubTitle from '@/components/SubTitle'
  72. import Block from '@/components/Block/block.vue'
  73. import Treeselect from "@riophae/vue-treeselect";
  74. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  75. export default {
  76. name: 'ElecStoreH',
  77. components: {
  78. Treeselect,
  79. BaseChart,
  80. Block,
  81. SubTitle
  82. },
  83. data () {
  84. return {
  85. activeName: 'summary',
  86. // 遮罩层
  87. loading: true,
  88. facsCategory: '',
  89. facsSubCategory: '',
  90. // 储能计量-小时表格数据
  91. elecStoreHList: [],
  92. areaName: undefined,
  93. defaultProps: {
  94. children: "children",
  95. label: "label"
  96. },
  97. selectedLabel: '',
  98. // 查询参数
  99. queryParams: {
  100. areaCode: ''
  101. },
  102. pickerOptions: {
  103. shortcuts: [
  104. {
  105. text: '最近一周',
  106. onClick (picker) {
  107. const end = new Date()
  108. const start = new Date()
  109. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  110. picker.$emit('pick', [start, end])
  111. }
  112. }, {
  113. text: '最近一个月',
  114. onClick (picker) {
  115. const end = new Date()
  116. const start = new Date()
  117. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  118. picker.$emit('pick', [start, end])
  119. }
  120. }, {
  121. text: '最近三个月',
  122. onClick (picker) {
  123. const end = new Date()
  124. const start = new Date()
  125. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  126. picker.$emit('pick', [start, end])
  127. }
  128. }
  129. ]
  130. },
  131. // 表单参数
  132. areaOptions: [],
  133. hourSum: [],
  134. daySum: {},
  135. todayList: [],
  136. dateRange: [dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00), dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59)]
  137. }
  138. },
  139. computed: {
  140. elecOptions () {
  141. const xData = this.todayList.map(item => item.time)
  142. const chargeQuantity = this.todayList.map(item => item.chargeElecQuantity)
  143. const dischargeQuantity = this.todayList.map(item => item.dischargeElecQuantity)
  144. const option = {
  145. tooltip: {
  146. trigger: 'axis',
  147. axisPointer: {
  148. type: 'cross',
  149. crossStyle: {
  150. color: '#999'
  151. }
  152. }
  153. },
  154. legend: {
  155. data: ['充电电量', '放电电量']
  156. },
  157. xAxis: {
  158. type: 'category',
  159. data: xData,
  160. axisPointer: {
  161. type: 'shadow'
  162. }
  163. },
  164. yAxis: [
  165. {
  166. name: 'kW·h(千瓦时)',
  167. type: 'value'
  168. }
  169. ],
  170. series: [
  171. {
  172. name: '充电电量',
  173. type: 'bar',
  174. data: chargeQuantity,
  175. barWidth: 20,
  176. itemStyle: {
  177. normal: {
  178. color: '#6395FA'
  179. }
  180. }
  181. },
  182. {
  183. name: '放电电量',
  184. type: 'bar',
  185. data: dischargeQuantity,
  186. barWidth: 20,
  187. itemStyle: {
  188. normal: {
  189. color: '#8CDF6C'
  190. }
  191. }
  192. }
  193. ]
  194. }
  195. return option
  196. },
  197. chargePieOptions () {
  198. return {
  199. tooltip: {
  200. trigger: 'item'
  201. },
  202. series: [
  203. {
  204. name: '充电量',
  205. type: 'pie',
  206. radius: [50, 150],
  207. center: ['50%', '50%'],
  208. roseType: 'area',
  209. itemStyle: {
  210. borderRadius: 8
  211. },
  212. data:
  213. this.hourSum.map(item => ({
  214. name: item.time,
  215. value: item.chargeElecQuantity
  216. }))
  217. }
  218. ]
  219. }
  220. },
  221. disChargePieOptions () {
  222. return {
  223. tooltip: {
  224. trigger: 'item'
  225. },
  226. series: [
  227. {
  228. name: '放电量',
  229. type: 'pie',
  230. radius: [50, 150],
  231. center: ['50%', '50%'],
  232. roseType: 'area',
  233. itemStyle: {
  234. borderRadius: 8
  235. },
  236. data: this.hourSum.map(item => ({
  237. name: item.time,
  238. value: item.dischargeElecQuantity
  239. }))
  240. }
  241. ]
  242. }
  243. }
  244. },
  245. watch: {
  246. // 根据名称筛选区域树
  247. areaName (val) {
  248. this.$refs.tree.filter(val)
  249. }
  250. },
  251. async created () {
  252. this.facsCategory = 'C'
  253. await this.getAreaList()
  254. this.tabClick()
  255. },
  256. methods: {
  257. // 查询区域列表
  258. async getAreaList () {
  259. await areaWithFacsCategoryAsTree(this.facsCategory, this.facsSubCategory).then(response => {
  260. this.areaOptions = [{
  261. id: '-1',
  262. label: '全部',
  263. children: response.data
  264. }]
  265. })
  266. },
  267. /** 查询储能计量-小时列表 */
  268. getList () {
  269. this.loading = true
  270. const {areaCode} = this.queryParams
  271. let startRecTime = ''
  272. let endRecTime = ''
  273. if (this.dateRange && this.dateRange.length) {
  274. const [start, end] = this.dateRange
  275. startRecTime = start
  276. endRecTime = end
  277. }
  278. listElecStoreH({
  279. areaCode,
  280. pageNum: 1,
  281. pageSize: 999,
  282. startRecTime,
  283. endRecTime
  284. }).then(response => {
  285. this.elecStoreHList = response.rows
  286. this.total = response.total
  287. this.loading = false
  288. })
  289. },
  290. getTodayChart () {
  291. const {areaCode} = this.queryParams
  292. const nowDay = dateFormat(new Date(), 'yyyy-MM-dd')
  293. listElecStoreH({
  294. areaCode,
  295. pageNum: 1,
  296. pageSize: 999,
  297. startRecTime: `${nowDay} 00:00:00`,
  298. endRecTime: `${nowDay} 23:59:59`
  299. }).then(response => {
  300. this.todayList = response.rows
  301. })
  302. },
  303. getSummary () {
  304. dayStatistics({date: dateFormat(new Date(), 'yyyy-MM-dd')}).then(({code, data}) => {
  305. if (code === 200) {
  306. this.hourSum = data.hourSum || []
  307. this.daySum = data.daySum || {}
  308. }
  309. })
  310. },
  311. // 筛选节点
  312. filterNode (value, data) {
  313. if (!value) return true
  314. return data.label.indexOf(value) !== -1
  315. },
  316. // 节点单击事件
  317. handleNodeClick (data) {
  318. this.queryParams.areaCode = data.id
  319. this.selectedLabel = data.label
  320. this.getList()
  321. this.getTodayChart();
  322. },
  323. /** 搜索按钮操作 */
  324. tabClick () {
  325. if (this.activeName === 'summary') {
  326. this.getSummary()
  327. } else {
  328. this.selectedLabel = '全部'
  329. this.queryParams.areaCode = '-1'
  330. this.getAreaList()
  331. this.getTodayChart()
  332. this.getList()
  333. }
  334. }
  335. }
  336. }
  337. </script>
  338. <style lang="scss" scoped>
  339. @import './index.scss';
  340. .app-container {
  341. ::v-deep .el-tabs__content {
  342. overflow: initial;
  343. }
  344. }
  345. .chartGroup {
  346. display: flex;
  347. >div {
  348. flex: 1;
  349. }
  350. .block-area {
  351. position: relative;
  352. width: 100%;
  353. }
  354. .center-label {
  355. position: absolute;
  356. top: 50%;
  357. left: 50%;
  358. transform: translate(-50%, -50%);
  359. display: flex;
  360. flex-direction: column;
  361. align-items: center;
  362. }
  363. }
  364. </style>