equipmentConditionMonitoring.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <template>
  2. <view>
  3. <u-navbar title="设备状态监测" title-color="#101010"></u-navbar>
  4. <u-select title="" v-model="tabsFrom.show1" :defaultValue="[current2]"
  5. :list="childList" value-name="id" label-name="name"
  6. @confirm="selector1confirm" >
  7. </u-select>
  8. <view class="dropdownMain" >
  9. <view class="dropdown" >
  10. <view class="dropdown-item" @click="show1=true">
  11. <view class="text">
  12. {{device}}
  13. </view>
  14. <view class="item-icon">
  15. <u-icon name="arrow-down" color="#999999" v-if="show1==false"></u-icon>
  16. <u-icon name="arrow-up" color="#999999" v-else></u-icon>
  17. </view>
  18. </view>
  19. <view class="dropdown-item" @click="show2=true">
  20. <view class="text">
  21. {{statusName}}
  22. </view>
  23. <view class="icon">
  24. <u-icon name="arrow-down" color="#999999" v-if="show2==false"></u-icon>
  25. <u-icon name="arrow-up" color="#999999" v-else></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 标签 -->
  30. <view class="tabs-box" >
  31. <view class="tabs" :class="'tabs-len-'+merchantList1.length" v-show="companyList.length>1"
  32. :style="{width: companyList.length>3 ? '' : '100%'}">
  33. <u-tabs-one v-if="utabsone"
  34. :list="merchantList1" :is-scroll="false" inactive-color="#999999" active-color="#666666"
  35. :current="current" @change="change"></u-tabs-one>
  36. </view>
  37. <view class="more" @click="popShow=true" v-if="companyList.length >= 4">
  38. <u-icon name="arrow-down" color="#fff" size="40"></u-icon>
  39. </view>
  40. </view>
  41. <!-- 标签弹出层 -->
  42. <u-popup v-model="popShow" duration="10" mode="top" :negative-top="88" border-radius="16">
  43. <view class="popup-tabs">
  44. <view class="tabs">
  45. <u-tabs :list="merchantList1" :is-scroll="false" :current="current" @change="change"></u-tabs>
  46. </view>
  47. <view class="more">
  48. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  49. </view>
  50. </view>
  51. <view class="tabs-options">
  52. <view class="item" v-for="(item, index) in merchantList2" :key="index"
  53. @click="merchantChange(item,index)">
  54. {{item.name}}
  55. </view>
  56. </view>
  57. </u-popup>
  58. <view class="electronicMonitoring-title"
  59. @click="titleCk"
  60. v-if="childList&&childList.length>0" >
  61. <view>
  62. {{childListName}}
  63. </view>
  64. <view v-show="childList.length>1">
  65. <u-icon name="arrow-down" color="#fff"></u-icon>
  66. </view>
  67. </view>
  68. </view>
  69. <u-select v-model="show1" mode="single-column" :list="deviceTypeList" @confirm="deviceChange"></u-select>
  70. <u-select v-model="show2" mode="single-column" :list="statusList" @confirm="statusChange"></u-select>
  71. <view class="main">
  72. <view class="item" v-for="(item,index) in deviceList" :key="index" @click="toElectronicMonitoring(item)">
  73. <view class="item-icon" v-if="item.classify == '1'">
  74. <image class="img" src="@/assets/img/energy1.svg" mode=""></image>
  75. </view>
  76. <view class="item-icon" v-if="item.classify == '2'">
  77. <image class="img" src="@/assets/img/transformer2.svg" mode=""></image>
  78. </view>
  79. <view class="item-content">
  80. <view class="content1">
  81. <view class="name1">
  82. {{replaceLastTwoWords(item.name)}}
  83. </view>
  84. </view>
  85. <view class="content3">
  86. {{item.installationAddressSimple}}
  87. </view>
  88. <view class="content2">
  89. <view class="text">
  90. {{item.deviceTypeN}}
  91. </view>
  92. <view class="item-state">
  93. <view class="dot" :class="item.online ? 'on-line' : 'off-line'">
  94. </view>
  95. <view class="text">
  96. {{item.online ? '在线' : '离线'}}
  97. </view>
  98. <view class="more">
  99. <u-icon name="arrow-right" size="24" color="#acacac"></u-icon>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="content3" v-if="item.classify == '2'">
  104. <view class="state-item">
  105. <view class="state-title">
  106. 运行状态:
  107. </view>
  108. <view class="state-value" v-if="item.deviceStatus == '1'">
  109. 正常
  110. </view>
  111. <view class="state-value2" v-else>
  112. 异常
  113. </view>
  114. </view>
  115. <view class="state-item">
  116. <view class="state-title">
  117. 温度状态:
  118. </view>
  119. <view class="state-value" v-if="item.temperatureStatus == '1'">
  120. 正常
  121. </view>
  122. <view class="state-value2" v-else>
  123. 异常
  124. </view>
  125. </view>
  126. <view class="state-item">
  127. <view class="state-title">
  128. 烟感状态:
  129. </view>
  130. <view class="state-value" v-if="item.smokeStatus == '1'">
  131. 正常
  132. </view>
  133. <view class="state-value2" v-else>
  134. 异常
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. <u-divider :isnone="deviceList.length==0" nonetext="暂无数据" border-color="#CFD2D5">已经到底了</u-divider>
  142. </view>
  143. </template>
  144. <script>
  145. import * as API from '@/apis/pagejs/index.js'
  146. import * as API_electricityMeter from '@/apis/pagejs/electricityMeter.js'
  147. export default {
  148. data() {
  149. return {
  150. companyList: [], // 商户
  151. merchantList1: [],
  152. merchantList2: [],
  153. deviceList: [],
  154. show1: false,
  155. show2: false,
  156. device: '全部设备',
  157. statusName: '全部状态',
  158. deviceTypeList: [],
  159. statusList: [{
  160. value: '',
  161. label: '全部状态'
  162. },
  163. {
  164. value: '1',
  165. label: '离线'
  166. },
  167. {
  168. value: '2',
  169. label: '温度异常'
  170. },
  171. {
  172. value: '3',
  173. label: '烟感异常'
  174. },
  175. {
  176. value: '4',
  177. label: '设备异常'
  178. }
  179. ],
  180. tabsFrom: {
  181. show1: false,
  182. show1Index: 0,
  183. show2Index: '',
  184. show2: false,
  185. show1Text: "全部类型",
  186. show2Text: "全部时间",
  187. },
  188. status: '',
  189. deviceType: '',
  190. companyId:"",
  191. pageIndex: 1,
  192. recordsTotal:0,
  193. utabsone:true,
  194. companyType:0,
  195. incomeExpenditureObj:{},
  196. opCompanyId: '',
  197. childList:[],
  198. companyListMain:[],
  199. current2:0,
  200. childInfo:{},
  201. companyInfo:{},
  202. popShow: false,
  203. current: 0,
  204. }
  205. },
  206. computed:{
  207. childListName(){
  208. return this.childInfo.name;
  209. },
  210. },
  211. onLoad(op) {
  212. if(op.companyId){
  213. this.companyId=op.companyId
  214. }else{
  215. this.getCompanyInfoList();
  216. }
  217. this.getDeviceStatusMonitoring();
  218. },
  219. onReady() {
  220. this.getDeviceTypeList();
  221. },
  222. onReachBottom() {
  223. if (this.deviceList.length < this.recordsTotal) {
  224. this.myLoadmore();
  225. }
  226. },
  227. methods: {
  228. merchantChangeApi() {
  229. this.popShow=false
  230. //this.getList(true)
  231. this.getDeviceStatusMonitoring(1);
  232. },
  233. titleCk() {
  234. if(this.childList.length>1){
  235. this.tabsFrom.show1 = true
  236. }
  237. },
  238. selector1confirm(e) {
  239. //this.getHomePageKwh()
  240. console.log(e)
  241. this.companyId=e[0].value
  242. this.current2=e[0].i
  243. this.childInfo=this.childList[this.current2];
  244. uni.showLoading()
  245. this.merchantChangeApi()
  246. },
  247. change(index) {
  248. this.current = index;
  249. this.current2=0;
  250. this.childList=[]
  251. var company= this.merchantList1[index]
  252. if(company.id!=''){
  253. this.childList=company.childList;
  254. if(this.childList&&this.childList.length){
  255. this.companyId = this.childList[0].id;
  256. this.childInfo=this.childList[0]
  257. }else{
  258. this.childList=[]
  259. this.companyId =company.id
  260. this.childInfo=company
  261. }
  262. }else{
  263. this.companyId =''
  264. }
  265. this.companyInfo=company;
  266. this.merchantChangeApi()
  267. },
  268. merchantChange(item, index) {
  269. if(this.current==0){
  270. this.current=1;
  271. }
  272. var m = company;
  273. var n = this.merchantList1[this.current];
  274. this.merchantList1[this.current] = m;
  275. this.merchantList2[index] = n;
  276. //this.$forceUpdate()
  277. this.utabsone=false
  278. this.companyId = company.id;
  279. this.companyInfo=company
  280. if(company.id!=''){
  281. this.childList=company.childList;
  282. if(this.childList&&this.childList.length){
  283. this.companyId = this.childList[0].id;
  284. this.childInfo=this.childList[0]
  285. }else{
  286. this.childList=[]
  287. this.companyId =company.id
  288. this.childInfo=company
  289. }
  290. }else{
  291. this.companyId =''
  292. }
  293. this.merchantChangeApi()
  294. this.popShow = false;
  295. },
  296. getCompanyInfoList() {
  297. this.companyKwhList = [];
  298. API.deviceCompanyList().then((response) => {
  299. var list = response.data.companyInfoList;
  300. this.companyListMain=response.data.companyInfoList;
  301. if(list.length==1&&list[0].childList&&list[0].childList.length){
  302. list=list[0].childList
  303. }
  304. this.companyList = list;
  305. var mList1 = [];
  306. var mList2 = [];
  307. mList1.push({
  308. id: '',
  309. name: '全部'
  310. });
  311. for (var i = 0; i < list.length; i++) {
  312. if (i >= 3) {
  313. mList2.push(list[i]);
  314. } else {
  315. mList1.push(list[i]);
  316. }
  317. }
  318. this.merchantList1 = mList1;
  319. this.merchantList2 = mList2;
  320. this.companyId = mList1[0].id;
  321. }).catch(error => {
  322. uni.showToast({
  323. title: error,
  324. icon: "none"
  325. })
  326. })
  327. },
  328. myLoadmore() {
  329. this.pageIndex += 1;
  330. this.getDeviceStatusMonitoring();
  331. },
  332. //设备查询
  333. deviceChange(e) {
  334. // console.log(e);
  335. this.deviceType = e[0].value;
  336. this.device = e[0].label;
  337. this.getDeviceStatusMonitoring(1);
  338. },
  339. //状态查询
  340. statusChange(e) {
  341. // console.log(e);
  342. this.status = e[0].value;
  343. this.statusName = e[0].label;
  344. this.getDeviceStatusMonitoring(1);
  345. },
  346. getDeviceStatusMonitoring(bl) {
  347. uni.showLoading({
  348. title: "加载中",
  349. mask: true,
  350. })
  351. if (bl) {
  352. this.deviceList = [];
  353. this.pageIndex = 1;
  354. }
  355. API.deviceStatusMonitoring({
  356. pageIndex: this.pageIndex,
  357. pageSize: 20,
  358. deviceType: this.deviceType,
  359. status: this.status,
  360. companyId:this.companyId,
  361. classify:"1"
  362. }).then((response) => {
  363. uni.hideLoading();
  364. this.deviceList = [
  365. ...this.deviceList,
  366. ...response.data.data
  367. ];
  368. this.recordsTotal = response.data.recordsTotal;
  369. }).catch(error => {
  370. uni.showToast({
  371. title: error,
  372. icon: "none"
  373. })
  374. })
  375. },
  376. //查询设备类型list
  377. getDeviceTypeList() {
  378. uni.showLoading({
  379. title: "加载中",
  380. mask: true,
  381. })
  382. API_electricityMeter.findByName({
  383. name: '设备类型'
  384. }).then((res) => {
  385. uni.hideLoading();
  386. var list = [];
  387. list = res.data.map(item => {
  388. return {
  389. label: item.name,
  390. value: item.value
  391. }
  392. })
  393. list.unshift({
  394. label: '全部设备',
  395. value: ''
  396. })
  397. this.deviceTypeList = list;
  398. }).catch(error => {
  399. uni.showToast({
  400. title: error,
  401. icon: "none"
  402. })
  403. })
  404. },
  405. toElectronicMonitoring(item) {
  406. uni.navigateTo({
  407. url: '/pages/equipmentDataMonitoring/electronicMonitoring?id=' + item.id + '&name=' + item.name +
  408. '&companyId=' + item.companyId
  409. })
  410. }
  411. }
  412. }
  413. </script>
  414. <style lang="scss" scoped>
  415. page{
  416. //padding-bottom: 100px;
  417. }
  418. .dropdownMain {
  419. position: sticky;
  420. top: 88rpx;
  421. background-color: #fff;
  422. z-index: 999;
  423. }
  424. .dropdown {
  425. padding: 18rpx 46rpx;
  426. display: flex;
  427. border-bottom: 1px solid rgba(245, 245, 245, 1);
  428. .dropdown-item {
  429. width: 50%;
  430. text-align: center;
  431. height: 60rpx;
  432. line-height: 60rpx;
  433. display: flex;
  434. align-items: center;
  435. justify-content: center;
  436. .text {
  437. max-width: 80%;
  438. white-space: nowrap;
  439. overflow: hidden;
  440. text-overflow: ellipsis;
  441. }
  442. }
  443. }
  444. .main {
  445. background-color: #fff;
  446. padding: 0 32rpx;
  447. .item:last-of-type {
  448. border: none;
  449. }
  450. .item {
  451. padding: 32rpx 0;
  452. display: flex;
  453. border-bottom: 1px solid rgba(245, 245, 245, 1);
  454. .item-icon {
  455. width: 72rpx;
  456. height: 72rpx;
  457. border-radius: 4px;
  458. background-color: rgba(219, 234, 255, 1);
  459. display: flex;
  460. align-items: center;
  461. justify-content: center;
  462. .img {
  463. width: 48rpx;
  464. height: 48rpx;
  465. }
  466. }
  467. .item-content {
  468. flex: 1;
  469. margin-left: 16rpx;
  470. .content3 {
  471. color: rgba(119, 119, 119, 1);
  472. font-size: 24rpx;
  473. }
  474. .content1 {
  475. display: flex;
  476. align-items: center;
  477. .name1 {
  478. color: rgba(51, 51, 51, 1);
  479. font-weight: bold;
  480. white-space: nowrap;
  481. overflow: hidden;
  482. text-overflow: ellipsis;
  483. }
  484. .name2 {
  485. color: rgba(119, 119, 119, 1);
  486. font-size: 24rpx;
  487. margin-left: 16rpx;
  488. }
  489. }
  490. .content2 {
  491. margin-top: 4rpx;
  492. display: flex;
  493. align-items: center;
  494. justify-content: space-between;
  495. .text {
  496. color: rgba(119, 119, 119, 1);
  497. font-size: 24rpx;
  498. }
  499. }
  500. .content3 {
  501. margin-top: 8rpx;
  502. display: flex;
  503. align-items: center;
  504. justify-content: space-between;
  505. padding-right: 16rpx;
  506. .state-item {
  507. display: flex;
  508. color: rgba(51, 51, 51, 1);
  509. font-size: 24rpx;
  510. .state-value {
  511. color: #00B962;
  512. }
  513. .state-value2 {
  514. color: #FF6923;
  515. }
  516. }
  517. }
  518. }
  519. }
  520. .item-state {
  521. margin-left: auto;
  522. display: flex;
  523. align-items: center;
  524. .dot {
  525. width: 16rpx;
  526. height: 16rpx;
  527. border-radius: 999px;
  528. }
  529. .text {
  530. margin: 0 8rpx;
  531. color: rgba(51, 51, 51, 1);
  532. font-size: 24rpx;
  533. }
  534. .off-line {
  535. background-color: rgba(255, 123, 0, 1);
  536. }
  537. .on-line {
  538. background-color: rgba(0, 185, 98, 1);
  539. }
  540. }
  541. }
  542. .tabs-box {
  543. background-color: #fff;
  544. display: flex;
  545. align-items: center;
  546. padding-right: 32rpx;
  547. justify-content: space-between;
  548. border-bottom: 1px solid rgba(232, 232, 232, 1);
  549. .tabs {
  550. width: 97%;
  551. }
  552. .more{
  553. padding-right: 12rpx;
  554. }
  555. .icon {
  556. margin-left: auto;
  557. margin-right: 24rpx;
  558. }
  559. }
  560. .tabs-len-1{
  561. }
  562. .tabs-len-2{
  563. /deep/.u-tab-item {
  564. // max-width: 39% !important;
  565. // flex: none !important;
  566. }
  567. }
  568. .tabs-len-3{
  569. /deep/.u-tab-item {
  570. max-width: 39% !important;
  571. flex: none !important;
  572. }
  573. }
  574. .tabs-len-4{
  575. /deep/.u-tab-item {
  576. max-width: 26% !important;
  577. flex: none !important;
  578. }
  579. }
  580. /deep/.u-tab-item:first-child {
  581. width: 20% !important;
  582. flex: none !important;
  583. }
  584. .popup-tabs {
  585. background-color: #fff;
  586. display: flex;
  587. align-items: center;
  588. justify-content: space-between;
  589. padding-right: 32rpx;
  590. color: rgba(51, 51, 51, 1);
  591. font-size: 32rpx;
  592. padding-top: 32rpx;
  593. .tabs {
  594. width: 88%;
  595. }
  596. }
  597. .tabs-options {
  598. display: flex;
  599. padding: 64rpx 32rpx 0;
  600. flex-wrap: wrap;
  601. .item {
  602. width: 25%;
  603. margin-bottom: 40rpx;
  604. }
  605. }
  606. .electronicMonitoring-title{
  607. display: flex;
  608. align-items: center;
  609. padding: 0px 32rpx;
  610. justify-content: space-between;
  611. height: 120rpx;
  612. font-size: 36rpx;
  613. background-color: rgba(22,119,255,1);
  614. color:#fff;
  615. }
  616. </style>