remoteOpen.vue 9.3 KB

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