修复权限缓存问题

This commit is contained in:
Zy
2026-07-20 16:43:09 +08:00
parent a5a883a652
commit 3a00c3dfe0
10 changed files with 343 additions and 306 deletions

View File

@@ -4,7 +4,7 @@
<view class="news-card" v-for="item in noticeList" :key="item.id">
<view class="news-header">
<text class="news-title">{{ item.item || '暂无标题' }}</text>
<view class="unread-dot" v-if="item.isCheckStr === '未读' "></view>
<view class="unread-dot" v-if="item.isCheckStr === '未读'"></view>
</view>
<view class="news-meta">
@@ -29,9 +29,7 @@
</view>
<!-- 空数据 -->
<view class="empty" v-if="noticeList.length === 0 && !loading">
暂无通知消息
</view>
<view class="empty" v-if="noticeList.length === 0 && !loading"> 暂无通知消息 </view>
</view>
</template>
@@ -39,16 +37,18 @@
import { ref } from 'vue'
import { onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
import { getNoticeList } from '../../api/api.js'
import { usePermStore } from '@/stores/usePermStore.js'
const permStore = usePermStore()
// 列表数据
const noticeList = ref([])
// 分页相关
const pageNum = ref(1) // 当前页
const pageSize = ref(10) // 每页条数
const total = ref(0) // 总条数
const loading = ref(false) // 加载状态
const noMore = ref(false) // 是否没有更多
const pageNum = ref(1) // 当前页
const pageSize = ref(10) // 每页条数
const total = ref(0) // 总条数
const loading = ref(false) // 加载状态
const noMore = ref(false) // 是否没有更多
// 获取列表数据
const getNoticeData = (isRefresh = false) => {
@@ -59,29 +59,32 @@ const getNoticeData = (isRefresh = false) => {
getNoticeList({
pageSize: pageSize.value,
pageNum: pageNum.value
}).then(res => {
if (res.code === 200) {
total.value = res.total || 0
const data = res.rows || []
// 第一页:覆盖,分页:追加
if (pageNum.value === 1) {
noticeList.value = data
} else {
noticeList.value = [...noticeList.value, ...data]
}
// 判断是否还有更多
noMore.value = noticeList.value.length >= total.value
}
}).catch(() => {
uni.showToast({ title: '加载失败', icon: 'none' })
}).finally(() => {
loading.value = false
if (isRefresh) {
uni.stopPullDownRefresh()
}
})
.then(res => {
if (res.code === 200) {
total.value = res.total || 0
const data = res.rows || []
// 第一页:覆盖,分页:追加
if (pageNum.value === 1) {
noticeList.value = data
} else {
noticeList.value = [...noticeList.value, ...data]
}
// 判断是否还有更多
noMore.value = noticeList.value.length >= total.value
}
})
.catch(() => {
uni.showToast({ title: '加载失败', icon: 'none' })
})
.finally(() => {
loading.value = false
if (isRefresh) {
uni.stopPullDownRefresh()
}
})
}
// 上拉加载更多
@@ -99,11 +102,17 @@ onPullDownRefresh(() => {
})
// 跳详情(即时标记已读)
const goToDetail = (item) => {
item.isCheck = '1'
uni.navigateTo({
url: `/pageSubPack/ticket/repairMain?id=${item.id}`
})
const goToDetail = item => {
const hasMine = permStore.hasPermi('butler:workOrder:mine')
const hasHall = permStore.hasPermi('butler:workOrder:hall')
if (hasMine || hasHall) {
item.isCheck = '1'
uni.navigateTo({
url: `/pageSubPack/ticket/repairMain?id=${item.id}`
})
} else {
uni.showToast({ title: '暂无操作权限', icon: 'none' })
}
}
// 页面显示时刷新(从详情页返回也会触发)
@@ -111,6 +120,7 @@ onShow(() => {
pageNum.value = 1
noMore.value = false
getNoticeData()
permStore.initPerm()
})
</script>
@@ -149,7 +159,7 @@ onShow(() => {
.unread-dot {
width: 16rpx;
height: 16rpx;
background-color: #E34D59;
background-color: #e34d59;
border-radius: 50%;
margin-top: 6rpx;
}
@@ -189,7 +199,7 @@ onShow(() => {
justify-content: space-between;
.detail-text {
font-size: 28rpx;
color: #4D5DFA;
color: #4d5dfa;
margin-right: 8rpx;
}
}