index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="page_notice" :style="{paddingTop: statusBarHeight + 362 + 'rpx', paddingBottom: safeAreaBottom + 160 + 'rpx' }">
  3. <noticeHeader
  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. </noticeHeader>
  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" @click="handleEdit(item)" >
  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. <noData 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/noticeHeader.vue';
  70. import CommonTabbar from '@/components/commonTabbar.vue';
  71. import NoData from '@/components/noData.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/taskOverview/components/index'
  199. });
  200. };
  201. const handleEdit = (item) => {
  202. uni.navigateTo({
  203. url: `/pages/materialCollection/taskOverview/components/index?id=${item.id}`
  204. });
  205. };
  206. const handleDetail = (id) => {
  207. uni.navigateTo({
  208. url: `/pages/materialCollection/submitMaterial/index?id=${id}`
  209. });
  210. };
  211. </script>
  212. <style lang="scss">
  213. .page_notice {
  214. min-height: 100vh;
  215. display: flex;
  216. flex-direction: column;
  217. background-color: #FFFFFF;
  218. box-sizing: border-box;
  219. }
  220. .notice_content {
  221. flex: 1;
  222. display: flex;
  223. flex-direction: column;
  224. overflow: hidden;
  225. padding-left: 0rpx;
  226. padding-right: 0rpx;
  227. }
  228. .notice_list {
  229. flex: 1;
  230. overflow-y: auto;
  231. overflow-x: hidden;
  232. padding: 0 24rpx;
  233. display: flex;
  234. flex-direction: column;
  235. }
  236. .notice_item {
  237. background-color: #F9FAFF;
  238. border-radius: 20rpx;
  239. margin-bottom: 24rpx;
  240. border: 2rpx solid #E4E7ED;
  241. .item_content {
  242. padding: 24rpx;
  243. .notice_title_row {
  244. display: flex;
  245. align-items: center;
  246. margin-bottom: 16rpx;
  247. .notice_icon {
  248. width: 32rpx;
  249. height: 32rpx;
  250. margin-right: 16rpx;
  251. }
  252. .notice_title {
  253. flex: 1;
  254. font-weight: 500;
  255. font-size: 28rpx;
  256. color: #333333;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. white-space: nowrap;
  260. }
  261. }
  262. .notice_meta {
  263. display: flex;
  264. align-items: center;
  265. flex-wrap: wrap;
  266. gap: 16rpx;
  267. .status_tag {
  268. font-size: 24rpx;
  269. height: 48rpx;
  270. width: 96rpx;
  271. text-align: center;
  272. line-height: 48rpx;
  273. border-radius: 4rpx;
  274. font-weight: 400;
  275. border-radius: 8rpx;
  276. &.status_pending {
  277. background: rgba(46, 100, 250, 0.1);
  278. color: #2E64FA;
  279. }
  280. &.status_published {
  281. background: rgba(82, 196, 26, 0.1);
  282. color: #2BC644;
  283. }
  284. &.status_closed {
  285. background: #6666661a;
  286. color: #666666;
  287. }
  288. }
  289. .need_shenhe {
  290. width: 48rpx;
  291. height: 48rpx;
  292. background: rgba(245,108,108,0.1);
  293. border-radius: 8rpx 8rpx 8rpx 8rpx;
  294. font-size: 24rpx;
  295. color: #F56C6C;
  296. text-align: center;
  297. line-height: 48rpx;
  298. }
  299. .meta_text {
  300. font-size: 24rpx;
  301. color: #999999;
  302. line-height: 48rpx;
  303. }
  304. .textLength {
  305. max-width: 160rpx;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. white-space: nowrap;
  309. }
  310. }
  311. }
  312. .item_bottom {
  313. border-top: 2rpx solid #E4E7ED;
  314. display: flex;
  315. flex-direction: row;
  316. justify-content: space-between;
  317. align-items: center;
  318. padding: 24rpx 16rpx;
  319. .notice_stats {
  320. display: flex;
  321. .stats_text {
  322. font-size: 24rpx;
  323. color: #999999;
  324. &:first-child {
  325. margin-right: 32rpx;
  326. }
  327. }
  328. }
  329. .notice_actions {
  330. display: flex;
  331. justify-content: flex-end;
  332. gap: 16rpx;
  333. .action_btn {
  334. font-size: 24rpx;
  335. padding: 12rpx 24rpx;
  336. border-radius: 8rpx;
  337. border: 2rpx solid transparent;
  338. &.delete {
  339. border-color: #F56C6C;
  340. color: #F56C6C;
  341. background-color: #FFFFFF;
  342. &.disabled {
  343. border-color: #C0C4CC;
  344. color: #C0C4CC;
  345. background-color: #FFFFFF;
  346. }
  347. }
  348. &.edit {
  349. border-color: #2E64FA;
  350. color: #2E64FA;
  351. background-color: #FFFFFF;
  352. &.disabled {
  353. border-color: #C0C4CC;
  354. color: #C0C4CC;
  355. background-color: #FFFFFF;
  356. }
  357. }
  358. &.disable {
  359. color: #C0C4CC !important;
  360. cursor: not-allowed;
  361. border-color: #C0C4CC !important;
  362. }
  363. &.disableLock{
  364. color: #C0C4CC !important;
  365. cursor: not-allowed;
  366. background-color: #F3F3F3 !important;
  367. border-color: #F3F3F3 !important;
  368. }
  369. }
  370. }
  371. }
  372. &:last-child {
  373. margin-bottom: 0;
  374. }
  375. }
  376. </style>