index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <!-- 头部 -->
  3. <nav-bar height="224" backPath="workspace" title="教师专业发展" :tabList="state.tabList" :onlyTitle="false" :showFilterPicker="false" :showTabs="true" :showTabBtns="false" rightWidth="0rpx" @CommonFilterData="CommonFilterData"></nav-bar>
  4. <view class="page_content">
  5. <scroll-view
  6. class="scroll_view_y"
  7. :scroll-top="state.scrollTop"
  8. scroll-y="true"
  9. :refresher-enabled="false"
  10. :enable-back-to-top="true"
  11. :show-scrollbar="false"
  12. :scroll-with-animation="true"
  13. refresher-default-style="none"
  14. refresher-background="#F8F9FD"
  15. :refresher-triggered="state.isRefreshing"
  16. @scrolltolower="OnLoadMore"
  17. @refresherrefresh="OnRefresh"
  18. @scroll="OnScroll">
  19. <view class="refresh_loading" v-if="state.isRefreshing"><uni-load-more status="loading" /></view>
  20. <view class="page_list">
  21. <view class="list_item" v-for="item in state.pageList" :key="item.honorTypeId" @click="HonorAuditDetail(item.honorTypeId,item.honorTypeName)">
  22. <view class="honor_name">{{item.honorTypeName}}</view>
  23. <view class="audit_status">
  24. <view class="status wait" v-if="state.honorStatus==='0'">待审核:{{item.number}}</view>
  25. <view class="status pass" v-if="state.honorStatus==='1'">已审核:{{item.number}}</view>
  26. <view class="status reject" v-if="state.honorStatus==='2'">已驳回:{{item.number}}</view>
  27. <view class="btn">{{state.honorStatus==='0'?'开始审核':'查看详情'}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="no_data" v-if="!state.isLoading && state.pageList.length == 0">
  32. <image class="no_data_img" src="@/static/image/bg/no_data.png"></image>
  33. <text class="no_data_text">暂无数据</text>
  34. </view>
  35. <uni-load-more v-if="state.pageList.length > 0" :status="state.loadStatus" />
  36. </scroll-view>
  37. </view>
  38. </template>
  39. <script setup>
  40. import navBar from '@/components/navBar.vue';
  41. import {queryHonorReviewDataList} from '@/reqApi/teacherHonor.js';
  42. import {
  43. reactive,
  44. nextTick,
  45. onMounted
  46. } from 'vue';
  47. const state = reactive({
  48. tabList:[{
  49. label:'待审核',
  50. value:'0'
  51. },{
  52. label:'已审核',
  53. value:'1'
  54. },{
  55. label:'已驳回',
  56. value:'2',
  57. }],
  58. pageLists:[],//全部数据
  59. pageList:[],//列表数据
  60. queryStr:'',
  61. honorStatus:'0',//0-待审核,1-已审核(审核通过),2-已驳回(审核失败)
  62. pageSize: 30,
  63. pageNum: 1,
  64. pages:0,
  65. scrollTop:0,
  66. oldScrollTop:0,
  67. isRefreshing:false,//设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  68. isLoading:true,//加载中
  69. noMoreData:false,//没有更多数据了
  70. loadStatus:'more',//loading状态
  71. })
  72. onMounted(() => {
  73. OnLoadData(true);
  74. });
  75. //切换条件选择器
  76. const CommonFilterData = (filterOptions,type) => {
  77. const { searchWord,tabsSelected } = filterOptions;
  78. state.queryStr = searchWord;
  79. state.honorStatus = tabsSelected;
  80. OnLoadData(true)
  81. }
  82. /*
  83. *获取数据
  84. * initPage:初始分页 从第一开始
  85. */
  86. const OnLoadData = (initPage) => {
  87. state.isLoading = true;
  88. state.loadStatus = 'loading';
  89. if (initPage) {
  90. // uni.showLoading({
  91. // title: '加载中'
  92. // });
  93. state.pageNum = 1;//如果是下拉刷新、重新查询 默认加载第一页
  94. state.pageLists = [];
  95. state.pageList = [];
  96. queryHonorReviewDataList({
  97. honorStatus:state.honorStatus,
  98. queryStr:state.queryStr
  99. }).then(res=>{
  100. if(res.code == 200){
  101. const tableData = res?.data || [];
  102. state.pageLists = tableData;//全部数据
  103. const total = tableData?.length || 0;//总数
  104. state.pages = Math.ceil(total / state.pageSize);//总页数
  105. //默认加载
  106. state.pageList = state.pageLists.slice(0, state.pageSize);
  107. //没有更多了
  108. state.noMoreData = state.pageNum == state.pages;
  109. //分页+1
  110. state.pageNum++;
  111. state.isLoading = false;
  112. state.isRefreshing = false;//下拉刷新未被触发
  113. state.loadStatus = state.noMoreData?'no-more':'more';
  114. }
  115. }).finally(()=>{
  116. // uni.hideLoading();
  117. //返回到页面顶部
  118. if(initPage){
  119. GoTop();
  120. }
  121. })
  122. }else{
  123. const start = (state.pageNum - 1) * state.pageSize;
  124. const end = start + state.pageSize;
  125. const list = state.pageLists.slice(start, end);
  126. state.pageList = [...state.pageList, ...list];
  127. state.noMoreData = state.pageNum == state.pages;
  128. state.pageNum++;
  129. setTimeout(() => {
  130. state.isLoading = false;
  131. state.isRefreshing = false; //下拉刷新未被触发
  132. state.loadStatus = state.noMoreData?'no-more':'more';
  133. }, 0)
  134. }
  135. }
  136. // 自定义下拉刷新被触发 下拉刷新
  137. const OnRefresh = () =>{
  138. state.isRefreshing = true;//下拉刷新已经被触发
  139. OnLoadData(true);
  140. }
  141. //滚动到底部/右边 触发上拉刷新
  142. const OnLoadMore = () => {
  143. if (state.isLoading || state.noMoreData) return;
  144. OnLoadData(false);
  145. }
  146. // 滚动时触发
  147. const OnScroll = (e) => {
  148. state.oldScrollTop = e.detail.scrollTop;
  149. }
  150. //返回到顶部
  151. const GoTop = () => {
  152. // 解决view层不同步的问题
  153. state.scrollTop = state.oldScrollTop;
  154. nextTick(() => {
  155. state.scrollTop = 0
  156. });
  157. }
  158. const HonorAuditDetail = (honorTypeId,honorTypeName) => {
  159. uni.navigateTo({
  160. url: `/pages/teacherHonor/honorAudit/honorAuditDetail?honorTypeId=${honorTypeId}&honorStatus=${state.honorStatus}&honorTypeName=${encodeURIComponent(honorTypeName)}`
  161. });
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .page_content{
  166. height: calc(100% - 360rpx);
  167. .scroll_view_y{
  168. height: 100%;
  169. .refresh_loading{
  170. padding: 10rpx 0;
  171. }
  172. }
  173. .page_list{
  174. display: flex;
  175. width: 100%;
  176. flex-wrap: wrap;
  177. gap: 24rpx 22rpx;
  178. .list_item{
  179. display: flex;
  180. flex-direction: column;
  181. width: calc((100% - 22rpx) / 2);
  182. min-height: 156rpx;
  183. padding: 24rpx;
  184. background: linear-gradient( 180deg, #EDF4FF 0%, #FFFFFF 100%);
  185. border-radius: 20rpx;
  186. border: 2rpx solid #E4E7ED;
  187. box-sizing: border-box;
  188. .honor_name{
  189. width: 100%;
  190. font-weight: 500;
  191. font-size: 36rpx;
  192. color: #333333;
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. white-space: nowrap;
  196. }
  197. .audit_status{
  198. margin-top: 24rpx;
  199. width: 100%;
  200. display: flex;
  201. justify-content: space-between;
  202. .status{
  203. font-weight: 400;
  204. font-size: 24rpx;
  205. flex: 1;
  206. word-break: break-all;
  207. margin-right: 5rpx;
  208. &.wait{
  209. color: #2E64FA;
  210. }
  211. &.pass{
  212. color: #2BC644;
  213. }
  214. &.reject{
  215. color: #F56C6C;
  216. }
  217. }
  218. }
  219. .btn{
  220. font-weight: 400;
  221. font-size: 24rpx;
  222. color: #2E64FA;
  223. flex-shrink: 0;
  224. }
  225. }
  226. }
  227. }
  228. </style>