studentCenter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <div class="container">
  3. <!-- 雷达图区域 -->
  4. <div class="top">
  5. <div class="top_chart" ref="radarChart"></div>
  6. <div class="top_select">
  7. <el-select
  8. v-model="examName"
  9. placeholder="请选择学期"
  10. @change="handleChange"
  11. >
  12. <el-option
  13. v-for="(item, index) in optionsExam"
  14. :key="index"
  15. :label="(item as any).name"
  16. :value="(item as any).id"
  17. />
  18. </el-select>
  19. </div>
  20. <!-- 教师寄语区域 -->
  21. <div class="top_msg">
  22. <div class="msg_title">教师寄语</div>
  23. <div class="msg_detail" :title="teacherMsg">
  24. {{ teacherMsg }}
  25. </div>
  26. </div>
  27. </div>
  28. <!-- 日常轨迹区域 -->
  29. <div class="bottom">
  30. <div class="bottom_title">
  31. <img src="@/assets/images/box-icon.png" />
  32. 日常轨迹
  33. </div>
  34. <!-- 轨迹线展示区域 -->
  35. <div class="bottom_box">
  36. <!-- 每一个轨迹区域 -->
  37. <div
  38. v-for="(item, index) in trackList"
  39. :key="index"
  40. :class="index % 2 === 0 ? 'bottom_line' : 'bottom_line2'"
  41. >
  42. <div class="circle">
  43. <!-- 详细信息区域 -->
  44. <div class="detail">
  45. <div class="detail_img">
  46. <img
  47. v-if="
  48. item.type === '准时打卡' ||
  49. item.type === '迟到打卡' ||
  50. item.type === '超时打卡' ||
  51. item.type === '请假'
  52. "
  53. src="@/assets/images/1.png"
  54. />
  55. <el-image
  56. v-else
  57. style="width: 38px; height: 45px"
  58. :src="item.image"
  59. :preview-src-list="[item.image]"
  60. fit="cover"
  61. />
  62. </div>
  63. <div>
  64. <div>地址:</div>
  65. <div class="detail_address" :title="item.location">
  66. {{ item.location }}
  67. </div>
  68. </div>
  69. </div>
  70. <!-- 时间区域 -->
  71. <div class="img">
  72. <span class="span">
  73. <el-icon size="12"><Clock /></el-icon>
  74. </span>
  75. <span class="text">{{ item.dateTime.slice(-14) }}</span>
  76. </div>
  77. </div>
  78. <span>—</span>
  79. <div class="small"></div>
  80. <span>—</span>
  81. <div class="small"></div>
  82. <span>—</span>
  83. <div class="small"></div>
  84. <span>—</span>
  85. </div>
  86. <!-- 没有数据时展示 -->
  87. <div class="bottom_nodata" v-if="!trackList.length">暂无数据</div>
  88. </div>
  89. </div>
  90. </div>
  91. </template>
  92. <script setup lang="ts">
  93. import { ref, onMounted, watch } from "vue";
  94. import { useRoute } from "vue-router";
  95. import * as Echarts from "echarts";
  96. // 引入用户肖像相关的接口
  97. import {
  98. reqGetScoreInfo,
  99. reqGetTeacherMsg,
  100. reqGetTrackData,
  101. reqGetSemesterInfo,
  102. } from "@/api/user/index";
  103. // 引入解密函数
  104. import { decryptDes } from "@/utils/des";
  105. const $props = defineProps(["userId"]);
  106. watch($props, () => {
  107. // console.log($props.userId);
  108. });
  109. const $route = useRoute();
  110. // 雷达图实例
  111. let myRaChart: any;
  112. // 雷达图DOM
  113. const radarChart = ref(null);
  114. // 用户id
  115. const userId = ref();
  116. // 用户信息
  117. const userInfo = ref();
  118. // 雷达图数据数组
  119. const valueList = ref<any>([]);
  120. // 雷达图学科数据数组
  121. const typeList = ref<any>([]);
  122. // 教师寄语信息
  123. const teacherMsg = ref("");
  124. // 轨迹数组数据
  125. const trackList = ref<any>([]);
  126. // 当前选择的学期
  127. const examName = ref("");
  128. // 成绩统计学期筛选框数组
  129. const optionsExam = ref<any>([]);
  130. onMounted(() => {
  131. const obj = JSON.parse(decodeURIComponent($route.query.obj as string));
  132. userInfo.value = obj;
  133. // 获取用户id
  134. userId.value = obj.id;
  135. // 获取雷达图学期数组
  136. getSemesterInfo();
  137. // 获取教师寄语信息
  138. getTeacherMsg();
  139. // 获取日常轨迹
  140. getTrackData();
  141. });
  142. // 获取雷达图学期数组
  143. const getSemesterInfo = async () => {
  144. const res = await reqGetSemesterInfo();
  145. // console.log(res);
  146. if ((res as any).code == 200) {
  147. const result = JSON.parse(decryptDes(res.data));
  148. // console.log(result);
  149. optionsExam.value = result;
  150. examName.value = optionsExam.value[0].id;
  151. // 获取学生各科成绩的平均分
  152. getScoreInfo();
  153. }
  154. };
  155. // 获取学生各科成绩的平均分
  156. const getScoreInfo = async () => {
  157. const res = await reqGetScoreInfo({
  158. userId: userId.value,
  159. semesterId: examName.value,
  160. });
  161. // console.log(res);
  162. if ((res as any).code == 200) {
  163. const result = JSON.parse(decryptDes(res.data));
  164. // console.log(result);
  165. result.forEach((ele: any) => {
  166. valueList.value.push(ele.score);
  167. typeList.value.push({
  168. name: ele.subjectName,
  169. max: 150,
  170. });
  171. });
  172. // 初始化雷达图
  173. initRaChart();
  174. }
  175. };
  176. // 获取教师寄语信息
  177. const getTeacherMsg = async () => {
  178. const res = await reqGetTeacherMsg({
  179. cardNo: userInfo.value.cardNo,
  180. termId: examName.value,
  181. });
  182. // console.log(res);
  183. if ((res as any).code == 200) {
  184. const result = JSON.parse(decryptDes(res.data));
  185. // console.log(result);
  186. teacherMsg.value = result.teacherMessage;
  187. }
  188. };
  189. // 获取日常轨迹
  190. const getTrackData = async () => {
  191. const res = await reqGetTrackData({
  192. userId: userId.value,
  193. });
  194. // console.log(res);
  195. if ((res as any).code == 200) {
  196. const result = JSON.parse(decryptDes(res.data));
  197. // console.log(result);
  198. trackList.value = result;
  199. }
  200. };
  201. // 初始化雷达图
  202. const initRaChart = () => {
  203. myRaChart = Echarts.init(radarChart.value);
  204. const options = {
  205. tooltip: {
  206. trigger: "item",
  207. },
  208. radar: {
  209. indicator: typeList.value,
  210. axisName: {
  211. color: "#fff",
  212. fontSize: 19.5,
  213. },
  214. splitArea: {
  215. areaStyle: {
  216. color: "none",
  217. },
  218. },
  219. axisLine: {
  220. lineStyle: {
  221. color: "rgba(255, 255, 255, 1)",
  222. },
  223. },
  224. splitLine: {
  225. lineStyle: {
  226. color: "rgba(255, 255, 255, 1)",
  227. },
  228. },
  229. },
  230. series: [
  231. {
  232. type: "radar",
  233. name: "学习成绩",
  234. data: [
  235. {
  236. value: valueList.value,
  237. areaStyle: {
  238. color: "rgba(0, 209, 200, 0.5)",
  239. },
  240. symbol: "none",
  241. },
  242. ],
  243. },
  244. ],
  245. color: "rgba(0, 209, 200, 1)",
  246. };
  247. myRaChart.setOption(options);
  248. };
  249. // 筛选框切换回调
  250. const handleChange = () => {
  251. myRaChart.dispose();
  252. typeList.value = [];
  253. valueList.value = [];
  254. getScoreInfo();
  255. getTeacherMsg();
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. .container {
  260. display: flex;
  261. flex-direction: column;
  262. justify-content: space-between;
  263. width: 800px;
  264. height: 834px;
  265. color: #fff;
  266. .top {
  267. position: relative;
  268. height: 530px;
  269. background-image: url(@/assets/images/box-bg6.png);
  270. background-size: 100% 100%;
  271. .top_chart {
  272. height: 407px;
  273. }
  274. .top_select {
  275. position: absolute;
  276. top: 0;
  277. left: 80px;
  278. width: 200px;
  279. }
  280. .top_msg {
  281. margin: auto;
  282. padding: 0 18px;
  283. width: 442px;
  284. height: 123px;
  285. background-color: rgba(212, 234, 250, 0.1);
  286. border: 1px solid rgba(212, 234, 250, 0.2);
  287. .msg_title {
  288. margin: 10px 0;
  289. font-size: 16px;
  290. font-weight: bold;
  291. }
  292. .msg_detail {
  293. font-size: 12px;
  294. line-height: 19px;
  295. display: -webkit-box;
  296. -webkit-box-orient: vertical;
  297. -webkit-line-clamp: 4;
  298. overflow: hidden;
  299. }
  300. }
  301. }
  302. .bottom {
  303. padding: 17px 10px 0 22px;
  304. height: 272px;
  305. background-image: url(@/assets/images/box-bg4.png);
  306. background-size: 100% 100%;
  307. .bottom_title {
  308. display: flex;
  309. align-items: center;
  310. font-size: 16px;
  311. font-weight: bold;
  312. img {
  313. margin-right: 12px;
  314. width: 24px;
  315. height: 24px;
  316. }
  317. }
  318. .bottom_box {
  319. display: flex;
  320. height: 220px;
  321. overflow-x: auto;
  322. overflow-y: hidden;
  323. .bottom_line {
  324. display: inline-flex;
  325. align-items: center;
  326. height: 220px;
  327. .circle {
  328. position: relative;
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. padding: 2px;
  333. width: 18px;
  334. height: 18px;
  335. border-radius: 50%;
  336. border: 1px solid #70b7fa;
  337. background-color: #70b7fa;
  338. background-clip: content-box;
  339. .img {
  340. position: absolute;
  341. top: 82px;
  342. left: 0;
  343. display: flex;
  344. align-items: center;
  345. width: 121px;
  346. height: 18px;
  347. font-size: 10px;
  348. background-image: url(@/assets/images/line-bg.png);
  349. background-size: 100% 100%;
  350. .span {
  351. margin-top: 2px;
  352. margin-left: 20px;
  353. margin-right: 10px;
  354. color: #fff;
  355. }
  356. .text {
  357. color: #fff;
  358. }
  359. }
  360. .detail {
  361. position: absolute;
  362. top: 22px;
  363. left: 8px;
  364. display: flex;
  365. padding: 6px;
  366. width: 111px;
  367. height: 57px;
  368. color: #fff;
  369. font-size: 10px;
  370. background-color: rgba(112, 183, 250, 0.4);
  371. .detail_img {
  372. margin-right: 4px;
  373. width: 38px;
  374. height: 45px;
  375. img {
  376. width: 30px;
  377. height: 30px;
  378. object-fit: contain;
  379. }
  380. }
  381. .detail_address {
  382. margin-top: 4px;
  383. cursor: pointer;
  384. display: -webkit-box;
  385. -webkit-box-orient: vertical;
  386. -webkit-line-clamp: 2;
  387. overflow: hidden;
  388. }
  389. }
  390. }
  391. .circle::after {
  392. content: "";
  393. position: relative;
  394. top: 37px;
  395. left: 0;
  396. height: 74px;
  397. border-left: 1px solid #70b7fa;
  398. }
  399. span {
  400. color: #70b7fa;
  401. }
  402. .small {
  403. margin-top: 4px;
  404. width: 6px;
  405. height: 6px;
  406. border-radius: 50%;
  407. background-color: #70b7fa;
  408. }
  409. }
  410. .bottom_line2 {
  411. display: inline-flex;
  412. align-items: center;
  413. height: 220px;
  414. .circle {
  415. position: relative;
  416. display: flex;
  417. justify-content: center;
  418. align-items: center;
  419. padding: 2px;
  420. width: 18px;
  421. height: 18px;
  422. border-radius: 50%;
  423. border: 1px solid #70b7fa;
  424. background-color: #70b7fa;
  425. background-clip: content-box;
  426. .img {
  427. position: absolute;
  428. top: -82px;
  429. left: 0;
  430. display: flex;
  431. align-items: center;
  432. width: 121px;
  433. height: 18px;
  434. font-size: 10px;
  435. background-image: url(@/assets/images/line-bg.png);
  436. background-size: 100% 100%;
  437. .span {
  438. margin-top: 2px;
  439. margin-left: 20px;
  440. margin-right: 10px;
  441. color: #fff;
  442. }
  443. .text {
  444. color: #fff;
  445. }
  446. }
  447. .detail {
  448. position: absolute;
  449. top: -61px;
  450. left: 8px;
  451. display: flex;
  452. padding: 6px;
  453. width: 111px;
  454. height: 57px;
  455. color: #fff;
  456. font-size: 10px;
  457. background-color: rgba(112, 183, 250, 0.4);
  458. .detail_img {
  459. margin-right: 4px;
  460. width: 38px;
  461. height: 45px;
  462. img {
  463. width: 30px;
  464. height: 30px;
  465. object-fit: contain;
  466. }
  467. }
  468. .detail_address {
  469. margin-top: 4px;
  470. cursor: pointer;
  471. display: -webkit-box;
  472. -webkit-box-orient: vertical;
  473. -webkit-line-clamp: 2;
  474. overflow: hidden;
  475. }
  476. }
  477. }
  478. .circle::after {
  479. content: "";
  480. position: relative;
  481. top: -37px;
  482. left: 0;
  483. height: 74px;
  484. border-left: 1px solid #70b7fa;
  485. }
  486. span {
  487. color: #70b7fa;
  488. }
  489. .small {
  490. margin-top: 4px;
  491. width: 6px;
  492. height: 6px;
  493. border-radius: 50%;
  494. background-color: #70b7fa;
  495. }
  496. }
  497. .bottom_nodata {
  498. margin: auto;
  499. }
  500. }
  501. }
  502. }
  503. /*定义滚动条样式(高宽及背景)*/
  504. ::-webkit-scrollbar {
  505. height: 10px;
  506. }
  507. /*定义滑块 样式*/
  508. ::-webkit-scrollbar-thumb {
  509. border-radius: 3px;
  510. background-color: rgba(2, 27, 41, 0.8);
  511. }
  512. // 修改select背景颜色
  513. ::v-deep(.el-input__wrapper) {
  514. background: transparent;
  515. background-color: rgba(48, 75, 95, 0.5);
  516. }
  517. // 修改select筛选框文字颜色
  518. ::v-deep(.el-input__inner) {
  519. color: #fff;
  520. }
  521. </style>