From 25975d7ec42b1691512ff6f29041bd3bd1a4a1e3 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 12 一月 2026 14:32:57 +0800
Subject: [PATCH] fix: 消息通知接口联调,页面跳转

---
 src/layout/components/NotificationCenter/index.vue        |   69 +++++++++++++++++++++++++++-------
 src/layout/components/Navbar.vue                          |    4 ++
 src/api/system/message.js                                 |   15 ++++---
 src/views/collaborativeApproval/approvalProcess/index.vue |   23 +++++++++++
 4 files changed, 90 insertions(+), 21 deletions(-)

diff --git a/src/api/system/message.js b/src/api/system/message.js
index b046016..871d7e8 100644
--- a/src/api/system/message.js
+++ b/src/api/system/message.js
@@ -10,19 +10,20 @@
 }
 
 // 鏌ヨ鏈娑堟伅鏁伴噺
-export function getUnreadCount() {
+export function getUnreadCount(consigneeId) {
   return request({
     url: "/system/notice/getCount",
     method: "get",
+    params: { consigneeId },
   });
 }
 
 // 鏍囪娑堟伅涓哄凡璇�
-export function markAsRead(noticeId) {
+export function markAsRead(noticeId, status) {
   return request({
-    url: "/system/notice/markAsRead",
-    method: "post",
-    data: { noticeId },
+    url: "/system/notice",
+    method: "put",
+    data: { noticeId, status },
   });
 }
 
@@ -37,8 +38,8 @@
 // 纭娑堟伅
 export function confirmMessage(noticeId, status) {
   return request({
-    url: "/system/notice/confirm",
-    method: "post",
+    url: "/system/notice",
+    method: "put",
     data: { noticeId, status },
   });
 }
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index 5e73968..03e2101 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -344,6 +344,7 @@
     }
   }
 }
+
 </style>
 
 <style lang="scss">
@@ -358,4 +359,7 @@
     padding: 0 !important;
   }
 }
+.el-badge__content.is-fixed{
+  top: 12px;
+}
 </style>
diff --git a/src/layout/components/NotificationCenter/index.vue b/src/layout/components/NotificationCenter/index.vue
index ea365ee..df42650 100644
--- a/src/layout/components/NotificationCenter/index.vue
+++ b/src/layout/components/NotificationCenter/index.vue
@@ -25,12 +25,12 @@
                 </el-icon>
               </div>
               <div class="notification-content-wrapper">
-                <div class="notification-title">{{ item.title }}</div>
-                <div class="notification-detail">{{ item.content }}</div>
+                <div class="notification-title">{{ item.noticeTitle }}</div>
+                <div class="notification-detail">{{ item.noticeContent }}</div>
                 <div class="notification-time">{{ item.createTime }}</div>
               </div>
               <div class="notification-action">
-                <el-button type="primary" size="small" @click="handleConfirm(item.id)">
+                <el-button type="primary" size="small" @click="handleConfirm(item)">
                   纭
                 </el-button>
               </div>
@@ -53,8 +53,8 @@
                 </el-icon>
               </div>
               <div class="notification-content-wrapper">
-                <div class="notification-title">{{ item.title }}</div>
-                <div class="notification-detail">{{ item.content }}</div>
+                <div class="notification-title">{{ item.noticeTitle }}</div>
+                <div class="notification-detail">{{ item.noticeContent }}</div>
                 <div class="notification-time">{{ item.createTime }}</div>
               </div>
             </div>
@@ -82,7 +82,11 @@
 import { Bell } from '@element-plus/icons-vue'
 import { listMessage, markAsRead, markAllAsRead, confirmMessage, getUnreadCount } from '@/api/system/message'
 import { ElMessage } from 'element-plus'
+import useUserStore from '@/store/modules/user'
+import { useRouter } from 'vue-router'
 
+const userStore = useUserStore()
+const router = useRouter()
 const emit = defineEmits(['unreadCountChange'])
 
 const activeTab = ref('unread')
