authManage.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:90rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section">
  7. <view class="search-form round bg-white">
  8. <text class="cuIcon-search"></text>
  9. <input class="" @focus="InputFocus" @blur="InputBlur" :adjust-position="false" type="text" confirm-type="search"
  10. v-model="phoneNumber"></input>
  11. </view>
  12. <view class="action">
  13. <button class="cu-btn bg-blue round" @click="searchAuthList">查询</button>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 筛选框end -->
  18. <!-- 权限管理start -->
  19. <view class="site-items" style="margin-top:0;height: calc(100vh - 286rpx);">
  20. <view class="cu-list menu-avatar">
  21. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in authList" :key="index"
  22. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  23. <view class="cu-avatar round lg" style="background-image: url(../../static/auth-icon.jpg);"></view>
  24. <view class="content">
  25. <view class="text-grey site-tit">{{item.phone}}</view>
  26. </view>
  27. <view class="move">
  28. <view class="bg-grey" @click.stop="EditItem(item)">编辑</view>
  29. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view v-if="!authList.length&&authListRes==1" class="text-center margin-top"> 暂无数据</view>
  34. </view>
  35. <!-- 权限管理end-->
  36. <!-- 新增按钮start -->
  37. <view class="plus">
  38. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage(type)"></image>
  39. </view>
  40. <!-- 新增按钮end -->
  41. </view>
  42. </template>
  43. <script>
  44. import json from '../../data/json.js';
  45. export default {
  46. data() {
  47. return {
  48. phoneNumber: '',
  49. authListRes: 0,
  50. authList: [],
  51. type: '0',
  52. siteListData: json.siteListData,
  53. modalName: null,
  54. listTouchStart: 0,
  55. listTouchDirection: null,
  56. CustomBar: this.CustomBar,
  57. csListArrl: [],
  58. //左滑默认宽度
  59. delBtnWidth: 160,
  60. flag: false
  61. };
  62. },
  63. onLoad: function(option) {
  64. this.getAuthData()
  65. },
  66. methods: {
  67. EditItem(item){
  68. uni.navigateTo({
  69. url: '/pages/authAdd/authAdd?phone='+item.phone+'',
  70. });
  71. },
  72. deleteItem(item) {
  73. let deleteT=0;
  74. uni.showModal({
  75. title: '确认删除吗?',
  76. content: '',
  77. success: function (result) {
  78. if (result.confirm) {
  79. this.deleteAuth({
  80. "phone": item.phone
  81. });
  82. } else if (result.cancel) {
  83. console.log('用户点击取消');
  84. }
  85. }.bind(this)
  86. });
  87. },
  88. // 删除请求接口
  89. async deleteAuth(ming = {}) {
  90. let res = await this.$myRequest({
  91. url: 'AuthorityManagement/setDelAuthority',
  92. data: ming
  93. })
  94. if (!res.data.flag) {
  95. alert('删除失败');
  96. return;
  97. }
  98. this.getAuthData()
  99. return res;
  100. },
  101. async getAuthData(ming = {}) {
  102. const res = await this.$myRequest({
  103. url: 'AuthorityManagement/getAuthorityList',
  104. showLoading: true,
  105. data: ming
  106. })
  107. this.authListRes = 1;
  108. this.authList = res.data.data
  109. console.log(res.data.data);
  110. },
  111. searchAuthList() {
  112. this.getAuthData({
  113. "phone": this.phoneNumber
  114. })
  115. },
  116. // 页面跳转
  117. goAddPage(type) {
  118. uni.navigateTo({
  119. url: '/pages/authAdd/authAdd',
  120. success: res => {},
  121. fail: () => {},
  122. complete: () => {}
  123. });
  124. },
  125. InputFocus(e) {
  126. this.InputBottom = e.detail.height
  127. },
  128. InputBlur(e) {
  129. this.InputBottom = 0
  130. },
  131. // ListTouch触摸开始
  132. ListTouchStart(e) {
  133. this.listTouchStart = e.touches[0].pageX
  134. },
  135. // ListTouch计算方向
  136. ListTouchMove(e) {
  137. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -60 ? 'left' : 'right'
  138. },
  139. // ListTouch计算滚动
  140. ListTouchEnd(e) {
  141. if (this.listTouchDirection == 'left') {
  142. this.modalName = e.currentTarget.dataset.target
  143. } else {
  144. this.modalName = null
  145. }
  146. this.listTouchDirection = null
  147. }
  148. }
  149. }
  150. </script>