index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <!-- 头部 -->
  3. <nav-bar height="336" title="教师专业发展" :tabList="state.tabList" :tabBtns="state.tabBtns" :onlyTitle="false" :showFilterPicker="false" :showTabs="true" :showTabBtns="true" rightWidth="0rpx" @CommonFilterData="CommonFilterData" @GoBack="GoBack">
  4. <template #tab_btns_lef>
  5. <uni-data-select class="date_select" v-model="state.dateType" :clear="false" placeholder="请选择" :localdata="state.dateTypeList">
  6. </uni-data-select>
  7. </template>
  8. </nav-bar>
  9. <view class="page_content">
  10. <scroll-view
  11. class="scroll_view_y"
  12. :scroll-top="state.scrollTop"
  13. scroll-y="true"
  14. :refresher-enabled="false"
  15. :enable-back-to-top="true"
  16. :show-scrollbar="false"
  17. :scroll-with-animation="true"
  18. refresher-default-style="none"
  19. refresher-background="#F8F9FD"
  20. :refresher-triggered="state.isRefreshing"
  21. @scrolltolower="OnLoadMore"
  22. @refresherrefresh="OnRefresh"
  23. @scroll="OnScroll">
  24. <view class="refresh_loading" v-if="state.isRefreshing"><uni-load-more status="loading" /></view>
  25. <view class="page_list">
  26. <view class="list_item" v-for="item in state.pageList" :key="item.id" @click="PreviewHonorDetail(item.id)">
  27. <view class="item_honor_type">
  28. <view class="honor_type_item">{{item.awardDatetime}}</view>
  29. <view class="honor_type_item">{{item.awardDatetime}}</view>
  30. </view>
  31. <view class="honor_content">
  32. <image class="honor_pic" :src="item.certPicUrl"></image>
  33. <view class="honor_info">
  34. <view class="honor_info_top">
  35. <view class="honor_name">{{item.honorName}}</view>
  36. <view class="teacher_name">获奖人:{{item.teacherName}}</view>
  37. </view>
  38. <view class="created_at">上传时间:{{item.createdAt}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="no_data" v-if="!state.isLoading && state.pageList.length == 0">
  44. <image class="no_data_img" src="@/static/image/bg/no_data.png"></image>
  45. <text class="no_data_text">暂无数据</text>
  46. </view>
  47. <uni-load-more v-if="state.pageList.length > 0" :status="state.loadStatus" />
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script setup>
  52. import navBar from '@/components/navBar.vue';
  53. import {queryHonorTypeList,queryHonorTeacherListDetail} from '@/reqApi/teacherHonor.js';
  54. import {
  55. reactive,
  56. nextTick,
  57. onMounted
  58. } from 'vue';
  59. const state = reactive({
  60. tabList:[],
  61. dateTypeList:[{
  62. text:'全部',
  63. value:'',
  64. },{
  65. text:'最近3月',
  66. value:'3',
  67. },{
  68. text:'最近半年',
  69. value:'6',
  70. },{
  71. text:'最近1年',
  72. value:'12',
  73. }],
  74. tabBtns:[{
  75. label:'全部',
  76. value:'',
  77. },{
  78. label:'待审核',
  79. value:'0',
  80. },{
  81. label:'已完成',
  82. value:'1',
  83. },{
  84. label:'已驳回',
  85. value:'2',
  86. }],
  87. pageLists:[],//全部数据
  88. pageList:[],//列表数据
  89. honorTypeId:'',//荣誉类型
  90. teacherId: '',//教师id
  91. dateType:'',//获奖时间
  92. pageSize: 30,
  93. pageNum: 1,
  94. pages:0,
  95. scrollTop:0,
  96. oldScrollTop:0,
  97. isRefreshing:false,//设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  98. isLoading:true,//加载中
  99. noMoreData:false,//没有更多数据了
  100. loadStatus:'more',//loading状态
  101. })
  102. onMounted((option) => {
  103. GetHonorTypeList();
  104. OnLoadData(true);
  105. });
  106. //查询荣誉类型列表
  107. const GetHonorTypeList = () => {
  108. queryHonorTypeList().then(res=>{
  109. if(res.code == 200){
  110. const list = res?.data || [];
  111. const tabList = list.map(item=>({
  112. ...item,
  113. label:item.honorTypeName,
  114. value:item.id
  115. }))
  116. state.tabList = [{label:'全部',value:''},...tabList];
  117. }
  118. })
  119. }
  120. //切换条件选择器
  121. const CommonFilterData = (filterOptions,type) => {
  122. const { tabsSelected,tabBtnSelected } = filterOptions;
  123. state.honorTypeId = tabsSelected;
  124. state.dateType = tabBtnSelected;
  125. OnLoadData(true)
  126. }
  127. /*
  128. *获取数据
  129. * initPage:初始分页 从第一开始
  130. */
  131. const OnLoadData = (initPage) => {
  132. state.isLoading = true;
  133. state.loadStatus = 'loading';
  134. if (initPage) {
  135. // uni.showLoading({
  136. // title: '加载中'
  137. // });
  138. state.pageNum = 1;//如果是下拉刷新、重新查询 默认加载第一页
  139. queryHonorTeacherListDetail({
  140. honorTypeId:state.honorTypeId,//荣誉类型id
  141. teacherId:state.teacherId,
  142. dateType:state.dateType,
  143. startDatetime:'',
  144. endDatetime:''
  145. }).then(res=>{
  146. if(res.code == 200){
  147. const tableData = res?.data?.tableData || [];
  148. state.pageLists = tableData;//全部数据
  149. const total = tableData?.length || 0;//总数
  150. state.pages = Math.ceil(total / state.pageSize);//总页数
  151. //默认加载
  152. state.pageList = state.pageLists.slice(0, state.pageSize);
  153. //没有更多了
  154. state.noMoreData = state.pageNum == state.pages;
  155. //分页+1
  156. state.pageNum++;
  157. state.isLoading = false;
  158. state.isRefreshing = false;//下拉刷新未被触发
  159. state.loadStatus = state.noMoreData?'no-more':'more';
  160. }
  161. }).finally(()=>{
  162. // uni.hideLoading();
  163. //返回到页面顶部
  164. if(initPage){
  165. GoTop();
  166. }
  167. })
  168. }else{
  169. const start = (state.pageNum - 1) * state.pageSize;
  170. const end = start + state.pageSize;
  171. const list = state.pageLists.slice(start, end);
  172. state.pageList = [...state.pageList, ...list];
  173. state.noMoreData = state.pageNum == state.pages;
  174. state.pageNum++;
  175. setTimeout(() => {
  176. state.isLoading = false;
  177. state.isRefreshing = false; //下拉刷新未被触发
  178. state.loadStatus = state.noMoreData?'no-more':'more';
  179. }, 0)
  180. }
  181. }
  182. // 自定义下拉刷新被触发 下拉刷新
  183. const OnRefresh = () =>{
  184. state.isRefreshing = true;//下拉刷新已经被触发
  185. OnLoadData(true);
  186. }
  187. //滚动到底部/右边 触发上拉刷新
  188. const OnLoadMore = () => {
  189. if (state.isLoading || state.noMoreData) return;
  190. OnLoadData(false);
  191. }
  192. // 滚动时触发
  193. const OnScroll = (e) => {
  194. state.oldScrollTop = e.detail.scrollTop;
  195. }
  196. //返回到顶部
  197. const GoTop = () => {
  198. // 解决view层不同步的问题
  199. state.scrollTop = state.oldScrollTop;
  200. nextTick(() => {
  201. state.scrollTop = 0
  202. });
  203. }
  204. //返回
  205. const GoBack = () => {
  206. uni.navigateBack({
  207. delta: 1
  208. });
  209. }
  210. const PreviewHonorDetail = () => {
  211. uni.navigateTo({
  212. url: `/pages/teacherHonor/honorTeacher/honorTeacherDetail?teacherId=${teacherId}`
  213. });
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .date_select{
  218. width: 196rpx;
  219. flex: auto;
  220. flex-shrink: 0;
  221. :deep(.uni-select__selector){
  222. position: fixed;
  223. top:313rpx !important;
  224. left: 24rpx;
  225. width: 196rpx;
  226. }
  227. }
  228. .page_content{
  229. height: calc(100% - 472rpx);
  230. .scroll_view_y{
  231. height: 100%;
  232. .refresh_loading{
  233. padding: 10rpx 0;
  234. }
  235. }
  236. .page_list{
  237. display: flex;
  238. width: 100%;
  239. flex-direction: column;
  240. .list_item{
  241. display: flex;
  242. width: 100%;
  243. flex-direction: column;
  244. margin-top: 32rpx;
  245. &:nth-child(1){
  246. margin-top: 0;
  247. }
  248. .item_honor_type{
  249. display: flex;
  250. width: 100%;
  251. .honor_type_item{
  252. font-weight: 400;
  253. font-size: 32rpx;
  254. color: #333333;
  255. &:nth-child(1){
  256. font-weight: 500;
  257. margin-right: 24rpx;
  258. }
  259. }
  260. }
  261. .honor_content{
  262. margin-top: 16rpx;
  263. display: flex;
  264. width: 100%;
  265. padding: 16rpx;
  266. box-sizing: border-box;
  267. background-color: #F8FAFE;
  268. border-radius: 15rpx;
  269. border: 2rpx solid #EBEEF5;
  270. .honor_pic{
  271. width: 320rpx;
  272. height: 200rpx;
  273. border-radius: 8rpx;
  274. margin-right: 16rpx;
  275. flex-shrink: 0;
  276. }
  277. .honor_info{
  278. flex:1;
  279. display: flex;
  280. justify-content: space-between;
  281. flex-direction: column;
  282. overflow: hidden;
  283. .honor_info_top{
  284. display: flex;
  285. width: 100%;
  286. flex-direction: column;
  287. .honor_name{
  288. font-weight: 500;
  289. font-size: 32rpx;
  290. color: #333333;
  291. width: 100%;
  292. white-space: nowrap;
  293. overflow: hidden;
  294. text-overflow: ellipsis;
  295. }
  296. .teacher_name{
  297. margin-top: 16rpx;
  298. font-weight: 400;
  299. font-size: 28rpx;
  300. color: #333333;
  301. width: 100%;
  302. white-space: nowrap;
  303. overflow: hidden;
  304. text-overflow: ellipsis;
  305. }
  306. }
  307. .created_at{
  308. width: 100%;
  309. line-height: 1.4;
  310. white-space: nowrap;
  311. overflow: hidden;
  312. text-overflow: ellipsis;
  313. font-weight: 400;
  314. font-size: 28rpx;
  315. color: #999999;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. }
  322. </style>