index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="page_todo">
  3. <page-header></page-header>
  4. <view class="todo_content">
  5. <!-- 待办事项 -->
  6. <view class="todo_header">
  7. <text class="todo_title">待办事项({{ todoList.length }}项)</text>
  8. </view>
  9. <!-- 待办事项列表 -->
  10. <view class="todo_list">
  11. <view v-for="item in todoList" :key="item.id" class="todo_item">
  12. <view class="todo_left">
  13. <view class="todo_info">
  14. <view class="todo_title_row">
  15. <image src="/static/image/todo/xiaoxi.png" class="todo_icon" mode="aspectFit"></image>
  16. <text class="todo_name">{{ item.title }}</text>
  17. <uni-icons type="right" size="18" color="#999999"></uni-icons>
  18. </view>
  19. <view class="todo_meta">
  20. <text class="meta_tag" :class="getTagStyle(item.status)">{{ item.status }}</text>
  21. <text v-for="(tag, idx) in item.categoryTags" :key="idx" class="meta_type">{{ tag }}</text>
  22. <text class="meta_time">{{ item.time }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view v-if="todoList.length === 0" class="schedule_empty">
  29. <image src="/static/image/analysis/no_data.png" class="empty_image" mode="aspectFit"></image>
  30. <text class="empty_text">暂无待办事项</text>
  31. </view>
  32. </view>
  33. <common-tabbar></common-tabbar>
  34. </view>
  35. </template>
  36. <script setup>
  37. import { ref, onMounted } from 'vue';
  38. import { onShow } from '@dcloudio/uni-app';
  39. import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
  40. import PageHeader from '@/components/page-header.vue';
  41. import workspace from '@/reqApi/workspace.js';
  42. const todoList = ref([]);
  43. const getTagStyle = (status) => {
  44. if (status === '已驳回') {
  45. return 'meta_tag_red'
  46. }
  47. if (status === '进行中' || status === "已通过") {
  48. return 'meta_tag_green'
  49. }
  50. return ''
  51. }
  52. const fetchTodoList = async () => {
  53. try {
  54. const res = await workspace.getTodoList();
  55. if (res && res.data) {
  56. todoList.value = res.data.map(item => {
  57. const categoryTags = [];
  58. if (item.departmentName) categoryTags.push(item.departmentName);
  59. if (item.materialCategoryName) categoryTags.push(item.materialCategoryName);
  60. return {
  61. id: item.id,
  62. title: item.title,
  63. status: item.source === 2 ? '进行中' : (item.notSubmitNum > 0 ? `待提交:${item.notSubmitNum}` : (item.rejectNum > 0 ? `已驳回:${item.rejectNum}` : '')),
  64. btnText: item.source === 1 ? '查看通知' : '查看任务',
  65. categoryTags,
  66. time: item.daysRemaining !== undefined ? `剩余${item.daysRemaining}天` : '',
  67. tag: '',
  68. };
  69. });
  70. }
  71. } catch (error) {
  72. console.error('获取待办事项列表失败:', error);
  73. }
  74. };
  75. onShow(() => {
  76. fetchTodoList();
  77. });
  78. </script>
  79. <style lang="scss">
  80. .page_todo {
  81. // min-height: 100vh;
  82. // background-color: #F5F7FA;
  83. // padding-bottom: 120rpx;
  84. }
  85. .todo_content {
  86. padding: 140rpx 24rpx 24rpx 24rpx;
  87. }
  88. // 待办事项标题
  89. .todo_header {
  90. display: flex;
  91. align-items: baseline;
  92. margin-bottom: 24rpx;
  93. .todo_title {
  94. font-weight: 500;
  95. font-size: 32rpx;
  96. color: #333333;
  97. }
  98. .todo_count {
  99. font-size: 26rpx;
  100. color: #999999;
  101. margin-left: 8rpx;
  102. }
  103. }
  104. .todo_list {
  105. .todo_item {
  106. display: flex;
  107. align-items: center;
  108. justify-content: space-between;
  109. padding: 20rpx 16rpx;
  110. background: #F9FAFF;
  111. border-radius: 20rpx;
  112. margin-bottom: 24rpx;
  113. border: 2rpx solid #E4E7ED;
  114. &:last-child {
  115. margin-bottom: 0;
  116. }
  117. .todo_left {
  118. display: flex;
  119. flex: 1;
  120. align-items: flex-start;
  121. gap: 16rpx;
  122. }
  123. .todo_icon {
  124. flex-shrink: 0;
  125. margin-top: 4rpx;
  126. width: 32rpx;
  127. height: 32rpx;
  128. }
  129. .todo_info {
  130. flex: 1;
  131. overflow: hidden;
  132. }
  133. .todo_title_row {
  134. display: flex;
  135. align-items: center;
  136. gap: 16rpx;
  137. margin-bottom: 16rpx;
  138. .todo_name {
  139. font-size: 28rpx;
  140. color: #333333;
  141. font-weight: 500;
  142. flex: 1;
  143. width: 0;
  144. overflow: hidden;
  145. text-overflow: ellipsis;
  146. white-space: nowrap;
  147. }
  148. .todo_tag {
  149. font-size: 24rpx;
  150. padding: 6rpx 12rpx;
  151. border-radius: 4rpx;
  152. flex-shrink: 0;
  153. &.tag-red {
  154. background-color: rgba(245, 108, 108, 0.1);
  155. color: #F56C6C;
  156. }
  157. }
  158. }
  159. .todo_meta {
  160. display: flex;
  161. align-items: center;
  162. flex-wrap: wrap;
  163. gap: 16rpx;
  164. .meta_tag {
  165. font-size: 22rpx;
  166. padding: 8rpx 12rpx;
  167. background-color: rgba(74, 108, 247, 0.1);
  168. color: #4A6CF7;
  169. border-radius: 4rpx;
  170. }
  171. .meta_tag_red {
  172. background-color: rgba(245, 108, 108, 0.1);
  173. color: #F56C6C;
  174. }
  175. .meta_tag_green {
  176. background-color: rgba(43, 198, 68, 0.1);
  177. color: #2BC644;
  178. }
  179. .meta_type {
  180. font-size: 24rpx;
  181. color: #999999;
  182. }
  183. .meta_time {
  184. font-size: 24rpx;
  185. color: #999999;
  186. }
  187. }
  188. }
  189. }
  190. .schedule_empty {
  191. display: flex;
  192. flex-direction: column;
  193. align-items: center;
  194. font-size: 28rpx;
  195. color: #999999;
  196. position: relative;
  197. .empty_image {
  198. width: 400rpx;
  199. height: 400rpx;
  200. }
  201. .empty_text {
  202. position: absolute;
  203. bottom: 15%;
  204. left: 50%;
  205. transform: translate(-50%, -50%);
  206. }
  207. }
  208. </style>