index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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_id = parameter.value.school_id;
  53. let params: any = {
  54. exam_name: type,
  55. school_id: school_id,
  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. ul,
  154. ol {
  155. margin: 0;
  156. padding: 0;
  157. }
  158. ul li {
  159. list-style: none;
  160. }
  161. .reportList {
  162. display: flex;
  163. flex-direction: column;
  164. height: 100%;
  165. .title {
  166. height: 7.05vh;
  167. line-height: 7.05vh;
  168. width: 100%;
  169. text-align: center;
  170. color: #1A293A;
  171. font-size: 3.5vh;
  172. background: radial-gradient(120% 126% at 5% 93%, #8EFFA9 0%, #07FFE7 100%);
  173. }
  174. ul {
  175. height: 100%;
  176. overflow-y: scroll;
  177. li {
  178. border-bottom: 1px solid #48677E;
  179. padding: 8px 25px;
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. cursor: pointer;
  184. transition: all 0.2s;
  185. &:hover {
  186. background: rgba(255, 255, 255, 0.4);
  187. }
  188. .left {
  189. display: flex;
  190. .pic {
  191. width: 7.5vh;
  192. height: 7.5vh;
  193. border-radius: 50%;
  194. display: flex;
  195. justify-content: center;
  196. align-items: center;
  197. overflow: hidden;
  198. box-sizing: border-box;
  199. border: 1px solid rgba(255, 255, 255, 0.5);
  200. margin-right: 13px;
  201. flex-shrink: 0;
  202. img {
  203. width: 100%;
  204. }
  205. }
  206. .txt {
  207. display: flex;
  208. align-items: center;
  209. .name {
  210. color: #F9F9F9;
  211. font-size: 1.38rem;
  212. }
  213. .className {
  214. color: #13ED84;
  215. font-size: 1.1rem;
  216. }
  217. }
  218. }
  219. .right {
  220. display: flex;
  221. font-weight: bold;
  222. align-items: center;
  223. .score {
  224. color: #ffffff;
  225. font-size: 1.1rem;
  226. font-family: 'Saira-ExtraBold';
  227. }
  228. .unit {
  229. color: #ffffff;
  230. font-size: 0.8rem;
  231. margin-left: 2px;
  232. }
  233. }
  234. }
  235. &::-webkit-scrollbar {
  236. width: 0px;
  237. }
  238. &::-webkit-scrollbar-thumb {
  239. border-width: 2px;
  240. border-radius: 4px;
  241. border-style: dashed;
  242. border-color: transparent;
  243. background-color: rgba(216, 216, 216, 0.8);
  244. background-clip: padding-box;
  245. }
  246. &::-webkit-scrollbar-button:hover {
  247. border-radius: 6px;
  248. background: rgba(216, 216, 216, 0.8);
  249. }
  250. }
  251. }
  252. </style>