remoteOpen.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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="openButton(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. } from '@/pages_manage/api/index.js'
  47. export default {
  48. components: {
  49. },
  50. data() {
  51. return {
  52. pageType: 1,
  53. baseUrl: config.base_url,
  54. newData: {
  55. },
  56. addForm: {
  57. },
  58. dataList: [],
  59. authorizeStatus: 2, //1成功 2失败
  60. successVisible: false,
  61. timer: null,
  62. count: '',
  63. total: 0,
  64. getData: {
  65. page: 1,
  66. pageSize: 20,
  67. searchValue: '',
  68. // adminId: uni.getStorageSync('userId'),
  69. },
  70. getDataType: false,
  71. msgId:'',
  72. }
  73. },
  74. onLoad(option) {
  75. },
  76. onShow() {
  77. },
  78. mounted() {
  79. this.systemSubjectGetAppSubjectByLogin();
  80. },
  81. methods: {
  82. //跳转授权记录
  83. goPage(){
  84. uni.navigateTo({
  85. url: '/pages_manage/views/accessControl/authorizationRecord'
  86. });
  87. },
  88. openButton(row) {
  89. let self = this;
  90. uni.showModal({
  91. content: '确定对 ' + row.subName + ' 进行远程开门操作?',
  92. cancelColor: "#999",
  93. confirmColor: "#0183FA",
  94. success: function(res) {
  95. if (res.confirm) {
  96. self.openClick(row);
  97. }
  98. }
  99. });
  100. },
  101. //开门
  102. async openClick(row) {
  103. let self = this;
  104. let obj = {
  105. labId: row.subId,
  106. }
  107. const {
  108. data
  109. } = await laboratoryApplyRemoteOpenLock(obj);
  110. if (data.code == 200) {
  111. if (data.data[0]) {
  112. this.$set(this, 'msgId', data.data[0])
  113. this.$set(this, 'authorizeStatus', 3)
  114. this.$set(this, 'successVisible', true)
  115. this.getMsg(row.subId);
  116. }else{
  117. this.$set(this, 'authorizeStatus', 2)
  118. this.$set(this, 'successVisible', true)
  119. this.getCode();
  120. }
  121. }
  122. },
  123. async applyRemoteOpenLockConfirm(subId) {
  124. let self = this;
  125. let obj = {
  126. messageId: this.msgId,
  127. }
  128. const {
  129. data
  130. } = await applyRemoteOpenLockConfirm(obj);
  131. if (data.code == 200) {
  132. if (data.data) {
  133. this.$set(this, 'authorizeStatus', 1)
  134. this.$set(this, 'successVisible', true)
  135. this.laboratoryLabOpenLockLogUpdateLockData(subId,1);
  136. this.getCode();
  137. } else {
  138. this.$set(this, 'authorizeStatus', 2)
  139. this.$set(this, 'successVisible', true)
  140. this.laboratoryLabOpenLockLogUpdateLockData(subId,0);
  141. this.getCode();
  142. }
  143. this.$set(this, 'msgId','')
  144. }
  145. },
  146. async laboratoryLabOpenLockLogUpdateLockData(subId,type) {
  147. let self = this;
  148. let obj = {
  149. subjectId: subId,
  150. userId: uni.getStorageSync('userId'),
  151. openStatus:type
  152. }
  153. const {
  154. data
  155. } = await laboratoryLabOpenLockLogUpdateLockData(obj);
  156. if(data.code == 200) {
  157. }
  158. },
  159. //滚动加载事件
  160. scrollGet() {
  161. let self = this;
  162. if (self.total / self.getData.pageSize <= self.getData.page) {
  163. this.$set(this, 'getDataType', true);
  164. } else {
  165. this.getData.page += 1;
  166. this.$nextTick(() => {
  167. this.systemSubjectGetAppSubjectByLogin();
  168. })
  169. }
  170. },
  171. //获取实验室
  172. async systemSubjectGetAppSubjectByLogin() {
  173. let self = this;
  174. const {
  175. data
  176. } = await systemSubjectGetAppSubjectByLogin(this.getData);
  177. if (data.code == 200) {
  178. if (self.getData.page == 1) {
  179. this.dataList = data.data.records;
  180. this.total = data.data.total;
  181. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  182. this.$set(this, 'getDataType', true);
  183. }
  184. } else {
  185. this.dataList = [...this.dataList, ...data.data.records]
  186. this.total = data.data.total;
  187. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  188. this.$set(this, 'getDataType', true);
  189. }
  190. }
  191. }
  192. },
  193. //实验室搜索
  194. subNameChange() {
  195. this.$set(this, 'getDataType', false);
  196. this.$set(this, 'dataList', []);
  197. this.$set(this, 'total', 0);
  198. this.$set(this.getData, 'page', 1);
  199. this.systemSubjectGetAppSubjectByLogin();
  200. },
  201. //实验室搜索框清除
  202. clearSearch() {
  203. this.$set(this, 'getDataType', false);
  204. this.$set(this, 'dataList', []);
  205. this.$set(this, 'total', 0);
  206. this.$set(this.getData, 'page', 1);
  207. this.$set(this.getData, 'searchValue', '');
  208. this.systemSubjectGetAppSubjectByLogin();
  209. },
  210. //关闭弹框倒计时
  211. getMsg(subId) {
  212. let self = this;
  213. const TIME_COUNT = 5;
  214. if (!self.timer) {
  215. self.count = TIME_COUNT;
  216. self.show = false;
  217. self.timer = setInterval(() => {
  218. if (self.count > 0 && self.count <= TIME_COUNT) {
  219. self.count -= 1;
  220. } else {
  221. self.successVisible = false;
  222. clearInterval(self.timer);
  223. self.timer = null;
  224. self.applyRemoteOpenLockConfirm(subId);
  225. }
  226. }, 1000);
  227. }
  228. },
  229. //关闭弹框倒计时
  230. getCode() {
  231. let self = this;
  232. const TIME_COUNT = 3;
  233. if (!this.timer) {
  234. this.count = TIME_COUNT;
  235. this.show = false;
  236. this.timer = setInterval(() => {
  237. if (this.count > 0 && this.count <= TIME_COUNT) {
  238. this.count -= 1;
  239. } else {
  240. self.successVisible = false;
  241. clearInterval(this.timer);
  242. this.timer = null;
  243. }
  244. }, 1000);
  245. }
  246. },
  247. closeTip() {
  248. this.$set(this, 'successVisible', false)
  249. },
  250. }
  251. }
  252. </script>
  253. <style lang="stylus" scoped>
  254. #empowerOpen {
  255. height: 100%;
  256. display flex;
  257. flex-direction column;
  258. .header {
  259. width: 749rpx;
  260. height: 120rpx;
  261. background: #FFFFFF;
  262. padding: 20rpx 30rpx;
  263. box-sizing: border-box;
  264. border-bottom: 1rpx solid #D8D8D8;
  265. .header-n {
  266. position: relative;
  267. width: 690rpx;
  268. height: 80rpx;
  269. border-radius: 10rpx 10rpx 10rpx 10rpx;
  270. border: 1rpx solid #E0E0E0;
  271. padding-left: 20rpx;
  272. box-sizing: border-box;
  273. .header-l {
  274. width: 590rpx;
  275. height: 80rpx;
  276. }
  277. .header-r {
  278. position: absolute;
  279. top: 0rpx;
  280. right: 0rpx;
  281. width: 68rpx;
  282. height: 80rpx;
  283. >img {
  284. width: 24rpx;
  285. height: 24rpx;
  286. margin-top: 24rpx;
  287. margin-left: 24rpx;
  288. }
  289. }
  290. }
  291. }
  292. .position-button{
  293. position: absolute;
  294. bottom:50rpx;
  295. left:75rpx;
  296. width:600rpx;
  297. height:100rpx;
  298. line-height:100rpx;
  299. text-align: center;
  300. background-color: #0183FA;
  301. font-size:28rpx;
  302. color:#fff;
  303. border-radius:20rpx;
  304. }
  305. .list {
  306. flex: 1;
  307. overflow-y scroll;
  308. padding: 0 30rpx;
  309. box-sizing: border-box;
  310. background: #fff;
  311. padding-bottom:160rpx;
  312. .list-li {
  313. // height: 90rpx;
  314. display: flex;
  315. // justify-content: space-between;
  316. // align-items: center;
  317. border-bottom: 1rpx solid #D8D8D8;
  318. .list-li-l {
  319. flex: 1;
  320. font-family: PingFang SC, PingFang SC;
  321. font-weight: 400;
  322. font-size: 30rpx;
  323. color: #333333;
  324. line-height: 40rpx;
  325. padding: 25rpx 25rpx 25rpx 0;
  326. }
  327. .list-li-r {
  328. font-family: PingFang SC, PingFang SC;
  329. font-weight: 400;
  330. font-size: 28rpx;
  331. color: #0183FA;
  332. line-height: 90rpx;
  333. display: flex;
  334. flex-direction: column;
  335. text-align: right;
  336. width: 80rpx;
  337. .null-p {
  338. flex: 1;
  339. }
  340. }
  341. }
  342. .list-li:last-child {
  343. border-bottom: none;
  344. }
  345. }
  346. .null-img {
  347. display block;
  348. width: 276rpx;
  349. height: 321rpx;
  350. position absolute;
  351. top: 200rpx;
  352. left: 238rpx;
  353. }
  354. .get-data-null-p {
  355. text-align: center;
  356. line-height: 100rpx;
  357. padding-bottom: 80px;
  358. color: #999;
  359. }
  360. .success {
  361. height: 100%;
  362. width: 100%;
  363. position: fixed;
  364. top: 0;
  365. display: flex;
  366. flex-direction: column;
  367. z-index: 10;
  368. background: rgba(0, 0, 0, 0.2);
  369. .null-box {
  370. flex: 1;
  371. }
  372. .panel {
  373. width: 550rpx;
  374. height: 255rpx;
  375. background: #FFFFFF;
  376. border-radius: 20rpx 20rpx 20rpx 20rpx;
  377. position: absolute;
  378. top: 320rpx;
  379. left: 100rpx;
  380. display: flex;
  381. flex-direction: column;
  382. align-items: center;
  383. .panel-t {
  384. width: 80rpx;
  385. height: 80rpx;
  386. margin: 40rpx 0 18rpx 0;
  387. }
  388. .panel-m {
  389. font-family: PingFang SC, PingFang SC;
  390. font-weight: 400;
  391. font-size: 30rpx;
  392. color: #3D3D3D;
  393. line-height: 42rpx;
  394. margin-bottom: 8rpx;
  395. }
  396. .panel-b {
  397. font-family: PingFang SC, PingFang SC;
  398. font-weight: 400;
  399. font-size: 30rpx;
  400. color: #999999;
  401. line-height: 42rpx;
  402. }
  403. }
  404. }
  405. }
  406. </style>