index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view class="page_notice" :style="{paddingTop: statusBarHeight + 332 + 'rpx', paddingBottom: safeAreaBottom + 160 + 'rpx' }">
  3. <notice-header
  4. title="任务总览"
  5. mode="taskOverview"
  6. :showSearch="true"
  7. :showFilter="true"
  8. :showTabs="true"
  9. :showCreateBtn="true"
  10. :tabs="tabs"
  11. :activeTab="activeTab"
  12. :academicYearOptions="academicYearOptions"
  13. :academicYearIds="academicYearIds"
  14. :categoryData="categoryData"
  15. @tabChange="handleTabChange"
  16. @academicYearChange="handleAcademicYearChange"
  17. @categoryChange="handleCategoryChange"
  18. @materialTypeChange="handleMaterialTypeChange"
  19. @searchChange="handleSearchChange"
  20. @create="handleCreate">
  21. </notice-header>
  22. <view class="notice_content">
  23. <view class="notice_list">
  24. <scroll-view scroll-y v-for="item in taskList" :key="item.id" class="notice_item">
  25. <!-- 任务内容 -->
  26. <view class="item_content">
  27. <view class="notice_title_row">
  28. <image class="notice_icon" src="/static/image/materialCollection/docIcon.png" mode="aspectFit"></image>
  29. <text class="notice_title">{{ item.taskName }}</text>
  30. </view>
  31. <view class="notice_meta">
  32. <view class="status_tag" :class="statusClassMap[item.taskStatus] || ''">
  33. <text>{{ taskStatusMap[item.taskStatus] }}</text>
  34. </view>
  35. <view class="need_shenhe" v-if="item.auditMechanism">
  36. <text>审</text>
  37. </view>
  38. <text class="meta_text textLength">{{ item.departmentName }}</text>
  39. <text class="meta_text textLength">{{ item.materialCategoryName }}</text>
  40. <text class="meta_text">{{ item.createdBy }}</text>
  41. </view>
  42. </view>
  43. <!-- 任务底部 -->
  44. <view class="item_bottom">
  45. <view class="notice_stats">
  46. <text class="stats_text">开始时间: {{ item.startTime }}</text>
  47. </view>
  48. <view class="notice_actions">
  49. <view class="action_btn delete" :class="{ disable: !!item.submitNum }">
  50. <text>删除</text>
  51. </view>
  52. <view class="action_btn edit" >
  53. <text>编辑</text>
  54. </view>
  55. <view class="action_btn edit" :class="{ disableLock: item.taskStatus === 0 }">
  56. <text>查看</text>
  57. </view>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. <no-data v-if="taskList.length === 0" centered text="暂无任务" />
  62. </view>
  63. </view>
  64. <common-tabbar></common-tabbar>
  65. </view>
  66. </template>
  67. <script setup>
  68. import { ref, onMounted } from 'vue';
  69. import NoticeHeader from '@/components/notice-header.vue';
  70. import CommonTabbar from '@/components/commonTabbar.vue';
  71. import NoData from '@/components/no-data.vue';
  72. import { useSafeArea } from '@/common/safeArea';
  73. import notification from '@/reqApi/notification.js';
  74. const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
  75. const tabs = ['全部', '待开始', '进行中', '已结束'];
  76. const activeTab = ref(-1);
  77. const academicYearIndex = ref(0);
  78. const academicYearOptions = ref(['请选择学年学期']);
  79. const academicYearIds = ref(['']);
  80. const academicYearCodes = ref(['']);
  81. const currentSchoolYearId = ref('');
  82. const currentSchoolYearCode = ref('');
  83. const categoryIndex = ref(0);
  84. const categoryId = ref('');
  85. const materialTypeIndex = ref(0);
  86. const materialTypeId = ref('');
  87. const categoryData = ref([]);
  88. const word = ref('');
  89. const taskList = ref([]);
  90. const statusMap = {
  91. 0: '待开始',
  92. 1: '进行中',
  93. 2: '已结束'
  94. };
  95. const statusClassMap = {
  96. 0: 'status_pending',
  97. 1: 'status_published',
  98. 2: 'status_closed'
  99. };
  100. const taskStatusMap = {
  101. 0: '待开始',
  102. 1: '进行中',
  103. 2: '已结束'
  104. };
  105. const fetchTaskList = async () => {
  106. taskList.value = [];
  107. try {
  108. const params = {
  109. schoolYearCode: currentSchoolYearCode.value || null,
  110. schoolYearId: currentSchoolYearId.value || null,
  111. departmentId: categoryId.value || null,
  112. materialCategory: materialTypeId.value || null,
  113. taskName: word.value || '',
  114. taskStatus: activeTab.value === -1 ? null : activeTab.value,
  115. pageNum: 1,
  116. pageSize: 9999
  117. };
  118. const res = await notification.find_collection_task(params);
  119. if (res.data && res.data.records) {
  120. taskList.value = res.data.records
  121. } else {
  122. taskList.value = [];
  123. }
  124. } catch (error) {
  125. console.error('获取任务列表失败:', error);
  126. taskList.value = [];
  127. }
  128. };
  129. const fetchSchoolYearList = async () => {
  130. try {
  131. const res = await notification.getSchoolYearList();
  132. if (res.data && Array.isArray(res.data)) {
  133. const names = res.data.map(item => item.schoolYearName);
  134. const ids = res.data.map(item => item.id);
  135. const codes = res.data.map(item => item.schoolYearCode);
  136. academicYearOptions.value = [...names];
  137. academicYearIds.value = [...ids];
  138. academicYearCodes.value = [...codes];
  139. // 默认选中第一个学年学期
  140. if (res.data.length > 0) {
  141. academicYearIndex.value = 0;
  142. currentSchoolYearId.value = res.data[0].id;
  143. currentSchoolYearCode.value = res.data[0].schoolYearCode;
  144. }
  145. }
  146. } catch (error) {
  147. console.error('获取学年学期列表失败:', error);
  148. }
  149. };
  150. const fetchCategoryList = async () => {
  151. try {
  152. const res = await notification.getCategoryList();
  153. if (res.data && Array.isArray(res.data)) {
  154. categoryData.value = res.data;
  155. }
  156. } catch (error) {
  157. console.error('获取分类列表失败:', error);
  158. }
  159. };
  160. onMounted(async () => {
  161. initSafeArea();
  162. await fetchSchoolYearList();
  163. fetchCategoryList();
  164. fetchTaskList();
  165. });
  166. const handleTabChange = (status) => {
  167. activeTab.value = status;
  168. fetchTaskList();
  169. };
  170. const handleAcademicYearChange = (index, id) => {
  171. academicYearIndex.value = index;
  172. currentSchoolYearId.value = id || '';
  173. currentSchoolYearCode.value = academicYearCodes.value[index] || '';
  174. fetchTaskList();
  175. };
  176. // 分类选择
  177. const handleCategoryChange = (index, id) => {
  178. categoryIndex.value = index;
  179. categoryId.value = id;
  180. // 清空类目选择
  181. materialTypeIndex.value = 0;
  182. materialTypeId.value = null;
  183. fetchTaskList();
  184. };
  185. // 类目选择
  186. const handleMaterialTypeChange = (index, id) => {
  187. materialTypeIndex.value = index;
  188. materialTypeId.value = id;
  189. fetchTaskList();
  190. };
  191. const handleSearchChange = (keyword) => {
  192. word.value = keyword;
  193. fetchTaskList();
  194. };
  195. const handleCreate = () => {
  196. uni.navigateTo({
  197. url: '/pages/materialCollection/submitMaterial/index'
  198. });
  199. };
  200. const handleDetail = (id) => {
  201. uni.navigateTo({
  202. url: `/pages/materialCollection/submitMaterial/index?id=${id}`
  203. });
  204. };
  205. </script>
  206. <style lang="scss">
  207. .page_notice {
  208. min-height: 100vh;
  209. display: flex;
  210. flex-direction: column;
  211. background-color: #FFFFFF;
  212. box-sizing: border-box;
  213. }
  214. .notice_content {
  215. flex: 1;
  216. display: flex;
  217. flex-direction: column;
  218. overflow: hidden;
  219. padding-left: 0rpx;
  220. padding-right: 0rpx;
  221. }
  222. .notice_list {
  223. flex: 1;
  224. overflow-y: auto;
  225. overflow-x: hidden;
  226. padding: 0 24rpx;
  227. display: flex;
  228. flex-direction: column;
  229. }
  230. .notice_item {
  231. background-color: #F9FAFF;
  232. border-radius: 20rpx;
  233. margin-bottom: 24rpx;
  234. border: 2rpx solid #E4E7ED;
  235. .item_content {
  236. padding: 24rpx;
  237. .notice_title_row {
  238. display: flex;
  239. align-items: center;
  240. margin-bottom: 16rpx;
  241. .notice_icon {
  242. width: 32rpx;
  243. height: 32rpx;
  244. margin-right: 16rpx;
  245. }
  246. .notice_title {
  247. flex: 1;
  248. font-weight: 500;
  249. font-size: 28rpx;
  250. color: #333333;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. }
  256. .notice_meta {
  257. display: flex;
  258. align-items: center;
  259. flex-wrap: wrap;
  260. gap: 16rpx;
  261. .status_tag {
  262. font-size: 24rpx;
  263. height: 48rpx;
  264. width: 96rpx;
  265. text-align: center;
  266. line-height: 48rpx;
  267. border-radius: 4rpx;
  268. font-weight: 400;
  269. border-radius: 8rpx;
  270. &.status_pending {
  271. background: rgba(46, 100, 250, 0.1);
  272. color: #2E64FA;
  273. }
  274. &.status_published {
  275. background: rgba(82, 196, 26, 0.1);
  276. color: #2BC644;
  277. }
  278. &.status_closed {
  279. background: #6666661a;
  280. color: #666666;
  281. }
  282. }
  283. .need_shenhe {
  284. width: 48rpx;
  285. height: 48rpx;
  286. background: rgba(245,108,108,0.1);
  287. border-radius: 8rpx 8rpx 8rpx 8rpx;
  288. font-size: 24rpx;
  289. color: #F56C6C;
  290. text-align: center;
  291. line-height: 48rpx;
  292. }
  293. .meta_text {
  294. font-size: 24rpx;
  295. color: #999999;
  296. line-height: 48rpx;
  297. }
  298. .textLength {
  299. max-width: 160rpx;
  300. overflow: hidden;
  301. text-overflow: ellipsis;
  302. white-space: nowrap;
  303. }
  304. }
  305. }
  306. .item_bottom {
  307. border-top: 2rpx solid #E4E7ED;
  308. display: flex;
  309. flex-direction: row;
  310. justify-content: space-between;
  311. align-items: center;
  312. padding: 24rpx 16rpx;
  313. .notice_stats {
  314. display: flex;
  315. .stats_text {
  316. font-size: 24rpx;
  317. color: #999999;
  318. &:first-child {
  319. margin-right: 32rpx;
  320. }
  321. }
  322. }
  323. .notice_actions {
  324. display: flex;
  325. justify-content: flex-end;
  326. gap: 16rpx;
  327. .action_btn {
  328. font-size: 24rpx;
  329. padding: 12rpx 24rpx;
  330. border-radius: 8rpx;
  331. border: 2rpx solid transparent;
  332. &.delete {
  333. border-color: #F56C6C;
  334. color: #F56C6C;
  335. background-color: #FFFFFF;
  336. &.disabled {
  337. border-color: #C0C4CC;
  338. color: #C0C4CC;
  339. background-color: #FFFFFF;
  340. }
  341. }
  342. &.edit {
  343. border-color: #2E64FA;
  344. color: #2E64FA;
  345. background-color: #FFFFFF;
  346. &.disabled {
  347. border-color: #C0C4CC;
  348. color: #C0C4CC;
  349. background-color: #FFFFFF;
  350. }
  351. }
  352. &.disable {
  353. color: #C0C4CC !important;
  354. cursor: not-allowed;
  355. border-color: #C0C4CC !important;
  356. }
  357. &.disableLock{
  358. color: #C0C4CC !important;
  359. cursor: not-allowed;
  360. background-color: #F3F3F3 !important;
  361. border-color: #F3F3F3 !important;
  362. }
  363. }
  364. }
  365. }
  366. &:last-child {
  367. margin-bottom: 0;
  368. }
  369. }
  370. </style>