From 232225891f27532a550ab9eb50d84f2f07dfac7f Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期一, 16 六月 2025 14:27:11 +0800 Subject: [PATCH] 用户权限管理,url替换后端获取,安装树状结构插件da-tree --- pages/userPermissions/userPermissions.vue | 137 ++++++++++++++++++++++++++++----------------- 1 files changed, 86 insertions(+), 51 deletions(-) diff --git a/pages/userPermissions/userPermissions.vue b/pages/userPermissions/userPermissions.vue index 12cf83f..7edfdf3 100644 --- a/pages/userPermissions/userPermissions.vue +++ b/pages/userPermissions/userPermissions.vue @@ -6,7 +6,7 @@ </view> <view> - <button class="add-btn" @click="navigateToAdd()">鏂板鐢ㄦ埛</button> + <button class="add-btn" @click="navigateToAdd()" :disabled="!isShopkeeper">鏂板鐢ㄦ埛</button> </view> <!-- 鎼滅储妗� --> <view class="search-box"> @@ -18,31 +18,38 @@ <view class="user-item" v-for="(user, index) in userList" :key="user.id" > <view class="user-info"> - <text class="realName">{{ user.realName }}</text> + <text class="realName">{{ user.realName ? user.realName: '鏈缃汉鍚�' }}</text> <text class="mobile">{{ user.mobile }}</text> </view> <!-- 鎿嶄綔鎸夐挳鍖哄煙 --> <view class="action-buttons"> - <u-button type="primary" size="mini" @click.stop="navigateToDetail(user.id)" class="edit-btn">淇敼</u-button> - <u-button type="error" size="mini" @click.stop="deleteUser(user.id)" - class="delete-btn">鍒犻櫎</u-button> - </view> + <u-button type="primary" size="mini" @click.stop="restPassword(user.memberId)" class="edit-btn" :disabled="!checkPermission(user)">閲嶇疆瀵嗙爜</u-button> + <u-button type="primary" size="mini" @click.stop="navigateToDetail(user.id)" class="edit-btn" :disabled="!checkPermission(user)">淇敼</u-button> + <u-button type="error" size="mini" @click.stop="deleteUser(user.id)" + class="delete-btn" :disabled="!checkPermission(user)">鍒犻櫎</u-button> + </view> </view> <!-- 鍔犺浇鏇村鎻愮ず --> - <view class="load-more" v-if="loading"> - <u-loading :show="loading"></u-loading> + + <view class="load-more"> + <u-loadmore + v-if="userList.length > 0" + :status="loading ? 'loading' : noMore ? 'nomore' : 'loadmore'" + :load-text="{ + loadmore: '涓婃媺鍔犺浇鏇村', + loading: '姝e湪鍔犺浇', + nomore: '娌℃湁鏇村浜�' + }" + /> </view> - <view class="load-more" v-if="noMoreData"> - <text>娌℃湁鏇村鏁版嵁浜�</text> + <view style="height:150rpx"> + </view> </scroll-view> - <!-- 绌虹姸鎬� --> - <view class="empty" v-else> - <text>鏆傛棤鐢ㄦ埛鏁版嵁</text> - </view> + </view> </template> @@ -51,7 +58,9 @@ getPage, del, add, - update + update, + restPassword, + checkClerkPermission } from "@/api/userPermissions.js" import UIcon from '@/uview-components/uview-ui/components/u-icon/u-icon.vue'; import UButton from '@/uview-components/uview-ui/components/u-button/u-button.vue'; @@ -60,9 +69,14 @@ import UInput from '@/uview-components/uview-ui/components/u-input/u-input.vue'; import USearch from '@/uview-components/uview-ui/components/u-search/u-search.vue'; import UPopup from '@/uview-components/uview-ui/components/u-popup/u-popup.vue'; - import ULoading from '@/uview-components/uview-ui/components/u-loading/u-loading.vue' + import ULoading from '@/uview-components/uview-ui/components/u-loading/u-loading.vue'; + import ULoadmore from '@/uview-components/uview-ui/components/u-loadmore/u-loadmore.vue'; - + import storage from "@/utils/storage.js"; //缂撳瓨 + import { + getUserInfo + } from "@/api/members"; + export default { components: { UIcon, @@ -72,7 +86,8 @@ UInput, USearch, UPopup, - ULoading + ULoading, + ULoadmore, }, data() { return { @@ -81,11 +96,12 @@ noMoreData: false, // 鏄惁娌℃湁鏇村鏁版嵁 query: { realName: '', - page: 1, - pageSize: 10, - } - - + pageNumber: 1, + pageSize: 15, + }, + isSuper:false, + isShopkeeper:false, + clerkId:'',//鐧诲綍璐﹀彿id } }, onShow() { @@ -93,8 +109,42 @@ }, onLoad() { this.getPage() + //鑾峰緱鐢ㄦ埛鏉冮檺 + checkClerkPermission().then(res=>{ + this.isSuper = res.data.data.isSuper; + this.isShopkeeper = res.data.data.isShopkeeper; + this.clerkId = res.data.data.clerkId; + }) + }, + methods: { + //妫�鏌ユ潈闄� + checkPermission(user){ + if(this.isShopkeeper){ + return true; + } + if(this.clerkId === user.id){ + return true; + }else{ + if(this.isSuper && !user.isSuper){ + return true; + } + return false; + } + + }, + restPassword(id){ + restPassword(id).then(res=>{ + if(res.statusCode === 200){ + uni.showToast({ + title: res.data.msg, // 鎻愮ず鏂囧瓧 + icon: 'none', // 鍥炬爣绫诲瀷锛坰uccess/loading/none锛� + mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛堥槻姝㈣Е鎽哥┛閫忥級 + }); + } + }) + }, async getPage() { // uni.showLoading({ @@ -104,8 +154,9 @@ uni.hideLoading(); if (res.statusCode === 200) { const data = res.data.data; - if (this.query.page === 1) { + if (this.query.pageNumber === 1) { this.userList = data || []; + console.log(this.userList.length) } else { // 鍚﹀垯杩藉姞鏁版嵁 this.userList = [...this.userList, ...(data || [])]; @@ -119,7 +170,7 @@ // 鎼滅储鐢ㄦ埛 searchUser() { - this.query.page = 1 + this.query.pageNumber = 1 this.noMoreData = false this.userList = [] this.getPage() @@ -128,7 +179,7 @@ // 鍔犺浇鏇村 loadMore() { if (!this.noMoreData) { - this.query.page++ + this.query.pageNumber++ this.getPage() } }, @@ -150,7 +201,9 @@ this.getPage(); } }) - } + }, + + } } </script> @@ -257,30 +310,12 @@ } } } - .load-more { - padding: 20rpx; - text-align: center; - color: #999; - font-size: 28rpx; - } + padding: 20rpx 0; + text-align: center; + color: #999; + font-size: 26rpx; + background-color: #f7f8fa; + } - .empty { - flex: 1; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 40rpx; - - image { - width: 200rpx; - margin-bottom: 20rpx; - } - - text { - color: #999; - font-size: 28rpx; - } - } </style> \ No newline at end of file -- Gitblit v1.8.0