feat: 新增电工APP端与定时任务管理功能
- 新增电工APP独立鉴权中间件与登录注册接口 - 新增定时任务管理模块,支持任务配置、执行日志与手动触发 - 新增运维费定价与电工派单成本价目管理 - 新增电工资质证照管理与到期提醒定时任务 - 完善数据库实体与DTO校验,优化权限控制
This commit is contained in:
1 parent
1803ad679c
commit
f4454ad014
57 files changed
+9388
-200
No files matched your search
@@ -48,6 +48,13 @@
|
||||
</div>
|
||||
|
||||
<div class="header-right">
|
||||
<!-- 消息中心铃铛:未读数为 0 时角标自动隐藏 -->
|
||||
<a-badge :count="unreadCount" :overflow-count="99" size="small">
|
||||
<div class="notice-bell" title="消息中心" @click="openNoticeDrawer">
|
||||
<BellOutlined />
|
||||
</div>
|
||||
</a-badge>
|
||||
|
||||
<!-- 用户信息下拉菜单 -->
|
||||
<a-dropdown :trigger="['click']">
|
||||
<a-space class="user-info">
|
||||
@@ -89,12 +96,43 @@
|
||||
</router-view>
|
||||
</a-layout-content>
|
||||
</a-layout>
|
||||
|
||||
<!-- 消息中心抽屉 -->
|
||||
<a-drawer v-model:open="noticeVisible" title="消息中心" placement="right" :width="440">
|
||||
<div class="notice-drawer">
|
||||
<div class="notice-toolbar">
|
||||
<span class="notice-summary">共 {{ noticeTotal }} 条通知,{{ unreadCount }} 条未读</span>
|
||||
<a-button type="link" size="small" :disabled="!unreadCount" @click="handleReadAll">全部已读</a-button>
|
||||
</div>
|
||||
<a-spin :spinning="noticeLoading">
|
||||
<div v-if="noticeList.length" class="notice-list">
|
||||
<div
|
||||
v-for="item in noticeList"
|
||||
:key="item.id"
|
||||
class="notice-item"
|
||||
:class="{ unread: item.isRead === 0 }"
|
||||
@click="handleNoticeClick(item)"
|
||||
>
|
||||
<div class="notice-item-head">
|
||||
<span v-if="item.isRead === 0" class="notice-dot"></span>
|
||||
<span class="notice-title">{{ item.title }}</span>
|
||||
<span class="notice-time">{{ formatNoticeTime(item) }}</span>
|
||||
</div>
|
||||
<p class="notice-content">{{ item.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<a-empty v-else description="暂无通知" />
|
||||
</a-spin>
|
||||
</div>
|
||||
</a-drawer>
|
||||
</a-layout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, h, type Component, type VNode } from 'vue'
|
||||
import { ref, computed, watch, h, onMounted, onBeforeUnmount, type Component, type VNode } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import dayjs from 'dayjs'
|
||||
import {
|
||||
DashboardOutlined,
|
||||
SettingOutlined,
|
||||
@@ -115,8 +153,10 @@ import {
|
||||
LogoutOutlined,
|
||||
LockOutlined,
|
||||
ThunderboltOutlined,
|
||||
BellOutlined,
|
||||
} from '@ant-design/icons-vue'
|
||||
import { usePermissionStore, type MenuNode } from '@/stores/permission'
|
||||
import { noticeApi, type NoticeInfo } from '@/api/notice'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -290,6 +330,92 @@ function handleUserMenuClick({ key }: { key: string }) {
|
||||
permissionStore.logout()
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 消息中心 ====================
|
||||
const noticeVisible = ref(false)
|
||||
const noticeLoading = ref(false)
|
||||
const noticeList = ref<NoticeInfo[]>([])
|
||||
const noticeTotal = ref(0)
|
||||
const unreadCount = ref(0)
|
||||
const NOTICE_POLL_INTERVAL = 60000
|
||||
let noticeTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
// 未读数轮询(顶栏红点)
|
||||
async function fetchUnreadCount() {
|
||||
try {
|
||||
const res = await noticeApi.getUnreadCount()
|
||||
if (res.code === 200) unreadCount.value = res.data?.count || 0
|
||||
} catch (error) {
|
||||
// 未读数拉取失败不阻断主界面
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchNoticeList() {
|
||||
noticeLoading.value = true
|
||||
try {
|
||||
const res = await noticeApi.getList({ page: 1, pageSize: 20 })
|
||||
if (res.code === 200 && res.data) {
|
||||
noticeList.value = res.data.list || []
|
||||
noticeTotal.value = res.data.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
// 列表拉取失败不阻断抽屉
|
||||
} finally {
|
||||
noticeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openNoticeDrawer() {
|
||||
noticeVisible.value = true
|
||||
fetchNoticeList()
|
||||
}
|
||||
|
||||
async function handleNoticeClick(item: NoticeInfo) {
|
||||
if (item.isRead === 0) {
|
||||
try {
|
||||
await noticeApi.markRead(item.id)
|
||||
item.isRead = 1
|
||||
fetchUnreadCount()
|
||||
} catch (error) {
|
||||
// 标记失败不阻断后续跳转
|
||||
}
|
||||
}
|
||||
// 电工资质到期提醒 → 跳转电工登记管理
|
||||
if (item.bizType === 'worker_cert') {
|
||||
noticeVisible.value = false
|
||||
router.push('/dispatch/worker')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReadAll() {
|
||||
try {
|
||||
const res = await noticeApi.readAll()
|
||||
if (res.code === 200) {
|
||||
message.success('已全部标记为已读')
|
||||
noticeList.value = noticeList.value.map((n) => ({ ...n, isRead: 1 }))
|
||||
unreadCount.value = 0
|
||||
}
|
||||
} catch (error) {
|
||||
// 由请求拦截器统一提示
|
||||
}
|
||||
}
|
||||
|
||||
function formatNoticeTime(item: NoticeInfo) {
|
||||
const time = item.createdAt || item.created_at
|
||||
return time ? dayjs(time).format('YYYY-MM-DD HH:mm') : ''
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchUnreadCount()
|
||||
noticeTimer = setInterval(fetchUnreadCount, NOTICE_POLL_INTERVAL)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (noticeTimer) {
|
||||
clearInterval(noticeTimer)
|
||||
noticeTimer = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@@ -458,6 +584,28 @@ function handleUserMenuClick({ key }: { key: string }) {
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18px;
|
||||
|
||||
.notice-bell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 8px;
|
||||
font-size: 18px;
|
||||
color: #424655;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
color: #1890ff;
|
||||
background: rgba(24, 144, 255, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.user-info {
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
@@ -548,4 +696,92 @@ function handleUserMenuClick({ key }: { key: string }) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 消息中心抽屉(抽屉内容被 teleport 到 body,样式不可嵌套在 .admin-layout 内) =====
|
||||
.notice-drawer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
|
||||
.notice-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #eef1f6;
|
||||
|
||||
.notice-summary {
|
||||
font-size: 12px;
|
||||
color: #5b6b7e;
|
||||
}
|
||||
}
|
||||
|
||||
.notice-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.notice-item {
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #eef1f6;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
border-color: #dbe4ee;
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
&.unread {
|
||||
background: #f4f7ff;
|
||||
border-color: #d6e4ff;
|
||||
}
|
||||
|
||||
.notice-item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.notice-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #ff4d4f;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.notice-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #0d1c2c;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notice-time {
|
||||
font-size: 11px;
|
||||
color: #8a97a8;
|
||||
flex-shrink: 0;
|
||||
font-family: Consolas, Menlo, monospace;
|
||||
}
|
||||
|
||||
.notice-content {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
color: #5b6b7e;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user