equipmentElectricity.vue 11 KB

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