electricityConsumptionAnalysis.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view>
  3. <u-navbar title="用电量分析" title-color="#101010"></u-navbar>
  4. <u-select v-model="tabsFrom.show1" mode="mutil-column-auto"
  5. :default-value ="tabsFrom.show1Index" child-name="childList"
  6. :list="companyList" value-name="id" label-name="name"
  7. @columnChange="columnChange"
  8. :title="title"
  9. @confirm="selector1confirm"></u-select>
  10. <view class="background">
  11. <!-- 选择电表 -->
  12. <view class="unit">
  13. <view class="title">
  14. 选择查询电表
  15. </view>
  16. <view class="value" @click="tabsFrom.show1=true">
  17. <view class="text">
  18. {{tabsFrom.show1Text}}
  19. </view>
  20. <view class="icon">
  21. <u-icon name="arrow-down" color="#999999" size="32" ></u-icon>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="main" v-show="info&&info.hourKwhList&&info.hourKwhList.length">
  26. <view class="title">
  27. <view class="icon">
  28. </view>
  29. <view class="text">
  30. 各时段平均用电量 (度)
  31. </view>
  32. </view>
  33. <view class="tips">
  34. <view>{{info.timeSlot}}</view>
  35. <view>日平均用电量:{{info.dayKwh}}度</view>
  36. </view>
  37. <!-- 图表 -->
  38. <view class="chart">
  39. <view id="barEcharts" style="min-height:440rpx;">
  40. </view>
  41. </view>
  42. <!-- 备注 -->
  43. <view class="remark">
  44. <p>备注说明:</p>
  45. 电表设备的各时段平均用电量,采集自设备上一个【不断电状态核准周期】内的每日各时段用电量平均值。以此平均用电量数据基准,作为智能停电节省电费的数据支撑。
  46. </view>
  47. </view>
  48. <view class="main2" v-show="info&&!info.hourKwhList">
  49. <u-divider :isnone="true" nonetext="选择电表" style="margin-top: 20rpx;"
  50. border-color="#CFD2D5">已经到底了</u-divider>
  51. </view>
  52. <view class="main2" v-show="info&&info.hourKwhList&&info.hourKwhList.length==0">
  53. <u-divider :isnone="true" nonetext="暂无数据" style="margin-top: 20rpx;"
  54. border-color="#CFD2D5">已经到底了</u-divider>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import * as echarts from 'echarts';
  61. import * as API_energyManage from '@/apis/pagejs/energyManage.js'
  62. import * as API from '@/apis/pagejs/meterTimer.js'
  63. export default {
  64. data() {
  65. return {
  66. timeShow:false,
  67. title:"",
  68. meterId :"",
  69. info:{},
  70. params: {
  71. year: true,
  72. month: true,
  73. day: false,
  74. hour: false,
  75. minute: false,
  76. second: false
  77. },
  78. tabsFrom: {
  79. show1: false,
  80. show1Index: [],
  81. show2Index: '',
  82. show2: false,
  83. show1Text: "选择电表",
  84. show2Text: "全部时间",
  85. selector1: [
  86. ]
  87. },
  88. myChart: null,
  89. companyList:null,
  90. meterList:null,
  91. }
  92. },
  93. onLoad(op) {
  94. uni.showLoading({
  95. title: "加载中",
  96. mask: true,
  97. })
  98. this.getHaveMeterList()
  99. this.getCompanyInfoList()
  100. },
  101. methods: {
  102. columnChange(e){
  103. this.title=e[2].label
  104. },
  105. callback(){
  106. if(this.companyList&&this.meterList){
  107. uni.hideLoading();
  108. }
  109. if(this.companyList.length&&this.meterList.length){
  110. this.companyList.forEach((item)=>{
  111. item.childList.forEach((info)=>{
  112. info.childList=[]
  113. })
  114. })
  115. this.meterList.forEach((meter)=>{
  116. this.companyList.forEach((item)=>{
  117. item.childList.forEach((info)=>{
  118. if(meter.parkId==info.id){
  119. info.childList.push(meter)
  120. }
  121. })
  122. })
  123. })
  124. }
  125. },
  126. getCompanyInfoList() {
  127. API_energyManage.deviceCompanyList().then((response) => {
  128. //uni.hideLoading();
  129. var list = response.data.companyInfoList;
  130. this.companyList=response.data.companyInfoList;
  131. this.callback()
  132. }).catch(error => {
  133. uni.showToast({
  134. title: error,
  135. icon: "none"
  136. })
  137. })
  138. },
  139. getInfo(){
  140. uni.showLoading({
  141. title: "加载中",
  142. mask: true,
  143. })
  144. API.meterHourKwhList({
  145. meterId:this.meterId
  146. }).then((response) => {
  147. uni.hideLoading();
  148. this.info=response.data
  149. if(this.myChart){
  150. this.myChart.clear();
  151. }
  152. if(this.info&&this.info.hourKwhList&&this.info.hourKwhList.length){
  153. this.$nextTick(()=>{
  154. this.getBarCharts()
  155. })
  156. }
  157. }).catch(error => {
  158. uni.showToast({
  159. title: error,
  160. icon: "none"
  161. })
  162. })
  163. },
  164. getBarCharts() {
  165. if (!this.myChart) {
  166. this.myChart = echarts.init(document.getElementById('barEcharts'), null, {
  167. // width: uni.upx2px(700),
  168. height: uni.upx2px(480)
  169. });
  170. }
  171. var data1 = [];
  172. var data2 = [];
  173. var list=this.info.hourKwhList;
  174. for (var i in list) {
  175. var obj=list[i]
  176. data1.push(obj.hour+'时')
  177. data2.push(obj.kwh)
  178. // sumQuantity+=list[i]
  179. }
  180. var option = {
  181. tooltip: {
  182. trigger: 'axis',
  183. axisPointer: {
  184. type: 'shadow'
  185. },
  186. },
  187. grid: {
  188. top: 40,
  189. left: 5,
  190. right: 10,
  191. bottom: 20,
  192. containLabel: true
  193. },
  194. xAxis: {
  195. type: 'category',
  196. data: data1,
  197. },
  198. yAxis: {
  199. type: 'value',
  200. },
  201. series: [{
  202. name: '合计',
  203. data: data2,
  204. type: 'bar',
  205. markPoint: {
  206. data: [
  207. {type: 'max', name: '最大值'},
  208. {type: 'min', name: '最小值'}
  209. // 或者使用具体的坐标(如果数据中有多个相同的最大值或最小值)
  210. // {coord: [maxIndex, maxVal], name: '最大值'},
  211. // {coord: [minIndex, minVal], name: '最小值'}
  212. ]
  213. }
  214. }]
  215. }
  216. console.log(option)
  217. this.myChart.setOption(option);
  218. },
  219. selector1confirm(e) {
  220. console.log(e)
  221. var index = [e[0].i,e[1].i,e[2].i]
  222. this.tabsFrom.show1Index = index
  223. this.tabsFrom.show1Text =e[2].label
  224. this.meterId = e[2].value
  225. this.getInfo()
  226. },
  227. getHaveMeterList(){
  228. var data = {
  229. queryForm:"property",
  230. };
  231. API.haveMeterList(data).then((response) => {
  232. //var MeterList=response.data.switchRecordList.data
  233. //this.meterList = response.data.remoteReadingMeterList;
  234. var meterList = response.data.remoteReadingMeterList;
  235. meterList=meterList.sort((item1,item2)=>{
  236. if(item1.sortNo==item2.sortNo){
  237. return item1.level>item2.level?1:-1
  238. }
  239. return item1.sortNo>item2.sortNo?1:-1
  240. })
  241. this.meterList=meterList
  242. this.callback()
  243. }).catch(error => {
  244. uni.showToast({
  245. title: error,
  246. icon: "none"
  247. })
  248. })
  249. },
  250. }
  251. }
  252. </script>
  253. <style>
  254. page{
  255. padding-bottom: 100px;
  256. }
  257. </style>
  258. <style lang="scss" scoped>
  259. .background {
  260. background: linear-gradient(180deg, rgba(22,119,255,1) 0%,rgba(22,119,255,0) 100%);
  261. padding: 32rpx 0;
  262. height: 720rpx;
  263. .unit {
  264. background-color: #fff;
  265. margin: 0 32rpx;
  266. border-radius: 8px;
  267. padding: 32rpx;
  268. .title {
  269. color: rgba(153, 153, 153, 1);
  270. }
  271. .value {
  272. color: rgba(51, 51, 51, 1);
  273. font-size: 40rpx;
  274. margin-top: 16rpx;
  275. display: flex;
  276. align-items: center;
  277. justify-content: space-between;
  278. font-weight: bold;
  279. }
  280. }
  281. .main2{
  282. background-color: #fff;
  283. border-radius: 8px;
  284. padding: 32rpx ;
  285. margin: 32rpx;
  286. }
  287. .main{
  288. background-color: #fff;
  289. border-radius: 8px;
  290. padding: 32rpx ;
  291. margin: 32rpx;
  292. .tips{
  293. display: flex;
  294. justify-content: space-around;
  295. color: rgba(119,119,119,1);
  296. font-size: 24rpx;
  297. }
  298. .title{
  299. display: flex;
  300. align-items: center;
  301. margin-bottom: 20px;
  302. .icon{
  303. width: 36rpx;
  304. height: 36rpx;
  305. background-color: #b6d4ff;
  306. border: 6px solid #1677ff;
  307. border-radius: 100px;
  308. }
  309. .text{
  310. color: #333333;
  311. font-size: 36rpx;
  312. margin-left: 16rpx;
  313. font-weight: bold;
  314. }
  315. .date{
  316. margin-left: auto;
  317. border: 1px solid #bbbbbb;
  318. border-radius: 4px;
  319. padding: 4px;
  320. font-size: 12px;
  321. text{
  322. margin-right: 8rpx;
  323. }
  324. }
  325. }
  326. // 图标
  327. .chart{
  328. img{
  329. width: 100%;
  330. height: 440rpx;
  331. }
  332. }
  333. }
  334. .total{
  335. color: rgba(51,51,51,1);
  336. text-align: center;
  337. font-weight: bold;
  338. }
  339. // 备注
  340. .remark {
  341. padding: 40rpx 24rpx;
  342. margin-top: 24rpx;
  343. border-radius: 8px;
  344. background-color: rgba(242, 244, 246, 1);
  345. color: rgba(16, 16, 16, 1);
  346. font-size: 24rpx;
  347. line-height: 34rpx;
  348. }
  349. }
  350. </style>