remoteOpen.vue 8.8 KB

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