equipmentElectricity.vue 9.9 KB

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