index.vue 9.3 KB

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