index.vue 9.5 KB

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