electronicMonitoring.vue 31 KB

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