store.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. <el-row :gutter="10">
  18. <el-col v-for="item in deviceModelStatus" :key="item.deviceCode" :span="12" :xs="24">
  19. <el-card shadow="hover">
  20. <el-descriptions :title="item.deviceName">
  21. <el-descriptions-item label="位置信息">{{ item.location }}</el-descriptions-item>
  22. <el-descriptions-item label="设备编码">{{ item.deviceCode }}</el-descriptions-item>
  23. <el-descriptions-item v-for="attr in item.attrJson" :key="attr.attr_key" :label="attr.attr_name">{{attr.attr_value}} {{attr.attr_unit}}</el-descriptions-item>
  24. </el-descriptions>
  25. </el-card>
  26. </el-col>
  27. </el-row>
  28. </el-card>
  29. <el-card style="margin-top: 10px;">
  30. <div class="container-block">
  31. <div style="display: flex;justify-content: space-between;">
  32. <SubTitle :title="`储能-日【${selectedLabel}】`"/>
  33. <el-button-group>
  34. <el-button v-for="item in btnGroup" :key="item.name" size="mini"
  35. :type="item.name === activeBtn ? 'primary' : ''" :icon="item.icon" @click="btnChange(item)"/>
  36. </el-button-group>
  37. </div>
  38. <div class="ctl-container">
  39. <el-date-picker v-model="dateRange" type="daterange" @change="getList" :picker-options="pickerOptions"
  40. value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期"
  41. end-placeholder="结束日期"
  42. align="right" :clearable="false">
  43. </el-date-picker>
  44. </div>
  45. <el-table v-if="activeBtn == 'table'" v-loading="loading" :data="storeList" max-height="400px">
  46. <el-table-column label="日期" align="center" prop="date" width="180">
  47. </el-table-column>
  48. <el-table-column label="充电电量(kW·h)" align="center" prop="chargeElecQuantity"/>
  49. <el-table-column label="放电电量(kW·h)" align="center" prop="dischargeElecQuantity"/>
  50. </el-table>
  51. <BaseChart v-else width="100%" height="400px" :option="elecOptions"/>
  52. </div>
  53. </el-card>
  54. </el-col>
  55. </el-row>
  56. </div>
  57. </template>
  58. <script>
  59. import {getStoreDayList} from '@/api/mgr/elecStoreH.js'
  60. import {areaTreeByFacsCategory} from '@/api/basecfg/area'
  61. import BaseChart from '@/components/BaseChart'
  62. import SubTitle from '@/components/SubTitle'
  63. import Treeselect from "@riophae/vue-treeselect";
  64. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  65. import {dateFormat, getDayAgoDate} from '@/utils'
  66. import {listDeviceModel} from "@/api/device/device";
  67. export default {
  68. name: 'ElecStoreD',
  69. components: {
  70. Treeselect,
  71. BaseChart,
  72. SubTitle
  73. },
  74. data() {
  75. const lastWeek = getDayAgoDate(7)
  76. const nowDay = new Date()
  77. return {
  78. // 遮罩层
  79. loading: true,
  80. facsCategory: 'E',
  81. facsSubCategory: '',
  82. storeList: [],
  83. areaName: undefined,
  84. defaultProps: {
  85. children: "children",
  86. label: "label"
  87. },
  88. selectedLabel: '',
  89. // 查询参数
  90. queryParams: {
  91. areaCode: ''
  92. },
  93. pickerOptions: {
  94. shortcuts: [
  95. {
  96. text: '最近一周',
  97. onClick(picker) {
  98. const end = new Date()
  99. const start = new Date()
  100. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  101. picker.$emit('pick', [start, end])
  102. }
  103. }, {
  104. text: '最近一个月',
  105. onClick(picker) {
  106. const end = new Date()
  107. const start = new Date()
  108. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  109. picker.$emit('pick', [start, end])
  110. }
  111. }, {
  112. text: '最近三个月',
  113. onClick(picker) {
  114. const end = new Date()
  115. const start = new Date()
  116. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  117. picker.$emit('pick', [start, end])
  118. }
  119. }
  120. ]
  121. },
  122. // 表单参数
  123. areaOptions: [],
  124. deviceModelStatus: [],
  125. dateRange: [dateFormat(lastWeek, 'yyyy-MM-dd'), dateFormat(nowDay, 'yyyy-MM-dd')],
  126. activeBtn: 'chart', //--chart图表 --table表格
  127. btnGroup: [
  128. {
  129. name: 'chart',
  130. icon: 'el-icon-s-data'
  131. },
  132. {
  133. name: 'table',
  134. icon: 'el-icon-menu'
  135. }]
  136. }
  137. },
  138. computed: {
  139. elecOptions() {
  140. const xData = this.storeList.map(item => item.date)
  141. const chargeQuantity = this.storeList.map(item => item.chargeElecQuantity)
  142. const dischargeQuantity = this.storeList.map(item => item.dischargeElecQuantity)
  143. const option = {
  144. toolbox: {
  145. itemGap: 10,
  146. itemSize: 16,
  147. right: 10,
  148. top: 0,
  149. show: true,
  150. feature: {
  151. magicType: {
  152. show: true,
  153. type: ['bar', 'line']
  154. },
  155. saveAsImage: {
  156. show: true
  157. }
  158. }
  159. },
  160. tooltip: {
  161. trigger: 'axis',
  162. formatter: (params) => {
  163. var relVal = params[0].name
  164. for (var i = 0, l = params.length; i < l; i++) {
  165. relVal =
  166. relVal +
  167. '<br/>' +
  168. params[i].marker +
  169. params[i].seriesName +
  170. '&nbsp;&nbsp;&nbsp;' +
  171. params[i].value +
  172. 'kW·h'
  173. }
  174. return relVal
  175. }
  176. },
  177. legend: {},
  178. xAxis: {
  179. type: 'category',
  180. data: xData,
  181. axisPointer: {
  182. type: 'shadow'
  183. }
  184. },
  185. yAxis: [
  186. {
  187. name: 'kW·h(千瓦时)',
  188. type: 'value'
  189. }
  190. ],
  191. series: [
  192. {
  193. name: '充电电量',
  194. type: 'bar',
  195. data: chargeQuantity,
  196. barWidth: 20,
  197. itemStyle: {
  198. normal: {
  199. color: '#6395FA'
  200. }
  201. }
  202. },
  203. {
  204. name: '放电电量',
  205. type: 'bar',
  206. data: dischargeQuantity,
  207. barWidth: 20,
  208. itemStyle: {
  209. normal: {
  210. color: '#8CDF6C'
  211. }
  212. }
  213. }
  214. ]
  215. }
  216. return option
  217. },
  218. },
  219. watch: {
  220. // 根据名称筛选区域树
  221. areaName(val) {
  222. this.$refs.tree.filter(val)
  223. }
  224. },
  225. async created() {
  226. await this.getAreaList()
  227. this.getList()
  228. this.getListDeviceModel()
  229. },
  230. methods: {
  231. btnChange(item) {
  232. this.activeBtn = item.name
  233. },
  234. // 查询区域列表
  235. async getAreaList() {
  236. await areaTreeByFacsCategory(this.facsCategory, this.facsSubCategory, false).then(response => {
  237. this.areaOptions = [{
  238. id: '-1',
  239. label: '全部',
  240. children: []
  241. }].concat(response.data)
  242. this.selectedLabel = '全部'
  243. this.queryParams.areaCode = '-1'
  244. })
  245. },
  246. /** 查询储能计量-小时列表 */
  247. getList() {
  248. this.loading = true
  249. const {areaCode} = this.queryParams
  250. const [startRecTime, endRecTime] = this.dateRange
  251. getStoreDayList({
  252. areaCode,
  253. startRecTime,
  254. endRecTime
  255. }).then(({code, data}) => {
  256. this.loading = false
  257. if (code === 200) {
  258. this.storeList = data
  259. }
  260. })
  261. },
  262. // 筛选节点
  263. filterNode(value, data) {
  264. if (!value) return true
  265. return data.label.indexOf(value) !== -1
  266. },
  267. // 节点单击事件
  268. handleNodeClick(data) {
  269. this.queryParams.areaCode = data.id
  270. this.selectedLabel = data.label
  271. this.getList()
  272. this.getListDeviceModel()
  273. },
  274. async getListDeviceModel() {
  275. const {data} = await listDeviceModel({
  276. areaCode: this.queryParams.areaCode,
  277. subsystemCode: 'SYS_CN',
  278. attrGroup: 'State'
  279. })
  280. this.deviceModelStatus = data
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. @import './index.scss';
  287. .app-container {
  288. ::v-deep .el-tabs__content {
  289. overflow: initial;
  290. }
  291. }
  292. .ctl-container {
  293. display: flex;
  294. justify-content: flex-end;
  295. margin: 10px 0;
  296. }
  297. </style>