equipmentElectricity.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view>
  3. <view class="navbar-c">
  4. <view class="back" @click="backStatistics">
  5. <u-icon name="arrow-left" color="#101010" size="36"></u-icon>
  6. </view>
  7. <view class="title">
  8. 用电量(度)
  9. <image class="img" src="@/assets/img/refresh-line.svg" @click="getList(true)"></image>
  10. </view>
  11. </view>
  12. <!-- 标签 -->
  13. <view class="tabs-box" v-if="companyList.length >= 2">
  14. <view class="tabs" :style="{width: companyList.length>4 ? '' : '100%'}">
  15. <u-tabs :list="merchantList1" :is-scroll="false" inactive-color="#999999" active-color="#666666"
  16. :current="current" @change="change"></u-tabs>
  17. </view>
  18. <view class="icon" @click="popShow=true" v-if="companyList.length >= 4">
  19. <u-icon name="arrow-down" color="#999999"></u-icon>
  20. </view>
  21. </view>
  22. <!-- 标签弹出层 -->
  23. <u-popup v-model="popShow" duration="10" mode="top" :negative-top="88" border-radius="16">
  24. <view class="popup-tabs">
  25. <view class="tabs">
  26. <u-tabs :list="merchantList1" :is-scroll="false" :current="current" @change="change"></u-tabs>
  27. </view>
  28. <view class="more">
  29. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  30. </view>
  31. </view>
  32. <view class="tabs-options">
  33. <view class="item" v-for="(item, index) in merchantList2" :key="index" @click="merchantChange(item,index)">
  34. {{item.name}}
  35. </view>
  36. </view>
  37. </u-popup>
  38. <!-- <view class="main" v-for="(item, index) in companyKwhList" :key="index" v-if="current==0"
  39. @click="companyChange(item,index)">
  40. <view class="item">
  41. <view class="item-content">
  42. <view class="equipment">
  43. <view class="equipment1 ">
  44. {{item.name}}
  45. </view>
  46. <view class="equipment2">
  47. 共 {{item.listNum}} 台设备
  48. </view>
  49. </view>
  50. <view class="electricity">
  51. <view class="electricity-item electricity-item-day">
  52. <view class="date">
  53. 今日
  54. </view>
  55. <view class="number">
  56. {{item.thisDayKwh}}
  57. </view>
  58. </view>
  59. <view class="electricity-item">
  60. <view class="date">
  61. 本月
  62. </view>
  63. <view class="number">
  64. {{item.thisMonthKwh}}
  65. </view>
  66. </view>
  67. <view class="electricity-item">
  68. <view class="date">
  69. 上月
  70. </view>
  71. <view class="number">
  72. {{item.lastMonthKwh}}
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="more">
  78. <u-icon name="arrow-right" color="#d4d4d4" size="24"></u-icon>
  79. </view>
  80. </view>
  81. </view> -->
  82. <view class="main" >
  83. <view class="item" v-for="(item, index) in kWhList" :key="item.index"
  84. @click="toElectronicMonitoring(item)">
  85. <view class="item-content">
  86. <view class="equipment">
  87. <view class="equipment1 ">
  88. {{item.name}}
  89. </view>
  90. <view class="equipment2">
  91. {{item.installationAddressSimple}}
  92. </view>
  93. <view class="state" v-if="!item.online">
  94. <view class="dot off-line"></view>
  95. <view class="text">离线</view>
  96. </view>
  97. <view class="state state2" v-else>
  98. <view class="dot on-line"></view>
  99. <view class="text">在线</view>
  100. </view>
  101. </view>
  102. <view class="electricity">
  103. <view class="electricity-item electricity-item-day">
  104. <view class="date">
  105. 今日
  106. </view>
  107. <view class="number">
  108. {{item.thisDayKwh}}
  109. </view>
  110. </view>
  111. <view class="electricity-item">
  112. <view class="date">
  113. 本月
  114. </view>
  115. <view class="number">
  116. {{item.thisMonthKwh}}
  117. </view>
  118. </view>
  119. <view class="electricity-item">
  120. <view class="date">
  121. 上月
  122. </view>
  123. <view class="number">
  124. {{item.lastMonthKwh}}
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <view class="more">
  130. <u-icon name="arrow-right" color="#d4d4d4" size="24"></u-icon>
  131. </view>
  132. </view>
  133. </view>
  134. <u-divider :isnone="kWhList.length==0" nonetext="暂无数据" border-color="#CFD2D5"></u-divider>
  135. </view>
  136. </template>
  137. <script>
  138. import * as API from '@/apis/pagejs/index.js'
  139. export default {
  140. data() {
  141. return {
  142. companyList: [], // 商户
  143. merchantList1: [],
  144. merchantList2: [],
  145. kWhList: [], //设备
  146. companyId: '',
  147. popShow: false,
  148. current: 0,
  149. allKWhList: [],
  150. companyKwhList: [],
  151. pageIndex: 1,
  152. recordsTotal: 0,
  153. windowHeight: ''
  154. }
  155. },
  156. onReady() {
  157. uni.getSystemInfo({
  158. success: function(res) {
  159. this.windowHeight = res.windowHeight
  160. // console.log(this.windowHeight)
  161. }
  162. });
  163. this.getCompanyInfoList();
  164. },
  165. onReachBottom() {
  166. if (this.kWhList.length < this.recordsTotal) {
  167. this.myLoadmore();
  168. }
  169. },
  170. methods: {
  171. refreshList() {
  172. if(this.current != 0) {
  173. this.getList(true);
  174. } else {
  175. this.getCompanyInfoList();
  176. }
  177. },
  178. companyChange(item, index) {
  179. this.current = index + 1;
  180. this.companyId = item.id;
  181. this.getList(true);
  182. },
  183. getCompanyKwhList(list) {
  184. uni.showLoading({
  185. title: "加载中",
  186. mask: true,
  187. })
  188. API.companyKwhList({
  189. companyId: list.id
  190. }).then((response) => {
  191. var wkh = response.data;
  192. var num = 0;
  193. if (list.remoteReadingMeterList.length != 0) {
  194. num = list.remoteReadingMeterList.length;
  195. }
  196. var wkhList = {
  197. id: list.id,
  198. name: list.name,
  199. listNum: num,
  200. thisDayKwh: wkh.thisDayTotalKwh,
  201. thisMonthKwh: wkh.thisMonthTotalKwh,
  202. lastMonthKwh: wkh.lastMonthTotalKwh,
  203. };
  204. this.companyKwhList.push(wkhList);
  205. if(this.companyKwhList.length == this.companyList.length) {
  206. uni.hideLoading();
  207. }
  208. }).catch(error => {
  209. uni.showToast({
  210. title: error,
  211. icon: "none"
  212. })
  213. })
  214. },
  215. getCompanyInfoList() {
  216. this.companyKwhList = [];
  217. API.deviceCompanyList().then((response) => {
  218. var list = response.data.companyInfoList;
  219. this.companyList = list;
  220. var mList1 = [];
  221. var mList2 = [];
  222. // mList1.push({
  223. // id: '',
  224. // name: '全部'
  225. // });
  226. for (var i = 0; i < list.length; i++) {
  227. if (i >= 3) {
  228. mList2.push(list[i]);
  229. } else {
  230. mList1.push(list[i]);
  231. }
  232. // this.getCompanyKwhList(list[i]);
  233. }
  234. this.merchantList1 = mList1;
  235. this.merchantList2 = mList2;
  236. this.companyId = mList1[0].id;
  237. this.getList();
  238. }).catch(error => {
  239. uni.showToast({
  240. title: error,
  241. icon: "none"
  242. })
  243. })
  244. },
  245. myLoadmore() {
  246. this.pageIndex += 1;
  247. this.getList();
  248. },
  249. getList(bl) {
  250. uni.showLoading({
  251. title: "加载中",
  252. mask: true,
  253. })
  254. if (bl) {
  255. this.kWhList = [];
  256. this.pageIndex = 1;
  257. }
  258. var data = {
  259. pageIndex: this.pageIndex,
  260. pageSize: 10,
  261. companyId: this.companyId
  262. };
  263. API.homePageKwh(data).then((res) => {
  264. uni.hideLoading();
  265. this.kWhList = [
  266. ...this.kWhList,
  267. ...res.data.data
  268. ];
  269. this.recordsTotal = res.data.recordsTotal;
  270. }).catch(error => {
  271. uni.showToast({
  272. title: error,
  273. icon: "none"
  274. })
  275. })
  276. },
  277. merchantChange(item, index) {
  278. var m = item;
  279. var n = this.merchantList1[this.current];
  280. this.merchantList1[this.current] = m;
  281. this.merchantList2[index] = n;
  282. this.companyId = item.id;
  283. this.popShow = false;
  284. this.getList(true);
  285. },
  286. change(index) {
  287. this.current = index;
  288. this.companyId = this.merchantList1[index].id;
  289. // if (index != 0) {
  290. this.getList(true);
  291. // }
  292. },
  293. backStatistics() {
  294. uni.navigateBack()
  295. },
  296. toElectronicMonitoring(item) {
  297. uni.navigateTo({
  298. url: '/pages/equipmentDataMonitoring/electronicMonitoring?id=' + item.id + '&name=' + item.name +
  299. '&companyId=' + item.companyId
  300. })
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. page {
  307. padding-bottom: 100rpx;
  308. }
  309. .back {
  310. z-index: 999;
  311. width: 200rpx;
  312. }
  313. ::v-deep.u-drawer-content {
  314. margin-top: 88rpx;
  315. }
  316. // ::v-deep.u-tab-item {
  317. // width: 25% !important;
  318. // flex: none !important;
  319. // }
  320. .tabs-box {
  321. background-color: #fff;
  322. display: flex;
  323. align-items: center;
  324. padding: 32rpx 0;
  325. padding-right: 32rpx;
  326. justify-content: space-between;
  327. border-bottom: 1px solid rgba(232, 232, 232, 1);
  328. .tabs {
  329. width: 88%;
  330. }
  331. .icon {
  332. margin-left: auto;
  333. margin-right: 24rpx;
  334. }
  335. }
  336. .popup-tabs {
  337. background-color: #fff;
  338. display: flex;
  339. align-items: center;
  340. justify-content: space-between;
  341. padding-right: 32rpx;
  342. color: rgba(51, 51, 51, 1);
  343. font-size: 32rpx;
  344. padding-top: 32rpx;
  345. .tabs {
  346. width: 88%;
  347. }
  348. }
  349. .tabs-options {
  350. display: flex;
  351. padding: 64rpx 32rpx 0;
  352. flex-wrap: wrap;
  353. .item {
  354. width: 25%;
  355. margin-bottom: 40rpx;
  356. }
  357. }
  358. // 用电量合计
  359. .total {
  360. padding: 24rpx 32rpx;
  361. background: linear-gradient(90deg, rgba(49, 110, 207, 1) 2%, rgba(37, 138, 255, 1) 100%);
  362. .company {
  363. display: flex;
  364. align-items: center;
  365. justify-content: space-between;
  366. .name {
  367. color: rgba(255, 255, 255, 1);
  368. font-size: 36rpx;
  369. font-weight: bold;
  370. }
  371. .amount {
  372. color: #f2f4f6;
  373. margin-top: 4rpx;
  374. }
  375. }
  376. .infos {
  377. display: flex;
  378. justify-content: space-between;
  379. align-items: center;
  380. margin-top: 4rpx;
  381. width: 93%;
  382. .infos-item {
  383. display: flex;
  384. width: 33.3%;
  385. .number {
  386. color: rgba(255, 255, 255, 1);
  387. font-size: 32rpx;
  388. font-weight: bold;
  389. margin-left: 8rpx;
  390. }
  391. .time {
  392. color: #f2f4f6;
  393. }
  394. }
  395. }
  396. }
  397. // 用电量
  398. .main {
  399. background-color: #fff;
  400. padding: 26rpx 32rpx;
  401. .item:last-of-type {
  402. border: none;
  403. }
  404. .item {
  405. padding: 16rpx 0;
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. border-bottom: 1px solid rgba(245, 245, 245, 1);
  410. .item-content {
  411. width: 93%;
  412. }
  413. .equipment {
  414. display: flex;
  415. align-items: center;
  416. .equipment1 {
  417. color: rgba(51, 51, 51, 1);
  418. font-size: 32rpx;
  419. max-width: 40%;
  420. font-weight: bold;
  421. white-space: nowrap;
  422. overflow: hidden;
  423. text-overflow: ellipsis;
  424. }
  425. .equipment2 {
  426. color: rgba(119, 119, 119, 1);
  427. margin-left: 16rpx;
  428. max-width: 40%;
  429. white-space: nowrap;
  430. overflow: hidden;
  431. text-overflow: ellipsis;
  432. }
  433. }
  434. // 状态
  435. .state {
  436. display: flex;
  437. align-items: center;
  438. color: rgba(255, 123, 0, 1);
  439. margin-left: auto;
  440. .dot {
  441. margin-right: 8rpx;
  442. width: 16rpx;
  443. height: 16rpx;
  444. background-color: rgba(255, 123, 0, 1);
  445. border-radius: 999px;
  446. margin-left: auto;
  447. }
  448. .off-line {
  449. background-color: rgba(255, 123, 0, 1);
  450. }
  451. .on-line {
  452. background-color: rgba(0, 185, 98, 1);
  453. }
  454. }
  455. .state2 {
  456. color: rgba(0, 185, 98, 1);
  457. }
  458. .electricity {
  459. display: flex;
  460. justify-content: space-between;
  461. align-items: center;
  462. margin-top: 8rpx;
  463. text-align: center;
  464. .electricity-item {
  465. display: flex;
  466. align-items: center;
  467. width: 33.3%;
  468. .number {
  469. color: rgba(51, 51, 51, 1);
  470. font-weight: bold;
  471. font-size: 32rpx;
  472. margin-left: 8rpx;
  473. }
  474. .date {
  475. color: rgba(119, 119, 119, 1);
  476. }
  477. }
  478. }
  479. }
  480. }
  481. </style>