index.vue 14 KB

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