prod.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <el-col :span="4" :xs="24">
  5. <div class="head-container">
  6. <el-input v-model="areaName" placeholder="请输入区域名称" clearable size="small" prefix-icon="el-icon-search"
  7. style="margin-bottom: 20px" />
  8. </div>
  9. <div class="head-container" style="height: 100vh; overflow: hidden; position: relative;">
  10. <el-tree :data="areaOptions" :props="defaultProps" :expand-on-click-node="false"
  11. :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
  12. @node-click="handleNodeClick" style="height: calc(100vh - 50px); overflow-y: auto;" />
  13. </div>
  14. </el-col>
  15. <el-col :span="20" :xs="24">
  16. <el-card>
  17. <div class="container-block">
  18. <div style="display: flex;justify-content: space-between;">
  19. <SubTitle :title="`发电量-日【${selectedLabel}】`" />
  20. <el-button-group>
  21. <el-button v-for="item in btnGroup" :key="item.name" size="mini"
  22. :type="item.name === activeBtn ? 'primary' : ''" :icon="item.icon" @click="btnChange(item)" />
  23. </el-button-group>
  24. </div>
  25. <div class="ctl-container">
  26. <el-date-picker v-model="dateRange" type="daterange" @change="getList" :picker-options="pickerOptions"
  27. value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
  28. align="right" :clearable="false">
  29. </el-date-picker>
  30. </div>
  31. <el-table v-if="activeBtn == 'table'" v-loading="loading" :data="elecStoreHList" max-height="400px">
  32. <el-table-column label="日期" align="center" prop="date" width="180">
  33. </el-table-column>
  34. <el-table-column label="发电量(kW·h)" align="center" prop="genElecQuantity" />
  35. <el-table-column label="上网电量(kW·h)" align="center" prop="upElecQuantity" />
  36. <el-table-column label="自用电量(kW·h)" align="center" prop="useElecQuantity" />
  37. <el-table-column label="上网收益(元)" align="center" prop="upElecEarn" />
  38. </el-table>
  39. <BaseChart v-else width="100%" height="400px" :option="elecOptions" />
  40. </div>
  41. </el-card>
  42. </el-col>
  43. </el-row>
  44. </div>
  45. </template>
  46. <script>
  47. import {listPvSupplyD} from '@/api/mgr/pgSupplyH.js'
  48. import { areaTreeByFacsCategory } from '@/api/basecfg/area'
  49. import BaseChart from '@/components/BaseChart'
  50. import SubTitle from '@/components/SubTitle'
  51. import Treeselect from "@riophae/vue-treeselect";
  52. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  53. import {dateFormat, getDayAgoDate} from '@/utils'
  54. export default {
  55. name: 'ElecStoreD',
  56. components: {
  57. Treeselect,
  58. BaseChart,
  59. SubTitle
  60. },
  61. data () {
  62. const lastWeek = getDayAgoDate(7)
  63. const nowDay = new Date()
  64. return {
  65. // 遮罩层
  66. loading: true,
  67. facsCategory: 'E',
  68. facsSubCategory: '',
  69. elecStoreHList: [],
  70. areaName: undefined,
  71. defaultProps: {
  72. children: "children",
  73. label: "label"
  74. },
  75. selectedLabel: '',
  76. // 查询参数
  77. queryParams: {
  78. areaCode: ''
  79. },
  80. pickerOptions: {
  81. shortcuts: [
  82. {
  83. text: '最近一周',
  84. onClick (picker) {
  85. const end = new Date()
  86. const start = new Date()
  87. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  88. picker.$emit('pick', [start, end])
  89. }
  90. }, {
  91. text: '最近一个月',
  92. onClick (picker) {
  93. const end = new Date()
  94. const start = new Date()
  95. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  96. picker.$emit('pick', [start, end])
  97. }
  98. }, {
  99. text: '最近三个月',
  100. onClick (picker) {
  101. const end = new Date()
  102. const start = new Date()
  103. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  104. picker.$emit('pick', [start, end])
  105. }
  106. }
  107. ]
  108. },
  109. // 表单参数
  110. areaOptions: [],
  111. dateRange: [dateFormat(lastWeek, 'yyyy-MM-dd'), dateFormat(nowDay, 'yyyy-MM-dd')],
  112. activeBtn: 'chart', //--chart图表 --table表格
  113. btnGroup: [
  114. {
  115. name: 'chart',
  116. icon: 'el-icon-s-data'
  117. },
  118. {
  119. name: 'table',
  120. icon: 'el-icon-menu'
  121. }]
  122. }
  123. },
  124. computed: {
  125. elecOptions () {
  126. return {
  127. tooltip: {
  128. trigger: 'axis',
  129. formatter: (params) => {
  130. let relVal = params[0].name
  131. for (let i = 0, l = params.length; i < l; i++) {
  132. const unit = params[i].seriesName==='上网收益'?'元':'kW·h'
  133. relVal =
  134. relVal +
  135. '<br/>' +
  136. params[i].marker +
  137. params[i].seriesName +
  138. '&nbsp;&nbsp;&nbsp;' +
  139. params[i].value + unit
  140. }
  141. return relVal
  142. }
  143. },
  144. legend: {
  145. },
  146. xAxis: {
  147. type: 'category',
  148. data: this.elecStoreHList.map(item => item.date),
  149. axisPointer: {
  150. type: 'shadow'
  151. }
  152. },
  153. yAxis: [
  154. {
  155. name: 'kW·h(千瓦时)',
  156. type: 'value'
  157. },
  158. {
  159. name: '¥(元)',
  160. type: 'value'
  161. }
  162. ],
  163. dataZoom: [
  164. {
  165. type: "slider",
  166. start: 0,
  167. end: 40,
  168. height: 10,
  169. bottom: '5%',
  170. showDetail: false,
  171. showDataShadow: false,
  172. borderColor: "transparent"
  173. },
  174. {
  175. type: "inside",
  176. start: 0,
  177. end: 40,
  178. },
  179. ],
  180. series: [
  181. {
  182. name: '自用电量',
  183. type: 'bar',
  184. stack: '总数',
  185. barWidth: 30,
  186. label: {
  187. show: false,
  188. position: 'insideRight'
  189. },
  190. data: this.elecStoreHList.map(item => item.useElecQuantity),
  191. itemStyle: {
  192. normal: {
  193. color: '#6395FA',
  194. label: {
  195. show: true, // 开启显示
  196. position: 'top', // 在上方显示
  197. textStyle: {
  198. // 数值样式
  199. color: '#000',
  200. fontSize: 14,
  201. fontWeight: 600
  202. }
  203. }
  204. }
  205. }
  206. },
  207. {
  208. name: '上网电量',
  209. type: 'bar',
  210. stack: '总数',
  211. barWidth: 30,
  212. label: {
  213. show: false,
  214. position: 'insideRight'
  215. },
  216. data: this.elecStoreHList.map(item => item.upElecQuantity),
  217. itemStyle: {
  218. normal: {
  219. color: '#8CDF6C',
  220. label: {
  221. show: true, // 开启显示
  222. position: 'top', // 在上方显示
  223. textStyle: {
  224. // 数值样式
  225. color: '#000',
  226. fontSize: 14,
  227. fontWeight: 600
  228. }
  229. }
  230. }
  231. }
  232. },
  233. {
  234. name: '上网收益',
  235. type: 'line',
  236. yAxisIndex: 1,
  237. data: this.elecStoreHList.map(item => item.upElecEarn),
  238. smooth: false
  239. }
  240. ]
  241. }
  242. },
  243. },
  244. watch: {
  245. // 根据名称筛选区域树
  246. areaName (val) {
  247. this.$refs.tree.filter(val)
  248. }
  249. },
  250. async created () {
  251. await this.getAreaList()
  252. this.getList()
  253. },
  254. methods: {
  255. btnChange (item) {
  256. this.activeBtn = item.name
  257. },
  258. // 查询区域列表
  259. async getAreaList () {
  260. await areaTreeByFacsCategory(this.facsCategory, this.facsSubCategory, false).then(response => {
  261. this.areaOptions = [{
  262. id: '-1',
  263. label: '全部',
  264. children: []
  265. }].concat(response.data)
  266. this.selectedLabel = '全部'
  267. this.queryParams.areaCode = '-1'
  268. })
  269. },
  270. /** 查询储能计量-小时列表 */
  271. getList () {
  272. this.loading = true
  273. const {areaCode} = this.queryParams
  274. let startTime = ''
  275. let endTime = ''
  276. if (this.dateRange && this.dateRange.length) {
  277. const [start, end] = this.dateRange
  278. startTime = start
  279. endTime = end
  280. }
  281. listPvSupplyD({
  282. areaCode,
  283. startTime,
  284. endTime
  285. }).then(({code, data}) => {
  286. this.loading = false
  287. if (code === 200) {
  288. this.elecStoreHList = data
  289. }
  290. })
  291. },
  292. // 筛选节点
  293. filterNode (value, data) {
  294. if (!value) return true
  295. return data.label.indexOf(value) !== -1
  296. },
  297. // 节点单击事件
  298. handleNodeClick (data) {
  299. this.queryParams.areaCode = data.id
  300. this.selectedLabel = data.label
  301. this.getList()
  302. },
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. @import './index.scss';
  308. .app-container {
  309. ::v-deep .el-tabs__content {
  310. overflow: initial;
  311. }
  312. }
  313. .ctl-container {
  314. display: flex;
  315. justify-content: flex-end;
  316. margin: 10px 0;
  317. }
  318. </style>