prod.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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="500px" :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 {areaWithFacsCategoryAsTree} 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. axisPointer: {
  130. type: 'cross',
  131. crossStyle: {
  132. color: '#999'
  133. }
  134. }
  135. },
  136. legend: {
  137. data: ['自用电量', '上网电量', '上网收益']
  138. },
  139. xAxis: {
  140. type: 'category',
  141. data: this.elecStoreHList.map(item => item.date),
  142. axisPointer: {
  143. type: 'shadow'
  144. }
  145. },
  146. yAxis: [
  147. {
  148. name: 'kW·h(千瓦时)',
  149. type: 'value'
  150. },
  151. {
  152. name: '¥(元)',
  153. type: 'value'
  154. }
  155. ],
  156. dataZoom: [
  157. {
  158. type: "slider",
  159. start: 0,
  160. end: 40,
  161. height: 10,
  162. bottom: '5%',
  163. showDetail: false,
  164. showDataShadow: false,
  165. borderColor: "transparent"
  166. },
  167. {
  168. type: "inside",
  169. start: 0,
  170. end: 40,
  171. },
  172. ],
  173. series: [
  174. {
  175. name: '自用电量',
  176. type: 'bar',
  177. stack: '总数',
  178. barWidth: 30,
  179. label: {
  180. show: false,
  181. position: 'insideRight'
  182. },
  183. data: this.elecStoreHList.map(item => item.useElecQuantity),
  184. itemStyle: {
  185. normal: {
  186. color: '#6395FA',
  187. label: {
  188. show: true, // 开启显示
  189. position: 'top', // 在上方显示
  190. textStyle: {
  191. // 数值样式
  192. color: '#000',
  193. fontSize: 14,
  194. fontWeight: 600
  195. }
  196. }
  197. }
  198. }
  199. },
  200. {
  201. name: '上网电量',
  202. type: 'bar',
  203. stack: '总数',
  204. barWidth: 30,
  205. label: {
  206. show: false,
  207. position: 'insideRight'
  208. },
  209. data: this.elecStoreHList.map(item => item.upElecQuantity),
  210. itemStyle: {
  211. normal: {
  212. color: '#8CDF6C',
  213. label: {
  214. show: true, // 开启显示
  215. position: 'top', // 在上方显示
  216. textStyle: {
  217. // 数值样式
  218. color: '#000',
  219. fontSize: 14,
  220. fontWeight: 600
  221. }
  222. }
  223. }
  224. }
  225. },
  226. {
  227. name: '上网收益',
  228. type: 'line',
  229. yAxisIndex: 1,
  230. data: this.elecStoreHList.map(item => item.upElecEarn),
  231. smooth: false
  232. }
  233. ]
  234. }
  235. },
  236. },
  237. watch: {
  238. // 根据名称筛选区域树
  239. areaName (val) {
  240. this.$refs.tree.filter(val)
  241. }
  242. },
  243. async created () {
  244. await this.getAreaList()
  245. this.getList()
  246. },
  247. methods: {
  248. btnChange (item) {
  249. this.activeBtn = item.name
  250. },
  251. // 查询区域列表
  252. async getAreaList () {
  253. await areaWithFacsCategoryAsTree(this.facsCategory, this.facsSubCategory).then(response => {
  254. this.areaOptions = [{
  255. id: '-1',
  256. label: '全部',
  257. children: []
  258. }].concat(response.data)
  259. this.selectedLabel = '全部'
  260. this.queryParams.areaCode = '-1'
  261. })
  262. },
  263. /** 查询储能计量-小时列表 */
  264. getList () {
  265. this.loading = true
  266. const {areaCode} = this.queryParams
  267. let startTime = ''
  268. let endTime = ''
  269. if (this.dateRange && this.dateRange.length) {
  270. const [start, end] = this.dateRange
  271. startTime = start
  272. endTime = end
  273. }
  274. listPvSupplyD({
  275. areaCode,
  276. startTime,
  277. endTime
  278. }).then(({code, data}) => {
  279. this.loading = false
  280. if (code === 200) {
  281. this.elecStoreHList = data
  282. }
  283. })
  284. },
  285. // 筛选节点
  286. filterNode (value, data) {
  287. if (!value) return true
  288. return data.label.indexOf(value) !== -1
  289. },
  290. // 节点单击事件
  291. handleNodeClick (data) {
  292. this.queryParams.areaCode = data.id
  293. this.selectedLabel = data.label
  294. this.getList()
  295. },
  296. }
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. @import './index.scss';
  301. .app-container {
  302. ::v-deep .el-tabs__content {
  303. overflow: initial;
  304. }
  305. }
  306. .ctl-container {
  307. display: flex;
  308. justify-content: flex-end;
  309. margin: 10px 0;
  310. }
  311. </style>