equipmentElectricity.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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" v-for="(item, index) in kWhList" :key="item.index"
  83. @click="toElectronicMonitoring(item)">
  84. <view class="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. </view>
  135. </template>
  136. <script>
  137. import * as API from '@/apis/pagejs/index.js'
  138. export default {
  139. data() {
  140. return {
  141. companyList: [], // 商户
  142. merchantList1: [],
  143. merchantList2: [],
  144. kWhList: [], //设备
  145. companyId: '',
  146. popShow: false,
  147. current: 0,
  148. allKWhList: [],
  149. companyKwhList: [],
  150. pageIndex: 1,
  151. recordsTotal: 0,
  152. windowHeight: ''
  153. }
  154. },
  155. onReady() {
  156. uni.getSystemInfo({
  157. success: function(res) {
  158. this.windowHeight = res.windowHeight
  159. // console.log(this.windowHeight)
  160. }
  161. });
  162. this.getCompanyInfoList();
  163. },
  164. onReachBottom() {
  165. if (this.kWhList.length < this.recordsTotal) {
  166. this.myLoadmore();
  167. }
  168. },
  169. methods: {
  170. refreshList() {
  171. if(this.current != 0) {
  172. this.getList(true);
  173. } else {
  174. this.getCompanyInfoList();
  175. }
  176. },
  177. companyChange(item, index) {
  178. this.current = index + 1;
  179. this.companyId = item.id;
  180. this.getList(true);
  181. },
  182. getCompanyKwhList(list) {
  183. uni.showLoading({
  184. title: "加载中",
  185. mask: true,
  186. })
  187. API.companyKwhList({
  188. companyId: list.id
  189. }).then((response) => {
  190. var wkh = response.data;
  191. var num = 0;
  192. if (list.remoteReadingMeterList.length != 0) {
  193. num = list.remoteReadingMeterList.length;
  194. }
  195. var wkhList = {
  196. id: list.id,
  197. name: list.name,
  198. listNum: num,
  199. thisDayKwh: wkh.thisDayTotalKwh,
  200. thisMonthKwh: wkh.thisMonthTotalKwh,
  201. lastMonthKwh: wkh.lastMonthTotalKwh,
  202. };
  203. this.companyKwhList.push(wkhList);
  204. if(this.companyKwhList.length == this.companyList.length) {
  205. uni.hideLoading();
  206. }
  207. }).catch(error => {
  208. uni.showToast({
  209. title: error,
  210. icon: "none"
  211. })
  212. })
  213. },
  214. getCompanyInfoList() {
  215. this.companyKwhList = [];
  216. API.deviceCompanyList().then((response) => {
  217. var list = response.data.companyInfoList;
  218. this.companyList = list;
  219. var mList1 = [];
  220. var mList2 = [];
  221. // mList1.push({
  222. // id: '',
  223. // name: '全部'
  224. // });
  225. for (var i = 0; i < list.length; i++) {
  226. if (i >= 3) {
  227. mList2.push(list[i]);
  228. } else {
  229. mList1.push(list[i]);
  230. }
  231. // this.getCompanyKwhList(list[i]);
  232. }
  233. this.merchantList1 = mList1;
  234. this.merchantList2 = mList2;
  235. this.companyId = mList1[0].id;
  236. this.getList();
  237. }).catch(error => {
  238. uni.showToast({
  239. title: error,
  240. icon: "none"
  241. })
  242. })
  243. },
  244. myLoadmore() {
  245. this.pageIndex += 1;
  246. this.getList();
  247. },
  248. getList(bl) {
  249. uni.showLoading({
  250. title: "加载中",
  251. mask: true,
  252. })
  253. if (bl) {
  254. this.kWhList = [];
  255. this.pageIndex = 1;
  256. }
  257. var data = {
  258. pageIndex: this.pageIndex,
  259. pageSize: 8,
  260. companyId: this.companyId
  261. };
  262. API.homePageKwh(data).then((res) => {
  263. uni.hideLoading();
  264. this.kWhList = [
  265. ...this.kWhList,
  266. ...res.data.data
  267. ];
  268. this.recordsTotal = res.data.recordsTotal;
  269. }).catch(error => {
  270. uni.showToast({
  271. title: error,
  272. icon: "none"
  273. })
  274. })
  275. },
  276. merchantChange(item, index) {
  277. var m = item;
  278. var n = this.merchantList1[this.current];
  279. this.merchantList1[this.current] = m;
  280. this.merchantList2[index] = n;
  281. this.companyId = item.id;
  282. this.popShow = false;
  283. this.getList(true);
  284. },
  285. change(index) {
  286. this.current = index;
  287. this.companyId = this.merchantList1[index].id;
  288. // if (index != 0) {
  289. this.getList(true);
  290. // }
  291. },
  292. backStatistics() {
  293. uni.navigateBack()
  294. },
  295. toElectronicMonitoring(item) {
  296. uni.navigateTo({
  297. url: '/pages/equipmentDataMonitoring/electronicMonitoring?id=' + item.id + '&name=' + item.name +
  298. '&companyId=' + item.companyId
  299. })
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang="scss" scoped>
  305. page {
  306. padding-bottom: 100rpx;
  307. }
  308. .back {
  309. z-index: 999;
  310. width: 200rpx;
  311. }
  312. /deep/.u-drawer-content {
  313. margin-top: 88rpx;
  314. }
  315. /deep/.u-tab-item {
  316. width: 25% !important;
  317. flex: none !important;
  318. }
  319. .tabs-box {
  320. background-color: #fff;
  321. display: flex;
  322. align-items: center;
  323. padding: 32rpx 0;
  324. padding-right: 32rpx;
  325. justify-content: space-between;
  326. border-bottom: 1px solid rgba(232, 232, 232, 1);
  327. .tabs {
  328. width: 88%;
  329. }
  330. .icon {
  331. margin-left: auto;
  332. margin-right: 24rpx;
  333. }
  334. }
  335. .popup-tabs {
  336. background-color: #fff;
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. padding-right: 32rpx;
  341. color: rgba(51, 51, 51, 1);
  342. font-size: 32rpx;
  343. padding-top: 32rpx;
  344. .tabs {
  345. width: 88%;
  346. }
  347. }
  348. .tabs-options {
  349. display: flex;
  350. padding: 64rpx 32rpx 0;
  351. flex-wrap: wrap;
  352. .item {
  353. width: 25%;
  354. margin-bottom: 40rpx;
  355. }
  356. }
  357. /deep/.u-tab-item {
  358. width: 25% !important;
  359. flex: none !important;
  360. }
  361. // 用电量合计
  362. .total {
  363. padding: 24rpx 32rpx;
  364. background: linear-gradient(90deg, rgba(49, 110, 207, 1) 2%, rgba(37, 138, 255, 1) 100%);
  365. .company {
  366. display: flex;
  367. align-items: center;
  368. justify-content: space-between;
  369. .name {
  370. color: rgba(255, 255, 255, 1);
  371. font-size: 36rpx;
  372. font-weight: bold;
  373. }
  374. .amount {
  375. color: #f2f4f6;
  376. margin-top: 4rpx;
  377. }
  378. }
  379. .infos {
  380. display: flex;
  381. justify-content: space-between;
  382. align-items: center;
  383. margin-top: 4rpx;
  384. width: 93%;
  385. .infos-item {
  386. display: flex;
  387. width: 33.3%;
  388. .number {
  389. color: rgba(255, 255, 255, 1);
  390. font-size: 32rpx;
  391. font-weight: bold;
  392. margin-left: 8rpx;
  393. }
  394. .time {
  395. color: #f2f4f6;
  396. }
  397. }
  398. }
  399. }
  400. // 用电量
  401. .main {
  402. background-color: #fff;
  403. padding: 26rpx 32rpx;
  404. .item:last-of-type {
  405. border: none;
  406. }
  407. .item {
  408. padding: 16rpx 0;
  409. display: flex;
  410. align-items: center;
  411. justify-content: space-between;
  412. border-bottom: 1px solid rgba(245, 245, 245, 1);
  413. .item-content {
  414. width: 93%;
  415. }
  416. .equipment {
  417. display: flex;
  418. align-items: center;
  419. .equipment1 {
  420. color: rgba(51, 51, 51, 1);
  421. font-size: 32rpx;
  422. max-width: 40%;
  423. font-weight: bold;
  424. white-space: nowrap;
  425. overflow: hidden;
  426. text-overflow: ellipsis;
  427. }
  428. .equipment2 {
  429. color: rgba(119, 119, 119, 1);
  430. margin-left: 16rpx;
  431. max-width: 40%;
  432. white-space: nowrap;
  433. overflow: hidden;
  434. text-overflow: ellipsis;
  435. }
  436. }
  437. // 状态
  438. .state {
  439. display: flex;
  440. align-items: center;
  441. color: rgba(255, 123, 0, 1);
  442. margin-left: auto;
  443. .dot {
  444. margin-right: 8rpx;
  445. width: 16rpx;
  446. height: 16rpx;
  447. background-color: rgba(255, 123, 0, 1);
  448. border-radius: 999px;
  449. margin-left: auto;
  450. }
  451. .off-line {
  452. background-color: rgba(255, 123, 0, 1);
  453. }
  454. .on-line {
  455. background-color: rgba(0, 185, 98, 1);
  456. }
  457. }
  458. .state2 {
  459. color: rgba(0, 185, 98, 1);
  460. }
  461. .electricity {
  462. display: flex;
  463. justify-content: space-between;
  464. align-items: center;
  465. margin-top: 8rpx;
  466. text-align: center;
  467. .electricity-item {
  468. display: flex;
  469. align-items: center;
  470. width: 33.3%;
  471. .number {
  472. color: rgba(51, 51, 51, 1);
  473. font-weight: bold;
  474. font-size: 32rpx;
  475. margin-left: 8rpx;
  476. }
  477. .date {
  478. color: rgba(119, 119, 119, 1);
  479. }
  480. }
  481. }
  482. }
  483. }
  484. </style>