@@ -96,19 +100,25 @@
 // 鍔犺浇娑堟伅鍒楄〃
 const loadMessages = async () => {
   try {
+    const consigneeId = userStore.id
+    if (!consigneeId) {
+      console.warn('鏈幏鍙栧埌褰撳墠鐧诲綍鐢ㄦ埛ID')
+      return
+    }
     const params = {
+      consigneeId: consigneeId,
       pageNum: pageNum.value,
       pageSize: pageSize.value,
-      isRead: activeTab.value === 'read' ? 1 : 0
+      status: activeTab.value === 'read' ? 1 : 0
     }
     const res = await listMessage(params)
     if (res.code === 200) {
       if (activeTab.value === 'unread') {
-        unreadList.value = res.rows || []
+        unreadList.value = res.data.records || []
       } else {
-        readList.value = res.rows || []
+        readList.value = res.data.records || []
       }
-      total.value = res.total || 0
+      total.value = res.data.total || 0
     }
   } catch (error) {
     console.error('鍔犺浇娑堟伅鍒楄〃澶辫触:', error)
@@ -118,7 +128,12 @@
 // 鍔犺浇鏈鏁伴噺
 const loadUnreadCount = async () => {
   try {
-    const res = await getUnreadCount()
+    const consigneeId = userStore.id
+    if (!consigneeId) {
+      console.warn('鏈幏鍙栧埌褰撳墠鐧诲綍鐢ㄦ埛ID')
+      return
+    }
+    const res = await getUnreadCount(consigneeId)
     if (res.code === 200) {
       unreadCount.value = res.data || 0
       emit('unreadCountChange', unreadCount.value)
@@ -135,16 +150,42 @@
 }
 
 // 纭娑堟伅
-const handleConfirm = async (messageId) => {
+const handleConfirm = async (item) => {
   try {
-    const res = await confirmMessage(messageId, 1)
+    console.log('item', item)
+    const res = await confirmMessage(item.noticeId, 1)
     if (res.code === 200) {
       ElMessage.success('纭鎴愬姛')
-      // 鏍囪涓哄凡璇�
-      await markAsRead(messageId)
       // 閲嶆柊鍔犺浇鏁版嵁
       loadMessages()
       loadUnreadCount()
+      
+      // 鏍规嵁 jumpPath 杩涜椤甸潰璺宠浆
+      if (item.jumpPath) {
+        try {
+          // 瑙f瀽 jumpPath锛屽垎绂昏矾寰勫拰鏌ヨ鍙傛暟
+          const [path, queryString] = item.jumpPath.split('?')
+          let query = {}
+          
+          if (queryString) {
+            // 瑙f瀽鏌ヨ鍙傛暟
+            queryString.split('&').forEach(param => {
+              const [key, value] = param.split('=')
+              if (key && value) {
+                query[key] = decodeURIComponent(value)
+              }
+            })
+          }
+          
+          // 璺宠浆鍒版寚瀹氶〉闈�
+          router.push({
+            path: path,
+            query: query
+          })
+        } catch (error) {
+          console.error('椤甸潰璺宠浆澶辫触:', error)
+        }
+      }
     }
   } catch (error) {
     console.error('纭娑堟伅澶辫触:', error)
diff --git a/src/views/collaborativeApproval/approvalProcess/index.vue b/src/views/collaborativeApproval/approvalProcess/index.vue
index d8a99dd..8c84b27 100644
--- a/src/views/collaborativeApproval/approvalProcess/index.vue
+++ b/src/views/collaborativeApproval/approvalProcess/index.vue
@@ -7,6 +7,8 @@
       <el-tab-pane label="鍑哄樊绠$悊" name="3"></el-tab-pane>
       <el-tab-pane label="鎶ラ攢绠$悊" name="4"></el-tab-pane>
       <el-tab-pane label="閲囪喘瀹℃壒" name="5"></el-tab-pane>
+      <el-tab-pane label="鎶ヤ环瀹℃壒" name="6"></el-tab-pane>
+      <el-tab-pane label="鍑哄簱瀹℃壒" name="7"></el-tab-pane>
     </el-tabs>
     
     <div class="search_form">
@@ -62,12 +64,14 @@
 import { Search } from "@element-plus/icons-vue";
 import {onMounted, ref, computed, reactive, toRefs, nextTick, getCurrentInstance} from "vue";
 import {ElMessageBox} from "element-plus";
+import { useRoute } from 'vue-router';
 import InfoFormDia from "@/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue";
 import ApprovalDia from "@/views/collaborativeApproval/approvalProcess/components/approvalDia.vue";
 import {approveProcessDelete, approveProcessListPage} from "@/api/collaborativeApproval/approvalProcess.js";
 import useUserStore from "@/store/modules/user";
 
 const userStore = useUserStore();
+const route = useRoute();
 
 // 褰撳墠閫変腑鐨勬爣绛鹃〉锛岄粯璁や负鍏嚭绠$悊
 const activeTab = ref('1');
@@ -277,6 +281,8 @@
     3: "/approveProcess/exportThree",
     4: "/approveProcess/exportFour",
     5: "/approveProcess/exportFive",
+    6: "/approveProcess/exportSix",
+    7: "/approveProcess/exportSeven",
   }
   const url = urlMap[type] || urlMap[0]
   const nameMap = {
@@ -286,6 +292,8 @@
     3: "鍑哄樊绠$悊瀹℃壒琛�",
     4: "鎶ラ攢绠$悊瀹℃壒琛�",
     5: "閲囪喘鐢宠瀹℃壒琛�",
+    6: "鎶ヤ环瀹℃壒琛�",
+    7: "鍑哄簱瀹℃壒琛�",
   }
   const fileName = nameMap[type] || nameMap[0]
   proxy.download(url, {}, `${fileName}.xlsx`)
@@ -333,6 +341,21 @@
       });
 };
 onMounted(() => {
+  // 鏍规嵁URL鍙傛暟璁剧疆鏍囩椤靛拰鏌ヨ鏉′欢
+  const approveType = route.query.approveType;
+  const approveId = route.query.approveId;
+  
+  if (approveType) {
+    // 璁剧疆鏍囩椤碉紙approveType 瀵瑰簲 activeTab 鐨� name锛�
+    activeTab.value = String(approveType);
+  }
+  
+  if (approveId) {
+    // 璁剧疆娴佺▼缂栧彿鏌ヨ鏉′欢
+    searchForm.value.approveId = String(approveId);
+  }
+  
+  // 鏌ヨ鍒楄〃
   getList();
 });
 </script>

--
Gitblit v1.9.3