index.vue 14 KB

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