index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <div class="result bg">
  3. <div class="resultMain">
  4. <div class="resultCenter">
  5. <div class="top">
  6. <div class="topLeft">
  7. <div class="pic">
  8. <img class="image" :src="parameter.pic ? parameter.pic : '../../static/images/train/noImg.png'"></img>
  9. </div>
  10. <div class="name">{{ parameter.name }}</div>
  11. </div>
  12. </div>
  13. <div class="bottom">
  14. <div class="type">
  15. <div class="li more">
  16. <el-select class="select" v-model="project" :popper-append-to-body="false" placeholder="请选择"
  17. @change="getProject" clearable>
  18. <el-option v-for="item in projectList" :key="item.value" :label="item.label" :value="item.value" />
  19. </el-select>
  20. </div>
  21. <div class="li"> 成绩 </div>
  22. <div class="li more"> 日期 </div>
  23. <div class="li"> 报告 </div>
  24. </div>
  25. <div class="list">
  26. <div ref="reportScrollRef" @scroll="getNext($event)" class="scrollBox">
  27. <div class="ul" v-for="(item, index) in reportList" :key="index">
  28. <div class="li"> {{ item.title }} </div>
  29. <div class="li"> {{ item.result }} </div>
  30. <div class="li date"> {{ item.date }} </div>
  31. <div class="li url" @click="openReport(item)"> 查看 </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div @click="getBack" class="btn">退 出</div>
  38. </div>
  39. </div>
  40. </template>
  41. <script setup lang="ts">
  42. import dayjs from 'dayjs';
  43. import dataDictionary from '@/utils/dataDictionary';
  44. const reportScrollRef = ref();
  45. const { proxy } = getCurrentInstance() as any;
  46. const router = useRouter();
  47. const route = useRoute();
  48. const dic: any = dataDictionary;
  49. const data = reactive<any>({
  50. parameter: {
  51. id: 0,
  52. name: "",
  53. student_number: "",
  54. pic: "",
  55. },
  56. reportList: [],
  57. page: {
  58. current: 1,
  59. size: 30,
  60. pages: 1,
  61. },
  62. projectList: [{
  63. label: "项目",
  64. value: null,
  65. },],
  66. project: '',
  67. date: "",
  68. debounceTime: '', //防抖状态
  69. });
  70. const { parameter, reportList, page, projectList, project, date, debounceTime } = toRefs(data);
  71. //筛选日期
  72. const bindDateChange = (e: any) => {
  73. date.value = e.detail.value;
  74. getListData();
  75. };
  76. //取消选择日期
  77. const bindDateCancel = () => {
  78. date.value = "";
  79. getListData();
  80. };
  81. //筛选项目
  82. const getProject = (e: any) => {
  83. getListData();
  84. };
  85. //初始数据
  86. const getListData = () => {
  87. //返回的时候重新请求更多页码数据
  88. if (page.value.current > 1) {
  89. page.value.size = page.value.size * page.value.current;
  90. }
  91. page.value.current = 1; //页面初始化
  92. getReportList(); //获取数据
  93. };
  94. //成绩列表
  95. const getReportList = () => {
  96. if (!parameter.value.id) {
  97. return false;
  98. }
  99. let myInfo: any = localStorage.getItem('userInfo');
  100. let userInfo = JSON.parse(myInfo);
  101. let params: any = {
  102. school_id: userInfo.school_id,
  103. student_ids: parameter.value.id,
  104. page: page.value.current,
  105. per_page: page.value.size,
  106. };
  107. if (project.value) {
  108. params.exam_name = project.value;
  109. }
  110. if (date.value == "") {
  111. params.start_date = "2021-01-01";
  112. delete params.end_date;
  113. } else {
  114. params.start_date = date.value;
  115. params.end_date = date.value;
  116. }
  117. proxy?.$http.common.studentReport(params).then((res: any) => {
  118. if (res.status == 200) {
  119. let list = res.data.map((item: any) => {
  120. item.title = dic.project[item.exam_name];
  121. let result = null;
  122. if (["trijump", "solidball", "shotput", "longjump"].includes(item.exam_name)) {
  123. result = (Math.round(item.result) / 100).toFixed(2);
  124. } else if (["basketballv1", "footballv1"].includes(item.exam_name)) {
  125. result = proxy?.$utils.runTime(item.result, true, false);
  126. } else {
  127. result = item.result;
  128. }
  129. if (['run50', 'run70', 'run100', 'run200', 'run400', 'run800', 'run1000', 'run15x4', 'run50x8', 'run10x4', 'runwb800', 'runwb1000'].includes(item.exam_name)) {
  130. item.result = proxy?.$utils.runTime(item.result, false, false);
  131. } else {
  132. item.result = result + dic.unit[item.exam_name];
  133. }
  134. item.date = dayjs.unix(item.ctime).format("YYYY-MM-DD");
  135. return item;
  136. });
  137. page.value.current == 1 ?
  138. (reportList.value = list) :
  139. reportList.value.push(...list);
  140. getPages(res.total);
  141. }
  142. });
  143. };
  144. //测试报告
  145. const openReport = (data: any) => {
  146. let result_ids = data.result_id;
  147. let exam_name = data.exam_name;
  148. let student_id = data.student_id;
  149. if (!result_ids || !exam_name) {
  150. proxy?.$modal.msgWarning('缺少参数');
  151. return false;
  152. }
  153. let obj = {
  154. result_ids: result_ids,
  155. exam_name: exam_name,
  156. student_id: student_id
  157. }
  158. router.push({ path: '/analysis/detail', query: obj });
  159. };
  160. //下一页
  161. const getNext = (event?: any) => {
  162. if (page.value.current == page.value.pages) {
  163. return false;
  164. }
  165. let obj = event.target;
  166. let scrollHeight = obj.scrollHeight;
  167. let scrollTop = obj.scrollTop;
  168. let clientHeight = obj.clientHeight;
  169. //提前100高度加载数据
  170. if (scrollTop + clientHeight + 150 >= scrollHeight) {
  171. console.log('到底了!');
  172. //继续加载下一页
  173. if (debounceTime.value) {
  174. clearTimeout(debounceTime.value);
  175. }
  176. debounceTime.value = setTimeout(() => {
  177. page.value.current++;
  178. getReportList();
  179. }, 500);
  180. } else {
  181. console.log('没到底');
  182. }
  183. };
  184. //计算页码
  185. const getPages = (data: any) => {
  186. page.value.pages = Math.ceil(data / page.value.size);
  187. };
  188. //返回
  189. const getBack = () => {
  190. router.go(-1);
  191. };
  192. onBeforeMount(() => {
  193. parameter.value = route.query;
  194. //重组项目为数组
  195. for (let i in dic.project) {
  196. projectList.value.push({
  197. label: dic.project[i],
  198. value: i,
  199. })
  200. }
  201. getListData();
  202. });
  203. onMounted(() => {
  204. });
  205. </script>
  206. <style lang="scss" scoped>
  207. .result {
  208. min-height: 100vh;
  209. }
  210. .resultMain {
  211. padding-top: 6vh;
  212. }
  213. .resultCenter {
  214. width: 90%;
  215. height: 80vh;
  216. background: #ffffff;
  217. border-radius: 25px;
  218. margin: 0 auto 2vh;
  219. box-shadow: 0 0 15px #ffffff80;
  220. overflow: hidden;
  221. position: relative;
  222. display: flex;
  223. flex-direction: column;
  224. }
  225. .top {
  226. width: 100%;
  227. height: 12vh;
  228. background-color: #b0ffac;
  229. background-image: url("@/assets/images/common/btnbg2.png");
  230. background-size: 100% 100%;
  231. background-repeat: repeat;
  232. display: flex;
  233. align-items: center;
  234. }
  235. .top .topLeft {
  236. display: flex;
  237. align-items: center;
  238. padding: 0 15px;
  239. }
  240. .top .topLeft .pic {
  241. width: 8vh;
  242. height: 8vh;
  243. overflow: hidden;
  244. border-radius: 50%;
  245. border: 2px solid #ffffff;
  246. }
  247. .top .topLeft .pic .image {
  248. width: 100%;
  249. height: 100%;
  250. }
  251. .top .topLeft .name {
  252. font-size: 3.2vh;
  253. color: #fff;
  254. margin-left: 3vw;
  255. }
  256. .bottom {
  257. display: flex;
  258. flex-direction: column;
  259. height: calc(100% - 12vh);
  260. }
  261. .type {
  262. height: 5vh;
  263. display: flex;
  264. text-align: center;
  265. background: #f3f3f3;
  266. color: #63cacc;
  267. font-size: 2vh;
  268. padding: 0 4px;
  269. }
  270. .type .li {
  271. width: 25%;
  272. padding: 8px 3px;
  273. flex: 1;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. }
  278. .type .more::before {
  279. content: "";
  280. width: 0;
  281. height: 0;
  282. display: block;
  283. border: 0.7vh;
  284. border-style: solid;
  285. border-color: #63cacc transparent transparent transparent;
  286. margin-top: 0.8vh;
  287. margin-right: 2px;
  288. }
  289. .list {
  290. text-align: center;
  291. font-size: 2vh;
  292. padding: 0 4px;
  293. height: calc(100% - 5vh);
  294. }
  295. .list .ul {
  296. display: flex;
  297. }
  298. .list .ul .li {
  299. width: 25%;
  300. padding: 8px 3px;
  301. flex: 1;
  302. word-break: break-all;
  303. flex-direction: column;
  304. }
  305. .list .ul .date {
  306. font-size: 1.8vh;
  307. }
  308. .list .ul .url {
  309. color: #90dba4;
  310. }
  311. .type .li:nth-of-type(1),
  312. .list .ul .li:nth-of-type(1) {
  313. flex-grow: 1;
  314. }
  315. .type .li:nth-of-type(2),
  316. .list .ul .li:nth-of-type(2) {
  317. flex-grow: 1.4;
  318. }
  319. .type .li:nth-of-type(3),
  320. .list .ul .li:nth-of-type(3) {
  321. flex-grow: 1.4;
  322. }
  323. .type .li:nth-of-type(4),
  324. .list .ul .li:nth-of-type(4) {
  325. flex-grow: 1;
  326. }
  327. .type .li:nth-of-type(5),
  328. .list .ul .li:nth-of-type(5) {
  329. flex-grow: 0.7;
  330. }
  331. .scrollBox {
  332. height: 98%;
  333. }
  334. .btn {
  335. width: 90%;
  336. height: 7vh;
  337. line-height: 7vh;
  338. text-align: center;
  339. color: #fff;
  340. font-size: 2.2vh;
  341. margin: 0 auto;
  342. background: url("@/assets/images/common/areabg2.png") center center repeat-y;
  343. background-size: 100% 100%;
  344. border-radius: 2.1vh;
  345. box-shadow: 0px 0px 15px #ffffff80;
  346. cursor: pointer;
  347. }
  348. </style>