remoteOpen.vue 8.7 KB

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