remoteControl.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. <view class="head-head">
  9. <u-search placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  10. </view>
  11. <view class="head-head-placeholder ">
  12. </view>
  13. <view class="tabs-box" v-if="!popShow&&false" >
  14. <view class="tabs1" v-show="tenantList.length>1" :style="{width: tenantList.length>4 ? '' : '100%'}" >
  15. <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  16. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs>
  17. </view>
  18. <view class="icon" @click="popShow=true" v-if="tenantList.length >= 4" >
  19. <u-icon name="arrow-down" color="#777777" size="28"></u-icon>
  20. </view>
  21. </view>
  22. <!-- 标签弹出层 -->
  23. <u-popup v-model="popShow" length="80%" @close="keyword=''" duration="10" mode="top" :negative-top="188" border-radius="32">
  24. <u-navbar title="远程控制" title-color="#101010" >
  25. <view class="u-nav-slot" slot="right" v-if="0" >
  26. 操作日志
  27. </view>
  28. </u-navbar>
  29. <view class="head-head">
  30. <u-search placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  31. </view>
  32. <view class="head-head-placeholder ">
  33. </view>
  34. <view class="popup-tabs" v-if="false">
  35. <view class="tabs1">
  36. <!-- <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  37. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
  38. <u-tabs :list="tenantList1" :is-scroll="false" :current="current" @change="change"></u-tabs >
  39. </view>
  40. <view class="more">
  41. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  42. </view>
  43. </view>
  44. <view class="tabs-options">
  45. <view class="item" v-for="(item, index) in tenantList"
  46. v-show="keyword==''||(item.name&&item.name.indexOf(keyword)!=-1)"
  47. :class="{
  48. 'item-index' : item.id==formData.tenantId
  49. }"
  50. :key="index"
  51. @click="merchantChange(item,index)">
  52. {{item.name}}
  53. </view>
  54. <u-divider nonetext="没有找到相关内容"
  55. border-color="#CFD2D5">已经到底了</u-divider>
  56. </view>
  57. </u-popup>
  58. <view class="main">
  59. <view class="switch"
  60. v-for="(item,i) in meterList"
  61. v-if="item.type!=6"
  62. v-show="(keyword==''||(item.name&&item.name.indexOf(keyword)!=-1))"
  63. @click="item.type!=6&&item.allowSwitch?gotoUrl('/pages/tenantList/switchDetail?id='+item.id):''"
  64. :key="i" >
  65. <view class="switch-name">
  66. <view class="name">
  67. {{item.name}}
  68. </view>
  69. <view class="place">
  70. {{item.installationAddressSimple}}
  71. </view>
  72. </view>
  73. <view class="switch-icon">
  74. <view class="icon icon2" v-if="role&&item.type!=6&&item.allowSwitch" >
  75. <img src="@/assets/img/switchIcon.png"
  76. @tap.stop="switchBtnApi(item,0)" class="img"
  77. v-if="item.switchStatus" alt="" ></img >
  78. <img src="@/assets/img/switchClose.png"
  79. @tap.stop="switchBtnApi(item,1)" class="img"
  80. v-else alt="" ></img >
  81. </view>
  82. <view v-else style=" display: flex; flex-direction: column;">
  83. <template v-if="item.type!=6">
  84. <span class="spanClass span1" v-if="item.switchStatus">开启</span>
  85. <span class="spanClass span2" v-else>关闭</span>
  86. <span class="spanClass span1" v-if="item.online">在线</span>
  87. <span class="spanClass span2" v-else>离线</span>
  88. </template>
  89. <template v-else>
  90. <span class="spanClass span1" >虚拟</span>
  91. </template>
  92. </view>
  93. <!-- <image class="img" src="@/assets/img/switch-open.png" ></image -->
  94. </view>
  95. </view>
  96. </view>
  97. <u-divider :isnone="meterList.length==0" nonetext="无记录"
  98. border-color="#CFD2D5">已经到底了</u-divider>
  99. </view>
  100. </template>
  101. <script>
  102. import * as API from '@/apis/pagejs/tenantList.js'
  103. import * as API_meterTimer from '@/apis/pagejs/meterTimer.js'
  104. export default {
  105. data() {
  106. return {
  107. formData:{},
  108. popShow:false,
  109. meterList:[],
  110. tenantList:[],
  111. tenantList1:[],
  112. remoteReadingMeterList:[],
  113. list1: [{
  114. name: '格莱慧'
  115. }, {
  116. name: '楚之源'
  117. }, {
  118. name: '杜宝银',
  119. }, {
  120. name: '王玉清',
  121. }, {
  122. name: '荆州万乘',
  123. }],
  124. list2: [{
  125. name: '全部'
  126. }, {
  127. name: '一楼大厅'
  128. }, {
  129. name: '门房',
  130. }, {
  131. name: '八楼',
  132. }, {
  133. name: '九楼',
  134. }],
  135. current:0,
  136. current1: 0,
  137. current2: 0,
  138. role:false,
  139. codes:"",
  140. keyword:'',
  141. }
  142. },
  143. onReady() {
  144. this.codes =this.carhelp.getPersonInfo().codes;
  145. this.role=this.codes&&this.codes.indexOf('switch')!=-1;
  146. //this.getTenantList()
  147. this.getHaveMeterList()
  148. },
  149. methods: {
  150. getHaveMeterList(){
  151. var data = {
  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?'开启':'关闭'}"${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.formData.tenantId = this.tenantList1[index].id;
  223. this.popShow = false;
  224. this.merchantChangeApi()
  225. },
  226. merchantChange(item, index) {
  227. // if(this.current==0){
  228. // this.current=1;
  229. // }
  230. this.formData.tenantId= item.id;
  231. //this.$forceUpdate()
  232. this.getTenantListSort(this.tenantList)
  233. this.merchantChangeApi()
  234. this.popShow = false;
  235. },
  236. getTenantList(){
  237. uni.showLoading({
  238. title: "加载中",
  239. mask: true,
  240. })
  241. API.tenantList().then((response) => {
  242. uni.hideLoading();
  243. var list=response.data.tenantInfoList;
  244. this.formData.tenantId=list[0].id
  245. this.getTenantListSort(list)
  246. this.merchantChangeApi()
  247. }).catch(error => {
  248. uni.showToast({
  249. title: error,
  250. icon: "none"
  251. })
  252. })
  253. },
  254. getTenantListSort(list){
  255. for(var i in list){
  256. var obj=list[i]
  257. if(this.formData.tenantId==obj.id){
  258. var obj1=list[this.current];
  259. list[this.current]=obj;
  260. list[i]=obj1;
  261. }
  262. }
  263. this.tenantList=list;
  264. var mList1 = [];
  265. for (var i = 0; i < list.length; i++) {
  266. if (i >= 4) {
  267. } else {
  268. mList1.push(list[i]);
  269. }
  270. }
  271. this.tenantList1 = mList1;
  272. },
  273. merchantChangeApi(){
  274. this.getTenantMeterList()
  275. },
  276. change1(index) {
  277. this.current1 = index;
  278. },
  279. change2(index) {
  280. this.current2 = index;
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. page{
  287. //background: url('@/assets/img/controlCover.png') center fixed ;
  288. //background-size:cover;
  289. }
  290. .u-nav-slot {
  291. margin-right: 32rpx;
  292. }
  293. // 标签
  294. .tabs-box{
  295. display: flex;
  296. align-items: center;
  297. justify-content: space-between;
  298. padding: 16rpx 32rpx 16rpx 0;
  299. .tabs{
  300. width: 96%;
  301. }
  302. /deep/.u-tabs{
  303. background-color: inherit !important
  304. }
  305. }
  306. .main{
  307. padding: 0 32rpx;
  308. display: flex;
  309. justify-content: space-between;
  310. flex-wrap: wrap;
  311. background: inherit;
  312. .switch{
  313. width: 100%;
  314. background-color: #fff;
  315. border-radius: 4px;
  316. padding: 24rpx 24rpx;
  317. display: flex;
  318. align-items: center;
  319. justify-content: space-between;
  320. margin: 18rpx 0;
  321. }
  322. .switch-name{
  323. margin-right: 2px;
  324. .name{
  325. color: rgba(51,51,51,1);
  326. font-size: 32rpx;
  327. font-weight: bold;
  328. }
  329. .place{
  330. color: rgba(119,119,119,1);
  331. font-size: 24rpx;
  332. }
  333. }
  334. .switch-icon{
  335. white-space: pre;
  336. .img{
  337. width: 64rpx;
  338. height: 64rpx;
  339. }
  340. }
  341. }
  342. // 标签
  343. .tabs-box{
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-between;
  347. padding: 16rpx 32rpx 16rpx 0;
  348. .tabs{
  349. width: 96%;
  350. }
  351. }
  352. .tabs-box{
  353. background-color: #fff;
  354. display: flex;
  355. align-items: center;
  356. justify-content: space-between;
  357. padding: 16rpx 32rpx 16rpx 32rpx;
  358. .tabs1{
  359. width: 96%;
  360. }
  361. }
  362. .popup-tabs {
  363. background-color: #fff;
  364. display: flex;
  365. align-items: center;
  366. justify-content: space-between;
  367. padding-top: 32rpx;
  368. padding-right: 32rpx;
  369. color: rgba(51, 51, 51, 1);
  370. font-size: 32rpx;
  371. .tabs1 {
  372. width: 88%;
  373. }
  374. }
  375. /deep/.u-tab-item {
  376. width: 25% !important;
  377. flex: none !important;
  378. }
  379. .tabs-options {
  380. //display: flex;
  381. padding: 24rpx 32rpx ;
  382. flex-wrap: wrap;
  383. .item {
  384. //width: 25%;
  385. color:rgb(119, 119, 119);
  386. margin-bottom: 24rpx;
  387. font-size: 32rpx;
  388. }
  389. .item-index{
  390. color: rgb(51, 51, 51);
  391. font-weight: bold;
  392. }
  393. }
  394. .spanClass{
  395. margin: 2px 0;
  396. padding: 2rpx 8rpx;
  397. border: 1px solid #00b962;
  398. color: #00b962;
  399. border-radius: 3px;
  400. white-space: pre;
  401. }
  402. .span2{
  403. border: 1px solid #ff7b00;
  404. color: #ff7b00;
  405. }
  406. .head-head{
  407. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.15);
  408. background: #fff;
  409. padding:24rpx;
  410. position: fixed;
  411. left: 0;
  412. right: 0;
  413. top: 80rpx;
  414. z-index: 991;
  415. }
  416. .head-head-placeholder{
  417. height: 112rpx;
  418. }
  419. </style>