electronicMonitoring.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533
  1. <template>
  2. <view>
  3. <view class="background">
  4. <!-- 日期选择器 -->
  5. <u-picker-select title="日期选择" v-model="tabsFrom.show2" :defaultTime="tabsFrom.show2Index" :endYear="endYear"
  6. mode="time" :params="params" :noselect="false" @confirm="selector2confirm" @cancel="selector2cancel"
  7. @reset="selector2reset">
  8. </u-picker-select>
  9. <view class="navbar-c">
  10. <view class="back" @click="backDataMonitoringList">
  11. <u-icon name="arrow-left" color="#fff" size="36"></u-icon>
  12. </view>
  13. <view class="title" @click="titleCk">
  14. {{tabsFrom.title}}
  15. <u-icon name="arrow-down" color="#fff" size="24"></u-icon>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 设备选择器 -->
  20. <u-select title="设备选择" v-model="tabsFrom.show1" mode="mutil-column-auto" :list="tabsFrom.selector1"
  21. @confirm="selector1confirm" cancel-text="重置" @cancel="selector1cancel">
  22. </u-select>
  23. <!-- 用电量 -->
  24. <view class="electricity-consumption">
  25. <!-- <view class="title">
  26. 用电量统计 (度)
  27. </view> -->
  28. <!-- <view class="degree">
  29. <view class="item">
  30. <view class="item-text">
  31. 百万
  32. </view>
  33. <view class="item-number" v-text="showTop[0]">
  34. 0
  35. </view>
  36. </view>
  37. <view class="item">
  38. <view class="item-text">
  39. 拾万
  40. </view>
  41. <view class="item-number" v-text="showTop[1]">
  42. 0
  43. </view>
  44. </view>
  45. <view class="item">
  46. <view class="item-text">
  47. </view>
  48. <view class="item-number" v-text="showTop[2]">
  49. 0
  50. </view>
  51. </view>
  52. <view class="item">
  53. <view class="item-text">
  54. </view>
  55. <view class="item-number" v-text="showTop[3]">
  56. 0
  57. </view>
  58. </view>
  59. <view class="item">
  60. <view class="item-text">
  61. </view>
  62. <view class="item-number" v-text="showTop[4]">
  63. 0
  64. </view>
  65. </view>
  66. <view class="item">
  67. <view class="item-text">
  68. </view>
  69. <view class="item-number" v-text="showTop[5]">
  70. 7
  71. </view>
  72. </view>
  73. <view class="item">
  74. <view class="item-text">
  75. 1
  76. </view>
  77. <view class="item-number" v-text="showTop[6]">
  78. 7
  79. </view>
  80. </view>
  81. <view class="item">
  82. <view class="item-text">
  83. 0.1
  84. </view>
  85. <view class="item-number decimal" v-text="showTop[7]">
  86. 7
  87. </view>
  88. </view>
  89. </view> -->
  90. <!-- 统计 -->
  91. <view class="statistics-content">
  92. <view class="statistics-item">
  93. <view class="item-title">
  94. 电量统计(度)
  95. </view>
  96. <view class="item-value">
  97. 18,287.23
  98. </view>
  99. </view>
  100. <view class="statistics-item">
  101. <view class="item-title">
  102. 电费统计(度)
  103. </view>
  104. <view class="item-value">
  105. 18,287.23
  106. </view>
  107. </view>
  108. </view>
  109. <view class="radio">
  110. <u-radio-group v-model="value" @change="radioGroupChange">
  111. <u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.id"
  112. :disabled="item.disabled">
  113. {{item.name}}
  114. </u-radio>
  115. </u-radio-group>
  116. </view>
  117. </view>
  118. <!-- 各时段用电量 -->
  119. <view class="electricity-chart">
  120. <view class="title">
  121. <view class="icon">
  122. </view>
  123. <view class="text">
  124. 各时段用电量 (度)
  125. </view>
  126. <view class="more" @click="tabsFrom.show2=true,params.day=true">
  127. {{queryDay}}<u-icon name="arrow-down"></u-icon>
  128. </view>
  129. </view>
  130. <view class="chart">
  131. <view id="barEcharts" style="min-height:440rpx;">
  132. </view>
  133. </view>
  134. <view style="text-align: center;background: white;">当日电量合计:{{sumQuantity}}度</view>
  135. </view>
  136. <!-- 异常波动 -->
  137. <view class="abnormal" v-if="abnormalRecordsList.length != 0">
  138. <view class="headline">
  139. <view class="title">
  140. <view class="icon">
  141. </view>
  142. <view class="text">
  143. 异常告警
  144. </view>
  145. </view>
  146. <view class="more" @click="gotoUrl('/pages/abnormal/abnormalAlarmRecord?id='+companyId)">
  147. 查看全部
  148. <u-icon name="arrow-right" size="24" color="#d4d4d4"></u-icon>
  149. </view>
  150. </view>
  151. <view class="details">
  152. <view class="item" v-for="(item, index) in abnormalRecordsList" :key="index"
  153. @click="gotoUrl('/pages/abnormal/abnormalAlarmDetails?id='+item.id)">
  154. <view class="name">
  155. {{item.configName}}
  156. </view>
  157. <view class="time">
  158. {{item.createTime}}
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <!-- 能源监测 -->
  164. <view class="energy-inspection">
  165. <view class="title">
  166. <view class="icon">
  167. </view>
  168. <view class="text">
  169. 能源监测
  170. </view>
  171. </view>
  172. <view class="grid">
  173. <u-grid :col="3" :border="false">
  174. <u-grid-item @click="gotoInfo('3PhaseCurrentDetails','A','三相电流')">
  175. <view class="icon icon1">
  176. <image class="img" src="@/assets/img/Image@1.png" mode=""></image>
  177. </view>
  178. <view class="grid-text">三相电流</view>
  179. </u-grid-item>
  180. <u-grid-item @click="gotoInfo('3PhaseCurrentDetails','V','三相电压')">
  181. <view class="icon icon2">
  182. <image class="img" src="@/assets/img/Image@2.png" mode=""></image>
  183. </view>
  184. <view class="grid-text">三相电压</view>
  185. </u-grid-item>
  186. <u-grid-item @click="gotoInfo('3PhaseCurrentDetails','T','三相温度')">
  187. <view class="icon icon3">
  188. <image class="img" src="@/assets/img/Image@3.png" mode=""></image>
  189. </view>
  190. <view class="grid-text">三相温度</view>
  191. </u-grid-item>
  192. <u-grid-item @click="gotoInfo('3PhaseCurrentDetails','P','三相有功功率')">
  193. <view class="icon icon4">
  194. <image class="img" src="@/assets/img/Image@4.png" mode=""></image>
  195. </view>
  196. <view class="grid-text">三相有功功率</view>
  197. </u-grid-item>
  198. <u-grid-item @click="gotoInfo('3PhaseCurrentDetails','F','三相功率因数')">
  199. <view class="icon icon5">
  200. <image class="img" src="@/assets/img/Image@5.png" mode=""></image>
  201. </view>
  202. <view class="grid-text">三相功率因数</view>
  203. </u-grid-item>
  204. <u-grid-item @click="gotoInfo('3PhaseCurrentDetails','AF','平均功率因数')">
  205. <view class="icon icon6">
  206. <image class="img" src="@/assets/img/Image@5.png" mode=""></image>
  207. </view>
  208. <view class="grid-text">平均功率因数</view>
  209. </u-grid-item>
  210. </u-grid>
  211. </view>
  212. </view>
  213. <!-- 数据分析 -->
  214. <view class="data-analysis">
  215. <view class="title">
  216. <view class="icon">
  217. </view>
  218. <view class="text">
  219. 数据分析
  220. </view>
  221. </view>
  222. <view class="grid">
  223. <u-grid :col="3" :border="false">
  224. <u-grid-item @click="gotoInfo('chartYoY','','')">
  225. <view class="icon icon7">
  226. <image class="img" src="@/assets/img/Image@7.png" mode=""></image>
  227. </view>
  228. <view class="grid-text">同比分析</view>
  229. </u-grid-item>
  230. <u-grid-item @click="gotoInfo('chartMoM','','')">
  231. <view class="icon icon8">
  232. <image class="img" src="@/assets/img/Image@8.png" mode=""></image>
  233. </view>
  234. <view class="grid-text">环比分析</view>
  235. </u-grid-item>
  236. <u-grid-item v-if="false">
  237. <view class="icon icon9">
  238. <image class="img" src="@/assets/img/Image@9.svg" mode=""></image>
  239. </view>
  240. <view class="grid-text">用电统计</view>
  241. </u-grid-item>
  242. </u-grid>
  243. </view>
  244. </view>
  245. <!-- 设备信息 -->
  246. <view class="equipment-information">
  247. <view class="title">
  248. <view class="icon">
  249. </view>
  250. <view class="text">
  251. 设备信息
  252. </view>
  253. <view class="more" @click="equipmentInfosShow=true">
  254. 查看全部<u-icon name="arrow-right" size="24" color="#d4d4d4"></u-icon>
  255. </view>
  256. </view>
  257. <view class="infos">
  258. <view class="item">
  259. <view class="item-title">
  260. 类型
  261. </view>
  262. <view class="item-value">
  263. 变压器
  264. </view>
  265. </view>
  266. <view class="border">
  267. </view>
  268. <view class="item">
  269. <view class="item-title">
  270. 设备编号
  271. </view>
  272. <view class="item-value">
  273. SN9015001
  274. </view>
  275. </view>
  276. <view class="border">
  277. </view>
  278. <view class="item">
  279. <view class="item-title">
  280. 上次故障时间
  281. </view>
  282. <view class="item-value">
  283. 2024-02-14
  284. </view>
  285. </view>
  286. </view>
  287. </view>
  288. <!-- 设备信息弹窗 -->
  289. <view class="equipment-popup">
  290. <u-popup v-model="equipmentInfosShow" mode="bottom" border-radius="12">
  291. <view class="content">
  292. <view class="headline">
  293. 设备信息
  294. </view>
  295. <view class="infos">
  296. <view class="item">
  297. <view class="item-title">
  298. 类型
  299. </view>
  300. <view class="item-value">
  301. 变压器
  302. </view>
  303. </view>
  304. <view class="item">
  305. <view class="item-title">
  306. 编号
  307. </view>
  308. <view class="item-value">
  309. SN9015001
  310. </view>
  311. </view>
  312. <view class="item">
  313. <view class="item-title">
  314. 所属公司
  315. </view>
  316. <view class="item-value">
  317. 荆鹏集团
  318. </view>
  319. </view>
  320. <view class="item">
  321. <view class="item-title">
  322. 地址
  323. </view>
  324. <view class="item-value">
  325. 荆州市沙市区江津东路155号
  326. </view>
  327. </view>
  328. <view class="item">
  329. <view class="item-title">
  330. 上线时间
  331. </view>
  332. <view class="item-value">
  333. 2024-01-01
  334. </view>
  335. </view>
  336. <view class="item">
  337. <view class="item-title">
  338. 上次故障时间
  339. </view>
  340. <view class="item-value">
  341. 2024-02-14
  342. </view>
  343. </view>
  344. </view>
  345. <button class="get" @click="equipmentInfosShow=false">知道了</button>
  346. </view>
  347. </u-popup>
  348. </view>
  349. <!-- 故障上报 -->
  350. <view class="create-order">
  351. <view class="img-box">
  352. <image class="img" src="@/assets/img/fas fa-exclamation-triangle Copy 2@3x.png" mode=""></image>
  353. </view>
  354. <view class="text">
  355. 故障上报
  356. </view>
  357. </view>
  358. </view>
  359. </template>
  360. <script>
  361. import {
  362. parseUnixTime,
  363. beforeTimeStamp,
  364. getWeek
  365. } from '@/apis/utils'
  366. import * as echarts from 'echarts';
  367. import * as API from '@/apis/pagejs/index.js'
  368. export default {
  369. data() {
  370. return {
  371. abnormalRecordsList: [], //异常list
  372. companyId: '', //企业id
  373. meterId: '', //设备id
  374. titleName: '',
  375. clickType: 0,
  376. sumQuantity: 0,
  377. equipmentInfosShow: false,
  378. kWhList: [],
  379. queryDay: '',
  380. showTop: [0, 0, 0, 0, 0, 0, 0, 0],
  381. FormData: {
  382. queryDate: '',
  383. meterId: '',
  384. type: 0
  385. },
  386. FormData2: {
  387. queryDate: '',
  388. meterId: ''
  389. },
  390. myChart: null,
  391. endYear: '',
  392. equipmentShow: false,
  393. multiSelector: [],
  394. equipmentList: [],
  395. params: {
  396. year: true,
  397. month: true,
  398. day: true,
  399. hour: false,
  400. minute: false,
  401. second: false
  402. },
  403. tabsFrom: {
  404. show1: false,
  405. show1Index: 0,
  406. show2Index: '',
  407. show2: false,
  408. show1Text: "全部类型",
  409. show2Text: "全部时间",
  410. selector1: [{
  411. label: '全部类型',
  412. value: '',
  413. },
  414. {
  415. label: '线上充值',
  416. value: '1',
  417. },
  418. {
  419. label: '线下充值',
  420. value: '2',
  421. },
  422. ]
  423. },
  424. background: {
  425. backgroundColor: '#1677FF',
  426. },
  427. list: [{
  428. id: 4,
  429. name: '当月',
  430. disabled: false
  431. }, {
  432. id: 1,
  433. name: '当日',
  434. disabled: false
  435. }, {
  436. id: 2,
  437. name: '上月',
  438. disabled: false
  439. }, {
  440. id: 3,
  441. name: '当年',
  442. disabled: false
  443. }, {
  444. id: 0,
  445. name: '合计',
  446. disabled: false
  447. }, {
  448. id: 10,
  449. name: '指定月份',
  450. disabled: false
  451. }],
  452. value: '2',
  453. intervalId: null, // 用于存储间隔ID
  454. intervalReady: true, // 用于存储间隔ID
  455. };
  456. },
  457. onLoad(op) {
  458. if (op.id) {
  459. this.FormData.meterId = op.id;
  460. this.FormData2.meterId = op.id;
  461. this.tabsFrom.title = op.name;
  462. this.meterId = op.id;
  463. this.titleName = op.name;
  464. this.companyId = op.companyId;
  465. }
  466. this.endYear = new Date().getFullYear();
  467. this.FormData.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  468. this.FormData2.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  469. this.FormData.type = 2;
  470. this.getElectricityStatistics();
  471. this.getTimeSlotStatistics();
  472. this.getCompanyInfoList();
  473. this.getAbnormalAlarmRecord();
  474. },
  475. beforeDestroy() {
  476. this.clearTimer(); // 组件销毁前清除定时器
  477. this.intervalReady = false;
  478. console.log("组件销毁前清除定时器")
  479. },
  480. methods: {
  481. clearTimer() {
  482. if (this.intervalId) {
  483. clearInterval(this.intervalId); // 清除定时器
  484. this.intervalId = null; // 重置定时器ID
  485. }
  486. },
  487. startInterval() {
  488. this.clearTimer(); // 组件销毁前清除定时器
  489. this.intervalId = setInterval(() => {
  490. // 每隔5秒运行的代码
  491. // console.log('这段代码每隔5秒运行一次');
  492. this.getElectricityStatistics(true)
  493. this.getTimeSlotStatistics(true)
  494. }, 60000);
  495. },
  496. gotoInfo(path, type, name) {
  497. if (!this.FormData.meterId) {
  498. uni.showToast({
  499. title: "未查询到电表",
  500. icon: "none"
  501. })
  502. return
  503. }
  504. uni.navigateTo({
  505. url: "/pages/equipmentDataMonitoring/" + path + "?id=" + this.FormData.meterId + "&type=" + type +
  506. "&typeName=" + name
  507. })
  508. },
  509. // 异常告警记录
  510. getAbnormalAlarmRecord() {
  511. var queryDate = parseUnixTime(new Date(), '{y}-{m}');
  512. uni.showLoading({
  513. title: "加载中",
  514. mask: true,
  515. })
  516. API.alarmRecord({
  517. queryDate: queryDate,
  518. configId: '',
  519. pageIndex: 1,
  520. pageSize: 2,
  521. companyId: this.companyId,
  522. meterId: this.meterId
  523. }).then((res) => {
  524. uni.hideLoading();
  525. this.abnormalRecordsList = res.data.data;
  526. }).catch(error => {
  527. uni.showToast({
  528. title: error,
  529. icon: "none"
  530. })
  531. })
  532. },
  533. titleCk() {
  534. if (this.tabsFrom.selector1.length > 1) {
  535. this.tabsFrom.show1 = true
  536. }
  537. },
  538. selector1confirm(e) {
  539. console.log(e)
  540. // var index = e[2];
  541. // this.tabsFrom.show1Index = index;
  542. if (e[2].value != null) {
  543. this.tabsFrom.show1Text = e[2].label;
  544. this.tabsFrom.title = e[2].label;
  545. this.FormData.meterId = e[2].value;
  546. this.FormData.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  547. this.FormData2.meterId = e[2].value;
  548. this.FormData2.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  549. //this.meterId =e[2].value;
  550. this.FormData.type = 2;
  551. this.value = '2';
  552. this.getTimeSlotStatistics();
  553. this.getElectricityStatistics();
  554. }
  555. },
  556. selector1cancel() {
  557. this.tabsFrom.show1Text = this.titleName;
  558. this.tabsFrom.title = this.titleName;
  559. this.FormData.meterId = this.meterId;
  560. this.FormData.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  561. this.FormData2.meterId = this.meterId;
  562. this.FormData2.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  563. this.FormData.type = 2;
  564. this.value = '2';
  565. this.getTimeSlotStatistics();
  566. this.getElectricityStatistics();
  567. },
  568. queryDate(queryTime, day) {
  569. if (day) {
  570. this.FormData2.queryDate = queryTime;
  571. //this.FormData2.type =day?"9":"10"
  572. //this.value="-1"
  573. this.getTimeSlotStatistics();
  574. } else {
  575. this.FormData.queryDate = queryTime + "-01";
  576. this.FormData.type = 10;
  577. this.value = "10";
  578. this.list[5].name = queryTime;
  579. this.getElectricityStatistics();
  580. }
  581. },
  582. getCompanyInfoList() {
  583. uni.showLoading({
  584. title: "加载中",
  585. mask: true,
  586. })
  587. API.deviceCompanyList().then((response) => {
  588. uni.hideLoading();
  589. var list = response.data.companyInfoList;
  590. this.tabsFrom.selector1 = [];
  591. this.tabsFrom.selector1 = list.map(item => {
  592. if (item.remoteReadingMeterList.length != 0 && item.remoteMonitorMeterList.length != 0) {
  593. return {
  594. label: item.fullName,
  595. value: item.id,
  596. children: [{
  597. label: '抄表',
  598. value: '1',
  599. children: item.remoteReadingMeterList.map(item => {
  600. return {
  601. label: item.name,
  602. value: item.id,
  603. }
  604. })
  605. },
  606. {
  607. label: '监控表',
  608. value: '1',
  609. children: item.remoteMonitorMeterList.map(item => {
  610. return {
  611. label: item.name,
  612. value: item.id,
  613. }
  614. })
  615. }
  616. ]
  617. }
  618. } else if (item.remoteReadingMeterList.length != 0 && item.remoteMonitorMeterList.length == 0) {
  619. return {
  620. label: item.fullName,
  621. value: item.id,
  622. children: [{
  623. label: '抄表',
  624. value: '1',
  625. children: item.remoteReadingMeterList.map(item => {
  626. return {
  627. label: item.name,
  628. value: item.id,
  629. }
  630. })
  631. }]
  632. }
  633. } else if (item.remoteReadingMeterList.length == 0 && item.remoteMonitorMeterList.length != 0) {
  634. return {
  635. label: item.fullName,
  636. value: item.id,
  637. children: [{
  638. label: '监控表',
  639. value: '1',
  640. children: item.remoteMonitorMeterList.map(item => {
  641. return {
  642. label: item.name,
  643. value: item.id,
  644. }
  645. })
  646. }]
  647. }
  648. } else {
  649. }
  650. })
  651. }).catch(error => {
  652. uni.showToast({
  653. title: error,
  654. icon: "none"
  655. })
  656. })
  657. },
  658. getTimeSlotStatistics(interval) {
  659. if (!interval) {
  660. uni.showLoading({
  661. title: "加载中",
  662. mask: true,
  663. })
  664. }
  665. this.queryDay = parseUnixTime(new Date(this.FormData2.queryDate), '{y}年{m}月{d}日');
  666. API.timeSlotStatistics(this.FormData2).then((response) => {
  667. if (!interval) {
  668. uni.hideLoading();
  669. }
  670. this.hourMap = response.data.hourMap;
  671. this.sumQuantity = response.data.allKwh;
  672. this.getBarCharts(this.hourMap, interval);
  673. if (!interval) {
  674. this.startInterval(); // 组件挂载后开始间隔
  675. }
  676. }).catch(error => {
  677. uni.showToast({
  678. title: error,
  679. icon: "none"
  680. })
  681. })
  682. },
  683. getElectricityStatistics(interval) {
  684. if (!interval) {
  685. uni.showLoading({
  686. title: "加载中",
  687. mask: true,
  688. })
  689. }
  690. var obj = {
  691. ...this.FormData
  692. }
  693. // if(obj.type==10){
  694. // obj.queryDate+="-01"
  695. // }
  696. API.electricityStatistics(obj).then((response) => {
  697. if (!interval) {
  698. uni.hideLoading();
  699. }
  700. this.showTop = [0, 0, 0, 0, 0, 0, 0, 0]
  701. var electricity = response.data.kwhMap.kwh + "";
  702. if (electricity) {
  703. var sz = electricity.split(".")
  704. var str1 = sz[0];
  705. var str2 = [];
  706. if (sz.length > 1) {
  707. str2 = sz[1];
  708. this.showTop[7] = str2[0];
  709. }
  710. var j = 0;
  711. for (var i in str1) {
  712. if (i != undefined) {
  713. this.showTop[6 - str1.length + j + 1] = str1[i]
  714. }
  715. j++;
  716. }
  717. this.$forceUpdate()
  718. }
  719. if (!interval) {
  720. this.startInterval(); // 组件挂载后开始间隔
  721. }
  722. }).catch(error => {
  723. uni.showToast({
  724. title: error,
  725. icon: "none"
  726. })
  727. })
  728. },
  729. getBarCharts(list, interval) {
  730. if (!this.myChart) {
  731. this.myChart = echarts.init(document.getElementById('barEcharts'), null, {
  732. width: uni.upx2px(700),
  733. height: uni.upx2px(480)
  734. });
  735. }
  736. if (!interval) {
  737. this.myChart.clear();
  738. }
  739. var data1 = [];
  740. var data2 = [];
  741. // var sumQuantity=0
  742. for (var i in list) {
  743. data1.push(i)
  744. data2.push(list[i].kwh)
  745. // sumQuantity+=list[i]
  746. }
  747. var axisLabel = {
  748. rotate: 40,
  749. interval: 0,
  750. textStyle: {
  751. color: "#333"
  752. }
  753. }
  754. if (data1.length < 4) {
  755. axisLabel = {
  756. interval: 0,
  757. textStyle: {
  758. color: "#333"
  759. },
  760. }
  761. }
  762. // this.sumQuantity = sumQuantity.toFixed(2);
  763. var headitemby = "";
  764. var showkey = "";
  765. var option = {
  766. tooltip: {
  767. trigger: 'axis',
  768. axisPointer: {
  769. type: 'shadow'
  770. },
  771. formatter: (value) => {
  772. var name = value[0].name;
  773. var obj=list[name]
  774. var text= `<p>${name}</p>`
  775. if (obj.electricityPrice != undefined) {
  776. text += `<p>电价:${obj.electricityPrice}元/度</p>`
  777. }
  778. if (obj.kwh != undefined) {
  779. text += `用电量:${obj.kwh}度`
  780. }
  781. if (obj.amount != undefined) {
  782. text += ` <p>电费:${obj.amount}元</p>`
  783. }
  784. return text
  785. }
  786. },
  787. grid: {
  788. top: '10%',
  789. left: '3%',
  790. right: '8%',
  791. bottom: '8%',
  792. containLabel: true
  793. },
  794. xAxis: {
  795. type: 'category',
  796. data: data1,
  797. axisLabel: axisLabel,
  798. },
  799. yAxis: {
  800. type: 'value',
  801. },
  802. series: [{
  803. name: '合计',
  804. data: data2,
  805. type: 'bar',
  806. label: {
  807. show: true,
  808. position: 'top',
  809. color: '#5C7BD9'
  810. }
  811. }]
  812. }
  813. console.log(option)
  814. this.myChart.setOption(option);
  815. },
  816. selector2confirm(e) {
  817. this.tabsFrom.show2Text = e.year + "年" + e.month + "月"
  818. this.tabsFrom.show2Index = e.year + "-" + e.month
  819. if (e.day) {
  820. this.tabsFrom.show2Text += e.day + "日"
  821. this.tabsFrom.show2Index += '-' + e.day
  822. this.queryDate(this.tabsFrom.show2Index, true)
  823. } else {
  824. this.queryDate(this.tabsFrom.show2Index, false)
  825. }
  826. },
  827. selector2cancel() {
  828. this.value = this.clickType;
  829. },
  830. selector2reset(e) {
  831. console.log(e)
  832. this.tabsFrom.show2Text = '全部时间'
  833. this.tabsFrom.show2Index = '';
  834. if (e.day) {
  835. this.FormData2.queryDate = parseUnixTime(new Date(), '{y}-{m}-{d}');
  836. this.queryDay = parseUnixTime(new Date(this.FormData2.queryDate), '{y}年{m}月{d}日');
  837. this.getTimeSlotStatistics();
  838. } else {
  839. this.FormData.type = this.clickType;
  840. this.value = this.clickType;
  841. if (this.value != 10) {
  842. this.list[5].name = '指定月份';
  843. }
  844. this.getElectricityStatistics();
  845. }
  846. },
  847. // 选中某个单选框时,由radio时触发
  848. radioChange(e) {
  849. console.log(`选择前的值: ${this.value}`);
  850. this.clickType = this.value;
  851. },
  852. // 选中任一radio时,由radio-group触发
  853. radioGroupChange(e) {
  854. console.log(e)
  855. this.FormData.type = e;
  856. if (e == 10) {
  857. this.tabsFrom.show2 = true;
  858. this.params.day = false;
  859. } else {
  860. this.list[5].name = '指定月份'
  861. this.getElectricityStatistics();
  862. }
  863. },
  864. backDataMonitoringList() {
  865. uni.navigateBack()
  866. },
  867. }
  868. };
  869. </script>
  870. <style lang="scss" scoped>
  871. page {
  872. padding-bottom: 184rpx;
  873. }
  874. /deep/.u-select__header__title {
  875. font-size: 36rpx;
  876. font-weight: bold;
  877. }
  878. .navbar-c {
  879. background-color: rgba(22, 119, 255, 1);
  880. position: fixed;
  881. top: 0;
  882. left: 0;
  883. right: 0;
  884. z-index: 999;
  885. .back {
  886. z-index: 999;
  887. width: 200rpx;
  888. }
  889. .title {
  890. color: #fff;
  891. display: flex;
  892. align-items: center;
  893. justify-content: center;
  894. }
  895. .right {
  896. .img {
  897. width: 48rpx;
  898. height: 48rpx;
  899. }
  900. }
  901. }
  902. /deep/.uicon-nav-back {
  903. color: #fff !important;
  904. }
  905. .background {
  906. background-color: rgba(22, 119, 255, 1);
  907. padding-top: 88rpx;
  908. padding-bottom: 100rpx;
  909. /deep/.u-border-bottom:after {
  910. border: none;
  911. }
  912. .u-nav-slot {
  913. margin-right: 32rpx;
  914. .img {
  915. width: 48rpx;
  916. height: 48rpx;
  917. vertical-align: middle;
  918. }
  919. }
  920. }
  921. .background::after {
  922. content: '';
  923. position: absolute;
  924. width: 160%;
  925. height: 80px;
  926. background-color: rgba(22, 119, 255, 1);
  927. left: -30%;
  928. border-radius: 0 0 50% 50%;
  929. }
  930. // // 日期
  931. .date-box {
  932. display: flex;
  933. align-items: center;
  934. justify-content: space-between;
  935. margin: 24rpx 32rpx;
  936. .item {
  937. border-radius: 8px;
  938. background-color: rgba(255, 255, 255, 0.1);
  939. border: 1px solid rgba(255, 255, 255, 0.15);
  940. width: 120rpx;
  941. height: 120rpx;
  942. color: #fff;
  943. text-align: center;
  944. display: flex;
  945. flex-direction: column;
  946. justify-content: center;
  947. .date {
  948. font-size: 40rpx;
  949. }
  950. }
  951. .item-today {
  952. background-color: rgba(255, 255, 255, 1);
  953. position: relative;
  954. .date {
  955. color: rgba(22, 119, 255, 1);
  956. }
  957. .week {
  958. color: rgba(16, 16, 16, 1);
  959. }
  960. .dot {
  961. width: 10rpx;
  962. height: 10rpx;
  963. background-color: rgba(255, 150, 0, 1);
  964. border-radius: 999px;
  965. position: absolute;
  966. bottom: -5rpx;
  967. left: 50%;
  968. transform: translateX(-50%);
  969. }
  970. }
  971. }
  972. // 用电量
  973. .electricity-consumption {
  974. background-color: #fff;
  975. padding: 40rpx 32rpx 0rpx;
  976. border-radius: 8px;
  977. margin: -88rpx 32rpx 0;
  978. position: relative;
  979. // 统计
  980. .statistics-content{
  981. display: flex;
  982. align-items: center;
  983. justify-content: space-between;
  984. .statistics-item{
  985. width: 300rpx;
  986. padding: 24rpx;
  987. border-radius: 8px;
  988. background: linear-gradient(180deg, rgba(207,227,255,1) 0%,rgba(255,255,255,0) 100%);
  989. box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.1);
  990. }
  991. .item-title{
  992. color: #333333;
  993. }
  994. .item-value{
  995. color: rgba(16,16,16,1);
  996. font-size: 48rpx;
  997. font-weight: bold;
  998. margin-top: 8rpx;
  999. overflow: hidden;
  1000. white-space: nowrap;
  1001. text-overflow: ellipsis;
  1002. }
  1003. }
  1004. .title {
  1005. color: rgba(16, 16, 16, 1);
  1006. font-size: 36rpx;
  1007. }
  1008. .degree {
  1009. display: flex;
  1010. margin-top: 32rpx;
  1011. .item {
  1012. margin-right: 6rpx;
  1013. text-align: center;
  1014. .item-text {
  1015. color: rgba(16, 16, 16, 1);
  1016. }
  1017. .item-number {
  1018. margin-top: 24rpx;
  1019. width: 72rpx;
  1020. height: 96rpx;
  1021. background-color: rgba(16, 16, 16, 1);
  1022. color: #fff;
  1023. font-size: 72rpx;
  1024. }
  1025. .decimal {
  1026. background-color: #900005;
  1027. }
  1028. }
  1029. }
  1030. // .tab {
  1031. // width: 240rpx;
  1032. // height: 0;
  1033. // border-width: 0px 48rpx 72rpx 0px;
  1034. // border-radius: 8px 8px 0 0;
  1035. // border-style: none solid solid none;
  1036. // border-color: transparent transparent #fff;
  1037. // position: absolute;
  1038. // top: -72rpx;
  1039. // left: 0rpx;
  1040. // right: 0rpx;
  1041. // color: #101010;
  1042. // color: rgba(16, 16, 16, 1);
  1043. // text-align: center;
  1044. // line-height: 72rpx;
  1045. // z-index: 999;
  1046. // text-indent: 16rpx;
  1047. // }
  1048. // .tab2 {
  1049. // width: 240rpx;
  1050. // height: 0;
  1051. // border-width: 0px 48rpx 72rpx 0px;
  1052. // border-radius: 8px 8px 0 0;
  1053. // border-style: none solid solid none;
  1054. // border-color: transparent transparent #D4DBE4;
  1055. // position: absolute;
  1056. // top: -72rpx;
  1057. // left: 210rpx;
  1058. // right: 0rpx;
  1059. // color: #777777;
  1060. // text-align: center;
  1061. // line-height: 72rpx;
  1062. // text-indent: 16rpx;
  1063. // }
  1064. .radio {
  1065. margin-top: 24rpx;
  1066. /deep/.u-radio__label {
  1067. font-size: 24rpx
  1068. }
  1069. /deep/.u-radio {
  1070. margin-bottom: 16px;
  1071. // width: 160rpx !important;
  1072. margin-right: 24rpx;
  1073. }
  1074. }
  1075. }
  1076. //各时段用电量
  1077. .electricity-chart {
  1078. margin: 24rpx 32rpx;
  1079. padding: 40rpx 0rpx;
  1080. background-color: #fff;
  1081. border-radius: 8px;
  1082. .title {
  1083. display: flex;
  1084. align-items: center;
  1085. // justify-content: space-between;
  1086. padding: 0 12rpx;
  1087. margin-bottom: 40rpx;
  1088. .icon {
  1089. width: 36rpx;
  1090. height: 36rpx;
  1091. background-color: rgba(182, 212, 255, 1);
  1092. border: 6px solid rgba(22, 119, 255, 1);
  1093. border-radius: 100px;
  1094. }
  1095. .text {
  1096. color: rgba(51, 51, 51, 1);
  1097. font-size: 36rpx;
  1098. margin-left: 16rpx;
  1099. }
  1100. .more {
  1101. margin-left: auto;
  1102. }
  1103. }
  1104. .chart {
  1105. width: 100%;
  1106. height: 500rpx;
  1107. .img {
  1108. width: 100%;
  1109. height: 440rpx;
  1110. }
  1111. }
  1112. }
  1113. .equipment-information {
  1114. margin: 24rpx 32rpx;
  1115. padding: 40rpx 0rpx;
  1116. background-color: #fff;
  1117. border-radius: 8px;
  1118. .title {
  1119. display: flex;
  1120. align-items: center;
  1121. padding: 0 32rpx;
  1122. margin-bottom: 40rpx;
  1123. .icon {
  1124. width: 36rpx;
  1125. height: 36rpx;
  1126. background-color: rgba(182, 212, 255, 1);
  1127. border: 6px solid rgba(22, 119, 255, 1);
  1128. border-radius: 100px;
  1129. }
  1130. .text {
  1131. display: flex;
  1132. align-items: center;
  1133. color: rgba(51, 51, 51, 1);
  1134. font-size: 36rpx;
  1135. margin-left: 16rpx;
  1136. }
  1137. .date {
  1138. margin-left: auto;
  1139. }
  1140. .more {
  1141. color: #838383;
  1142. font-size: 24rpx;
  1143. margin-left: auto;
  1144. }
  1145. }
  1146. .chart {
  1147. width: 100%;
  1148. height: 440rpx;
  1149. .img {
  1150. width: 100%;
  1151. height: 440rpx;
  1152. }
  1153. }
  1154. .infos {
  1155. padding: 0 32rpx;
  1156. display: flex;
  1157. justify-content: space-between;
  1158. text-align: center;
  1159. .border {
  1160. margin: auto 0;
  1161. height: 70rpx;
  1162. width: 2rpx;
  1163. background-color: rgba(204, 204, 204, 1);
  1164. ;
  1165. }
  1166. .item-title {
  1167. color: rgba(119, 119, 119, 1);
  1168. }
  1169. .item-value {
  1170. color: rgba(16, 16, 16, 1);
  1171. font-size: 32rpx;
  1172. margin-top: 16rpx;
  1173. }
  1174. }
  1175. }
  1176. // 异常
  1177. .abnormal {
  1178. margin: 24rpx 32rpx;
  1179. padding: 40rpx 32rpx;
  1180. background-color: #fff;
  1181. border-radius: 8px;
  1182. .headline {
  1183. display: flex;
  1184. align-items: center;
  1185. justify-content: space-between;
  1186. }
  1187. .title {
  1188. display: flex;
  1189. align-items: center;
  1190. font-weight: bold;
  1191. .icon {
  1192. width: 36rpx;
  1193. height: 36rpx;
  1194. background-color: rgba(182, 212, 255, 1);
  1195. border: 6px solid rgba(22, 119, 255, 1);
  1196. border-radius: 100px;
  1197. }
  1198. .text {
  1199. color: rgba(51, 51, 51, 1);
  1200. font-size: 36rpx;
  1201. margin-left: 16rpx;
  1202. }
  1203. }
  1204. .more {
  1205. color: #838383;
  1206. font-size: 24rpx
  1207. }
  1208. .details {
  1209. margin-top: 40rpx;
  1210. .item {
  1211. display: flex;
  1212. align-items: center;
  1213. justify-content: space-between;
  1214. margin-top: 32rpx;
  1215. .name {
  1216. color: rgba(51, 51, 51, 1);
  1217. }
  1218. .time {
  1219. color: rgba(119, 119, 119, 1);
  1220. font-size: 24rpx;
  1221. }
  1222. }
  1223. }
  1224. }
  1225. // 能源监测
  1226. .energy-inspection,
  1227. .data-analysis {
  1228. margin: 24rpx 32rpx;
  1229. padding: 40rpx 32rpx;
  1230. background-color: #fff;
  1231. border-radius: 8px;
  1232. .title {
  1233. display: flex;
  1234. align-items: center;
  1235. font-weight: bold;
  1236. .icon {
  1237. width: 36rpx;
  1238. height: 36rpx;
  1239. background-color: rgba(182, 212, 255, 1);
  1240. border: 6px solid rgba(22, 119, 255, 1);
  1241. border-radius: 100px;
  1242. }
  1243. .text {
  1244. color: rgba(51, 51, 51, 1);
  1245. font-size: 36rpx;
  1246. margin-left: 16rpx;
  1247. }
  1248. }
  1249. .grid {
  1250. .icon {
  1251. width: 128rpx;
  1252. height: 128rpx;
  1253. border-radius: 12px;
  1254. background-color: rgba(35, 186, 178, 1);
  1255. display: flex;
  1256. align-items: center;
  1257. justify-content: center;
  1258. margin-bottom: 16rpx;
  1259. .img {
  1260. width: 80rpx;
  1261. height: 80rpx;
  1262. }
  1263. }
  1264. .icon2 {
  1265. background-color: rgba(42, 186, 72, 1);
  1266. }
  1267. .icon3 {
  1268. background-color: rgba(78, 96, 246, 1);
  1269. }
  1270. .icon4 {
  1271. background-color: rgba(22, 119, 255, 1);
  1272. }
  1273. .icon5 {
  1274. background-color: rgba(35, 186, 178, 1);
  1275. }
  1276. .icon6 {
  1277. background-color: rgba(42, 186, 72, 1);
  1278. }
  1279. .icon7 {
  1280. background-color: rgba(22, 119, 255, 1);
  1281. }
  1282. .icon8 {
  1283. background-color: rgba(35, 186, 178, 1);
  1284. }
  1285. .icon9 {
  1286. background-color: rgba(42, 186, 72, 1);
  1287. }
  1288. .grid-text {
  1289. color: #333333;
  1290. }
  1291. }
  1292. }
  1293. // 设备信息弹窗
  1294. .equipment-popup {
  1295. .content {
  1296. padding: 32rpx;
  1297. .headline {
  1298. color: rgba(16, 16, 16, 1);
  1299. font-size: 36rpx;
  1300. text-align: center;
  1301. font-weight: bold;
  1302. }
  1303. .infos {
  1304. padding-bottom: 100rpx;
  1305. .item:last-of-type {
  1306. border: none;
  1307. }
  1308. .item {
  1309. display: flex;
  1310. align-items: center;
  1311. height: 80rpx;
  1312. line-height: 80rpx;
  1313. border-bottom: 1px solid #cccccc;
  1314. .item-title {
  1315. color: rgba(51, 51, 51, 1);
  1316. width: 200rpx;
  1317. }
  1318. .item-value {
  1319. color: #666666;
  1320. flex: 1;
  1321. margin-left: 16rpx;
  1322. }
  1323. }
  1324. }
  1325. .get {
  1326. height: 80rpx;
  1327. line-height: 80rpx;
  1328. border-radius: 4px;
  1329. background-color: rgba(22, 119, 255, 1);
  1330. color: rgba(255, 255, 255, 1);
  1331. font-size: 32rpx;
  1332. }
  1333. }
  1334. }
  1335. // 创建工单
  1336. .create-order {
  1337. width: 120rpx;
  1338. height: 120rpx;
  1339. border-radius: 20px;
  1340. background: linear-gradient(180.29deg, rgba(255, 124, 112, 1) 0.9%, rgba(255, 79, 63, 1) 100.4%);
  1341. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
  1342. text-align: center;
  1343. display: flex;
  1344. flex-direction: column;
  1345. justify-content: center;
  1346. align-items: center;
  1347. position: fixed;
  1348. right: 32rpx;
  1349. bottom: 64rpx;
  1350. .img {
  1351. width: 56rpx;
  1352. height: 56rpx;
  1353. vertical-align: middle;
  1354. }
  1355. .text {
  1356. color: rgba(255, 255, 255, 1);
  1357. font-size: 22rpx;
  1358. }
  1359. }
  1360. </style>