This commit is contained in:
qsh
2024-11-11 16:32:21 +08:00
parent d1c4632f72
commit a8e41fe889
5 changed files with 44 additions and 23 deletions

View File

@@ -1,5 +1,4 @@
import request from '@/config/axios'
import qs from 'qs'
export interface NotifyMessageVO {
id: number
@@ -16,35 +15,39 @@ export interface NotifyMessageVO {
}
// 查询站内信消息列表
export const getNotifyMessagePage = async (params: PageParam) => {
export const getNotifyMessagePage = async (params: any) => {
return await request.get({ url: '/admin-api/system/notify-message/page', params })
}
// 获得我的站内信分页
export const getMyNotifyMessagePage = async (params: PageParam) => {
export const getMyNotifyMessagePage = async (params: any) => {
return await request.get({ url: '/admin-api/system/notify-message/my-page', params })
}
// 批量标记已读
export const updateNotifyMessageRead = async (ids) => {
export const updateNotifyMessageRead = async (data: any) => {
return await request.put({
url:
'/admin-api/system/notify-message/update-read?' +
qs.stringify({ ids: ids }, { indices: false })
url: '/admin-api/system/notify-message/update-read?',
data
})
}
// 标记所有站内信为已读
export const updateAllNotifyMessageRead = async () => {
return await request.put({ url: '/admin-api/system/notify-message/update-all-read' })
export const updateAllNotifyMessageRead = async (data: any) => {
return await request.put({ url: '/admin-api/system/notify-message/update-all-read', data })
}
// 获取当前用户的最新站内信列表
export const getUnreadNotifyMessageList = async () => {
return await request.get({ url: '/admin-api/system/notify-message/get-unread-list' })
export const getUnreadNotifyMessageList = async (params: any) => {
return await request.get({ url: '/admin-api/system/notify-message/get-unread-list', params })
}
// 获得当前用户的未读站内信数量
export const getUnreadNotifyMessageCount = async () => {
return await request.get({ url: '/admin-api/system/notify-message/get-unread-count' })
export const getUnreadNotifyMessageCount = async (params: any) => {
return await request.get({ url: '/admin-api/system/notify-message/get-unread-count', params })
}
// 获取详情
export const getNotifyMessageDetail = async (id: number) => {
return await request.get({ url: '/admin-api/system/notify-message/get', params: { id } })
}

View File

@@ -1,7 +1,9 @@
<script lang="ts" name="Message" setup>
import { formatDate } from '@/utils/formatTime'
import * as NotifyMessageApi from '@/api/system/notify/message'
// import * as NotifyMessageApi from '@/api/system/notify/message'
// import { useUserStore } from '@/store/modules/user'
// const userStore = useUserStore()
const { push } = useRouter()
const activeName = ref('notice')
const unreadCount = ref(0) // 未读消息数量
@@ -9,17 +11,21 @@ const list = ref<any[]>([]) // 消息列表
// 获得消息列表
const getList = async () => {
list.value = await NotifyMessageApi.getUnreadNotifyMessageList()
// list.value = await NotifyMessageApi.getUnreadNotifyMessageList({
// roleId: userStore.getUser?.currentRole
// })
// 强制设置 unreadCount 为 0避免小红点因为轮询太慢不消除
unreadCount.value = 0
}
// 获得未读消息数
const getUnreadCount = async () => {
NotifyMessageApi.getUnreadNotifyMessageCount().then((data) => {
unreadCount.value = data
})
}
// const getUnreadCount = async () => {
// NotifyMessageApi.getUnreadNotifyMessageCount({ roleId: userStore.getUser?.currentRole }).then(
// (data) => {
// unreadCount.value = data
// }
// )
// }
// 跳转我的站内信
const goMyList = () => {
@@ -32,7 +38,7 @@ const goMyList = () => {
const msgInterval = ref<any>(null)
onMounted(() => {
// 首次加载小红点
getUnreadCount()
// getUnreadCount()
// 轮询刷新小红点
// msgInterval.value = setInterval(() => {
// getUnreadCount()

View File

@@ -56,7 +56,7 @@ export const useAppStore = defineStore('app', {
screenfull: true, // 全屏图标
size: false, // 尺寸图标
locale: false, // 多语言图标
message: true, // 消息图标
message: false, // 消息图标
tagsView: true, // 标签页
tagsViewIcon: false, // 是否显示标签图标
logo: true, // logo

View File

@@ -50,7 +50,7 @@ export const useUserStore = defineStore('admin-user', {
return null
}
let userInfo = cache.local.get(CACHE_KEY.USER)
if (!userInfo) {
if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
userInfo = await getInfo({})
}
this.permissions = userInfo.permissions

View File

@@ -9,6 +9,18 @@
:label="col.label"
:width="col.width"
/>
<el-table-column label="状态" key="status">
<template #default="scope">
<el-switch
v-model="scope.row.status"
:active-value="0"
active-text="在职"
inactive-text="离职"
:inactive-value="1"
disabled
/>
</template>
</el-table-column>
</el-table>
<Pagination
v-model:limit="pageSize"