index.vue 8.7 KB

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