authManage.vue 4.2 KB

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