diff --git a/api/dashboard.js b/api/dashboard.js index 4ed89ba..fe4c78d 100644 --- a/api/dashboard.js +++ b/api/dashboard.js @@ -49,3 +49,29 @@ export const getCustomerStatistics = (params = {}) => { }); }; +/** + * 获取公告列表 + * @param {Object} params 请求参数 + * @param {number} params.pageNum 页码 + * @param {number} params.pageSize 每页数量 + * @returns {Promise} 返回公告列表 + */ +export const getNoticeList = (params = {}) => { + const queryParams = []; + + if (params.pageNum !== undefined) { + queryParams.push(`pageNum=${params.pageNum}`); + } + if (params.pageSize !== undefined) { + queryParams.push(`pageSize=${params.pageSize}`); + } + + const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : ''; + + return uni.$uv.http.get(`bst/notice/list${queryString}`, { + custom: { + auth: true // 启用 token 认证 + } + }); +}; + diff --git a/components/index/ContentDashboard.vue b/components/index/ContentDashboard.vue index 0431450..1a6b9f2 100644 --- a/components/index/ContentDashboard.vue +++ b/components/index/ContentDashboard.vue @@ -79,17 +79,30 @@ - - 📢 - 公告事项 + + 公告 + 查看全部》 - - {{ announcement.title }} - {{ announcement.description }} - {{ announcement.time }} + + + {{ announcement.title }} + + 置顶 + 重要 + + + + + 👤 + {{ announcement.userName }} + + + 🕐 + {{ announcement.createTime }} + + - @@ -156,7 +169,7 @@ import { ref, onMounted, watch, computed } from 'vue'; import { storeToRefs } from 'pinia'; import { getTaskStatusType, getTaskStatusStyle, getStatusText } from '@/utils/taskConfig.js'; -import { getDashboardBrief, getTaskList } from '@/api'; +import { getDashboardBrief, getTaskList, getNoticeList } from '@/api'; import { useUserStore } from '@/store/user'; import {truncateText} from "@/utils/textSolve/truncateText"; @@ -182,14 +195,7 @@ const taskStats = ref([ const overdueTasks = ref([]); // 公告事项 -const announcements = ref([ - { - id: 1, - title: '·国庆放假通知', - description: '国庆放假安排1号至6号,前后不调休...', - time: '2025-09-26 16:54:46' - } -]); +const announcements = ref([]); // 项目状态 const projectStatus = ref([ @@ -313,6 +319,33 @@ const loadOverdueTasks = async () => { } }; +// 加载公告列表 +const loadAnnouncements = async () => { + try { + const res = await getNoticeList({ pageNum: 1, pageSize: 2 }); + console.log('公告列表加载成功:', res); + + if (res && res.rows && Array.isArray(res.rows)) { + announcements.value = res.rows.map((item) => { + return { + id: item.id || '', + title: item.title || '', + content: item.content || '', + userName: item.userName || '', + createTime: item.createTime || '', + top: item.top || false, + level: item.level || '' + }; + }); + } else { + announcements.value = []; + } + } catch (err) { + console.error('加载公告列表失败:', err); + announcements.value = []; + } +}; + // 加载看板数据 const loadDashboardData = async () => { try { @@ -349,6 +382,9 @@ const loadDashboardData = async () => { // 加载逾期任务列表 await loadOverdueTasks(); + + // 加载公告列表 + await loadAnnouncements(); } catch (err) { console.error('加载看板数据失败:', err); uni.showToast({ @@ -415,12 +451,22 @@ const handleOverdueTask = (task) => { // 查看公告 const viewAnnouncement = (announcement) => { console.log('查看公告:', announcement); + // TODO: 跳转到公告详情页 uni.showToast({ title: '查看公告详情', icon: 'none' }); }; +// 查看全部公告 +const viewAllAnnouncements = () => { + // TODO: 跳转到公告列表页 + uni.showToast({ + title: '查看全部公告', + icon: 'none' + }); +}; + // 获取项目状态标签类型 const getProjectStatusType = (label) => { const typeMap = { @@ -706,7 +752,6 @@ const getTagCustomStyle = (status) => { .project-status-section, .customer-status-section { margin-top: 8px; - } .section-header { @@ -726,45 +771,101 @@ const getTagCustomStyle = (status) => { color: #333; } -.announcement-item { +// 公告头部 +.announcement-header { display: flex; align-items: center; justify-content: space-between; - margin-bottom: 8px; + margin-bottom: 12px; + padding-bottom: 8px; + border-bottom: 1px solid #f0f0f0; +} + +.announcement-title-header { + font-size: 16px; + font-weight: 600; + color: #333; +} + +.announcement-view-all { + font-size: 14px; + color: #2885ff; + cursor: pointer; +} + +.announcement-item { + display: flex; + flex-direction: column; + margin-bottom: 12px; } .task-card-announcement { - border-left: 4px solid #2885ff; + border-left: none; + padding: 16px; } -.announcement-content { - flex: 1; +.announcement-content-wrapper { display: flex; flex-direction: column; - gap: 8px; + gap: 12px; +} + +.announcement-title-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; } .announcement-title { font-size: 14px; font-weight: 500; - color: #333; + color: #f56c6c; + flex: 1; } -.announcement-desc { +.announcement-tags { + display: flex; + align-items: center; + gap: 6px; + flex-shrink: 0; +} + +.announcement-tag { + padding: 2px 8px; + border-radius: 4px; + font-size: 12px; + color: #fff; + white-space: nowrap; +} + +.tag-pinned { + background-color: #f56c6c; +} + +.tag-important { + background-color: #ff9800; +} + +.announcement-meta { + display: flex; + align-items: center; + gap: 16px; +} + +.announcement-meta-item { + display: flex; + align-items: center; + gap: 4px; +} + +.announcement-meta-icon { + font-size: 14px; +} + +.announcement-meta-text { font-size: 12px; color: #666; - line-height: 1.5; -} - -.announcement-time { - font-size: 12px; - color: #999; -} - -.arrow { - font-size: 20px; - color: #999; - margin-left: 12px; } .status-grid { diff --git a/utils/request/index.js b/utils/request/index.js index cd3cada..f97b9cc 100644 --- a/utils/request/index.js +++ b/utils/request/index.js @@ -10,8 +10,8 @@ export const Request = () => { // 初始化请求配置 uni.$uv.http.setConfig((config) => { /* config 为默认全局配置*/ - // config.baseURL = 'http://192.168.1.4:4001'; /* 根域名 */ - config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */ + config.baseURL = 'http://192.168.1.4:4001'; /* 根域名 */ + // config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */ return config })