studentRight.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div class="container">
  3. <!-- 成绩统计区域 -->
  4. <div class="container_box">
  5. <div class="box_title">
  6. <img src="@/assets/images/box-icon.png" />
  7. 成绩统计
  8. </div>
  9. <!-- 筛选框区域 -->
  10. <div class="box_select">
  11. <span>考试名称</span>
  12. <el-select
  13. v-model="examName"
  14. placeholder="请选择学期"
  15. style="width: 206px"
  16. @change="handleChange"
  17. >
  18. <el-option
  19. v-for="(item, index) in optionsTime"
  20. :key="index"
  21. :label="(item as any).totalName"
  22. :value="(item as any).totalName"
  23. />
  24. </el-select>
  25. </div>
  26. <!-- 图表展示区域 -->
  27. <div v-if="examName" class="box_chart" ref="barChart"></div>
  28. <!-- 没有数据时展示 -->
  29. <div v-if="!examName" class="box_nodata">暂无数据</div>
  30. </div>
  31. <!-- 考评记录区域 -->
  32. <div class="container_box">
  33. <div class="box_title">
  34. <img src="@/assets/images/box-icon.png" />
  35. 考评记录
  36. </div>
  37. <div class="box_form form">
  38. <el-table :data="tableData">
  39. <el-table-column
  40. prop="time"
  41. label="考评时间"
  42. align="center"
  43. width="150"
  44. />
  45. <el-table-column prop="leave" label="考评等级" align="center" />
  46. </el-table>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script setup lang="ts">
  52. import { ref, onMounted } from "vue";
  53. import { useRoute } from "vue-router";
  54. import * as Echarts from "echarts";
  55. // 引入用户画像相关的接口
  56. import {
  57. reqGetExamName,
  58. reqGetHisExamData,
  59. reqGetEvaluateData,
  60. } from "@/api/user/index";
  61. // 引入解密函数
  62. import { decryptDes } from "@/utils/des";
  63. const $route = useRoute();
  64. // 用户id
  65. const userId = ref();
  66. // 用户信息
  67. const userInfo = ref();
  68. // 柱状图实例
  69. let myBarChart: any;
  70. // 柱状图DOM
  71. const barChart = ref();
  72. // 当前选择的学期
  73. const examName = ref("");
  74. // 成绩统计学期筛选框数组
  75. const optionsTime = ref([]);
  76. // 图表X轴学科数组数据
  77. const subjectList = ref<any>([]);
  78. // 图表Y轴成绩数组数据
  79. const valueList = ref<any>([]);
  80. // 考评记录数组
  81. const tableData = [
  82. {
  83. time: "2020-2021秋季",
  84. leave: "A",
  85. },
  86. {
  87. time: "2020-2021秋季",
  88. leave: "A",
  89. },
  90. {
  91. time: "2020-2021秋季",
  92. leave: "A",
  93. },
  94. {
  95. time: "2020-2021秋季",
  96. leave: "A",
  97. },
  98. {
  99. time: "2020-2021秋季",
  100. leave: "A",
  101. },
  102. {
  103. time: "2020-2021秋季",
  104. leave: "A",
  105. },
  106. {
  107. time: "2020-2021秋季",
  108. leave: "A",
  109. },
  110. {
  111. time: "2020-2021秋季",
  112. leave: "A",
  113. },
  114. ];
  115. onMounted(() => {
  116. const obj = JSON.parse(decodeURIComponent($route.query.obj as string));
  117. userInfo.value = obj;
  118. userId.value = obj.id;
  119. // 获取考试名称数组
  120. getExamName();
  121. // 获取考评记录数据
  122. getEvaluateData();
  123. });
  124. // 获取考试名称数组
  125. const getExamName = async () => {
  126. const res = await reqGetExamName({
  127. userId: userId.value,
  128. });
  129. // console.log(res);
  130. if ((res as any).code == 200) {
  131. const result = JSON.parse(decryptDes(res.data));
  132. // console.log(result);
  133. optionsTime.value = result;
  134. if (result.length) {
  135. examName.value = result[0].totalName;
  136. // 获取学生各科成绩
  137. getScoreInfo();
  138. }
  139. }
  140. };
  141. // 获取考评记录数据
  142. const getEvaluateData = async () => {
  143. const res = await reqGetEvaluateData({
  144. cardNo: userInfo.value.cardNo,
  145. });
  146. // console.log(res);
  147. if ((res as any).code == 200) {
  148. const result = JSON.parse(decryptDes(res.data));
  149. // console.log(result);
  150. }
  151. };
  152. // 获取学生各科成绩
  153. const getScoreInfo = async () => {
  154. const temObj: any = optionsTime.value.find(
  155. (ele: any) => ele.totalName === examName.value
  156. );
  157. // console.log(temObj);
  158. const res = await reqGetHisExamData({
  159. userId: userId.value,
  160. semesterId: temObj.semesterId,
  161. examTypeId: temObj.examTypeId,
  162. });
  163. // console.log(res);
  164. if ((res as any).code == 200) {
  165. const result = JSON.parse(decryptDes(res.data));
  166. // console.log(result);
  167. if (result.length) {
  168. result.forEach((ele: any) => {
  169. subjectList.value.push(ele.subjectName);
  170. valueList.value.push(ele.score);
  171. });
  172. }
  173. // 初始化柱状图
  174. initBarChart();
  175. }
  176. };
  177. // 初始化柱状图
  178. const initBarChart = () => {
  179. myBarChart = Echarts.init(barChart.value);
  180. const options = {
  181. tooltip: {
  182. trigger: "axis",
  183. axisPointer: {
  184. type: "shadow",
  185. },
  186. },
  187. grid: {
  188. top: "13%",
  189. left: "8%",
  190. right: "4%",
  191. bottom: "18%",
  192. },
  193. xAxis: {
  194. type: "category",
  195. data: subjectList.value,
  196. axisTick: {
  197. show: false,
  198. },
  199. axisLabel: {
  200. margin: 12,
  201. interval: 0,
  202. fontSize: 14,
  203. color: "#fff",
  204. },
  205. },
  206. yAxis: {
  207. name: "分数",
  208. nameTextStyle: {
  209. fontSize: 14,
  210. color: "#fff",
  211. },
  212. type: "value",
  213. axisLabel: {
  214. color: "#fff",
  215. },
  216. splitLine: {
  217. show: true,
  218. lineStyle: {
  219. color: "rgba(108, 128, 151, 0.5)",
  220. },
  221. },
  222. },
  223. series: [
  224. {
  225. data: valueList.value,
  226. type: "bar",
  227. barWidth: "60%",
  228. label: {
  229. show: true,
  230. position: "top",
  231. distance: 5,
  232. color: "#14B6F3",
  233. fontSize: 14,
  234. },
  235. itemStyle: {
  236. color: new Echarts.graphic.LinearGradient(0, 1, 0, 0, [
  237. { offset: 0, color: "#0336FF" },
  238. { offset: 1, color: "#01B4FF" },
  239. ]),
  240. },
  241. },
  242. ],
  243. };
  244. myBarChart.setOption(options);
  245. };
  246. // 筛选框切换回调
  247. const handleChange = () => {
  248. myBarChart.dispose();
  249. subjectList.value = [];
  250. valueList.value = [];
  251. getScoreInfo();
  252. };
  253. </script>
  254. <style lang="scss" scoped>
  255. .container {
  256. display: flex;
  257. flex-direction: column;
  258. justify-content: space-between;
  259. width: 500px;
  260. height: 834px;
  261. color: #fff;
  262. .container_box {
  263. padding: 17px 0 0 22px;
  264. width: 500px;
  265. height: 412px;
  266. background-image: url(@/assets/images/box-bg5.png);
  267. background-size: 100% 100%;
  268. .box_title {
  269. display: flex;
  270. align-items: center;
  271. font-size: 16px;
  272. font-weight: bold;
  273. img {
  274. margin-right: 12px;
  275. width: 24px;
  276. height: 24px;
  277. }
  278. }
  279. .box_select {
  280. display: flex;
  281. align-items: center;
  282. margin: 31px 0 31px 170px;
  283. font-size: 14px;
  284. span {
  285. margin-right: 13px;
  286. }
  287. }
  288. .box_chart {
  289. height: 270px;
  290. }
  291. .box_nodata {
  292. margin-top: 150px;
  293. text-align: center;
  294. }
  295. .box_form {
  296. padding-right: 44px;
  297. margin-top: 48px;
  298. height: 287px;
  299. overflow: hidden;
  300. }
  301. }
  302. }
  303. // 修改select背景颜色
  304. ::v-deep(.el-input__wrapper) {
  305. background: transparent;
  306. background-color: rgba(48, 75, 95, 0.5);
  307. }
  308. // 修改select筛选框文字颜色
  309. ::v-deep(.el-input__inner) {
  310. color: #fff;
  311. }
  312. /*最外层透明*/
  313. .form ::v-deep(.el-table),
  314. .form ::v-deep(.el-table__expanded-cell) {
  315. background-color: transparent;
  316. color: white;
  317. border: none;
  318. }
  319. /* 表格内背景颜色 */
  320. .form ::v-deep(.el-table th),
  321. .form ::v-deep(.el-table tr),
  322. .form ::v-deep(.el-table td),
  323. ::v-deep(.el-table th.el-table__cell.is-leaf) {
  324. background-color: transparent !important;
  325. color: white;
  326. font-size: 12px;
  327. border-color: rgba(255, 255, 255, 0.1);
  328. height: 40px;
  329. }
  330. // 表格底部白线清除
  331. ::v-deep(.el-table__inner-wrapper::before) {
  332. height: 0;
  333. }
  334. // 修改表头背景颜色
  335. ::v-deep(.el-table__header) {
  336. background-color: rgba(58, 126, 199, 0.5);
  337. }
  338. // 清除表格默认padding
  339. ::v-deep(.el-table .cell) {
  340. padding: 0;
  341. }
  342. // 动画滚动
  343. // ::v-deep(.el-scrollbar__view) {
  344. // animation: run 12s linear infinite;
  345. // }
  346. </style>