DimensionTasks.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="section" v-if="displayTasks && displayTasks.length > 0">
  3. <view class="section-header">
  4. <text class="section-title">📋 今日任务</text>
  5. <text class="section-more" @click="$emit('moreTasks')">全部 ›</text>
  6. </view>
  7. <view class="task-list">
  8. <view class="task-card" v-for="task in displayTasks" :key="task.id" @click="$emit('taskClick', task)">
  9. <view class="task-left">
  10. <view class="task-check" :class="{ 'checked': task.status === 'completed' }">
  11. <text class="task-check-icon" v-if="task.status === 'completed'">✓</text>
  12. </view>
  13. </view>
  14. <view class="task-content">
  15. <text class="task-name" :class="{ 'done': task.status === 'completed' }">{{ task.title }}</text>
  16. <view class="task-meta">
  17. <text class="task-points" v-if="task.points">+{{ task.points }}分</text>
  18. <text class="task-penalty" v-if="task.penalty">-{{ task.penalty }}分</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. props: {
  28. dimensionCode: { type: String, required: true },
  29. tasks: { type: Array, default: function() { return [] } },
  30. childId: { type: Number, default: null }
  31. },
  32. data: function() {
  33. return {
  34. tasksData: []
  35. }
  36. },
  37. computed: {
  38. displayTasks: function() {
  39. return this.tasksData.length > 0 ? this.tasksData : this.tasks
  40. }
  41. },
  42. created: function() {
  43. this.loadTasks()
  44. },
  45. methods: {
  46. loadTasks: function() {
  47. var self = this
  48. if (!self.childId) return
  49. import('@/utils/api.js').then(function(api) {
  50. api.getTodayTasksByCategory(self.childId, self.dimensionCode).then(function(res) {
  51. self.tasksData = res.data || []
  52. }).catch(function() {
  53. // silently fail
  54. })
  55. })
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped>
  61. .section {
  62. margin: 20rpx 20rpx;
  63. }
  64. .section-header {
  65. display: flex;
  66. justify-content: space-between;
  67. align-items: center;
  68. margin-bottom: 20rpx;
  69. }
  70. .section-title {
  71. font-size: 30rpx;
  72. font-weight: bold;
  73. color: #333;
  74. }
  75. .section-more {
  76. font-size: 24rpx;
  77. color: #999;
  78. }
  79. .task-list {
  80. display: flex;
  81. flex-direction: column;
  82. }
  83. .task-card {
  84. display: flex;
  85. flex-direction: row;
  86. align-items: center;
  87. background: #fff;
  88. border-radius: 16rpx;
  89. padding: 24rpx 20rpx;
  90. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  91. margin-bottom: 16rpx;
  92. }
  93. .task-card:active { opacity: 0.8; }
  94. .task-left {
  95. margin-right: 20rpx;
  96. }
  97. .task-check {
  98. width: 44rpx;
  99. height: 44rpx;
  100. border-radius: 50%;
  101. border: 3rpx solid #ddd;
  102. display: flex;
  103. align-items: center;
  104. justify-content: center;
  105. background: #f9f9f9;
  106. }
  107. .task-check.checked {
  108. background: #22C55E;
  109. border-color: #22C55E;
  110. }
  111. .task-check-icon {
  112. font-size: 24rpx;
  113. color: #fff;
  114. font-weight: bold;
  115. }
  116. .task-content {
  117. flex: 1;
  118. display: flex;
  119. flex-direction: row;
  120. justify-content: space-between;
  121. align-items: center;
  122. }
  123. .task-name {
  124. font-size: 28rpx;
  125. color: #333;
  126. }
  127. .task-name.done {
  128. text-decoration: line-through;
  129. color: #999;
  130. }
  131. .task-meta {
  132. display: flex;
  133. flex-direction: row;
  134. align-items: center;
  135. }
  136. .task-points {
  137. font-size: 24rpx;
  138. color: #22C55E;
  139. margin-right: 12rpx;
  140. }
  141. .task-penalty {
  142. font-size: 24rpx;
  143. color: #EF4444;
  144. }
  145. </style>