remoteControl.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view>
  3. <u-navbar title="远程控制" title-color="#101010" >
  4. <view class="u-nav-slot" slot="right" @click="gotoUrl('/pages/tenantList/operationLog')" >
  5. 操作日志
  6. </view>
  7. </u-navbar>
  8. <!-- 标签 -->
  9. <view class="head-head">
  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. <u-search style="padding:24rpx 24rpx 0 24rpx ;" placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  22. </view>
  23. <view class="head-head-placeholder " :class="{
  24. 'head-head-placeholder2':companyList.length>1
  25. }">
  26. </view>
  27. <!-- 标签弹出层 -->
  28. <u-popup v-model="popShow" duration="10" mode="top" :negative-top="88" border-radius="16">
  29. <view class="popup-tabs">
  30. <view class="tabs">
  31. <u-tabs :list="merchantList1" :is-scroll="false" :current="current" @change="change"></u-tabs>
  32. </view>
  33. <view class="more">
  34. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  35. </view>
  36. </view>
  37. <view class="tabs-options">
  38. <view class="item" v-for="(item, index) in merchantList2" :key="index"
  39. @click="merchantChange(item,index)">
  40. {{item.name}}
  41. </view>
  42. </view>
  43. </u-popup>
  44. <view class="main">
  45. <view class="switch"
  46. v-for="(item,i) in meterList"
  47. v-show="(keyword==''||(item.name&&item.name.indexOf(keyword)!=-1))"
  48. @click="item.allowSwitch?gotoUrl('/pages/tenantList/switchDetail?id='+item.id):''"
  49. :key="i" >
  50. <view class="switch-name">
  51. <view class="name">
  52. <span class="spanClass " :style="{
  53. borderColor:colorList[item.type%7],
  54. background:colorList[item.type%7],
  55. fontSize: '24rpx',
  56. margin:'2rpx 8rpx 2rpx 0',
  57. color:'#fff',
  58. }" >{{item.typeN}}</span>
  59. <span class="name2">{{replaceLastTwoWords(item.name)}}</span>
  60. </view>
  61. <view class="place">
  62. {{item.installationAddressSimple}}
  63. </view>
  64. </view>
  65. <view class="switch-icon">
  66. <view class="icon icon2" v-if="role&&item.allowSwitch" >
  67. <img src="@/assets/img/switchIcon.png"
  68. @tap.stop="switchBtnApi(item,0)" class="img"
  69. v-if="item.switchStatus" alt="" ></img >
  70. <img src="@/assets/img/switchClose.png"
  71. @tap.stop="switchBtnApi(item,1)" class="img"
  72. v-else alt="" ></img >
  73. </view>
  74. <view v-else style=" display: flex; flex-direction: column;">
  75. <template >
  76. <!-- <span class="spanClass span1" v-if="item.switchStatus">开启</span>
  77. <span class="spanClass span2" v-else>关闭</span>
  78. -->
  79. <span class="spanClass span1" v-if="item.online">在线</span>
  80. <span class="spanClass span2" v-else>离线</span>
  81. </template>
  82. </view>
  83. <!-- <image class="img" src="@/assets/img/switch-open.png" ></image -->
  84. </view>
  85. </view>
  86. </view>
  87. <u-divider :isnone="meterList.length==0" nonetext="无记录"
  88. border-color="#CFD2D5">已经到底了</u-divider>
  89. </view>
  90. </template>
  91. <script>
  92. import * as API from '@/apis/pagejs/tenantList.js'
  93. import * as API_meterTimer from '@/apis/pagejs/meterTimer.js'
  94. import * as API_energyManage from '@/apis/pagejs/energyManage.js'
  95. export default {
  96. data() {
  97. return {
  98. formData:{},
  99. popShow:false,
  100. meterList:[],
  101. tenantList:[],
  102. tenantList1:[],
  103. remoteReadingMeterList:[],
  104. list1: [{
  105. name: '格莱慧'
  106. }, {
  107. name: '楚之源'
  108. }, {
  109. name: '杜宝银',
  110. }, {
  111. name: '王玉清',
  112. }, {
  113. name: '荆州万乘',
  114. }],
  115. list2: [{
  116. name: '全部'
  117. }, {
  118. name: '一楼大厅'
  119. }, {
  120. name: '门房',
  121. }, {
  122. name: '八楼',
  123. }, {
  124. name: '九楼',
  125. }],
  126. merchantList1: [], // 商户
  127. merchantList2: [],
  128. companyList: [],
  129. current:0,
  130. current1: 0,
  131. current2: 0,
  132. role:false,
  133. codes:"",
  134. companyId:"",
  135. utabsone:true,
  136. keyword:'',
  137. colorList:['',"#52b8aa","#53b56b","#ef8132",
  138. "#307af6","#5cb657","#777777"],
  139. }
  140. },
  141. onReady() {
  142. this.codes =this.carhelp.getPersonInfo().codes;
  143. this.role=this.codes&&this.codes.indexOf('switch')!=-1;
  144. //this.getTenantList()
  145. this.getHaveMeterList()
  146. this.getCompanyInfoList();
  147. },
  148. methods: {
  149. getHaveMeterList(){
  150. var data = {
  151. companyId:this.companyId,
  152. queryForm:"property",
  153. };
  154. API_meterTimer.haveMeterList(data).then((response) => {
  155. //var MeterList=response.data.switchRecordList.data
  156. var meterList = response.data.remoteReadingMeterList;
  157. meterList=meterList.sort((item1,item2)=>{
  158. if(item1.sortNo==item2.sortNo){
  159. return item1.level>item2.level?1:-1
  160. }
  161. return item1.sortNo>item2.sortNo?1:-1
  162. })
  163. this.meterList=meterList
  164. //this.recordsTotal = response.data.switchRecordList.recordsTotal;
  165. }).catch(error => {
  166. uni.showToast({
  167. title: error,
  168. icon: "none"
  169. })
  170. })
  171. },
  172. switchBtnApiMethod(node,key){
  173. uni.showLoading({
  174. title: "加载中",
  175. mask: true,
  176. })
  177. API.remoteSwitch({
  178. meterId:node.id,
  179. enabled:key
  180. }).then((res) => {
  181. uni.hideLoading();
  182. node.switchStatus=key
  183. }).catch(error => {
  184. uni.showToast({
  185. title: error,
  186. icon: "none"
  187. })
  188. })
  189. },
  190. switchBtnApi(node,key){
  191. uni.showModal({
  192. confirmColor:`${key?'#3CC51F':'red'}`,
  193. confirmText:`${key?'开启':'关闭'}`,
  194. content: `确认是否要"${key?'开启':'关闭'}"${this.replaceLastTwoWords(node.name)}`,
  195. title: "提示",
  196. success:res=> {
  197. if(res.confirm){
  198. this.switchBtnApiMethod(node,key);
  199. }
  200. }
  201. })
  202. console.log(node,key)
  203. },
  204. getTenantMeterList(){
  205. uni.showLoading({
  206. mask:true,title:'加载中...'
  207. })
  208. API.tenantMeterList(this.formData).then((response) => {
  209. uni.hideLoading();
  210. //this.list=response.data.data;
  211. this.remoteReadingMeterList=response.data.remoteReadingMeterList
  212. }).catch(error => {
  213. uni.hideLoading();
  214. uni.showToast({
  215. icon: "none",
  216. title: error
  217. })
  218. })
  219. },
  220. change(index) {
  221. this.current = index;
  222. this.companyId = this.merchantList1[index].id;
  223. // this.companyIdSet(this.companyId)
  224. this.popShow = false;
  225. this.merchantChangeApi()
  226. },
  227. merchantChange(item, index) {
  228. if(this.current==0){
  229. this.current=1;
  230. }
  231. this.utabsone=false
  232. var m = item;
  233. var n = this.merchantList1[this.current];
  234. this.merchantList1[this.current] = m;
  235. this.merchantList2[index] = n;
  236. this.companyId = item.id;
  237. this.popShow = false;
  238. this.$nextTick(()=>{
  239. this.utabsone=true
  240. })
  241. //this.getList(true);
  242. this.merchantChangeApi()
  243. },
  244. getTenantList(){
  245. uni.showLoading({
  246. title: "加载中",
  247. mask: true,
  248. })
  249. API.tenantList().then((response) => {
  250. uni.hideLoading();
  251. var list=response.data.tenantInfoList;
  252. this.formData.tenantId=list[0].id
  253. this.getTenantListSort(list)
  254. this.merchantChangeApi()
  255. }).catch(error => {
  256. uni.showToast({
  257. title: error,
  258. icon: "none"
  259. })
  260. })
  261. },
  262. getTenantListSort(list){
  263. for(var i in list){
  264. var obj=list[i]
  265. if(this.formData.tenantId==obj.id){
  266. var obj1=list[this.current];
  267. list[this.current]=obj;
  268. list[i]=obj1;
  269. }
  270. }
  271. this.tenantList=list;
  272. var mList1 = [];
  273. for (var i = 0; i < list.length; i++) {
  274. if (i >= 4) {
  275. } else {
  276. mList1.push(list[i]);
  277. }
  278. }
  279. this.tenantList1 = mList1;
  280. },
  281. getCompanyInfoList() {
  282. // uni.showLoading({
  283. // title: "加载中",
  284. // mask: true,
  285. // })
  286. API_energyManage.deviceCompanyList().then((response) => {
  287. //uni.hideLoading();
  288. var list = response.data.companyInfoList;
  289. var mList1 = [];
  290. var mList2 = [];
  291. mList1.push({
  292. id: '',
  293. name: '全部'
  294. });
  295. for (var i = 0; i < list.length; i++) {
  296. if (i >= 3) {
  297. mList2.push(list[i]);
  298. } else {
  299. mList1.push(list[i]);
  300. }
  301. }
  302. this.companyList = list;
  303. // if(list.length==1){
  304. // this.companyId=list[0].id
  305. // this.companyIdSet(this.companyId)
  306. // }else{
  307. // this.getHomePageKwh('')
  308. // }
  309. this.merchantList1 = mList1;
  310. this.merchantList2 = mList2;
  311. //this.merchantChangeApi()
  312. }).catch(error => {
  313. uni.showToast({
  314. title: error,
  315. icon: "none"
  316. })
  317. })
  318. },
  319. merchantChangeApi(){
  320. // this.getTenantMeterList()
  321. this.getHaveMeterList()
  322. },
  323. change1(index) {
  324. this.current1 = index;
  325. },
  326. change2(index) {
  327. this.current2 = index;
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. page{
  334. //background: url('@/assets/img/controlCover.png') center fixed ;
  335. //background-size:cover;
  336. }
  337. .u-nav-slot {
  338. margin-right: 32rpx;
  339. }
  340. // 标签
  341. .main{
  342. padding: 0 32rpx;
  343. display: flex;
  344. justify-content: space-between;
  345. flex-wrap: wrap;
  346. background: inherit;
  347. .switch{
  348. width: 100%;
  349. background-color: #fff;
  350. border-radius: 4px;
  351. padding: 24rpx 24rpx;
  352. display: flex;
  353. align-items: center;
  354. justify-content: space-between;
  355. margin: 18rpx 0;
  356. }
  357. .switch-name{
  358. margin-right: 2px;
  359. width: 85%;
  360. .name{
  361. color: rgba(51,51,51,1);
  362. font-size: 32rpx;
  363. font-weight: bold;
  364. display: flex;
  365. align-items: center;
  366. }
  367. .name2{
  368. overflow: hidden;
  369. white-space: nowrap;
  370. text-overflow: ellipsis;
  371. width: 552rpx;
  372. }
  373. .place{
  374. margin-top: 12rpx;
  375. color: rgba(119,119,119,1);
  376. font-size: 24rpx;
  377. }
  378. }
  379. .switch-icon{
  380. white-space: pre;
  381. .img{
  382. width: 64rpx;
  383. height: 64rpx;
  384. }
  385. }
  386. }
  387. .popup-tabs {
  388. background-color: #fff;
  389. display: flex;
  390. align-items: center;
  391. justify-content: space-between;
  392. padding-top: 32rpx;
  393. padding-right: 32rpx;
  394. color: rgba(51, 51, 51, 1);
  395. font-size: 32rpx;
  396. .tabs1 {
  397. width: 88%;
  398. }
  399. }
  400. /deep/.u-tab-item {
  401. width: 25% !important;
  402. flex: none !important;
  403. }
  404. .tabs-options {
  405. //display: flex;
  406. padding: 24rpx 32rpx ;
  407. flex-wrap: wrap;
  408. .item {
  409. //width: 25%;
  410. color:rgb(119, 119, 119);
  411. margin-bottom: 24rpx;
  412. font-size: 32rpx;
  413. }
  414. .item-index{
  415. color: rgb(51, 51, 51);
  416. font-weight: bold;
  417. }
  418. }
  419. .spanClass{
  420. margin: 2px 0;
  421. padding: 2rpx 8rpx;
  422. border: 1px solid #00b962;
  423. color: #00b962;
  424. border-radius: 3px;
  425. white-space: pre;
  426. }
  427. .span2{
  428. border: 1px solid #ff7b00;
  429. color: #ff7b00;
  430. }
  431. .head-head{
  432. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.15);
  433. background: #fff;
  434. padding:24rpx 0;
  435. position: fixed;
  436. left: 0;
  437. right: 0;
  438. top: 80rpx;
  439. z-index: 991;
  440. }
  441. .head-head-placeholder{
  442. height: 138rpx;
  443. }
  444. .head-head-placeholder2{
  445. height: 212rpx;
  446. }
  447. // 标签
  448. .tabs-box {
  449. background-color: #fff;
  450. display: flex;
  451. align-items: center;
  452. padding-right: 32rpx;
  453. justify-content: space-between;
  454. border-bottom: 1px solid rgba(232, 232, 232, 1);
  455. .tabs {
  456. width: 97%;
  457. }
  458. .more{
  459. padding-right: 12rpx;
  460. }
  461. .icon {
  462. margin-left: auto;
  463. margin-right: 24rpx;
  464. }
  465. }
  466. .tabs-len-1{
  467. }
  468. .tabs-len-2{
  469. /deep/.u-tab-item {
  470. // max-width: 39% !important;
  471. // flex: none !important;
  472. }
  473. }
  474. .tabs-len-3{
  475. /deep/.u-tab-item {
  476. max-width: 39% !important;
  477. flex: none !important;
  478. }
  479. }
  480. .tabs-len-4{
  481. /deep/.u-tab-item {
  482. max-width: 26% !important;
  483. flex: none !important;
  484. }
  485. }
  486. /deep/.u-tab-item:first-child {
  487. width: 20% !important;
  488. flex: none !important;
  489. }
  490. </style>