dataMonitoring-map.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <template>
  2. <view>
  3. <!-- <u-navbar title="设备数据监测" title-color="#101010" > -->
  4. <view class="navbar-c">
  5. <view class="back">
  6. <u-icon name="arrow-left" color="#101010" size="36"></u-icon>
  7. </view>
  8. <view class="title">
  9. 设备数据监测<image class="img" src="@/assets/img/refresh-line.svg"></image>
  10. </view>
  11. <view class="right" @click="toDataMonitoringList">
  12. <image class="img" src="@/assets/img/riLine-road-map-line.svg" mode=""></image>列表
  13. </view>
  14. </view>
  15. <view class="slot" slot="right">
  16. <image class="img" src="@/assets/img/riLine-list-check-2.svg" mode=""></image>地图
  17. </view>
  18. </u-navbar>
  19. <view class="dropdown">
  20. <u-dropdown-change>
  21. <u-dropdown-item v-model="companyId" :title="device" :options="selectDeviceList"
  22. @change="deviceChange"></u-dropdown-item>
  23. <u-dropdown-item v-model="status" :title="state" :options="stateList" @change="stateChange"></u-dropdown-item>
  24. </u-dropdown-change>
  25. </view>
  26. <!-- 地图 -->
  27. <view class="map">
  28. <MapEquipment @onMoveStart="moveStart" @onMoveEnd="moveEnd" ref="amap" @onClicked="onClicked" @onload="mapdown"
  29. @clickMap="clickMap"></MapEquipment>
  30. <!-- <image class="img" src="@/assets/img/map.png" mode=""></image -->
  31. <!-- 标注1 -->
  32. <view class="location1" v-if="false">
  33. <image class="img" src="@/assets/img/antFill-alert Copy 1.svg" mode=""></image>
  34. <view class="corner">
  35. </view>
  36. </view>
  37. <!-- 标注2 -->
  38. <view class="location2" v-if="false">
  39. <view class="icon2-left">
  40. <image class="img1" src="@/assets/img/antFill-alert.svg" mode=""></image>
  41. </view>
  42. <view class="icon2-right">
  43. <view class="corner2-top">
  44. 荆鹏软件园01
  45. </view>
  46. <view class="corner2-bottom">
  47. <image class="img2" src="@/assets/img/antFill-alert(2).svg"></image>正常
  48. </view>
  49. </view>
  50. <view class="corner2"></view>
  51. </view>
  52. <view class="card" v-if="deviceList.length>0">
  53. <swiper v-if="deviceList.length>0" :current="currentIndex" @change="swiperChange"
  54. slide-change-transition-end='swiperTransitionEnd' @transition="swiperTransition">
  55. <swiper-item v-for="(item,index) in deviceList" :key="index" style="height: 100%;">
  56. <view class="item" style="height: 100%; background-color: #ffffff;">
  57. <view class="title">
  58. <view class="icon-box">
  59. <image class="img" src="@/assets/img/transformer1.svg" mode=""></image>
  60. </view>
  61. <view class="equipment">
  62. <view class="name1">
  63. {{item.name}}
  64. </view>
  65. <view class="name2">
  66. {{item.installationAddressSimple}}
  67. </view>
  68. </view>
  69. <!-- 状态 -->
  70. <view class="state">
  71. <view class="state1" v-if="item.temperatureStatus == '1'">
  72. <view class="icon"></view>
  73. <view class="text">
  74. 温度正常
  75. </view>
  76. </view>
  77. <view class="state1" v-else>
  78. <view class="icon icon2"></view>
  79. <view class="text">
  80. 温度异常
  81. </view>
  82. </view>
  83. <view class="state1" v-if="item.smokeStatus == '1'">
  84. <view class="icon"></view>
  85. <view class="text">
  86. 烟感正常
  87. </view>
  88. </view>
  89. <view class="state1" v-else>
  90. <view class="icon icon2"></view>
  91. <view class="text">
  92. 烟感异常
  93. </view>
  94. </view>
  95. <view class="state1" v-if="item.online">
  96. <view class="icon icon4"></view>
  97. <view class="text">
  98. 设备在线
  99. </view>
  100. </view>
  101. <view class="state1" v-else>
  102. <view class="icon icon3"></view>
  103. <view class="text">
  104. 设备离线
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <!-- 设备信息 -->
  110. <view class="infos">
  111. <view class="infos-item">
  112. <view class="item-title">
  113. 当前电流:
  114. </view>
  115. <view class="item-value">
  116. {{item.remoteMonitorRecord.dcaTotal.toFixed(2)}}A
  117. </view>
  118. </view>
  119. <view class="infos-item">
  120. <view class="item-title">
  121. 当前电压:
  122. </view>
  123. <view class="item-value">
  124. {{item.remoteMonitorRecord.dcvTop.toFixed(2)}}V
  125. </view>
  126. </view>
  127. <view class="infos-item">
  128. <view class="item-title">
  129. 当前温度:
  130. </view>
  131. <view class="item-value">
  132. {{item.remoteMonitorRecord.temperatureTop}}°C
  133. </view>
  134. </view>
  135. <view class="infos-item">
  136. <view class="item-title">
  137. 当前功率:
  138. </view>
  139. <view class="item-value">
  140. {{item.remoteMonitorRecord.totalPower.toFixed(2)}}kW
  141. </view>
  142. </view>
  143. <view class="infos-item">
  144. <view class="item-title">
  145. 当前功率因数:
  146. </view>
  147. <view class="item-value">
  148. {{item.remoteMonitorRecord.averPowerFactor.toFixed(2)}}
  149. </view>
  150. </view>
  151. <view class="infos-item">
  152. <view class="item-title">
  153. 平均功率因数:
  154. </view>
  155. <view class="item-value">
  156. {{item.remoteMonitorRecord.averPowerFactorHistory}}
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </swiper-item>
  162. </swiper>
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import MapEquipment from '@/components/Map-equipment.vue';
  169. import * as API from '@/apis/pagejs/index.js'
  170. import * as WxJsApi from '@/apis/utils/wxJsApi.js'
  171. export default {
  172. components: {
  173. MapEquipment,
  174. },
  175. data() {
  176. return {
  177. currentIndex: 0,
  178. show2: false, // 状态选择
  179. state: '全部状态',
  180. stateList: [{
  181. label: '全部状态',
  182. value: ''
  183. },
  184. {
  185. label: '设备正常',
  186. value: '0'
  187. },
  188. {
  189. label: '设备离线',
  190. value: '1'
  191. },
  192. {
  193. label: '温度异常',
  194. value: '2'
  195. },
  196. {
  197. label: '烟感异常',
  198. value: '3'
  199. },
  200. {
  201. label: '设备异常',
  202. value: '4'
  203. }
  204. ],
  205. show1: false, // 设备选择
  206. device: '全部设备',
  207. selectDeviceList: [],
  208. deviceList: [],
  209. pageIndex: 1,
  210. companyId: '',
  211. status: '',
  212. latitude: "",
  213. longitude: "",
  214. message: '',
  215. value1: '',
  216. value2: '',
  217. options1: [{
  218. label: '荆鹏集团',
  219. value: 1,
  220. },
  221. {
  222. label: '青少年宫',
  223. value: 2,
  224. },
  225. {
  226. label: '荆州院子',
  227. value: 3,
  228. },
  229. ],
  230. options2: [{
  231. label: '设备离线',
  232. value: 1,
  233. },
  234. {
  235. label: '温度异常',
  236. value: 2,
  237. },
  238. {
  239. label: '电压异常',
  240. value: 3,
  241. },
  242. {
  243. label: '功率因数异常',
  244. value: 4,
  245. },
  246. ],
  247. }
  248. },
  249. onReady() {
  250. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  251. // //(res)
  252. }).catch(error => {
  253. //(res)
  254. })
  255. this.$refs.amap.init();
  256. this.getList();
  257. this.getAlarmConfiguration();
  258. },
  259. onShow() {
  260. this.$nextTick(() => {
  261. this.$refs.amap.init();
  262. this.getList();
  263. })
  264. },
  265. watch: {
  266. companyId(newval) {
  267. for (var i = 0; i < this.selectDeviceList.length; i++) {
  268. if (this.selectDeviceList[i].value == this.companyId) {
  269. this.device = this.selectDeviceList[i].label
  270. }
  271. }
  272. },
  273. status(newval) {
  274. for (var i = 0; i < this.stateList.length; i++) {
  275. if (this.stateList[i].value == this.status) {
  276. this.state = this.stateList[i].label
  277. }
  278. }
  279. }
  280. },
  281. methods: {
  282. swiperTransitionEnd(e) {
  283. // console.log(e)
  284. },
  285. swiperTransition(e) {
  286. // console.log(e)
  287. },
  288. swiperChange(e) {
  289. console.log(e)
  290. this.currentIndex = e.detail.current;
  291. let bounds = this.$refs.amap.logMapInfo();
  292. this.$refs.amap.updateIcon(this.deviceList[this.currentIndex]);
  293. },
  294. // 状态查询
  295. stateChange(e) {
  296. this.getList();
  297. },
  298. // 设备查询
  299. deviceChange(e) {
  300. this.getList();
  301. },
  302. // 异常查询条件
  303. getAlarmConfiguration() {
  304. uni.showLoading({
  305. title: "加载中",
  306. mask: true,
  307. })
  308. API.alarmConfiguration().then((response) => {
  309. uni.hideLoading();
  310. var list2 = [];
  311. if (response.data.companyInfoList && response.data.companyInfoList.length != 0) {
  312. list2 = response.data.companyInfoList.map(item => {
  313. return {
  314. label: item.name,
  315. value: item.id
  316. }
  317. });
  318. }
  319. list2.unshift({
  320. value: '',
  321. label: '全部设备'
  322. });
  323. this.selectDeviceList = list2;
  324. }).catch(error => {
  325. uni.showToast({
  326. title: error,
  327. icon: "none"
  328. })
  329. })
  330. },
  331. //设备list
  332. getList() {
  333. uni.showLoading({
  334. title: "加载中",
  335. mask: true,
  336. })
  337. var data = {
  338. pageIndex: this.pageIndex,
  339. pageSize: 1000,
  340. companyId: this.companyId,
  341. status: this.status
  342. };
  343. API.homePageDeviceData(data).then((res) => {
  344. uni.hideLoading()
  345. var list = res.data.data;
  346. this.deviceList = list;
  347. this.$refs.amap.setList(list);
  348. if (list.length != 0) {
  349. this.$refs.amap.updateIcon(list[this.currentIndex]);
  350. }
  351. this.$forceUpdate();
  352. }).catch(error => {
  353. uni.showToast({
  354. title: error,
  355. icon: "none"
  356. })
  357. })
  358. },
  359. toDataMonitoringList() {
  360. uni.navigateBack()
  361. },
  362. clickMap(obj) {
  363. //this.show = false;
  364. console.log(obj)
  365. if (obj == null || obj.type == null) return;
  366. if (obj.type == 'charger') {
  367. if (obj.obj != null) {
  368. let index = this.deviceList.findIndex(item => item.id == obj.obj.id);
  369. this.currentIndex = index;
  370. //('find Index'+index);
  371. this.$refs.amap.updateIcon(obj.obj);
  372. }
  373. }
  374. },
  375. mapdown() {
  376. //this.isReady = true;
  377. //this.$refs.amap.getLocation ();
  378. //let state = {};
  379. uni.getSystemInfo({
  380. success: (res) => {
  381. let scrollH = res.windowHeight; // - uni.upx2px(88) - navbarH
  382. let scrollW = res.windowWidth;
  383. this.$refs.amap.setMyStyle("height:" + (scrollH - 88 - 50) + "px;width:" + scrollW +
  384. "px;");
  385. // this.$refs.amap.setList([{
  386. // name: "amap1",
  387. // status: 1,
  388. // longitude: 112.276527,
  389. // latitude: 30.306427,
  390. // },
  391. // {
  392. // name: "amap2",
  393. // status: 1,
  394. // longitude: 112.276663,
  395. // latitude: 30.307215,
  396. // }
  397. // ])
  398. }
  399. })
  400. },
  401. moveEnd(e) {
  402. //('moveEnd')
  403. //this.close_all();
  404. let posCenter = this.$refs.amap.logMapInfo();
  405. ////('posCenter'+JSON.stringify(posCenter))
  406. if (this.latitude == e.center.lat && this.longitude == e.center.lng) {
  407. return
  408. }
  409. this.latitude = e.center.lat;
  410. this.longitude = e.center.lng;
  411. },
  412. moveStart(e) {
  413. //this.close_all();
  414. },
  415. onClicked(e) {
  416. console.log(e)
  417. //this.close_all();
  418. ////('onClicked e'+JSON.stringify(e))
  419. },
  420. }
  421. }
  422. </script>
  423. <style lang="scss" scoped>
  424. // .chargerCard {
  425. // z-index: 999;
  426. // background-color: #fff;
  427. // margin: 0 24rpx;
  428. // border-radius: 16rpx;
  429. // // overflow: hidden;
  430. // bottom: 68px;
  431. // left: 0;
  432. // right: 0;
  433. // position: fixed;
  434. // // height: 380rpx;
  435. // // @include themeify{
  436. // // height:themed('cardHeight');
  437. // // }
  438. // }
  439. .slot {
  440. display: flex;
  441. align-items: center;
  442. .img {
  443. width: 32rpx;
  444. height: 32rpx;
  445. margin-right: 4rpx;
  446. }
  447. }
  448. .dropdown {
  449. background-color: #fff;
  450. // position: sticky;
  451. // top: 0;
  452. // z-index: 999;
  453. }
  454. // 地图
  455. .map {
  456. position: relative;
  457. .img {
  458. width: 100%;
  459. height: 100vh;
  460. }
  461. ::v-deep.location1 {
  462. width: 36px;
  463. height: 36px;
  464. text-align: center;
  465. border: 2px solid #FF3D00;
  466. border-radius: 999px;
  467. display: flex;
  468. align-items: center;
  469. justify-content: center;
  470. //position: relative;
  471. background: white;
  472. .img {
  473. width: 40rpx;
  474. height: 40rpx;
  475. }
  476. .corner {
  477. width: 0;
  478. height: 0;
  479. position: absolute;
  480. top: 78rpx;
  481. left: 0;
  482. right: 0;
  483. margin: auto;
  484. border-bottom: 8rpx solid transparent;
  485. border-left: 8rpx solid transparent;
  486. border-right: 8rpx solid transparent;
  487. border-top: 12rpx solid #FF3D00;
  488. }
  489. }
  490. ::v-deep.location2 {
  491. width: 280rpx;
  492. border-radius: 50px;
  493. background-color: #27B148;
  494. display: flex;
  495. // position: absolute;
  496. // top: 370rpx;
  497. // left: 280rpx;
  498. .icon2-left {
  499. width: 72rpx;
  500. height: 72rpx;
  501. line-height: 72rpx;
  502. text-align: center;
  503. border: 1px solid rgba(0, 185, 98, 100);
  504. border-radius: 999px;
  505. background-color: #fff;
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. .img1 {
  510. width: 40rpx;
  511. height: 40rpx;
  512. }
  513. }
  514. .icon2-right {
  515. color: #ffffff;
  516. line-height: 36rpx;
  517. padding-left: 8rpx;
  518. font-size: 28rpx;
  519. .corner2-top {
  520. font-weight: bold;
  521. white-space: nowrap;
  522. overflow: hidden;
  523. width: 200rpx;
  524. text-overflow: ellipsis;
  525. }
  526. .corner2-bottom {
  527. font-size: 24rpx;
  528. .img2 {
  529. width: 24rpx;
  530. height: 24rpx;
  531. }
  532. }
  533. }
  534. .corner2 {
  535. width: 0;
  536. height: 0;
  537. position: absolute;
  538. top: 72rpx;
  539. left: 0;
  540. right: 0;
  541. margin: auto;
  542. border-bottom: 6px solid transparent;
  543. border-left: 6px solid transparent;
  544. border-right: 6px solid transparent;
  545. border-top: 8px solid #27B148;
  546. }
  547. }
  548. // 卡片
  549. .card {
  550. border-radius: 8px;
  551. border: 1px solid rgba(232, 232, 232, 1);
  552. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
  553. background-color: rgba(255, 255, 255, 1);
  554. position: fixed;
  555. left: 24rpx;
  556. right: 24rpx;
  557. bottom: 0rpx;
  558. .item {
  559. border-bottom: 1px solid rgba(245, 245, 245, 1);
  560. padding: 32rpx 16rpx 16rpx 16rpx;
  561. .title {
  562. display: flex;
  563. align-items: flex-start;
  564. .icon-box {
  565. width: 72rpx;
  566. height: 72rpx;
  567. border-radius: 4px;
  568. display: flex;
  569. align-items: center;
  570. justify-content: center;
  571. background-color: rgba(219, 234, 255, 1);
  572. .img {
  573. width: 48rpx;
  574. height: 48rpx;
  575. }
  576. }
  577. .equipment {
  578. margin-left: 16rpx;
  579. .name1 {
  580. color: rgba(51, 51, 51, 1);
  581. }
  582. .name2 {
  583. color: rgba(119, 119, 119, 1);
  584. font-size: 24rpx;
  585. margin-top: 4rpx;
  586. }
  587. }
  588. // 状态
  589. .state {
  590. display: flex;
  591. align-items: center;
  592. flex-wrap: wrap;
  593. justify-content: flex-end;
  594. margin-left: auto;
  595. flex: 1;
  596. .state1 {
  597. display: flex;
  598. align-items: center;
  599. margin-left: 24rpx;
  600. .icon {
  601. width: 16rpx;
  602. height: 16rpx;
  603. border-radius: 99px;
  604. background-color: rgba(22, 119, 255, 1);
  605. margin-right: 8rpx;
  606. }
  607. .icon2 {
  608. background-color: #FF4F3F;
  609. }
  610. .icon3 {
  611. background-color: #C2C2C2;
  612. }
  613. .icon4{
  614. background-color: rgba(0,185,98,1);
  615. }
  616. }
  617. }
  618. }
  619. // 设备信息
  620. .infos {
  621. margin-top: 32rpx;
  622. display: flex;
  623. align-items: center;
  624. justify-content: space-between;
  625. flex-wrap: wrap;
  626. font-size: 24rpx;
  627. .infos-item {
  628. display: flex;
  629. margin-bottom: 16rpx;
  630. .warning {
  631. color: rgba(255, 61, 0, 1);
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. </style>