equipmentInformation.vue 13 KB

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