index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div class="reportList">
  3. <div class="title">{{ dic.project[parameter.project] || "" }}测试记录</div>
  4. <ul :ref="reportScrollRef" @scroll="getScroll($event)">
  5. <li v-for="(item, index) in reportList" :key="index" @click="openReport(item)">
  6. <div class="left">
  7. <div class="pic"><img :src="item.face_pic || item.logo_url || item.student_icon_url" /></div>
  8. <div class="txt">
  9. <div>
  10. <div class="name">{{ item.student_name }}</div>
  11. <div class="className">{{ item.class_name }}</div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="right" v-if="['basketballv1'].includes(parameter.project)">
  16. <div class="score">{{ proxy?.$utils.runTime(item.result, true, false) }}
  17. </div>
  18. </div>
  19. <div class="right" v-else>
  20. <div class="score">{{ item.result }}
  21. </div>
  22. <div class="unit">{{ unit }}</div>
  23. </div>
  24. </li>
  25. </ul>
  26. </div>
  27. </template>
  28. <script setup lang="ts">
  29. import dataDictionary from "@/utils/dataDictionary"
  30. const router = useRouter();
  31. const route = useRoute();
  32. const dic: any = dataDictionary;
  33. const { proxy } = getCurrentInstance() as any;
  34. const reportScrollRef = ref();
  35. const data = reactive<any>({
  36. parameter: {},
  37. reportList: [],//测试列表
  38. studentPage: {
  39. current: 1,
  40. size: 20,
  41. pages: 1,
  42. }, //学生分页
  43. debounceTime: '', //防抖状态
  44. unit: '',//单位
  45. });
  46. const { parameter, reportList, studentPage, debounceTime, unit } = toRefs(data);
  47. /**
  48. * 成绩列表
  49. */
  50. const getReportList = () => {
  51. let type = parameter.value.project;
  52. let school = parameter.value.school;
  53. let params: any = {
  54. exam_name: type,
  55. school_id: school,
  56. page: studentPage.value.current,
  57. per_page: studentPage.value.size
  58. };
  59. proxy?.$http.analysis.reportList(params).then((res: any) => {
  60. if (res.data.length > 0) {
  61. let list = res.data.map((item: any) => {
  62. if (type == 'solidball' || type == 'shotball') {
  63. item.result = item.result / 100
  64. }
  65. let result = null;
  66. if (item.result.toString().indexOf(".") != -1) {
  67. if (['jump', 'longjump', 'run50', 'run70', 'run100', 'run200', 'run400', 'run800', 'run1000', 'run15x4', 'run50x8', 'run10x4', 'basketballv1', 'basketballv1'].includes(type)) {
  68. result = item.result.toFixed(2)
  69. } else {
  70. result = item.result.toFixed(1);
  71. }
  72. } else {
  73. result = item.result
  74. }
  75. item.result = result;
  76. return item;
  77. });
  78. studentPage.value.current == 1 ?
  79. (reportList.value = list) :
  80. reportList.value.push(...list);
  81. studentPage.value.pages = res.total;
  82. getPages(res.total);
  83. }
  84. });
  85. };
  86. /**
  87. * 计算页码
  88. */
  89. const getPages = (data: any) => {
  90. studentPage.value.pages = Math.ceil(data / studentPage.value.size);
  91. };
  92. /**
  93. * 查看详情
  94. */
  95. const openReport = (data: any) => {
  96. let params = {
  97. exam_name: data.exam_name,
  98. student_id: data.student_id,
  99. result_ids: data.result_id,
  100. }
  101. router.push({
  102. path: '/analysis/detail', query: params
  103. });
  104. };
  105. /**
  106. * 成绩翻页
  107. */
  108. const getScroll = (event?: any) => {
  109. if (studentPage.value.current == studentPage.value.pages) {
  110. return false;
  111. }
  112. let obj = event.target;
  113. let scrollHeight = obj.scrollHeight;
  114. let scrollTop = obj.scrollTop;
  115. let clientHeight = obj.clientHeight;
  116. //提前100高度加载数据
  117. if (scrollTop + clientHeight + 150 >= scrollHeight) {
  118. console.log('到底了!')
  119. //继续加载下一页
  120. if (debounceTime.value) {
  121. clearTimeout(debounceTime.value)
  122. }
  123. debounceTime.value = setTimeout(() => {
  124. studentPage.value.current++;
  125. getReportList();
  126. }, 500)
  127. } else {
  128. console.log('没到底')
  129. }
  130. };
  131. /**
  132. * 初始化列表
  133. */
  134. const getIniReportList = () => {
  135. studentPage.value.current = 1;
  136. getReportList();
  137. };
  138. onBeforeMount(() => {
  139. parameter.value = route.query;
  140. let project = parameter.value.project;
  141. unit.value = dic.unit[project];
  142. })
  143. onMounted(() => {
  144. getIniReportList();
  145. })
  146. </script>
  147. <style lang="scss">
  148. @media screen and (max-width: 1280px) {
  149. :root {
  150. font-size: calc(1280px / 106);
  151. }
  152. }
  153. .reportList {
  154. display: flex;
  155. flex-direction: column;
  156. height: 100%;
  157. .title {
  158. height: 7.05vh;
  159. line-height: 7.05vh;
  160. width: 100%;
  161. text-align: center;
  162. color: #1A293A;
  163. font-size: 3.5vh;
  164. background: radial-gradient(120% 126% at 5% 93%, #8EFFA9 0%, #07FFE7 100%);
  165. }
  166. ul {
  167. height: 100%;
  168. overflow-y: scroll;
  169. li {
  170. border-bottom: 1px solid #48677E;
  171. padding: 8px 25px;
  172. display: flex;
  173. justify-content: space-between;
  174. align-items: center;
  175. cursor: pointer;
  176. transition: all 0.2s;
  177. &:hover {
  178. background: rgba(255, 255, 255, 0.4);
  179. }
  180. .left {
  181. display: flex;
  182. .pic {
  183. width: 7.5vh;
  184. height: 7.5vh;
  185. border-radius: 50%;
  186. display: flex;
  187. justify-content: center;
  188. align-items: center;
  189. overflow: hidden;
  190. box-sizing: border-box;
  191. border: 1px solid rgba(255, 255, 255, 0.5);
  192. margin-right: 13px;
  193. flex-shrink: 0;
  194. img {
  195. width: 100%;
  196. }
  197. }
  198. .txt {
  199. display: flex;
  200. align-items: center;
  201. .name {
  202. color: #F9F9F9;
  203. font-size: 1.38rem;
  204. }
  205. .className {
  206. color: #13ED84;
  207. font-size: 1.1rem;
  208. }
  209. }
  210. }
  211. .right {
  212. display: flex;
  213. font-weight: bold;
  214. align-items: center;
  215. .score {
  216. color: #ffffff;
  217. font-size: 1.1rem;
  218. font-family: 'Saira-ExtraBold';
  219. }
  220. .unit {
  221. color: #ffffff;
  222. font-size: 0.8rem;
  223. margin-left: 2px;
  224. }
  225. }
  226. }
  227. &::-webkit-scrollbar {
  228. width: 0px;
  229. }
  230. &::-webkit-scrollbar-thumb {
  231. border-width: 2px;
  232. border-radius: 4px;
  233. border-style: dashed;
  234. border-color: transparent;
  235. background-color: rgba(216, 216, 216, 0.8);
  236. background-clip: padding-box;
  237. }
  238. &::-webkit-scrollbar-button:hover {
  239. border-radius: 6px;
  240. background: rgba(216, 216, 216, 0.8);
  241. }
  242. }
  243. }
  244. </style>