authManage.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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"
  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 v-show="isLoadMore&&this.currentPage>1" style="padding-bottom:60px">
  35. <uni-load-more :status="loadStatus"></uni-load-more>
  36. </view>
  37. </view>
  38. <!-- 权限管理end-->
  39. <!-- 新增按钮start -->
  40. <view style="width: 100%;
  41. position: fixed;
  42. bottom: 0px;
  43. right: 0px;
  44. height: 64px;
  45. background: #fff;">
  46. <view class="plus">
  47. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage(type)"></image>
  48. </view>
  49. </view>
  50. <!-- 新增按钮end -->
  51. </view>
  52. </template>
  53. <script>
  54. import json from '../../data/json.js';
  55. export default {
  56. data() {
  57. return {
  58. phoneNumber: '',
  59. authListRes: 0,
  60. authList: [],
  61. type: '0',
  62. siteListData: json.siteListData,
  63. modalName: null,
  64. listTouchStart: 0,
  65. listTouchDirection: null,
  66. CustomBar: this.CustomBar,
  67. csListArrl: [],
  68. //左滑默认宽度
  69. delBtnWidth: 160,
  70. flag: false,
  71. currentPage: 1,
  72. size: 12,
  73. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  74. isLoadMore: false, //是否加载中
  75. deleteStatus:false
  76. };
  77. },
  78. onReachBottom() { //上拉触底函数
  79. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  80. this.isLoadMore = true
  81. this.currentPage += 1;
  82. this.loadData()
  83. }
  84. },
  85. onLoad: function(option) {
  86. this.loadData()
  87. },
  88. methods: {
  89. searchAuthList() {
  90. this.authList=[];
  91. this.currentPage = 1;
  92. this.authListRes=[]
  93. this.loadData()
  94. },
  95. loadData(){
  96. this.getAuthData({
  97. "phone": this.phoneNumber,
  98. currentPage: this.currentPage,
  99. size: this.size,
  100. })
  101. },
  102. EditItem(item){
  103. uni.redirectTo({
  104. url: '/pages/authAdd/authAdd?phone='+item.phone+'',
  105. });
  106. },
  107. deleteItem(item) {
  108. let deleteT=0;
  109. this.deleteStatus=true
  110. uni.showModal({
  111. title: '确认删除吗?',
  112. content: '',
  113. success: function (result) {
  114. if (result.confirm) {
  115. this.deleteAuth({
  116. "phone": item.phone
  117. });
  118. } else if (result.cancel) {
  119. console.log('用户点击取消');
  120. }
  121. }.bind(this)
  122. });
  123. },
  124. // 删除请求接口
  125. async deleteAuth(ming = {}) {
  126. let res = await this.$myRequest({
  127. url: 'AuthorityManagement/setDelAuthority',
  128. data: ming
  129. })
  130. if (!res.data.flag) {
  131. alert('删除失败');
  132. return;
  133. }
  134. this.loadData()
  135. return res;
  136. },
  137. async getAuthData(ming = {}) {
  138. const res = await this.$myRequest({
  139. url: 'AuthorityManagement/getAuthorityList',
  140. showLoading: true,
  141. data: ming
  142. })
  143. this.authListRes = 1;
  144. if(this.deleteStatus){
  145. this.authList=[];
  146. this.deleteStatus=false;
  147. }
  148. if (res.data.total) {
  149. this.authList = this.authList.concat(res.data.data)
  150. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  151. this.isLoadMore = true
  152. this.loadStatus = 'nomore'
  153. } else {
  154. this.isLoadMore = false
  155. }
  156. } else {
  157. this.isLoadMore = true
  158. this.loadStatus = 'nomore'
  159. }
  160. // this.authList = res.data.data
  161. // console.log(res.data.data);
  162. },
  163. // 页面跳转
  164. goAddPage(type) {
  165. uni.redirectTo({
  166. url: '/pages/authAdd/authAdd',
  167. success: res => {},
  168. fail: () => {},
  169. complete: () => {}
  170. });
  171. },
  172. InputFocus(e) {
  173. this.InputBottom = e.detail.height
  174. },
  175. InputBlur(e) {
  176. this.InputBottom = 0
  177. },
  178. // ListTouch触摸开始
  179. ListTouchStart(e) {
  180. this.listTouchStart = e.touches[0].pageX
  181. },
  182. // ListTouch计算方向
  183. ListTouchMove(e) {
  184. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -60 ? 'left' : 'right'
  185. },
  186. // ListTouch计算滚动
  187. ListTouchEnd(e) {
  188. if (this.listTouchDirection == 'left') {
  189. this.modalName = e.currentTarget.dataset.target
  190. } else {
  191. this.modalName = null
  192. }
  193. this.listTouchDirection = null
  194. }
  195. }
  196. }
  197. </script>