index.vue 7.3 KB

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