| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'announcement_model.dart';
- final mockAnnouncements = <AnnouncementModel>[
- AnnouncementModel(
- id: 'ann-001',
- title: '关于2026年端午节放假安排的通知',
- content:
- '根据国务院办公厅通知精神,现将2026年端午节放假安排通知如下:6月25日(星期四)至6月27日(星期六)放假调休,共3天。6月28日(星期日)上班。请各部门提前做好工作安排,确保节日期间各项工作正常运转。',
- type: 'activity',
- publisherId: 'u-admin',
- publisherName: '行政管理部',
- publishTime: DateTime(2026, 5, 22, 10, 0),
- isTop: true,
- expiryDate: DateTime(2026, 6, 28),
- readCount: 45,
- unreadCount: 12,
- isRead: false,
- attachments: ['放假安排表.pdf'],
- createTime: DateTime(2026, 5, 22, 10, 0),
- ),
- AnnouncementModel(
- id: 'ann-002',
- title: '关于启用新版考勤系统的通知',
- content:
- '为提升考勤管理效率,公司决定于2026年6月1日起全面启用新版考勤系统。新旧系统切换期间,请各部门配合完成以下事项:1. 5月28日前完成全员信息核对;2. 5月29日-31日进行系统试运行。如有问题请及时联系IT部门。',
- type: 'notice',
- publisherId: 'u-admin',
- publisherName: '信息技术部',
- publishTime: DateTime(2026, 5, 20, 14, 0),
- isTop: false,
- expiryDate: DateTime(2026, 6, 15),
- readCount: 30,
- unreadCount: 27,
- isRead: true,
- attachments: ['新版考勤系统操作手册.pdf', '考勤系统FAQ.docx'],
- createTime: DateTime(2026, 5, 20, 14, 0),
- ),
- AnnouncementModel(
- id: 'ann-003',
- title: '2026年第二季度团建活动报名通知',
- content:
- '为增强团队凝聚力,公司将于2026年6月10日组织第二季度团建活动。本次活动地点为北京市怀柔区雁栖湖,活动内容包括户外拓展训练、团队协作游戏和烧烤晚会。请各部门于6月3日前将参加人数报至行政管理部。',
- type: 'activity',
- publisherId: 'u-admin',
- publisherName: '行政管理部',
- publishTime: DateTime(2026, 5, 18, 9, 0),
- isTop: false,
- expiryDate: DateTime(2026, 6, 10),
- readCount: 52,
- unreadCount: 5,
- isRead: false,
- createTime: DateTime(2026, 5, 18, 9, 0),
- ),
- AnnouncementModel(
- id: 'ann-004',
- title: '员工绩效考核管理办法(2026年修订)',
- content:
- '为进一步完善公司绩效考核体系,人力资源部对原《员工绩效考核管理办法》进行了修订。主要修订内容包括:1. 考核周期由季度调整为月度;2. 新增OKR考核维度;3. 明确绩效评级比例分布。新办法自2026年7月1日起施行。',
- type: 'policy',
- publisherId: 'u-admin',
- publisherName: '人力资源部',
- publishTime: DateTime(2026, 5, 15, 11, 0),
- isTop: false,
- expiryDate: DateTime(2027, 5, 15),
- readCount: 38,
- unreadCount: 19,
- isRead: true,
- attachments: ['绩效考核管理办法(2026修订稿).pdf'],
- createTime: DateTime(2026, 5, 15, 11, 0),
- ),
- AnnouncementModel(
- id: 'ann-005',
- title: '关于办公区域禁止吸烟的再次通知',
- content:
- '公司办公区域全面禁止吸烟,请各位同事严格遵守。吸烟区设在大楼一层室外指定区域。违反规定者将按公司纪律条例处理。',
- type: 'notice',
- publisherId: 'u-admin',
- publisherName: '行政管理部',
- publishTime: DateTime(2026, 5, 10, 8, 30),
- isTop: false,
- expiryDate: DateTime(2026, 4, 10),
- readCount: 60,
- unreadCount: 0,
- isRead: true,
- createTime: DateTime(2026, 5, 10, 8, 30),
- ),
- AnnouncementModel(
- id: 'ann-006',
- title: '关于差旅报销标准调整的通知(草稿)',
- content:
- '根据公司财务管理制度,拟对差旅报销标准进行调整,现面向全体员工征求意见。',
- type: 'notice',
- status: 'draft',
- publisherId: 'u-admin',
- publisherName: '财务部',
- publishTime: DateTime(2026, 6, 1, 10, 0),
- isTop: false,
- readCount: 0,
- unreadCount: 0,
- isRead: true,
- createTime: DateTime(2026, 6, 1, 10, 0),
- ),
- ];
- final announcementTabProvider = StateProvider<int>((ref) => 0);
- final isAdminProvider = StateProvider<bool>((ref) => true);
- final filteredAnnouncementsProvider =
- Provider.autoDispose<List<AnnouncementModel>>((ref) {
- final tabIndex = ref.watch(announcementTabProvider);
- final isAdmin = ref.watch(isAdminProvider);
- // 管理员专属:我的草稿 Tab
- if (isAdmin && tabIndex == 4) {
- return mockAnnouncements.where((e) => e.status == 'draft').toList();
- }
- // 类型筛选
- List<AnnouncementModel> list;
- switch (tabIndex) {
- case 1: // 通知公告
- list = mockAnnouncements
- .where((e) => e.type == 'notice' && e.status != 'draft')
- .toList();
- break;
- case 2: // 人事与制度
- list = mockAnnouncements
- .where((e) => e.type == 'policy' && e.status != 'draft')
- .toList();
- break;
- case 3: // 放假与活动
- list = mockAnnouncements
- .where((e) => e.type == 'activity' && e.status != 'draft')
- .toList();
- break;
- default: // 全部
- list = mockAnnouncements
- .where((e) => e.status != 'draft')
- .toList();
- break;
- }
- // 排序:置顶优先 → 未过期按发布时间倒序 → 已过期置灰(排末尾)
- list.sort((a, b) {
- // 置顶优先
- if (a.isTop != b.isTop) return a.isTop ? -1 : 1;
- // 未过期 vs 已过期
- final aExpired = a.isExpired;
- final bExpired = b.isExpired;
- if (aExpired != bExpired) return aExpired ? 1 : -1;
- // 按发布时间倒序
- return b.publishTime.compareTo(a.publishTime);
- });
- return list;
- });
|