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 request from '@/config/axios'
import qs from 'qs'
export interface NotifyMessageVO { export interface NotifyMessageVO {
id: number 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 }) 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 }) 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({ return await request.put({
url: url: '/admin-api/system/notify-message/update-read?',
'/admin-api/system/notify-message/update-read?' + data
qs.stringify({ ids: ids }, { indices: false })
}) })
} }
// 标记所有站内信为已读 // 标记所有站内信为已读
export const updateAllNotifyMessageRead = async () => { export const updateAllNotifyMessageRead = async (data: any) => {
return await request.put({ url: '/admin-api/system/notify-message/update-all-read' }) return await request.put({ url: '/admin-api/system/notify-message/update-all-read', data })
} }
// 获取当前用户的最新站内信列表 // 获取当前用户的最新站内信列表
export const getUnreadNotifyMessageList = async () => { export const getUnreadNotifyMessageList = async (params: any) => {
return await request.get({ url: '/admin-api/system/notify-message/get-unread-list' }) return await request.get({ url: '/admin-api/system/notify-message/get-unread-list', params })
} }
// 获得当前用户的未读站内信数量 // 获得当前用户的未读站内信数量
export const getUnreadNotifyMessageCount = async () => { export const getUnreadNotifyMessageCount = async (params: any) => {
return await request.get({ url: '/admin-api/system/notify-message/get-unread-count' }) 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> <script lang="ts" name="Message" setup>
import { formatDate } from '@/utils/formatTime' 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 { push } = useRouter()
const activeName = ref('notice') const activeName = ref('notice')
const unreadCount = ref(0) // 未读消息数量 const unreadCount = ref(0) // 未读消息数量
@@ -9,17 +11,21 @@ const list = ref<any[]>([]) // 消息列表
// 获得消息列表 // 获得消息列表
const getList = async () => { const getList = async () => {
list.value = await NotifyMessageApi.getUnreadNotifyMessageList() // list.value = await NotifyMessageApi.getUnreadNotifyMessageList({
// roleId: userStore.getUser?.currentRole
// })
// 强制设置 unreadCount 为 0避免小红点因为轮询太慢不消除 // 强制设置 unreadCount 为 0避免小红点因为轮询太慢不消除
unreadCount.value = 0 unreadCount.value = 0
} }
// 获得未读消息数 // 获得未读消息数
const getUnreadCount = async () => { // const getUnreadCount = async () => {
NotifyMessageApi.getUnreadNotifyMessageCount().then((data) => { // NotifyMessageApi.getUnreadNotifyMessageCount({ roleId: userStore.getUser?.currentRole }).then(
unreadCount.value = data // (data) => {
}) // unreadCount.value = data
} // }
// )
// }
// 跳转我的站内信 // 跳转我的站内信
const goMyList = () => { const goMyList = () => {
@@ -32,7 +38,7 @@ const goMyList = () => {
const msgInterval = ref<any>(null) const msgInterval = ref<any>(null)
onMounted(() => { onMounted(() => {
// 首次加载小红点 // 首次加载小红点
getUnreadCount() // getUnreadCount()
// 轮询刷新小红点 // 轮询刷新小红点
// msgInterval.value = setInterval(() => { // msgInterval.value = setInterval(() => {
// getUnreadCount() // getUnreadCount()

View File

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

View File

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

View File

@@ -9,6 +9,18 @@
:label="col.label" :label="col.label"
:width="col.width" :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> </el-table>
<Pagination <Pagination
v-model:limit="pageSize" v-model:limit="pageSize"