related-items.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="related-items-page" :style="{ '--font-scale': fontScale }">
  3. <view class="tab-bar">
  4. <view v-for="(tab, idx) in tabs" :key="idx" :class="'tab-item ' + (activeTab === idx ? 'active' : '')" @click="switchTab(idx)">
  5. <text class="tab-text">{{ tab.label }}</text>
  6. <view v-if="activeTab === idx" class="tab-underline"></view>
  7. </view>
  8. </view>
  9. <view v-if="loading" class="loading-state"><text>加载中...</text></view>
  10. <view v-else-if="error" class="error-state"><text class="error-text">{{ error }}</text></view>
  11. <view v-else class="content">
  12. <view v-if="activeTab === 0" class="tab-content">
  13. <view v-if="!items.pendingTasks || items.pendingTasks.length === 0" class="empty-state"><text class="empty-text">暂无待办任务</text></view>
  14. <view v-else class="item-list">
  15. <view v-for="(item, idx) in items.pendingTasks" :key="idx" class="item-card" @click="goToTask(item)">
  16. <view class="item-header">
  17. <text class="item-title">{{ item.title }}</text>
  18. <text :class="'status-tag ' + statusClass(item.status)">{{ statusText(item.status) }}</text>
  19. </view>
  20. <view class="item-meta">
  21. <text class="meta-text" v-if="item.assignee">负责人: {{ item.assignee }}</text>
  22. <text class="meta-text" v-if="item.dueDate">截止: {{ item.dueDate }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view v-if="activeTab === 1" class="tab-content">
  28. <view v-if="!items.pendingAssessments || items.pendingAssessments.length === 0" class="empty-state"><text class="empty-text">暂无待测评</text></view>
  29. <view v-else class="item-list">
  30. <view v-for="(item, idx) in items.pendingAssessments" :key="idx" class="item-card">
  31. <view class="item-header">
  32. <text class="item-title">{{ item.childName }}的测评</text>
  33. <text :class="'status-tag ' + statusClass(item.status)">{{ statusText(item.status) }}</text>
  34. </view>
  35. <view class="item-meta">
  36. <text class="meta-text" v-if="item.appointmentDate">{{ item.appointmentDate }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="activeTab === 2" class="tab-content">
  42. <view v-if="!items.healthAlerts || items.healthAlerts.length === 0" class="empty-state"><text class="empty-text">暂无健康提醒</text></view>
  43. <view v-else class="item-list">
  44. <view v-for="(item, idx) in items.healthAlerts" :key="idx" class="item-card">
  45. <view class="item-header">
  46. <text class="item-title">{{ item.message }}</text>
  47. <text :class="'alert-level ' + alertLevelClass(item.severity)">{{ item.severity }}</text>
  48. </view>
  49. <view class="item-meta">
  50. <text class="meta-text" v-if="item.members && item.members.length > 0">成员: {{ item.members.join(', ') }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="activeTab === 3" class="tab-content">
  56. <view v-if="!items.upcomingMilestones || items.upcomingMilestones.length === 0" class="empty-state"><text class="empty-text">暂无里程碑</text></view>
  57. <view v-else class="item-list">
  58. <view v-for="(item, idx) in items.upcomingMilestones" :key="idx" class="item-card">
  59. <view class="item-header">
  60. <text class="item-title">{{ item.description }}</text>
  61. </view>
  62. <view class="item-meta">
  63. <text class="meta-text" v-if="item.targetDate">目标: {{ item.targetDate }}</text>
  64. <text class="meta-text" v-if="item.daysAway !== undefined">{{ item.daysAway }}天后</text>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import fontScaleMixin from '@/mixins/font-scale.js'
  74. export default {
  75. mixins: [fontScaleMixin],
  76. data: function() {
  77. return {
  78. activeTab: 0,
  79. tabs: [{ label: '任务' }, { label: '测评' }, { label: '健康' }, { label: '里程碑' }],
  80. items: { pendingTasks: [], pendingAssessments: [], healthAlerts: [], upcomingMilestones: [] },
  81. loading: false, error: null
  82. }
  83. },
  84. onLoad: function() { this.loadRelatedItems() },
  85. methods: {
  86. switchTab: function(idx) { this.activeTab = idx },
  87. loadRelatedItems: function() {
  88. var self = this
  89. self.loading = true; self.error = null
  90. self.$store.dispatch('tianpan/loadRelatedItems', { daysAhead: 7 })
  91. .then(function(data) { self.items = data || self.items })
  92. .catch(function(e) { self.error = e.message || '加载失败' })
  93. .finally(function() { self.loading = false })
  94. },
  95. goBack: function() { uni.navigateBack() },
  96. statusText: function(s) { var map = { pending: '待处理', in_progress: '进行中', completed: '已完成', cancelled: '已取消' }; return map[s] || s || '' },
  97. statusClass: function(s) { var map = { pending: 'pending', in_progress: 'in-progress', completed: 'completed', cancelled: 'cancelled' }; return map[s] || 'pending' },
  98. alertLevelClass: function(l) { var map = { low: 'alert-low', medium: 'alert-medium', high: 'alert-high' }; return map[l] || 'alert-low' },
  99. goToTask: function(item) { if (item.id) { uni.navigateTo({ url: '/pages/tasks/detail?id=' + item.id }) } }
  100. }
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .related-items-page { min-height: 100vh; background: $facade-fill-gray-100; }
  105. .nav-right { width: 80rpx; }
  106. .tab-bar { display: flex; background: $app-surface; border-bottom: 2rpx solid $facade-gray-200; position: sticky; top: 0; z-index: 10; }
  107. .tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 24rpx 0; position: relative; }
  108. .tab-text { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-slate; }
  109. .tab-item.active .tab-text { color: $brand-primary; font-weight: 500; }
  110. .tab-underline { position: absolute; bottom: 0; width: 80rpx; height: 4rpx; background: $brand-primary; border-radius: 8rpx; }
  111. .loading-state, .error-state, .empty-state { padding: 120rpx 40rpx; display: flex; justify-content: center; align-items: center; }
  112. .error-text, .empty-text { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-gray-400; }
  113. .content { padding: 24rpx; }
  114. .tab-content { min-height: 600rpx; }
  115. .item-list { display: flex; flex-direction: column; }
  116. .item-card { background: $app-surface; border-radius: 24rpx; padding: 28rpx; margin-bottom: 20rpx; }
  117. .item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx; }
  118. .item-title { font-size: calc(28rpx * var(--font-scale, 1)); font-weight: 500; color: $facade-text-gray-800; flex: 1; }
  119. .status-tag { font-size: calc(22rpx * var(--font-scale, 1)); padding: 4rpx 16rpx; border-radius: 24rpx; }
  120. .status-tag.pending { background: $status-warning-soft; color: $status-warning-strong; }
  121. .status-tag.in-progress { background: $status-info-soft; color: #1E40AF; }
  122. .status-tag.completed { background: $status-success-soft-2; color: $mat-green-800; }
  123. .status-tag.cancelled { background: $facade-fill-gray-100; color: $facade-text-slate; }
  124. .alert-level { font-size: calc(22rpx * var(--font-scale, 1)); padding: 4rpx 16rpx; border-radius: 24rpx; }
  125. .alert-low { background: $status-success-soft-2; color: $mat-green-800; }
  126. .alert-medium { background: $status-warning-soft; color: $status-warning-strong; }
  127. .alert-high { background: $status-danger-soft; color: #991B1B; }
  128. .item-meta { display: flex; gap: 24rpx; margin-bottom: 8rpx; }
  129. .meta-text { font-size: calc(24rpx * var(--font-scale, 1)); color: $facade-text-gray-400; }
  130. </style>