remoteControl.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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="tabs-box" v-if="!popShow" >
  9. <view class="tabs1" v-show="tenantList.length>1" :style="{width: tenantList.length>4 ? '' : '100%'}" >
  10. <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  11. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs>
  12. </view>
  13. <view class="icon" @click="popShow=true" v-if="tenantList.length >= 4" >
  14. <u-icon name="arrow-down" color="#777777" size="28"></u-icon>
  15. </view>
  16. </view>
  17. <!-- 标签弹出层 -->
  18. <u-popup v-model="popShow" length="80%" @close="keyword=''" duration="10" mode="top" :negative-top="188" border-radius="32">
  19. <u-navbar title="远程控制" title-color="#101010" >
  20. <view class="u-nav-slot" slot="right" v-if="0" >
  21. 操作日志
  22. </view>
  23. </u-navbar>
  24. <view class="head-head">
  25. <u-search placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  26. </view>
  27. <view class="head-head-placeholder ">
  28. </view>
  29. <view class="popup-tabs" v-if="false">
  30. <view class="tabs1">
  31. <!-- <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  32. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
  33. <u-tabs :list="tenantList1" :is-scroll="false" :current="current" @change="change"></u-tabs >
  34. </view>
  35. <view class="more">
  36. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  37. </view>
  38. </view>
  39. <view class="tabs-options">
  40. <view class="item" v-for="(item, index) in tenantList"
  41. v-show="keyword==''||(item.name&&item.name.indexOf(keyword)!=-1)"
  42. :class="{
  43. 'item-index' : item.id==formData.tenantId
  44. }"
  45. :key="index"
  46. @click="merchantChange(item,index)">
  47. {{item.name}}
  48. </view>
  49. <u-divider nonetext="没有找到相关内容"
  50. border-color="#CFD2D5">已经到底了</u-divider>
  51. </view>
  52. </u-popup>
  53. <view class="main">
  54. <view class="switch"
  55. v-for="(item,i) in remoteReadingMeterList"
  56. @click="item.type!=6?gotoUrl('/pages/tenantList/switchDetail?id='+item.id):''"
  57. :key="i" >
  58. <view class="switch-name">
  59. <view class="name">
  60. {{item.name}}
  61. </view>
  62. <view class="place">
  63. {{item.installationAddressSimple}}
  64. </view>
  65. </view>
  66. <view class="switch-icon">
  67. <view class="icon icon2" v-if="role&&item.type!=6" >
  68. <img src="@/assets/img/switchIcon.png"
  69. @tap.stop="switchBtnApi(item,0)" class="img"
  70. v-if="item.switchStatus" alt="" ></img >
  71. <img src="@/assets/img/switchClose.png"
  72. @tap.stop="switchBtnApi(item,1)" class="img"
  73. v-else alt="" ></img >
  74. </view>
  75. <view v-else style=" display: flex; flex-direction: column;">
  76. <template v-if="item.type!=6">
  77. <span class="spanClass span1" v-if="item.switchStatus">开启</span>
  78. <span class="spanClass span2" v-else>关闭</span>
  79. <span class="spanClass span1" v-if="item.online">在线</span>
  80. <span class="spanClass span2" v-else>离线</span>
  81. </template>
  82. <template v-else>
  83. <span class="spanClass span1" >虚拟</span>
  84. </template>
  85. </view>
  86. <!-- <image class="img" src="@/assets/img/switch-open.png" ></image -->
  87. </view>
  88. </view>
  89. </view>
  90. <u-divider :isnone="remoteReadingMeterList.length==0" nonetext="无记录"
  91. border-color="#CFD2D5">已经到底了</u-divider>
  92. </view>
  93. </template>
  94. <script>
  95. import * as API from '@/apis/pagejs/tenantList.js'
  96. export default {
  97. data() {
  98. return {
  99. formData:{},
  100. popShow:false,
  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. current:0,
  127. current1: 0,
  128. current2: 0,
  129. role:false,
  130. codes:"",
  131. keyword:'',
  132. }
  133. },
  134. onReady() {
  135. this.codes =this.carhelp.getPersonInfo().codes;
  136. this.role=this.codes&&this.codes.indexOf('switch')!=-1;
  137. this.getTenantList()
  138. },
  139. methods: {
  140. switchBtnApiMethod(node,key){
  141. uni.showLoading({
  142. title: "加载中",
  143. mask: true,
  144. })
  145. API.remoteSwitch({
  146. meterId:node.id,
  147. enabled:key
  148. }).then((res) => {
  149. uni.hideLoading();
  150. node.switchStatus=key
  151. }).catch(error => {
  152. uni.showToast({
  153. title: error,
  154. icon: "none"
  155. })
  156. })
  157. },
  158. switchBtnApi(node,key){
  159. uni.showModal({
  160. confirmColor:`${key?'#3CC51F':'red'}`,
  161. confirmText:`${key?'开启':'关闭'}`,
  162. content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
  163. title: "提示",
  164. success:res=> {
  165. if(res.confirm){
  166. this.switchBtnApiMethod(node,key);
  167. }
  168. }
  169. })
  170. console.log(node,key)
  171. },
  172. getTenantMeterList(){
  173. uni.showLoading({
  174. mask:true,title:'加载中...'
  175. })
  176. API.tenantMeterList(this.formData).then((response) => {
  177. uni.hideLoading();
  178. //this.list=response.data.data;
  179. this.remoteReadingMeterList=response.data.remoteReadingMeterList
  180. }).catch(error => {
  181. uni.hideLoading();
  182. uni.showToast({
  183. icon: "none",
  184. title: error
  185. })
  186. })
  187. },
  188. change(index) {
  189. this.current = index;
  190. this.formData.tenantId = this.tenantList1[index].id;
  191. this.popShow = false;
  192. this.merchantChangeApi()
  193. },
  194. merchantChange(item, index) {
  195. // if(this.current==0){
  196. // this.current=1;
  197. // }
  198. this.formData.tenantId= item.id;
  199. //this.$forceUpdate()
  200. this.getTenantListSort(this.tenantList)
  201. this.merchantChangeApi()
  202. this.popShow = false;
  203. },
  204. getTenantList(){
  205. uni.showLoading({
  206. title: "加载中",
  207. mask: true,
  208. })
  209. API.tenantList().then((response) => {
  210. uni.hideLoading();
  211. var list=response.data.tenantInfoList;
  212. this.formData.tenantId=list[0].id
  213. this.getTenantListSort(list)
  214. this.merchantChangeApi()
  215. }).catch(error => {
  216. uni.showToast({
  217. title: error,
  218. icon: "none"
  219. })
  220. })
  221. },
  222. getTenantListSort(list){
  223. for(var i in list){
  224. var obj=list[i]
  225. if(this.formData.tenantId==obj.id){
  226. var obj1=list[this.current];
  227. list[this.current]=obj;
  228. list[i]=obj1;
  229. }
  230. }
  231. this.tenantList=list;
  232. var mList1 = [];
  233. for (var i = 0; i < list.length; i++) {
  234. if (i >= 4) {
  235. } else {
  236. mList1.push(list[i]);
  237. }
  238. }
  239. this.tenantList1 = mList1;
  240. },
  241. merchantChangeApi(){
  242. this.getTenantMeterList()
  243. },
  244. change1(index) {
  245. this.current1 = index;
  246. },
  247. change2(index) {
  248. this.current2 = index;
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. page{
  255. background: url('@/assets/img/controlCover.png') center fixed ;
  256. background-size:cover;
  257. }
  258. .u-nav-slot {
  259. margin-right: 32rpx;
  260. }
  261. // 标签
  262. .tabs-box{
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. padding: 16rpx 32rpx 16rpx 0;
  267. .tabs{
  268. width: 96%;
  269. }
  270. /deep/.u-tabs{
  271. background-color: inherit !important
  272. }
  273. }
  274. .main{
  275. padding: 0 32rpx;
  276. display: flex;
  277. justify-content: space-between;
  278. flex-wrap: wrap;
  279. background: inherit;
  280. .switch{
  281. width: 100%;
  282. background-color: #fff;
  283. border-radius: 12px;
  284. padding: 24rpx 24rpx;
  285. display: flex;
  286. align-items: center;
  287. justify-content: space-between;
  288. margin: 24rpx 0;
  289. }
  290. .switch-name{
  291. margin-right: 2px;
  292. .name{
  293. color: rgba(51,51,51,1);
  294. font-size: 32rpx;
  295. font-weight: bold;
  296. }
  297. .place{
  298. color: rgba(119,119,119,1);
  299. font-size: 24rpx;
  300. }
  301. }
  302. .switch-icon{
  303. white-space: pre;
  304. .img{
  305. width: 64rpx;
  306. height: 64rpx;
  307. }
  308. }
  309. }
  310. // 标签
  311. .tabs-box{
  312. display: flex;
  313. align-items: center;
  314. justify-content: space-between;
  315. padding: 16rpx 32rpx 16rpx 0;
  316. .tabs{
  317. width: 96%;
  318. }
  319. }
  320. .tabs-box{
  321. background-color: #fff;
  322. display: flex;
  323. align-items: center;
  324. justify-content: space-between;
  325. padding: 16rpx 32rpx 16rpx 32rpx;
  326. .tabs1{
  327. width: 96%;
  328. }
  329. }
  330. .popup-tabs {
  331. background-color: #fff;
  332. display: flex;
  333. align-items: center;
  334. justify-content: space-between;
  335. padding-top: 32rpx;
  336. padding-right: 32rpx;
  337. color: rgba(51, 51, 51, 1);
  338. font-size: 32rpx;
  339. .tabs1 {
  340. width: 88%;
  341. }
  342. }
  343. /deep/.u-tab-item {
  344. width: 25% !important;
  345. flex: none !important;
  346. }
  347. .tabs-options {
  348. //display: flex;
  349. padding: 24rpx 32rpx ;
  350. flex-wrap: wrap;
  351. .item {
  352. //width: 25%;
  353. color:rgb(119, 119, 119);
  354. margin-bottom: 24rpx;
  355. font-size: 32rpx;
  356. }
  357. .item-index{
  358. color: rgb(51, 51, 51);
  359. font-weight: bold;
  360. }
  361. }
  362. .spanClass{
  363. margin: 2px 0;
  364. padding: 2rpx 8rpx;
  365. border: 1px solid #00b962;
  366. color: #00b962;
  367. border-radius: 3px;
  368. white-space: pre;
  369. }
  370. .span2{
  371. border: 1px solid #ff7b00;
  372. color: #ff7b00;
  373. }
  374. .head-head{
  375. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.15);
  376. background: #fff;
  377. padding:24rpx;
  378. position: fixed;
  379. left: 0;
  380. right: 0;
  381. top: 80rpx;
  382. z-index: 991;
  383. }
  384. .head-head-placeholder{
  385. height: 112rpx;
  386. }
  387. </style>