index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <template>
  2. <!-- 头部 -->
  3. <nav-bar height="400" backPath="workspace" title="材料采集" :filterPickerData="state.filterPickerData" :tabList="state.tabList" :onlyTitle="false" :showFilterPicker="true" :showTabs="true" rightWidth="0rpx" @CommonFilterData="CommonFilterData">
  4. <template #tabs_top_content>
  5. <view class="task_status_list">
  6. <view :class="['item_status',{'active':item.value==state.params.taskStatus}]" v-for="item in state.taskStatusList" :key="item.value" @click="ChangeTaskStatus(item.value)">{{item.label}}</view>
  7. </view>
  8. </template>
  9. </nav-bar>
  10. <view class="page_content">
  11. <scroll-view
  12. class="scroll_view_y"
  13. :scroll-top="state.scrollTop"
  14. scroll-y="true"
  15. :refresher-enabled="false"
  16. :enable-back-to-top="true"
  17. :show-scrollbar="false"
  18. :scroll-with-animation="true"
  19. refresher-default-style="none"
  20. refresher-background="#F8F9FD"
  21. :refresher-triggered="state.isRefreshing"
  22. @scrolltolower="OnLoadMore"
  23. @refresherrefresh="OnRefresh"
  24. @scroll="OnScroll">
  25. <view class="refresh_loading" v-if="state.isRefreshing"><uni-load-more status="loading" /></view>
  26. <view class="notice_list">
  27. <view v-for="item in state.pageList" :key="item.id" class="notice_item">
  28. <!-- 任务内容 -->
  29. <view class="item_content">
  30. <view class="notice_title_row">
  31. <image class="notice_icon" src="@/static/image/materialCollection/docIcon.png" mode="aspectFit"></image>
  32. <text class="notice_title">{{ item.taskName }}</text>
  33. </view>
  34. <view class="notice_meta">
  35. <view class="status_tag" :class="statusClassMap[item.taskStatus] || ''">
  36. <text>{{ taskStatusMap[item.taskStatus] }}</text>
  37. </view>
  38. <text class="meta_text ">{{ truncateText(item.departmentName, 5) }}</text>
  39. <text class="meta_text ">{{ 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. <view class="status_tag" :class="state.params.auditStatus">
  47. <text>{{ tabStatusClassMap[state.params.auditStatus] }}:{{ item?.taskTargetVos?.length || 0 }}</text>
  48. </view>
  49. <text class="stats_text">
  50. <template v-if="remainingDays(item.endTime) > 0">剩余时间:{{remainingDays(item.endTime) }}天</template>
  51. <template v-else>结束时间:{{item.endTime }}</template>
  52. </text>
  53. </view>
  54. <view class="notice_actions">
  55. <view class="action_btn edit" @click="handleDetail(item)">
  56. <text>查看</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="no_data" v-if="!state.isLoading && state.pageList.length == 0">
  63. <image class="no_data_img" src="@/static/image/bg/no_data.png"></image>
  64. <text class="no_data_text">暂无数据</text>
  65. </view>
  66. <uni-load-more v-if="state.pageList.length > 0" :status="state.loadStatus" />
  67. </scroll-view>
  68. </view>
  69. </template>
  70. <script setup>
  71. import { reactive,ref,nextTick, onMounted,onUnmounted } from 'vue';
  72. import navBar from '@/components/navBar.vue';
  73. import {onShow} from '@dcloudio/uni-app';
  74. import {findTeacherTaskTargetList,getSchoolYearList,getCategoryList} from '@/reqApi/notification.js';
  75. import { truncateText,remainingDays } from '@/common/common.js';
  76. const state = reactive({
  77. filterPickerData: [{
  78. valueIndex:0,//默认值索引
  79. defaultValue:'',//默认值
  80. list:[]
  81. },{
  82. valueIndex:0,//默认值索引
  83. defaultValue:'',//默认值
  84. list:[]
  85. },{
  86. valueIndex:0,//默认值索引
  87. defaultValue:'',//默认值
  88. list:[]
  89. }],
  90. tabList: [{
  91. label: '待提交',
  92. value: 'notSubmitList'
  93. }, {
  94. label: '审核中',
  95. value: 'notReviewList'
  96. }, {
  97. label: '已驳回',
  98. value: 'reviewReasonList'
  99. }, {
  100. label: '已提交',
  101. value: 'reviewList'
  102. }],
  103. taskStatusList:[{
  104. label:'进行中',
  105. value:1
  106. },{
  107. label:'已结束',
  108. value:2
  109. }],
  110. params:{//参数
  111. schoolYearCode: '',//学年
  112. schoolYearId:'',//学年id
  113. departmentId:'',//归属部门
  114. materialCategory:'',//材料类目
  115. taskName:'',//任务名称
  116. taskStatus:1,//任务状态 1-进行中 2-已结束
  117. auditStatus:'notSubmitList',//审核状态
  118. pageSize: 30,
  119. pageNum: 1,
  120. },
  121. pageLists:[],//全部数据
  122. pageList:[],//列表数据
  123. pages:0,
  124. scrollTop:0,
  125. oldScrollTop:0,
  126. isRefreshing:false,//设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  127. isLoading:true,//加载中
  128. noMoreData:false,//没有更多数据了
  129. loadStatus:'more',//loading状态
  130. })
  131. const statusClassMap = {
  132. 0: 'status_pending',
  133. 1: 'status_published',
  134. 2: 'status_closed'
  135. };
  136. const taskStatusMap = {
  137. 0: '待开始',
  138. 1: '进行中',
  139. 2: '已结束'
  140. }
  141. const tabStatusClassMap = {
  142. 'notSubmitList':'待提交', // 待提交
  143. 'notReviewList':'审核中', // 审核中
  144. 'reviewReasonList':'已驳回', // 已驳回
  145. 'reviewList':'已提交' // 已提交
  146. };
  147. // 学年学期列表
  148. const fetchSchoolYearList = async () => {
  149. try {
  150. const res = await getSchoolYearList();
  151. if (res.data && Array.isArray(res.data)) {
  152. const resData = res.data;
  153. state.filterPickerData[0].list = resData.map(item=>({
  154. ...item,
  155. label:item.schoolYearName,
  156. value:item.id
  157. }))
  158. const schoolYearId = state.filterPickerData?.[0]?.list?.[0]?.value || '';
  159. const schoolYearCode = state.filterPickerData?.[0]?.list?.[0]?.schoolYearCode || '';
  160. state.filterPickerData[0].defaultValue = schoolYearId;
  161. state.params.schoolYearId = schoolYearId;//默认值学年id
  162. state.params.schoolYearCode = schoolYearCode;//默认值学年code
  163. }
  164. } catch (error) {
  165. console.error('获取学年学期列表失败:', error);
  166. }
  167. };
  168. // 归属分类
  169. const fetchCategoryList = async () => {
  170. try {
  171. const res = await getCategoryList();
  172. if (res.data && Array.isArray(res.data)) {
  173. const categoryData = res.data;
  174. const categoryList = categoryData.map(item=>({
  175. ...item,
  176. label:item.categoryName,
  177. value:item.id
  178. }))
  179. state.filterPickerData[1].list = [{label:'归属分类',value:''}].concat(...categoryList);
  180. }
  181. } catch (error) {
  182. console.error('获取分类列表失败:', error);
  183. }
  184. };
  185. //切换条件选择器
  186. const CommonFilterData = (filterOptions,type) => {
  187. const {searchWord,filterOpts,tabsSelected} = filterOptions;
  188. const {valueIndex, index,filterPickerValue} = filterOpts;
  189. if(type == 'filterPicker'){
  190. state.params.departmentId = filterPickerValue[1];//归属部门
  191. state.params.materialCategory = filterPickerValue[2];//材料类目
  192. state.filterPickerData[index].valueIndex = valueIndex;
  193. if(index == 1){
  194. state.filterPickerData[2].valueIndex = 0;
  195. const parentData = state.filterPickerData[1].list;//分类归属
  196. const childrenData = parentData?.[valueIndex]?.childList || [];//材料类目
  197. const childrenList = childrenData.map(item=>({
  198. ...item,
  199. label:item?.categoryName || '',
  200. value:item?.id ?? ''
  201. }))
  202. if(childrenList.length){
  203. childrenList.unshift({
  204. label:'材料类目',
  205. value:''
  206. })
  207. }
  208. state.filterPickerData[2].list = childrenList;
  209. }else if(index == 0){//学年
  210. state.params.schoolYearId = filterPickerValue[0];//学年id
  211. state.params.schoolYearCode = state.filterPickerData?.[index]?.list?.[valueIndex]?.schoolYearCode || '';//学年code
  212. }
  213. }else if(type == 'search'){
  214. state.params.taskName = searchWord;//任务名称
  215. }else{
  216. state.params.auditStatus = tabsSelected;//审核状态
  217. }
  218. OnLoadData(true);
  219. }
  220. //切换任务状态
  221. const ChangeTaskStatus = (val) => {
  222. state.params.taskStatus = val;
  223. OnLoadData(true);
  224. }
  225. /*
  226. *任务列表
  227. * initPage:初始分页 从第一开始
  228. */
  229. const OnLoadData = (initPage) => {
  230. // uni.showLoading({
  231. // title: '加载中'
  232. // });
  233. state.isLoading = true;
  234. state.loadStatus = 'loading';
  235. if (initPage) {
  236. state.params.pageNum = 1;//如果是下拉刷新、重新查询 默认加载第一页
  237. state.pageLists = [];
  238. state.pageList = [];
  239. const params = {
  240. schoolYearCode: state.params.schoolYearCode,
  241. schoolYearId: state.params.schoolYearId,
  242. departmentId: state.params.departmentId,
  243. materialCategory: state.params.materialCategory,
  244. taskName: state.params.taskName,
  245. taskStatus: state.params.taskStatus,
  246. pageNum: state.params.pageNum,
  247. pageSize: 999
  248. };
  249. findTeacherTaskTargetList(params).then(res=>{
  250. if (res.code == 200) {
  251. const tableData = res?.data?.[state.params.auditStatus] || [];
  252. state.pageLists = tableData;//全部数据
  253. const total = tableData?.length || 0;//总数
  254. state.pages = Math.ceil(total / state.params.pageSize);//总页数
  255. //默认加载
  256. state.pageList = state.pageLists.slice(0, state.params.pageSize);
  257. //没有更多了
  258. state.noMoreData = state.params.pageNum == state.pages;
  259. //分页+1
  260. state.params.pageNum++;
  261. state.isLoading = false;
  262. state.isRefreshing = false;//下拉刷新未被触发
  263. state.loadStatus = state.noMoreData?'no-more':'more';
  264. }
  265. }).finally(()=>{
  266. // uni.hideLoading();
  267. //返回到页面顶部
  268. if(initPage){
  269. GoTop();
  270. }
  271. });
  272. }else{
  273. const start = (state.params.pageNum - 1) * state.params.pageSize;
  274. const end = start + state.params.pageSize;
  275. const list = state.pageLists.slice(start, end);
  276. state.pageList = [...state.pageList, ...list];
  277. state.noMoreData = state.params.pageNum == state.pages;
  278. state.params.pageNum++;
  279. setTimeout(() => {
  280. state.isLoading = false;
  281. state.isRefreshing = false; //下拉刷新未被触发
  282. state.loadStatus = state.noMoreData?'no-more':'more';
  283. }, 0)
  284. }
  285. };
  286. // 自定义下拉刷新被触发 下拉刷新
  287. const OnRefresh = () =>{
  288. state.isRefreshing = true;//下拉刷新已经被触发
  289. OnLoadData(true);
  290. }
  291. //滚动到底部/右边 触发上拉刷新
  292. const OnLoadMore = () => {
  293. if (state.isLoading || state.noMoreData) return;
  294. OnLoadData(false);
  295. }
  296. // 滚动时触发
  297. const OnScroll = (e) => {
  298. state.oldScrollTop = e.detail.scrollTop;
  299. }
  300. //返回到顶部
  301. const GoTop = () => {
  302. // 解决view层不同步的问题
  303. state.scrollTop = state.oldScrollTop;
  304. nextTick(() => {
  305. state.scrollTop = 0
  306. });
  307. }
  308. //任务详情
  309. const handleDetail = (item) => {
  310. state.details = uni.setStorageSync('submitMaterialDetailInfo',item);
  311. if(item?.taskTargetVos?.length > 1){
  312. uni.navigateTo({
  313. url: `/pages/materialCollection/submitMaterial/taskDetail?taskId=${item.id}&auditStatus=${state.params.auditStatus}`
  314. });
  315. }else{
  316. const targetId = item?.taskTargetVos?.[0].id;
  317. uni.navigateTo({
  318. url: `/pages/materialCollection/submitMaterial/submitDetail?taskId=${item.id}&targetId=${targetId}`
  319. });
  320. }
  321. };
  322. onShow(()=>{
  323. const isLoadSubmitMaterialIndex = uni.getStorageSync('isLoadSubmitMaterialIndex');//返回是否重新更新提交材料首页
  324. if(isLoadSubmitMaterialIndex){
  325. OnLoadData(true);
  326. }
  327. })
  328. onMounted(async () => {
  329. await fetchSchoolYearList();//学年学期列表
  330. fetchCategoryList();//归属分类
  331. OnLoadData(true);
  332. });
  333. onUnmounted(() => {
  334. uni.removeStorageSync('submitMaterialDetailInfo');//移除缓存
  335. uni.removeStorageSync('isLoadSubmitMaterialIndex');//返回是否重新更新提交材料首页
  336. })
  337. </script>
  338. <style lang="scss" scoped>
  339. .page_content{
  340. height: calc(100% - 536rpx);
  341. .scroll_view_y{
  342. height: 100%;
  343. .refresh_loading{
  344. padding: 10rpx 0;
  345. }
  346. }
  347. }
  348. .notice_list {
  349. width: 100%;
  350. display: flex;
  351. flex-direction: column;
  352. }
  353. .notice_item {
  354. background-color: #F9FAFF;
  355. border-radius: 20rpx;
  356. margin-top: 24rpx;
  357. border: 2rpx solid #E4E7ED;
  358. &:first-child{
  359. margin-top: 16rpx;
  360. }
  361. .item_content {
  362. padding: 24rpx 16rpx;
  363. .notice_title_row {
  364. display: flex;
  365. align-items: center;
  366. margin-bottom: 16rpx;
  367. .notice_icon {
  368. width: 32rpx;
  369. height: 32rpx;
  370. margin-right: 16rpx;
  371. }
  372. .notice_title {
  373. flex: 1;
  374. font-weight: 500;
  375. font-size: 28rpx;
  376. color: #333333;
  377. overflow: hidden;
  378. text-overflow: ellipsis;
  379. white-space: nowrap;
  380. }
  381. }
  382. .notice_meta {
  383. display: flex;
  384. align-items: center;
  385. flex-wrap: wrap;
  386. gap: 16rpx;
  387. .status_tag {
  388. font-size: 24rpx;
  389. height: 48rpx;
  390. width: 96rpx;
  391. text-align: center;
  392. line-height: 48rpx;
  393. border-radius: 4rpx;
  394. font-weight: 400;
  395. border-radius: 8rpx;
  396. &.status_pending {
  397. background: rgba(46, 100, 250, 0.1);
  398. color: #2E64FA;
  399. }
  400. &.status_published {
  401. background: rgba(82, 196, 26, 0.1);
  402. color: #2BC644;
  403. }
  404. &.status_closed {
  405. background: #6666661a;
  406. color: #666666;
  407. }
  408. }
  409. .meta_text {
  410. font-size: 24rpx;
  411. color: #999999;
  412. line-height: 48rpx;
  413. }
  414. .textLength {
  415. max-width: 160rpx;
  416. overflow: hidden;
  417. text-overflow: ellipsis;
  418. white-space: nowrap;
  419. }
  420. }
  421. }
  422. .item_bottom {
  423. border-top: 2rpx solid #E4E7ED;
  424. display: flex;
  425. flex-direction: row;
  426. justify-content: space-between;
  427. align-items: center;
  428. padding: 24rpx 16rpx;
  429. .notice_stats {
  430. display: flex;
  431. align-items: center;
  432. gap: 16rpx;
  433. .stats_text {
  434. font-size: 24rpx;
  435. color: #999999;
  436. }
  437. .status_tag{
  438. font-size: 24rpx;
  439. text-align: center;
  440. padding: 8rpx 12rpx;
  441. // height: 48rpx;
  442. // line-height: 48rpx;
  443. font-weight: 400;
  444. border-radius: 8rpx;
  445. flex-shrink: 0;
  446. &.notSubmitList {
  447. background: rgba(46,100,250,0.1);
  448. color: #2E64FA;
  449. }
  450. &.notReviewList {
  451. background: rgba(251,159,52,0.1);
  452. color: #FB9F34;
  453. }
  454. &.reviewReasonList {
  455. background: rgba(245,108,108,0.1);
  456. color: #F56C6C;
  457. }
  458. &.reviewList {
  459. background: rgba(43,198,68,0.1);
  460. color: #2BC644;
  461. }
  462. }
  463. }
  464. .notice_actions {
  465. display: flex;
  466. justify-content: flex-end;
  467. gap: 16rpx;
  468. flex-shrink: 0;
  469. .action_btn {
  470. font-size: 24rpx;
  471. padding: 12rpx 24rpx;
  472. border-radius: 8rpx;
  473. border: 2rpx solid transparent;
  474. &.delete {
  475. border-color: #F56C6C;
  476. color: #F56C6C;
  477. background-color: #FFFFFF;
  478. &.disabled {
  479. border-color: #C0C4CC;
  480. color: #C0C4CC;
  481. background-color: #FFFFFF;
  482. }
  483. }
  484. &.edit {
  485. border-color: #2E64FA;
  486. color: #2E64FA;
  487. background-color: #FFFFFF;
  488. &.disabled {
  489. border-color: #C0C4CC;
  490. color: #C0C4CC;
  491. background-color: #FFFFFF;
  492. }
  493. }
  494. &.disable {
  495. color: #C0C4CC !important;
  496. cursor: not-allowed;
  497. border-color: #C0C4CC !important;
  498. }
  499. &.disableLock{
  500. color: #C0C4CC !important;
  501. cursor: not-allowed;
  502. background-color: #F3F3F3 !important;
  503. border-color: #F3F3F3 !important;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. :deep(.scroll_tabs){
  510. height: 72rpx;
  511. align-items: center;
  512. .scroll_tabs_view{
  513. height: 56rpx;
  514. }
  515. }
  516. :deep(.filter_picker){
  517. gap: 16rpx !important;
  518. .item_filter_picker{
  519. width: calc((100% - 16rpx * 2) / 3) !important;
  520. }
  521. }
  522. .task_status_list{
  523. margin-top: 24rpx;
  524. padding: 0 24rpx;
  525. display: flex;
  526. width: 100%;
  527. gap:24rpx 30rpx;
  528. box-sizing: border-box;
  529. .item_status{
  530. flex: 1;
  531. display: inline-flex;
  532. justify-content: center;
  533. align-items: center;
  534. height: 64rpx;
  535. background-color: #FFFFFF;
  536. border-radius: 8rpx;
  537. border: 2rpx solid #DCDFE6;
  538. font-weight: 400;
  539. font-size: 28rpx;
  540. color: #333333;
  541. &.active{
  542. background-color: rgba(46,100,250,0.1);
  543. border: 2rpx solid #2E64FA;
  544. color: #2E64FA;
  545. }
  546. }
  547. }
  548. </style>