remoteOpen.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <!-- 远程开门 -->
  2. <template>
  3. <view id="empowerOpen">
  4. <view class="header">
  5. <view class="header-n">
  6. <input class="header-l" type="text" @change="subNameChange()" v-model="getData.searchValue" placeholder="实验室名称">
  7. <view class="header-r" v-if="getData.searchValue" @click="clearSearch()">
  8. <img :src="imagesUrl('commonality/clear.png')">
  9. </view>
  10. </view>
  11. </view>
  12. <scroll-view scroll-y @scrolltolower="scrollGet" class="list">
  13. <view class="list-li" v-for="(item,index) in dataList">
  14. <view class="list-li-l">{{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}</view>
  15. <view class="list-li-r" @click="laboratoryGreenhouseDoorList(item)">
  16. <view class="null-p"></view>
  17. <view>开门</view>
  18. <view class="null-p"></view>
  19. </view>
  20. </view>
  21. <view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
  22. <view class="get-data-null-p" v-else="getDataType">- 滑动加载更多 -</view>
  23. </scroll-view>
  24. <view class="position-button" @click="goPage()">授权记录</view>
  25. <view class="success" v-if="successVisible">
  26. <view class="null-box" @click="closeTip()"></view>
  27. <view class="panel">
  28. <img class="panel-t" v-if="authorizeStatus==1||authorizeStatus==3" :src="imagesUrl('commonality/icon_kcxq_cg.png')"/>
  29. <img class="panel-t" v-if="authorizeStatus==2" :src="imagesUrl('commonality/icon_kcxq_sb.png')"/>
  30. <view class="panel-m">{{authorizeStatus==1?'开门成功':(authorizeStatus==2?'开门失败':(authorizeStatus==3?'开门中请稍后':''))}}
  31. </view>
  32. <view class="panel-b">({{count}}S)</view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. config
  40. } from '@/api/request/config.js'
  41. import {
  42. systemSubjectGetAppSubjectByLogin,
  43. laboratoryApplyRemoteOpenLock,
  44. applyRemoteOpenLockConfirm,
  45. laboratoryLabOpenLockLogUpdateLockData,
  46. laboratoryGreenhouseDoorList,
  47. laboratoryGreenhouseOpenDoorByDeviceId
  48. } from '@/pages_manage/api/index.js'
  49. export default {
  50. components: {
  51. },
  52. data() {
  53. return {
  54. pageType: 1,
  55. baseUrl: config.base_url,
  56. newData: {
  57. },
  58. addForm: {
  59. },
  60. dataList: [],
  61. authorizeStatus: 2, //1成功 2失败
  62. successVisible: false,
  63. timer: null,
  64. count: '',
  65. total: 0,
  66. getData: {
  67. page: 1,
  68. pageSize: 20,
  69. searchValue: '',
  70. // adminId: uni.getStorageSync('userId'),
  71. },
  72. getDataType: false,
  73. msgId:'',
  74. }
  75. },
  76. onLoad(option) {
  77. },
  78. onShow() {
  79. },
  80. mounted() {
  81. this.systemSubjectGetAppSubjectByLogin();
  82. },
  83. methods: {
  84. //跳转授权记录
  85. goPage(){
  86. uni.navigateTo({
  87. url: '/pages_manage/views/accessControl/authorizationRecord'
  88. });
  89. },
  90. openButton(row) {
  91. let self = this;
  92. uni.showModal({
  93. content: '确定对 ' + row.subName + ' 进行远程开门操作?',
  94. cancelColor: "#999",
  95. confirmColor: "#0183FA",
  96. success: function(res) {
  97. if (res.confirm) {
  98. self.openClick(row);
  99. }
  100. }
  101. });
  102. },
  103. //查询实验室门锁列表
  104. async laboratoryGreenhouseDoorList(item) {
  105. let self = this;
  106. let obj = {
  107. subId: item.subId,
  108. }
  109. const {
  110. data
  111. } = await laboratoryGreenhouseDoorList(obj);
  112. if (data.code == 200) {
  113. if(data.data[0]){
  114. if(!data.data[1]){
  115. //只返回1条数据时
  116. if(data.data[0].code == 'hikAccess'){
  117. self.laboratoryGreenhouseOpenDoorByDeviceId(data.data[0].id);
  118. }else{
  119. self.openClick(item)
  120. }
  121. }else{
  122. //返回多条数据时
  123. let list = [];
  124. for(let i=0;i<data.data.length;i++){
  125. list.push(data.data[i].deviceName)
  126. }
  127. uni.showActionSheet({
  128. itemList: list,
  129. success: function(res) {
  130. if(data.data[res.tapIndex].code == 'hikAccess'){
  131. self.laboratoryGreenhouseOpenDoorByDeviceId(data.data[res.tapIndex].id);
  132. }else{
  133. self.openClick(item)
  134. }
  135. },
  136. fail: function(res) {
  137. // console.log(res.errMsg);
  138. }
  139. });
  140. }
  141. }else{
  142. uni.showToast({
  143. mask: true,
  144. icon: "none",
  145. position: "center",
  146. title: '未找到实验室门锁,请联系管理员',
  147. duration: 2000
  148. });
  149. }
  150. }
  151. },
  152. //新开门
  153. async laboratoryGreenhouseOpenDoorByDeviceId(id){
  154. let self = this;
  155. let obj = {
  156. id: id,
  157. }
  158. const {
  159. data
  160. } = await laboratoryGreenhouseOpenDoorByDeviceId(obj);
  161. if (data.code == 200) {
  162. if(data.data){
  163. this.$set(this, 'authorizeStatus', 1)
  164. this.$set(this, 'successVisible', true)
  165. const TIME_COUNT = 5;
  166. if (!self.timer) {
  167. self.count = TIME_COUNT;
  168. self.show = false;
  169. self.timer = setInterval(() => {
  170. if (self.count > 0 && self.count <= TIME_COUNT) {
  171. self.count -= 1;
  172. } else {
  173. self.successVisible = false;
  174. clearInterval(self.timer);
  175. self.timer = null;
  176. }
  177. }, 1000);
  178. }
  179. }else{
  180. this.$set(this, 'authorizeStatus', 2)
  181. this.$set(this, 'successVisible', true)
  182. const TIME_COUNT = 3;
  183. if (!this.timer) {
  184. this.count = TIME_COUNT;
  185. this.show = false;
  186. this.timer = setInterval(() => {
  187. if (this.count > 0 && this.count <= TIME_COUNT) {
  188. this.count -= 1;
  189. } else {
  190. self.successVisible = false;
  191. clearInterval(this.timer);
  192. this.timer = null;
  193. }
  194. }, 1000);
  195. }
  196. }
  197. }
  198. },
  199. //旧开门(电子信息牌开门)
  200. async openClick(row) {
  201. let self = this;
  202. let obj = {
  203. labId: row.subId,
  204. }
  205. const {
  206. data
  207. } = await laboratoryApplyRemoteOpenLock(obj);
  208. if (data.code == 200) {
  209. if (data.data[0]) {
  210. this.$set(this, 'msgId', data.data[0])
  211. this.$set(this, 'authorizeStatus', 3)
  212. this.$set(this, 'successVisible', true)
  213. this.getMsg(row.subId);
  214. }else{
  215. this.$set(this, 'authorizeStatus', 2)
  216. this.$set(this, 'successVisible', true)
  217. this.getCode();
  218. }
  219. }
  220. },
  221. async applyRemoteOpenLockConfirm(subId) {
  222. let self = this;
  223. let obj = {
  224. messageId: this.msgId,
  225. }
  226. const {
  227. data
  228. } = await applyRemoteOpenLockConfirm(obj);
  229. if (data.code == 200) {
  230. if (data.data) {
  231. this.$set(this, 'authorizeStatus', 1)
  232. this.$set(this, 'successVisible', true)
  233. this.laboratoryLabOpenLockLogUpdateLockData(subId,1);
  234. this.getCode();
  235. } else {
  236. this.$set(this, 'authorizeStatus', 2)
  237. this.$set(this, 'successVisible', true)
  238. this.laboratoryLabOpenLockLogUpdateLockData(subId,0);
  239. this.getCode();
  240. }
  241. this.$set(this, 'msgId','')
  242. }
  243. },
  244. async laboratoryLabOpenLockLogUpdateLockData(subId,type) {
  245. let self = this;
  246. let obj = {
  247. subjectId: subId,
  248. userId: uni.getStorageSync('userId'),
  249. openStatus:type
  250. }
  251. const {
  252. data
  253. } = await laboratoryLabOpenLockLogUpdateLockData(obj);
  254. if(data.code == 200) {
  255. }
  256. },
  257. //滚动加载事件
  258. scrollGet() {
  259. let self = this;
  260. if (self.total / self.getData.pageSize <= self.getData.page) {
  261. this.$set(this, 'getDataType', true);
  262. } else {
  263. this.getData.page += 1;
  264. this.$nextTick(() => {
  265. this.systemSubjectGetAppSubjectByLogin();
  266. })
  267. }
  268. },
  269. //获取实验室
  270. async systemSubjectGetAppSubjectByLogin() {
  271. let self = this;
  272. const {
  273. data
  274. } = await systemSubjectGetAppSubjectByLogin(this.getData);
  275. if (data.code == 200) {
  276. if (self.getData.page == 1) {
  277. this.dataList = data.data.records;
  278. this.total = data.data.total;
  279. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  280. this.$set(this, 'getDataType', true);
  281. }
  282. } else {
  283. this.dataList = [...this.dataList, ...data.data.records]
  284. this.total = data.data.total;
  285. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  286. this.$set(this, 'getDataType', true);
  287. }
  288. }
  289. }
  290. },
  291. //实验室搜索
  292. subNameChange() {
  293. this.$set(this, 'getDataType', false);
  294. this.$set(this, 'dataList', []);
  295. this.$set(this, 'total', 0);
  296. this.$set(this.getData, 'page', 1);
  297. this.systemSubjectGetAppSubjectByLogin();
  298. },
  299. //实验室搜索框清除
  300. clearSearch() {
  301. this.$set(this, 'getDataType', false);
  302. this.$set(this, 'dataList', []);
  303. this.$set(this, 'total', 0);
  304. this.$set(this.getData, 'page', 1);
  305. this.$set(this.getData, 'searchValue', '');
  306. this.systemSubjectGetAppSubjectByLogin();
  307. },
  308. //关闭弹框倒计时
  309. getMsg(subId) {
  310. let self = this;
  311. const TIME_COUNT = 5;
  312. if (!self.timer) {
  313. self.count = TIME_COUNT;
  314. self.show = false;
  315. self.timer = setInterval(() => {
  316. if (self.count > 0 && self.count <= TIME_COUNT) {
  317. self.count -= 1;
  318. } else {
  319. self.successVisible = false;
  320. clearInterval(self.timer);
  321. self.timer = null;
  322. self.applyRemoteOpenLockConfirm(subId);
  323. }
  324. }, 1000);
  325. }
  326. },
  327. //关闭弹框倒计时
  328. getCode() {
  329. let self = this;
  330. const TIME_COUNT = 3;
  331. if (!this.timer) {
  332. this.count = TIME_COUNT;
  333. this.show = false;
  334. this.timer = setInterval(() => {
  335. if (this.count > 0 && this.count <= TIME_COUNT) {
  336. this.count -= 1;
  337. } else {
  338. self.successVisible = false;
  339. clearInterval(this.timer);
  340. this.timer = null;
  341. }
  342. }, 1000);
  343. }
  344. },
  345. closeTip() {
  346. this.$set(this, 'successVisible', false)
  347. },
  348. }
  349. }
  350. </script>
  351. <style lang="stylus" scoped>
  352. #empowerOpen {
  353. height: 100%;
  354. display flex;
  355. flex-direction column;
  356. .header {
  357. width: 749rpx;
  358. height: 120rpx;
  359. background: #FFFFFF;
  360. padding: 20rpx 30rpx;
  361. box-sizing: border-box;
  362. border-bottom: 1rpx solid #D8D8D8;
  363. .header-n {
  364. position: relative;
  365. width: 690rpx;
  366. height: 80rpx;
  367. border-radius: 10rpx 10rpx 10rpx 10rpx;
  368. border: 1rpx solid #E0E0E0;
  369. padding-left: 20rpx;
  370. box-sizing: border-box;
  371. .header-l {
  372. width: 590rpx;
  373. height: 80rpx;
  374. }
  375. .header-r {
  376. position: absolute;
  377. top: 0rpx;
  378. right: 0rpx;
  379. width: 68rpx;
  380. height: 80rpx;
  381. >img {
  382. width: 24rpx;
  383. height: 24rpx;
  384. margin-top: 24rpx;
  385. margin-left: 24rpx;
  386. }
  387. }
  388. }
  389. }
  390. .position-button{
  391. position: absolute;
  392. bottom:50rpx;
  393. left:75rpx;
  394. width:600rpx;
  395. height:100rpx;
  396. line-height:100rpx;
  397. text-align: center;
  398. background-color: #0183FA;
  399. font-size:28rpx;
  400. color:#fff;
  401. border-radius:20rpx;
  402. }
  403. .list {
  404. flex: 1;
  405. overflow-y scroll;
  406. padding: 0 30rpx;
  407. box-sizing: border-box;
  408. background: #fff;
  409. padding-bottom:160rpx;
  410. .list-li {
  411. // height: 90rpx;
  412. display: flex;
  413. // justify-content: space-between;
  414. // align-items: center;
  415. border-bottom: 1rpx solid #D8D8D8;
  416. .list-li-l {
  417. flex: 1;
  418. font-family: PingFang SC, PingFang SC;
  419. font-weight: 400;
  420. font-size: 30rpx;
  421. color: #333333;
  422. line-height: 40rpx;
  423. padding: 25rpx 25rpx 25rpx 0;
  424. }
  425. .list-li-r {
  426. font-family: PingFang SC, PingFang SC;
  427. font-weight: 400;
  428. font-size: 28rpx;
  429. color: #0183FA;
  430. line-height: 90rpx;
  431. display: flex;
  432. flex-direction: column;
  433. text-align: right;
  434. width: 80rpx;
  435. .null-p {
  436. flex: 1;
  437. }
  438. }
  439. }
  440. .list-li:last-child {
  441. border-bottom: none;
  442. }
  443. }
  444. .null-img {
  445. display block;
  446. width: 276rpx;
  447. height: 321rpx;
  448. position absolute;
  449. top: 200rpx;
  450. left: 238rpx;
  451. }
  452. .get-data-null-p {
  453. text-align: center;
  454. line-height: 100rpx;
  455. padding-bottom: 80px;
  456. color: #999;
  457. }
  458. .success {
  459. height: 100%;
  460. width: 100%;
  461. position: fixed;
  462. top: 0;
  463. display: flex;
  464. flex-direction: column;
  465. z-index: 10;
  466. background: rgba(0, 0, 0, 0.2);
  467. .null-box {
  468. flex: 1;
  469. }
  470. .panel {
  471. width: 550rpx;
  472. height: 255rpx;
  473. background: #FFFFFF;
  474. border-radius: 20rpx 20rpx 20rpx 20rpx;
  475. position: absolute;
  476. top: 320rpx;
  477. left: 100rpx;
  478. display: flex;
  479. flex-direction: column;
  480. align-items: center;
  481. .panel-t {
  482. width: 80rpx;
  483. height: 80rpx;
  484. margin: 40rpx 0 18rpx 0;
  485. }
  486. .panel-m {
  487. font-family: PingFang SC, PingFang SC;
  488. font-weight: 400;
  489. font-size: 30rpx;
  490. color: #3D3D3D;
  491. line-height: 42rpx;
  492. margin-bottom: 8rpx;
  493. }
  494. .panel-b {
  495. font-family: PingFang SC, PingFang SC;
  496. font-weight: 400;
  497. font-size: 30rpx;
  498. color: #999999;
  499. line-height: 42rpx;
  500. }
  501. }
  502. }
  503. }
  504. </style>