| | |
| | | |
| | | </view> |
| | | <view> |
| | | <button class="add-btn" @click="navigateToAdd()">新增用户</button> |
| | | <button class="add-btn" @click="navigateToAdd()" :disabled="!isShopkeeper">新增用户</button> |
| | | </view> |
| | | <!-- 搜索框 --> |
| | | <view class="search-box"> |
| | |
| | | <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="restPassword(user.memberId)" class="edit-btn">重置密码</u-button> |
| | | <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"> |
| | | <u-loadmore |
| | | v-if="mockData.length > 0" |
| | | v-if="userList.length > 0" |
| | | :status="loading ? 'loading' : noMore ? 'nomore' : 'loadmore'" |
| | | :load-text="{ |
| | | loadmore: '上拉加载更多', |
| | |
| | | del, |
| | | add, |
| | | update, |
| | | restPassword |
| | | 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'; |
| | |
| | | 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, |
| | |
| | | UInput, |
| | | USearch, |
| | | UPopup, |
| | | ULoading |
| | | ULoading, |
| | | ULoadmore, |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | noMoreData: false, // 是否没有更多数据 |
| | | query: { |
| | | realName: '', |
| | | page: 1, |
| | | pageSize: 10, |
| | | } |
| | | |
| | | |
| | | pageNumber: 1, |
| | | pageSize: 15, |
| | | }, |
| | | isSuper:false, |
| | | isShopkeeper:false, |
| | | clerkId:'',//登录账号id |
| | | } |
| | | }, |
| | | onShow() { |
| | |
| | | }, |
| | | 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.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 || [])]; |
| | |
| | | |
| | | // 搜索用户 |
| | | searchUser() { |
| | | this.query.page = 1 |
| | | this.query.pageNumber = 1 |
| | | this.noMoreData = false |
| | | this.userList = [] |
| | | this.getPage() |
| | |
| | | // 加载更多 |
| | | loadMore() { |
| | | if (!this.noMoreData) { |
| | | this.query.page++ |
| | | this.query.pageNumber++ |
| | | this.getPage() |
| | | } |
| | | }, |
| | |
| | | this.getPage(); |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | |
| | | } |
| | | } |
| | | </script> |