AccessControl.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="menjin">
  3. <view class="mjym" v-for="(item,index) in mjlist" :key="item.id">
  4. <view class="top">
  5. <view class="status" v-if="item.status==1">在线</view>
  6. <view class="status s2" v-if="item.status==0">离线</view>
  7. <h3>{{item.deviceName}}</h3>
  8. <view class="subtit">{{item.deviceSerial}}</view>
  9. <view class="subtit">{{item.parentCategory}}</view>
  10. </view>
  11. <view class="mjkg">
  12. <view class="anniu">
  13. <u-button type="primary" :plain="true" text="开启" @click="buttons(item,'open')"></u-button>
  14. </view>
  15. <view class="anniu">
  16. <u-button type="primary" :plain="true" text="关闭" @click="buttons(item,'close')"></u-button>
  17. </view>
  18. <view class="anniu">
  19. <u-button type="primary" :plain="true" text="常开" @click="buttons(item,'alwaysOpen')"></u-button>
  20. </view>
  21. <view class="anniu">
  22. <u-button type="primary" :plain="true" text="常关" @click="buttons(item,'alwaysClose')"></u-button>
  23. </view>
  24. </view>
  25. </view>
  26. <u-notify ref="uNotify" message=""></u-notify>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. mjlist: [],
  34. }
  35. },
  36. onLoad() {
  37. this.getalldata()
  38. },
  39. methods: {
  40. getalldata() {
  41. this.$api.get('/access/page', {})
  42. .then(res => {
  43. if (res.data.code == 0) {
  44. if (res.data.data.length == 0) {
  45. this.mjlist = []
  46. } else {
  47. this.mjlist = res.data.data;
  48. }
  49. } else {
  50. this.$refs.uNotify.error(res.data.msg)
  51. }
  52. })
  53. },
  54. buttons(e, fs) {
  55. let postdata = {
  56. cmd: fs,
  57. deviceSerial: e.deviceSerial
  58. }
  59. this.$api.post('/access/operate', postdata)
  60. .then(res => {
  61. if (res.data.code == 0) {
  62. this.$refs.uNotify.success('成功')
  63. } else {
  64. this.$refs.uNotify.error(res.data.msg)
  65. }
  66. })
  67. },
  68. operate(e) {
  69. this.$api.post('/access/operate', e)
  70. .then(res => {
  71. if (res.data.code == 0) {
  72. this.$refs.uNotify.success('成功')
  73. } else {
  74. this.$refs.uNotify.error(res.data.msg)
  75. }
  76. })
  77. },
  78. asyncChange1(e, ) {
  79. uni.showModal({
  80. content: e.value1 ? '确定要关闭门禁吗' : '确定要开启门禁吗',
  81. success: (res) => {
  82. if (res.confirm) {
  83. e.value1 = !e.value1;
  84. if (e.value1 == true) {
  85. let postdata = {
  86. cmd: 'open',
  87. deviceSerial: e.deviceSerial
  88. }
  89. this.operate(postdata)
  90. } else {
  91. let postdata = {
  92. cmd: 'close',
  93. deviceSerial: e.deviceSerial
  94. }
  95. this.operate(postdata)
  96. }
  97. }
  98. }
  99. })
  100. },
  101. asyncChange2(e, ) {
  102. uni.showModal({
  103. content: e.value2 ? '确定要关闭常开吗' : '确定要常开吗',
  104. success: (res) => {
  105. if (res.confirm) {
  106. e.value2 = !e.value2;
  107. if (e.value2 == true) {
  108. let postdata = {
  109. cmd: 'alwaysOpen',
  110. deviceSerial: e.deviceSerial
  111. }
  112. this.operate(postdata)
  113. } else {
  114. let postdata = {
  115. cmd: 'alwaysClose',
  116. deviceSerial: e.deviceSerial
  117. }
  118. this.operate(postdata)
  119. }
  120. }
  121. }
  122. })
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .menjin{padding-top: 24rpx;}
  129. .mjym {
  130. margin: 0 32rpx 24rpx;
  131. padding: 24rpx 0 0;
  132. background-color: #fff;
  133. .top {
  134. border-bottom: 1px solid #eee;
  135. padding: 0 32rpx 24rpx;
  136. position: relative;
  137. h3 {
  138. font-size: 32rpx;
  139. margin-bottom: 24rpx;
  140. }
  141. .subtit {
  142. color: #9DA0AC;
  143. font-size: 28rpx;
  144. }
  145. .status {
  146. position: absolute;
  147. width: 96rpx;
  148. height: 48rpx;
  149. border-radius: 0 8rpx 0 20rpx;
  150. right: 0;
  151. line-height: 48rpx;
  152. text-align: center;
  153. top: -24rpx;
  154. z-index: 1;
  155. font-size: 22rpx;
  156. background-color: #30D3A2;
  157. color: #fff;
  158. &.s2 {
  159. background-color: #C8C8C8;
  160. }
  161. }
  162. }
  163. }
  164. .mjkg {
  165. display: flex;
  166. align-items: center;
  167. justify-content: flex-end;
  168. padding: 20rpx 32rpx;
  169. .anniu {
  170. margin-left: 24rpx;
  171. }
  172. }
  173. </style>