remoteOpen.vue 7.6 KB

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