index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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="scrollRef" @scroll="getNext" 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 scrollRef = 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. });
  69. const { parameter, reportList, page, projectList, project, date } = toRefs(data);
  70. //筛选日期
  71. const bindDateChange = (e: any) => {
  72. date.value = e.detail.value;
  73. getListData();
  74. };
  75. //取消选择日期
  76. const bindDateCancel = () => {
  77. date.value = "";
  78. getListData();
  79. };
  80. //筛选项目
  81. const getProject = (e: any) => {
  82. getListData();
  83. };
  84. //初始数据
  85. const getListData = () => {
  86. //返回的时候重新请求更多页码数据
  87. if (page.value.current > 1) {
  88. page.value.size = page.value.size * page.value.current;
  89. }
  90. page.value.current = 1; //页面初始化
  91. getReportList(); //获取数据
  92. };
  93. //成绩列表
  94. const getReportList = () => {
  95. if (!parameter.value.id) {
  96. return false;
  97. }
  98. let myInfo: any = localStorage.getItem('userInfo');
  99. let userInfo = JSON.parse(myInfo);
  100. let params: any = {
  101. school_id: userInfo.school_id,
  102. student_ids: parameter.value.id,
  103. page: page.value.current,
  104. per_page: page.value.size,
  105. };
  106. if (project.value) {
  107. params.exam_name = project.value;
  108. }
  109. if (date.value == "") {
  110. params.start_date = "2021-01-01";
  111. delete params.end_date;
  112. } else {
  113. params.start_date = date.value;
  114. params.end_date = date.value;
  115. }
  116. proxy?.$http.common.studentReport(params).then((res: any) => {
  117. if (res.status == 200) {
  118. let list = res.data.map((item: any) => {
  119. item.title = dic.project[item.exam_name];
  120. let result = null;
  121. if (["trijump", "solidball", "shotput", "longjump"].includes(item.exam_name)) {
  122. result = (Math.round(item.result) / 100).toFixed(2);
  123. } else if (["basketballv1", "footballv1"].includes(item.exam_name)) {
  124. result = proxy?.$utils.runTime(item.result, true, false);
  125. } else {
  126. result = item.result;
  127. }
  128. if (['run50', 'run70', 'run100', 'run200', 'run400', 'run800', 'run1000', 'run15x4', 'run50x8', 'run10x4', 'runwb800', 'runwb1000'].includes(item.exam_name)) {
  129. item.result = proxy?.$utils.runTime(item.result, false, false);
  130. } else {
  131. item.result = result + dic.unit[item.exam_name];
  132. }
  133. item.date = dayjs.unix(item.ctime).format("YYYY-MM-DD");
  134. return item;
  135. });
  136. page.value.current == 1 ?
  137. (reportList.value = list) :
  138. reportList.value.push(...list);
  139. getPages(res.total);
  140. }
  141. });
  142. };
  143. //测试报告
  144. const openReport = (data: any) => {
  145. let result_ids = data.result_id;
  146. let exam_name = data.exam_name;
  147. let student_id = data.student_id;
  148. if (!result_ids || !exam_name) {
  149. proxy?.$modal.msgWarning('缺少参数');
  150. return false;
  151. }
  152. let obj = {
  153. result_ids: result_ids,
  154. exam_name: exam_name,
  155. student_id: student_id
  156. }
  157. router.push({ path: '/analysis/detail', query: obj });
  158. };
  159. //下一页
  160. const getNext = () => {
  161. if (page.value.current == page.value.pages) {
  162. return false;
  163. }
  164. page.value.current++;
  165. getReportList();
  166. };
  167. //计算页码
  168. const getPages = (data: any) => {
  169. page.value.pages = Math.ceil(data / page.value.size);
  170. };
  171. //返回
  172. const getBack = () => {
  173. router.go(-1);
  174. };
  175. onBeforeMount(() => {
  176. parameter.value = route.query;
  177. //重组项目为数组
  178. for (let i in dic.project) {
  179. projectList.value.push({
  180. label: dic.project[i],
  181. value: i,
  182. })
  183. }
  184. getListData();
  185. });
  186. onMounted(() => {
  187. });
  188. </script>
  189. <style lang="scss">
  190. .result {
  191. min-height: 100vh;
  192. }
  193. .resultMain {
  194. padding-top: 6vh;
  195. }
  196. .resultCenter {
  197. width: 90%;
  198. height: 80vh;
  199. background: #ffffff;
  200. border-radius: 25px;
  201. margin: 0 auto 2vh;
  202. box-shadow: 0 0 15px #ffffff80;
  203. overflow: hidden;
  204. position: relative;
  205. display: flex;
  206. flex-direction: column;
  207. }
  208. .top {
  209. width: 100%;
  210. height: 12vh;
  211. background-color: #b0ffac;
  212. background-image: url("~@/static/images/home/btnbg2.png");
  213. background-size: 100% 100%;
  214. background-repeat: repeat;
  215. display: flex;
  216. align-items: center;
  217. }
  218. .top .topLeft {
  219. display: flex;
  220. align-items: center;
  221. padding: 0 15px;
  222. }
  223. .top .topLeft .pic {
  224. width: 8vh;
  225. height: 8vh;
  226. overflow: hidden;
  227. border-radius: 50%;
  228. border: 2px solid #ffffff;
  229. }
  230. .top .topLeft .pic .image {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. .top .topLeft .name {
  235. font-size: 3.2vh;
  236. color: #fff;
  237. margin-left: 3vw;
  238. }
  239. .bottom {
  240. display: flex;
  241. flex-direction: column;
  242. height: calc(100% - 12vh);
  243. }
  244. .type {
  245. height: 5vh;
  246. display: flex;
  247. text-align: center;
  248. background: #f3f3f3;
  249. color: #63cacc;
  250. font-size: 2vh;
  251. padding: 0 4px;
  252. }
  253. .type .li {
  254. width: 25%;
  255. padding: 8px 3px;
  256. flex: 1;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. }
  261. .type .more::before {
  262. content: "";
  263. width: 0;
  264. height: 0;
  265. display: block;
  266. border: 0.7vh;
  267. border-style: solid;
  268. border-color: #63cacc transparent transparent transparent;
  269. margin-top: 0.8vh;
  270. margin-right: 2px;
  271. }
  272. .list {
  273. text-align: center;
  274. font-size: 2vh;
  275. padding: 0 4px;
  276. height: calc(100% - 5vh);
  277. }
  278. .list .ul {
  279. display: flex;
  280. }
  281. .list .ul .li {
  282. width: 25%;
  283. padding: 8px 3px;
  284. flex: 1;
  285. word-break: break-all;
  286. flex-direction: column;
  287. }
  288. .list .ul .date {
  289. font-size: 1.8vh;
  290. }
  291. .list .ul .url {
  292. color: #90dba4;
  293. }
  294. .type .li:nth-of-type(1),
  295. .list .ul .li:nth-of-type(1) {
  296. flex-grow: 1;
  297. }
  298. .type .li:nth-of-type(2),
  299. .list .ul .li:nth-of-type(2) {
  300. flex-grow: 1.4;
  301. }
  302. .type .li:nth-of-type(3),
  303. .list .ul .li:nth-of-type(3) {
  304. flex-grow: 1.4;
  305. }
  306. .type .li:nth-of-type(4),
  307. .list .ul .li:nth-of-type(4) {
  308. flex-grow: 1;
  309. }
  310. .type .li:nth-of-type(5),
  311. .list .ul .li:nth-of-type(5) {
  312. flex-grow: 0.7;
  313. }
  314. .scrollBox {
  315. height: 98%;
  316. }
  317. .btn {
  318. width: 90%;
  319. height: 7vh;
  320. line-height: 7vh;
  321. text-align: center;
  322. color: #fff;
  323. font-size: 2.2vh;
  324. margin: 0 auto;
  325. background: url("~@/static/images/train/areabg2.png") center center repeat-y;
  326. background-size: 100% 100%;
  327. border-radius: 2.1vh;
  328. box-shadow: 0px 0px 15px #ffffff80;
  329. cursor: pointer;
  330. }
  331. </style>