equipmentElectricity.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388
  1. <template>
  2. <view>
  3. <view class="navbar-c">
  4. <view class="back" @click="backStatistics">
  5. <u-icon name="arrow-left" color="#101010" size="36"></u-icon>
  6. </view>
  7. <view class="title">
  8. 用电量(度)
  9. <image class="img" src="@/assets/img/refresh-line.svg" @click="getList(true)"></image>
  10. </view>
  11. </view>
  12. <u-picker-select title="日期选择" v-model="tabsFrom.show2" :defaultTime="tabsFrom.show2Index" :endYear="endYear"
  13. mode="time" :params="params" :noselect="false" @confirm="selector2confirm" @cancel="selector2cancel"
  14. @reset="selector2reset"></u-picker-select>
  15. <!-- 标签 -->
  16. <view class="tabs-box" >
  17. <view class="tabs" :class="'tabs-len-'+merchantList1.length" v-show="companyList.length>1"
  18. :style="{width: companyList.length>3 ? '' : '100%'}">
  19. <u-tabs-one v-if="utabsone"
  20. :list="merchantList1" :is-scroll="false" inactive-color="#999999" active-color="#666666"
  21. :current="current" @change="change"></u-tabs-one>
  22. </view>
  23. <view class="more" @click="popShow=true" v-if="companyList.length >= 4">
  24. <u-icon name="arrow-down" color="#fff" size="40"></u-icon>
  25. </view>
  26. </view>
  27. <!-- 标签弹出层 -->
  28. <u-popup v-model="popShow" duration="10" mode="top" :negative-top="88" border-radius="16">
  29. <view class="popup-tabs">
  30. <view class="tabs">
  31. <u-tabs :list="merchantList1" :is-scroll="false" :current="current" @change="change"></u-tabs>
  32. </view>
  33. <view class="more">
  34. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  35. </view>
  36. </view>
  37. <view class="tabs-options">
  38. <view class="item" v-for="(item, index) in merchantList2" :key="index"
  39. @click="merchantChange(item,index)">
  40. {{item.name}}
  41. </view>
  42. </view>
  43. </u-popup>
  44. <!-- 全部标签 -->
  45. <view class="main" v-show="current==0" >
  46. <view class="item" v-for="(item, index) in kWhListHome" :key="item.index" v-if="current==0"
  47. @click="toElectronicMonitoring(item)">
  48. <view class="item-content">
  49. <view class="equipment">
  50. <view class="equipment1 ">
  51. {{replaceLastTwoWords(item.name)}}
  52. </view>
  53. <view class="equipment2">
  54. {{item.installationAddressSimple}}
  55. </view>
  56. <view class="state" v-if="!item.online">
  57. <view class="dot off-line"></view>
  58. <view class="text">离线</view>
  59. </view>
  60. <view class="state state2" v-else>
  61. <view class="dot on-line"></view>
  62. <view class="text">在线</view>
  63. </view>
  64. </view>
  65. <view class="electricity">
  66. <view class="electricity-item electricity-item-day">
  67. <view class="date">
  68. 今日
  69. </view>
  70. <view class="number">
  71. {{item.thisDayKwh}}
  72. </view>
  73. </view>
  74. <view class="electricity-item">
  75. <view class="date">
  76. 本月
  77. </view>
  78. <view class="number">
  79. {{item.thisMonthKwh}}
  80. </view>
  81. </view>
  82. <view class="electricity-item">
  83. <view class="date">
  84. 上月
  85. </view>
  86. <view class="number">
  87. {{item.lastMonthKwh}}
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="more">
  93. <u-icon name="arrow-right" color="#d4d4d4" size="24"></u-icon>
  94. </view>
  95. </view>
  96. </view>
  97. <u-divider v-show="current==0" :isnone="kWhListHome.length==0" nonetext="暂无数据" border-color="#CFD2D5">已经到底了</u-divider>
  98. <view class="content" v-show="kWhList.length==1" style="padding: 0;">
  99. <electronicMonitoring v-show="kWhList.length" :ref="'refMyEm'+companyId"></electronicMonitoring>
  100. <u-divider :isnone="kWhList.length==0" nonetext="暂无数据" border-color="#CFD2D5">已经到底了</u-divider>
  101. </view>
  102. <view v-show="kWhList.length!=1">
  103. <!-- 子项标签 -->
  104. <view class="content"
  105. v-if="!getHomePageManageshowLoading&&current!=0">
  106. <div class="uni-toast" style="display: flex;font-size: 60rpx; color: rgb(192, 196, 204);" >
  107. <i class="uni-icon_toast uni-loading"
  108. style="
  109. width: 80rpx;
  110. height: 80rpx;
  111. "
  112. ></i><p class="uni-toast__content"> </p>加载中...</div>
  113. </view>
  114. <view class="content" v-else-if="getHomePageManageshowLoading&&meterList.length == 0&&current!=0">
  115. <u-divider :isnone="true" nonetext="无记录"
  116. border-color="#fff"></u-divider>
  117. </view>
  118. <view class="statistics-manage" v-show="current!=0&&getHomePageManageshowLoading" >
  119. <!-- 图表 -->
  120. <view class="chart">
  121. <view class="u-subsection">
  122. <u-subsection :list="list" :current="homePageManageType" @change="sectionChange" font-size="24"></u-subsection>
  123. </view>
  124. <view class="incomeExpenditureClass" v-show="companyType!=4&&homePageManageObj.showPark" >
  125. <view class="income1">
  126. <view class="income11">
  127. 电费支出 (元)
  128. </view>
  129. <view class="income12">
  130. {{incomeExpenditureObj.expenditureFee}}
  131. <span class="income121" v-if="!incomeExpenditureObj.id">加载中...</span>
  132. </view>
  133. </view>
  134. <view class="income1">
  135. <view class="income11">
  136. 电费收入 (元)
  137. </view>
  138. <view class="income12">
  139. {{incomeExpenditureObj.incomeFee}}
  140. <span class="income121" v-if="!incomeExpenditureObj.id">加载中...</span>
  141. </view>
  142. </view>
  143. <view class="income1">
  144. <view class="income11">
  145. 收支情况 (元)
  146. </view>
  147. <view class="income12" :style="incomeExpenditureObj.differenceFee>=0?'color:red':'color:#52b8aa'">
  148. {{incomeExpenditureObj.differenceFee}}
  149. <span class="income121" v-if="!incomeExpenditureObj.id">加载中...</span>
  150. </view>
  151. </view>
  152. </view>
  153. <view class="chat-box" id="barEcharts-statistics" v-show="companyType!=4&&homePageManageObj.showPark">
  154. </view>
  155. </view>
  156. <view class="search" v-if="0">
  157. <view class="switch">
  158. <u-switch v-model="checked" size="40"></u-switch><text>只看离线表</text>
  159. </view>
  160. <view class="search-box" >
  161. <input type="text" placeholder="请输入电表查询" />
  162. <view class="icon">
  163. <img src="@/assets/img/riLine-search-line 1.svg" alt="" />
  164. </view>
  165. </view>
  166. </view>
  167. <!-- 电表统计 -->
  168. <Tree-Body :meterList="meterList" ref="mytree"
  169. @query="getHomePageManageChildMeter"
  170. :showPark="homePageManageObj.showPark"
  171. v-if="getHomePageManageReady"
  172. :role="codes&&codes.indexOf('switch')!=-1"
  173. @switchBtn="switchBtnApi"
  174. ></Tree-Body>
  175. </view>
  176. <u-divider nonetext="无记录" v-show="current!=0&&getHomePageManageshowLoading"
  177. border-color="#CFD2D5">已经到底了</u-divider>
  178. </view>
  179. </view>
  180. </template>
  181. <script>
  182. import * as API from '@/apis/pagejs/index.js'
  183. import * as API2 from '@/apis/pagejs/energyManage.js'
  184. import * as echarts from 'echarts';
  185. import {
  186. parseUnixTime,
  187. beforeTimeStamp,
  188. getWeek
  189. } from '@/apis/utils'
  190. import TreeBody from '@/components/tree/tree-body.vue';
  191. import electronicMonitoring from '@/pages/equipmentDataMonitoring/electronicMonitoring.vue'
  192. export default {
  193. components: {
  194. TreeBody,electronicMonitoring
  195. },
  196. data() {
  197. return {
  198. codes:"",
  199. getHomePageManageReady:false,
  200. getHomePageManageshowLoading:false,
  201. companyList: [], // 商户
  202. merchantList1: [],
  203. merchantList2: [],
  204. myLineChart: null, // 图表
  205. myBarChart: null,
  206. myPieChart: null,
  207. homePageManageType: 2,
  208. homePageManageObj: {
  209. chargeKwh: 0,
  210. lostKwh: 0,
  211. parkKwh: 0,
  212. freeKwh:0,
  213. publicKwh:0,
  214. },
  215. meterList: [],
  216. meterListShow:{},
  217. queryDate: '',
  218. kWhList: [], //设备
  219. kWhListHome: [], //设备
  220. companyId: '',
  221. popShow: false,
  222. current: 0,
  223. allKWhList: [],
  224. companyKwhList: [],
  225. pageIndex: 1,
  226. recordsTotal: 0,
  227. windowHeight: '',
  228. checked:false,
  229. list: [{
  230. name: '上月',
  231. value: "2"
  232. },
  233. {
  234. name: '当月',
  235. value: "1"
  236. },
  237. {
  238. name: '今日',
  239. value: "4"
  240. }, {
  241. name: '当年',
  242. value: "3"
  243. }, {
  244. name: '合计',
  245. value: "0"
  246. },
  247. {
  248. name: '指定月份',
  249. value: "10"
  250. }
  251. ],
  252. endYear: '',
  253. params: {
  254. year: true,
  255. month: true,
  256. day: true,
  257. hour: false,
  258. minute: false,
  259. second: false
  260. },
  261. value: '2',
  262. clickType: -1,
  263. tabsFrom: {
  264. show1: false,
  265. show1Index: 0,
  266. show2Index: '',
  267. show2: false,
  268. show1Text: "全部类型",
  269. show2Text: "全部时间",
  270. },
  271. utabsone:true,
  272. companyType:0,
  273. incomeExpenditureObj:{},
  274. }
  275. },
  276. onReady() {
  277. this.endYear = new Date().getFullYear();
  278. this.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  279. this.getCompanyInfoList();
  280. },
  281. onLoad() {
  282. },
  283. onReachBottom() {
  284. if (this.current==0&&this.kWhListHome.length < this.recordsTotal) {
  285. this.myLoadmore();
  286. }
  287. },
  288. methods: {
  289. companyIdSet(val,item){
  290. this.companyType= 0
  291. if(val&&item){
  292. this.companyType= item.type
  293. }else{
  294. if(!val){
  295. }else{
  296. var bl=false
  297. this.companyList.find(item=>{
  298. if(item.id==val){
  299. this.companyType= item.type;
  300. }
  301. })
  302. }
  303. }
  304. },
  305. switchBtnApiMethod(node,key){
  306. uni.showLoading({
  307. title: "加载中",
  308. mask: true,
  309. })
  310. API2.remoteSwitch({
  311. meterId:node.id,
  312. enabled:key
  313. }).then((res) => {
  314. uni.hideLoading();
  315. node.switchStatus=key
  316. }).catch(error => {
  317. uni.showToast({
  318. title: error,
  319. icon: "none"
  320. })
  321. })
  322. },
  323. switchBtnApi(node,key){
  324. uni.showModal({
  325. confirmColor:`${key?'#3CC51F':'red'}`,
  326. confirmText:`${key?'开启':'关闭'}`,
  327. content: `确认是否要"${key?'开启':'关闭'}"${this.replaceLastTwoWords(node.name)}`,
  328. title: "提示",
  329. success:res=> {
  330. if(res.confirm){
  331. this.switchBtnApiMethod(node,key);
  332. }
  333. }
  334. })
  335. console.log(node,key)
  336. },
  337. refreshList() {
  338. if (this.current != 0) {
  339. this.getList(true);
  340. } else {
  341. this.getCompanyInfoList();
  342. }
  343. },
  344. companyChange(item, index) {
  345. this.current = index + 1;
  346. this.companyId = item.id;
  347. this.companyIdSet(this.companyId)
  348. this.getList(true);
  349. },
  350. getCompanyInfoList() {
  351. this.companyKwhList = [];
  352. API.deviceCompanyList().then((response) => {
  353. var list = response.data.companyInfoList;
  354. this.companyList = list;
  355. var mList1 = [];
  356. var mList2 = [];
  357. mList1.push({
  358. id: '',
  359. name: '全部'
  360. });
  361. for (var i = 0; i < list.length; i++) {
  362. if (i >= 3) {
  363. mList2.push(list[i]);
  364. } else {
  365. mList1.push(list[i]);
  366. }
  367. }
  368. this.merchantList1 = mList1;
  369. this.merchantList2 = mList2;
  370. this.companyId = mList1[0].id;
  371. this.companyIdSet(this.companyId)
  372. this.getList();
  373. }).catch(error => {
  374. uni.showToast({
  375. title: error,
  376. icon: "none"
  377. })
  378. })
  379. },
  380. myLoadmore() {
  381. this.pageIndex += 1;
  382. this.getList();
  383. },
  384. getList(bl) {
  385. uni.showLoading({
  386. title: "加载中",
  387. mask: true,
  388. })
  389. if (bl) {
  390. this.kWhListHome = [];
  391. this.pageIndex = 1;
  392. }
  393. var data = {
  394. pageIndex: this.pageIndex,
  395. pageSize: 20,
  396. companyId: this.companyId
  397. };
  398. API.homePageKwh(data).then((res) => {
  399. uni.hideLoading();
  400. this.kWhListHome = [
  401. ...this.kWhListHome,
  402. ...res.data.data
  403. ];
  404. this.recordsTotal = res.data.recordsTotal;
  405. }).catch(error => {
  406. uni.showToast({
  407. title: error,
  408. icon: "none"
  409. })
  410. })
  411. },
  412. getHomePageKwh(companyId) {
  413. uni.showLoading({
  414. title: "加载中",
  415. mask: true,
  416. })
  417. var data = {
  418. pageIndex: this.pageIndex,
  419. pageSize: 20,
  420. companyId: companyId
  421. };
  422. API.homePageKwh(data).then((res) => {
  423. uni.hideLoading();
  424. this.kWhList =res.data.data;
  425. //this.recordsTotal = res.data.recordsTotal;
  426. if(this.kWhList.length==1){
  427. var item=this.kWhList[0];
  428. this.$refs['refMyEm'+companyId].init({
  429. id:item.id,
  430. name:item.name,
  431. companyId:item.companyId,
  432. ref:1,
  433. })
  434. }else{
  435. this.getHomePageManage(1)
  436. //this.getDeviceStatus()
  437. //this.getAbnormalAlarmRecord();
  438. }
  439. }).catch(error => {
  440. uni.showToast({
  441. title: error,
  442. icon: "none"
  443. })
  444. })
  445. },
  446. merchantChange(item, index) {
  447. if(this.current==0){
  448. this.current=1;
  449. }
  450. this.utabsone=false
  451. var m = item;
  452. var n = this.merchantList1[this.current];
  453. this.merchantList1[this.current] = m;
  454. this.merchantList2[index] = n;
  455. this.companyId = item.id;
  456. this.companyIdSet(this.companyId)
  457. this.popShow = false;
  458. this.$nextTick(()=>{
  459. this.utabsone=true
  460. })
  461. //this.getList(true);
  462. this.merchantChangeApi()
  463. },
  464. // 设备数据监测
  465. getHomePageManageChildMeter(item,bl) {
  466. // if(!bl){
  467. // uni.showLoading({
  468. // title: "加载中",
  469. // mask: true,
  470. // })
  471. // }
  472. API2.homePageManageChildMeter({
  473. parentMeterId:item.id,
  474. queryDate:this.queryDate,
  475. companyId: this.companyId,
  476. type: this.list[this.homePageManageType].value
  477. }).then((response) => {
  478. // if(!bl){
  479. // uni.hideLoading();
  480. // }
  481. // this.meterList = response.data.meterList;
  482. // if(!this.meterListShow.id){
  483. // this.meterListShow.id=1
  484. // this.recursionList(this.meterList)
  485. // }
  486. var childMeterList=response.data.childMeterList
  487. item.childMeterList=childMeterList
  488. if(!bl){
  489. for(var i in childMeterList){
  490. var obj=childMeterList[i]
  491. this.getHomePageManageChildMeter(obj,true)
  492. }
  493. }
  494. }).catch(error => {
  495. uni.showToast({
  496. title: error,
  497. icon: "none"
  498. })
  499. })
  500. },
  501. getIncomeExpenditure(){
  502. API2.incomeExpenditure({
  503. //parentMeterId:item.id,
  504. queryDate:this.queryDate,
  505. companyId: this.companyId,
  506. type: this.list[this.homePageManageType].value
  507. }).then((response) => {
  508. this.incomeExpenditureObj=response.data
  509. this.incomeExpenditureObj.id=1
  510. }).catch(error => {
  511. uni.showToast({
  512. title: error,
  513. icon: "none"
  514. })
  515. })
  516. },
  517. // 设备数据监测
  518. // 设备数据监测
  519. getHomePageManage(bl) {
  520. this.getHomePageManageReady=false
  521. if(bl){
  522. this.getHomePageManageshowLoading=false
  523. }else{
  524. uni.showLoading({
  525. title: "加载中",
  526. mask: true,
  527. })
  528. }
  529. // uni.showLoading({
  530. // title: "加载中",
  531. // mask: true,
  532. // })
  533. this.incomeExpenditureObj={}
  534. API2.homePageManage({
  535. queryDate:this.queryDate,
  536. companyId: this.companyId,
  537. type: this.list[this.homePageManageType].value
  538. }).then((response) => {
  539. //uni.hideLoading();
  540. this.getHomePageManageReady=true
  541. if(bl){
  542. this.getHomePageManageshowLoading=true
  543. }else{
  544. uni.hideLoading();
  545. }
  546. this.utabsone=true;
  547. this.codes =this.carhelp.getPersonInfo().codes;
  548. this.meterList = response.data.meterList;
  549. // this.$nextTick(()=>{
  550. // this.$refs.mytree.toggle()
  551. // })
  552. this.homePageManageObj = response.data;
  553. if(this.companyType!=4&&this.homePageManageObj.showPark){
  554. this.$nextTick(()=>{
  555. this.myBarChart=null;
  556. this.getBarCharts()
  557. })
  558. this.getIncomeExpenditure();
  559. }
  560. }).catch(error => {
  561. uni.showToast({
  562. title: error,
  563. icon: "none"
  564. })
  565. })
  566. },
  567. sectionChange(index) {
  568. this.clickType = this.homePageManageType;
  569. this.homePageManageType = index;
  570. if (index == 5) {
  571. this.tabsFrom.show2 = true;
  572. this.params.day = false;
  573. } else {
  574. this.list[5].name = '指定月份'
  575. this.getHomePageManage()
  576. }
  577. },
  578. recursionList(list){
  579. if(list){
  580. for(var i in list){
  581. var obj=list[i]
  582. this.meterListShow[obj.id]=false
  583. this.recursionList(obj.childMeterList)
  584. }
  585. }
  586. },
  587. ifBtnShow(item){
  588. return this.meterListShow[item.id]
  589. },
  590. showBtn(item){
  591. var key=this.meterListShow[item.id];
  592. this.$set(this.meterListShow,item.id,!key)
  593. console.log("showBtn,",key)
  594. this.getHomePageManageChildMeter(item);
  595. this.$forceUpdate()
  596. },
  597. selector2reset(e) {
  598. console.log(e)
  599. this.tabsFrom.show2Text = '全部时间'
  600. this.tabsFrom.show2Index = '';
  601. if (e.day) {
  602. this.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  603. this.getHomePageManage();
  604. } else {
  605. this.homePageManageType = this.clickType;
  606. if (this.homePageManageType != 5) {
  607. this.list[5].name = '指定月份';
  608. }
  609. this.getHomePageManage();
  610. }
  611. },
  612. selector2cancel() {
  613. if(this.clickType != -1) {
  614. }
  615. this.homePageManageType = this.clickType;
  616. },
  617. selector2confirm(e) {
  618. this.tabsFrom.show2Text = e.year + "年" + e.month + "月"
  619. this.tabsFrom.show2Index = e.year + "-" + e.month
  620. if (e.day) {
  621. this.tabsFrom.show2Text += e.day + "日"
  622. this.tabsFrom.show2Index += '-' + e.day
  623. this.queryDateMethod(this.tabsFrom.show2Index, true)
  624. } else {
  625. this.queryDateMethod(this.tabsFrom.show2Index, false)
  626. }
  627. },
  628. queryDateMethod(queryTime, day) {
  629. if (day) {
  630. this.queryDate = queryTime;
  631. } else {
  632. this.queryDate = queryTime + "-01";
  633. this.homePageManageType = "5";
  634. this.list[5].name = queryTime;
  635. this.getHomePageManage();
  636. }
  637. },
  638. getBarCharts() {
  639. if (!this.myBarChart) {
  640. this.myBarChart = echarts.init(document.getElementById('barEcharts-statistics'),null,{
  641. width:uni.upx2px(620),height:uni.upx2px(740)
  642. });
  643. }
  644. this.myBarChart.clear()
  645. var data=[
  646. {
  647. name:"园区电量",
  648. key:"parkKwh",
  649. color:"#307af6"
  650. },
  651. {
  652. name:"计费电量",
  653. key:"chargeKwh",
  654. color:"#52b8aa"
  655. },
  656. {
  657. name:"自用电量",
  658. key:"freeKwh",
  659. color:"#53b56b"
  660. },
  661. {
  662. name:"公用电量",
  663. key:"publicKwh",
  664. color:"#ef8132"
  665. },
  666. {
  667. name:"电损量",
  668. key:"lostKwh",
  669. color:"#dc4441"
  670. }
  671. ]
  672. var dataName=[]
  673. var dataSeries=[]
  674. for(var i in data){
  675. var it=data[i]
  676. dataName.push(it.name)
  677. dataSeries.push({})
  678. }
  679. for(var i in data){
  680. var it=data[i]
  681. dataSeries[data.length-i-1]={
  682. name:it.name,
  683. type: 'bar',
  684. itemStyle:{
  685. color:it.color
  686. },
  687. data: [
  688. this.homePageManageObj[it.key]
  689. ],
  690. coordinateSystem: 'polar',
  691. label: {
  692. show: true,
  693. position: 'start',
  694. formatter: '{c}度'
  695. }
  696. }
  697. }
  698. var option = {
  699. polar: {
  700. center:['50%','58%'],
  701. radius:[25, '80%']
  702. },
  703. angleAxis: {
  704. startAngle: 75,
  705. label: {
  706. rotate: 45, // 旋转标签,使得重叠的概率降低
  707. // margin: 5 // 设置标签与轴线之间的距离,增加空间
  708. }
  709. },
  710. legend: {
  711. itemGap:5,
  712. data: dataName,
  713. //orient :'vertical'
  714. },
  715. radiusAxis: {
  716. type: 'category',
  717. data: ['']
  718. },
  719. tooltip: {},
  720. series: dataSeries
  721. };
  722. console.log(option)
  723. this.myBarChart.setOption(option);
  724. },
  725. merchantChangeApi() {
  726. this.popShow=false
  727. if (this.companyId) {
  728. this.getHomePageKwh(this.companyId)
  729. }else{
  730. this.kWhList=[]
  731. }
  732. },
  733. change(index) {
  734. this.current = index;
  735. this.companyId = this.merchantList1[index].id;
  736. this.companyIdSet(this.companyId)
  737. this.merchantChangeApi()
  738. },
  739. backStatistics() {
  740. uni.navigateBack()
  741. },
  742. toElectronicMonitoring(item) {
  743. uni.navigateTo({
  744. url: '/pages/equipmentDataMonitoring/electronicMonitoring?id=' + item.id + '&name=' + item
  745. .name +
  746. '&companyId=' + item.companyId
  747. })
  748. }
  749. }
  750. }
  751. </script>
  752. <style lang="scss" scoped>
  753. .incomeExpenditureClass{
  754. display: flex;
  755. justify-content: space-evenly;
  756. width: 100%;
  757. padding:32rpx 0;
  758. .income1:last-child{
  759. .income11,.income12{
  760. border-right: 1px solid #c5c3c3;
  761. }
  762. }
  763. .income1{
  764. .income121{
  765. font-size: 24rpx;
  766. color:#c5c3c3;
  767. }
  768. width: 33.33%;
  769. text-align: center;
  770. .income11{
  771. padding:12rpx 0;
  772. background-color: #1677FF ;
  773. color:#fff;
  774. // font-size: 36rpx;
  775. font-size: 32rpx;
  776. border-top: 1px solid #c5c3c3;
  777. border-left: 1px solid #c5c3c3;
  778. }
  779. .income12{
  780. padding:12rpx 0;
  781. border-top: 1px solid #c5c3c3;
  782. border-bottom: 1px solid #c5c3c3;
  783. border-left: 1px solid #c5c3c3;
  784. font-size: 40rpx;
  785. }
  786. }
  787. }
  788. .back {
  789. z-index: 999;
  790. width: 200rpx;
  791. }
  792. /deep/.u-drawer-content {
  793. margin-top: 88rpx;
  794. }
  795. // /deep/.u-tab-item {
  796. // width: 25% !important;
  797. // flex: none !important;
  798. // }
  799. .tabs-box {
  800. background-color: #fff;
  801. display: flex;
  802. align-items: center;
  803. padding-right: 32rpx;
  804. justify-content: space-between;
  805. border-bottom: 1px solid rgba(232, 232, 232, 1);
  806. .tabs {
  807. width: 97%;
  808. }
  809. .more{
  810. padding-right: 12rpx;
  811. }
  812. .icon {
  813. margin-left: auto;
  814. margin-right: 24rpx;
  815. }
  816. }
  817. .tabs-len-1{
  818. }
  819. .tabs-len-2{
  820. /deep/.u-tab-item {
  821. // max-width: 39% !important;
  822. // flex: none !important;
  823. }
  824. }
  825. .tabs-len-3{
  826. /deep/.u-tab-item {
  827. max-width: 39% !important;
  828. flex: none !important;
  829. }
  830. }
  831. .tabs-len-4{
  832. /deep/.u-tab-item {
  833. max-width: 26% !important;
  834. flex: none !important;
  835. }
  836. }
  837. /deep/.u-tab-item:first-child {
  838. width: 20% !important;
  839. flex: none !important;
  840. }
  841. .popup-tabs {
  842. background-color: #fff;
  843. display: flex;
  844. align-items: center;
  845. justify-content: space-between;
  846. padding-right: 32rpx;
  847. color: rgba(51, 51, 51, 1);
  848. font-size: 32rpx;
  849. padding-top: 32rpx;
  850. .tabs {
  851. width: 88%;
  852. }
  853. }
  854. .tabs-options {
  855. display: flex;
  856. padding: 64rpx 32rpx 0;
  857. flex-wrap: wrap;
  858. .item {
  859. width: 25%;
  860. margin-bottom: 40rpx;
  861. }
  862. }
  863. // 用电量合计
  864. .total {
  865. padding: 24rpx 32rpx;
  866. background: linear-gradient(90deg, rgba(49, 110, 207, 1) 2%, rgba(37, 138, 255, 1) 100%);
  867. .company {
  868. display: flex;
  869. align-items: center;
  870. justify-content: space-between;
  871. .name {
  872. color: rgba(255, 255, 255, 1);
  873. font-size: 36rpx;
  874. font-weight: bold;
  875. }
  876. .amount {
  877. color: #f2f4f6;
  878. margin-top: 4rpx;
  879. }
  880. }
  881. .infos {
  882. display: flex;
  883. justify-content: space-between;
  884. align-items: center;
  885. margin-top: 4rpx;
  886. width: 93%;
  887. .infos-item {
  888. display: flex;
  889. width: 33.3%;
  890. .number {
  891. color: rgba(255, 255, 255, 1);
  892. font-size: 32rpx;
  893. font-weight: bold;
  894. margin-left: 8rpx;
  895. }
  896. .time {
  897. color: #f2f4f6;
  898. }
  899. }
  900. }
  901. }
  902. // 用电量
  903. .main {
  904. background-color: #fff;
  905. padding: 26rpx 32rpx;
  906. .item:last-of-type {
  907. border: none;
  908. }
  909. .item {
  910. padding: 16rpx 0;
  911. display: flex;
  912. align-items: center;
  913. justify-content: space-between;
  914. border-bottom: 1px solid rgba(245, 245, 245, 1);
  915. .item-content {
  916. width: 93%;
  917. }
  918. .equipment {
  919. display: flex;
  920. align-items: center;
  921. .equipment1 {
  922. color: rgba(51, 51, 51, 1);
  923. font-size: 32rpx;
  924. max-width: 40%;
  925. font-weight: bold;
  926. white-space: nowrap;
  927. overflow: hidden;
  928. text-overflow: ellipsis;
  929. }
  930. .equipment2 {
  931. color: rgba(119, 119, 119, 1);
  932. margin-left: 16rpx;
  933. max-width: 40%;
  934. white-space: nowrap;
  935. overflow: hidden;
  936. text-overflow: ellipsis;
  937. }
  938. }
  939. // 状态
  940. .state {
  941. display: flex;
  942. align-items: center;
  943. color: rgba(255, 123, 0, 1);
  944. margin-left: auto;
  945. .dot {
  946. margin-right: 8rpx;
  947. width: 16rpx;
  948. height: 16rpx;
  949. background-color: rgba(255, 123, 0, 1);
  950. border-radius: 999px;
  951. margin-left: auto;
  952. }
  953. .off-line {
  954. background-color: rgba(255, 123, 0, 1);
  955. }
  956. .on-line {
  957. background-color: rgba(0, 185, 98, 1);
  958. }
  959. }
  960. .state2 {
  961. color: rgba(0, 185, 98, 1);
  962. }
  963. .electricity {
  964. display: flex;
  965. justify-content: space-between;
  966. align-items: center;
  967. margin-top: 8rpx;
  968. text-align: center;
  969. .electricity-item {
  970. display: flex;
  971. align-items: center;
  972. width: 33.3%;
  973. .number {
  974. color: rgba(51, 51, 51, 1);
  975. font-weight: bold;
  976. font-size: 32rpx;
  977. margin-left: 8rpx;
  978. }
  979. .date {
  980. color: rgba(119, 119, 119, 1);
  981. }
  982. }
  983. }
  984. }
  985. }
  986. .statistics-manage {
  987. border-radius: 8px;
  988. background-color: rgba(255, 255, 255, 1);
  989. box-shadow: 0px 1px 6px 0px rgba(0, 59, 142, 0.05);
  990. margin: 32rpx;
  991. padding: 40rpx 0;
  992. .title,
  993. .chart,
  994. .search,
  995. .meter-statistic {
  996. padding: 0 32rpx;
  997. }
  998. // 图表
  999. .chart {
  1000. /deep/.u-subsection {
  1001. padding: 2px;
  1002. }
  1003. /deep/.u-item {
  1004. padding: 0;
  1005. font-size: 24rpx
  1006. }
  1007. .chat-box {
  1008. //margin-top: 24rpx;
  1009. width: 100%;
  1010. //height: 480rpx;
  1011. img {
  1012. width: 100%;
  1013. height: 100%;
  1014. }
  1015. }
  1016. }
  1017. .search {
  1018. border-top: 1px solid rgba(242, 242, 242, 1);
  1019. border-bottom: 1px solid rgba(242, 242, 242, 1);
  1020. display: flex;
  1021. align-items: center;
  1022. justify-content: space-between;
  1023. padding: 40rpx 32rpx;
  1024. .switch {
  1025. display: flex;
  1026. align-items: center;
  1027. text {
  1028. margin-left: 8rpx;
  1029. color: rgba(51, 51, 51, 1);
  1030. }
  1031. }
  1032. .search-box {
  1033. border-radius: 50px;
  1034. background-color: rgba(242, 244, 246, 1);
  1035. color: rgba(136, 136, 136, 1);
  1036. height: 56rpx;
  1037. line-height: 56rpx;
  1038. padding-left: 16rpx;
  1039. padding-right: 8rpx;
  1040. flex: 1;
  1041. margin-left: 28rpx;
  1042. display: flex;
  1043. align-items: center;
  1044. justify-content: space-between;
  1045. uni-input {
  1046. height: 56rpx;
  1047. line-height: 56rpx !important;
  1048. font-size: 28rpx;
  1049. width: 75%;
  1050. }
  1051. .icon {
  1052. display: flex;
  1053. align-items: center;
  1054. justify-content: center;
  1055. width: 64rpx;
  1056. height: 40rpx;
  1057. border-radius: 50px;
  1058. background-color: rgba(22, 119, 255, 1);
  1059. }
  1060. }
  1061. }
  1062. }
  1063. .meter-statistic {
  1064. margin-top: 32rpx;
  1065. .meter-statistic-main{
  1066. display: flex;
  1067. align-items: center;
  1068. }
  1069. .sum {
  1070. .meter-name {
  1071. color: rgba(51, 51, 51, 1);
  1072. font-size: 32rpx;
  1073. margin-left: 8rpx;
  1074. font-weight: bold;
  1075. }
  1076. .icon {
  1077. margin-right: 8rpx;
  1078. img {
  1079. width: 40rpx;
  1080. height: 40rpx;
  1081. vertical-align: middle;
  1082. }
  1083. }
  1084. .meter-state {
  1085. margin-left: 8rpx;
  1086. width: 64rpx;
  1087. height: 36rpx;
  1088. line-height: 36rpx;
  1089. border-radius: 4px;
  1090. background-color: rgba(255, 255, 255, 1);
  1091. color: rgba(0, 185, 98, 1);
  1092. font-size: 22rpx;
  1093. text-align: center;
  1094. border: 1px solid rgba(0, 185, 98, 1);
  1095. }
  1096. .meter-state2 {
  1097. border: 1px solid rgba(255, 123, 0, 1);
  1098. color: rgba(255, 123, 0, 1);
  1099. }
  1100. .meter-number {
  1101. margin-left: auto;
  1102. color: rgba(51, 51, 51, 1);
  1103. font-size: 32rpx;
  1104. /deep/.u-icon--right {
  1105. margin-left: 8rpx;
  1106. }
  1107. }
  1108. }
  1109. .sum2 {
  1110. padding: 0 32rpx;
  1111. margin-top: 8rpx;
  1112. display: flex;
  1113. align-items: center;
  1114. justify-content: space-between;
  1115. .title {
  1116. color: rgba(119, 119, 119, 1);
  1117. }
  1118. .value {
  1119. color: rgba(119, 119, 119, 1);
  1120. }
  1121. }
  1122. .first-level-list{
  1123. width: 100%;
  1124. display: flex;
  1125. align-items: center;
  1126. }
  1127. // 一级表
  1128. .first-level {
  1129. padding-left: 32rpx;
  1130. margin-top: 20rpx;
  1131. .meter-name {
  1132. font-size: 28rpx
  1133. }
  1134. }
  1135. // 二级表
  1136. .second-level {
  1137. padding-left: 64rpx;
  1138. margin-top: 20rpx;
  1139. .meter-name {
  1140. font-size: 24rpx
  1141. }
  1142. }
  1143. .else-switch {
  1144. padding-left: 144rpx;
  1145. .meter-name {
  1146. font-size: 24rpx
  1147. }
  1148. .item {
  1149. margin-top: 24rpx;
  1150. }
  1151. }
  1152. }
  1153. </style>