index.vue 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  1. <template>
  2. <div class="learning-behavior-analysis">
  3. <!-- 页面头部 -->
  4. <div class="header">
  5. <h1>📊 学习行为分析</h1>
  6. <p>全面分析学院教学情况和学员学习行为</p>
  7. </div>
  8. <!-- 导航标签 -->
  9. <div class="nav-tabs">
  10. <div class="nav-tab" :class="{ active: activeTab === 'college' }" @click="switchTab('college')">
  11. 🏫 学院维度分析
  12. </div>
  13. <div class="nav-tab" :class="{ active: activeTab === 'student' }" @click="switchTab('student')">
  14. 👤 学员维度分析
  15. </div>
  16. </div>
  17. <!-- 学院维度分析 -->
  18. <div v-show="activeTab === 'college'" class="tab-content">
  19. <!-- 筛选条件 -->
  20. <div class="filter-section">
  21. <h3>🔍 数据筛选</h3>
  22. <div class="filter-controls">
  23. <div class="filter-group">
  24. <label>选择学院</label>
  25. <a-select v-model:value="collegeFilters.collegeId" placeholder="全部学院" @change="updateCollegeData">
  26. <a-select-option v-for="college in collegeList" :key="college.id" :value="college.id">
  27. {{ college.name }}
  28. </a-select-option>
  29. </a-select>
  30. </div>
  31. <div class="filter-group">
  32. <label>时间范围</label>
  33. <a-select v-model:value="collegeFilters.timeRange" @change="updateCollegeData">
  34. <a-select-option :value="7">最近7天</a-select-option>
  35. <a-select-option :value="30">最近30天</a-select-option>
  36. <a-select-option :value="90">最近90天</a-select-option>
  37. <a-select-option :value="365">最近一年</a-select-option>
  38. </a-select>
  39. </div>
  40. <div class="filter-group">
  41. <a-button type="primary" @click="updateCollegeData">查询</a-button>
  42. </div>
  43. </div>
  44. </div>
  45. <!-- 学院整体统计 -->
  46. <div class="stats-grid">
  47. <div class="stat-card">
  48. <h3>📚 课程访问统计</h3>
  49. <div class="stat-number">{{ collegeStats.allCourseCount }}</div>
  50. <div class="stat-label">总课程数</div>
  51. <div class="stat-number">{{ collegeStats.activeCourseCount }}</div>
  52. <div class="stat-label">活跃课程数</div>
  53. <div class="stat-number">{{ collegeStats.courseVisitCount }}%</div>
  54. <div class="stat-label">课程访问率</div>
  55. </div>
  56. <div class="stat-card">
  57. <h3>👥 用户登录统计</h3>
  58. <div class="stat-number">{{ collegeStats.allLoginCount.toLocaleString() }}</div>
  59. <div class="stat-label">总登录人次</div>
  60. <div class="stat-number">{{ collegeStats.userCount.toLocaleString() }}</div>
  61. <div class="stat-label">独立用户数</div>
  62. <div class="stat-number">{{ collegeStats.avgLoginCount }}</div>
  63. <div class="stat-label">人均登录次数</div>
  64. </div>
  65. <div class="stat-card">
  66. <h3>⏰ 观看时长统计</h3>
  67. <div class="stat-number">{{ collegeStats.userAllStayTime }}</div>
  68. <div class="stat-label">总观看时长</div>
  69. <div class="stat-number">{{ collegeStats.avgStayTime }}</div>
  70. <div class="stat-label">平均时长</div>
  71. <div class="stat-number">{{ collegeStats.peakWatchUserCount ? peakWatchUserCount.toLocaleString() : '0' }}</div>
  72. <div class="stat-label">峰值观看人数</div>
  73. </div>
  74. </div>
  75. <!-- 登录时段分析图表 -->
  76. <div class="chart-container">
  77. <h3>⏰ 用户登录时段分布</h3>
  78. <div ref="loginTimeChart" class="chart"></div>
  79. </div>
  80. <!-- 课程访问热度图表 -->
  81. <div class="chart-container">
  82. <h3>🔥 课程访问热度排行</h3>
  83. <div ref="courseHeatChart" class="chart"></div>
  84. </div>
  85. <!-- 学院课程详细统计 -->
  86. <div class="data-table">
  87. <h3>📊 学院课程详细统计</h3>
  88. <a-table
  89. :columns="collegeColumns"
  90. :data-source="collegeTableData"
  91. :pagination="{ pageSize: 10 }"
  92. row-key="id"
  93. />
  94. </div>
  95. </div>
  96. <!-- 学员维度分析 -->
  97. <div v-show="activeTab === 'student'" class="tab-content">
  98. <!-- 学员搜索 -->
  99. <div class="filter-section">
  100. <h3>🔍 学员搜索</h3>
  101. <div class="filter-controls">
  102. <div class="filter-group">
  103. <label>学员姓名/学号</label>
  104. <a-input v-model:value="studentSearch" placeholder="输入学员姓名或学号" @pressEnter="searchStudent" />
  105. </div>
  106. <div class="filter-group">
  107. <a-button type="primary" @click="searchStudent">搜索</a-button>
  108. </div>
  109. <div class="filter-group">
  110. <a-button @click="clearSearch">清除</a-button>
  111. </div>
  112. </div>
  113. </div>
  114. <!-- 学员学习行为卡片 -->
  115. <div class="student-cards">
  116. <div
  117. v-for="student in filteredStudents"
  118. :key="student.userId"
  119. class="student-card"
  120. :class="{ highlighted: student.highlighted }"
  121. >
  122. <div class="student-header">
  123. <div class="student-info">
  124. <h4>{{ student.userIdName }} ({{ student.userId }})</h4>
  125. <div class="student-meta">{{ student.college }} | {{ student.majorIdName }} | {{ student.grade }}</div>
  126. </div>
  127. <div class="student-stats">
  128. <div class="stat-item">
  129. <div class="stat-value">{{ (student.finishRate)* 100 }}%</div>
  130. <div class="stat-label">总体进度</div>
  131. </div>
  132. </div>
  133. </div>
  134. <div class="course-progress">
  135. <div v-for="course in student.courseList" :key="course.id" class="course-item">
  136. <div class="course-name">{{ course.courseName }}</div>
  137. <div class="course-stats">
  138. <div class="stat-item">
  139. <div class="stat-value">{{ (course.finishRate)* 100 }}%</div>
  140. <div class="stat-label">学习进度</div>
  141. </div>
  142. <div class="stat-item">
  143. <div class="stat-value">{{ course.workRate }}</div>
  144. <div class="stat-label">作业完成</div>
  145. </div>
  146. <div class="stat-item">
  147. <div class="stat-value">{{ course.answerCount }}</div>
  148. <div class="stat-label">讨论参与</div>
  149. </div>
  150. <div class="stat-item">
  151. <div class="stat-value">{{ course.postCount }}</div>
  152. <div class="stat-label">提问次数</div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </template>
  162. <script setup>
  163. import { ref, reactive, computed, onMounted, nextTick, onUnmounted } from 'vue'
  164. import * as echarts from 'echarts'
  165. import {
  166. getCollegeList,
  167. getCollegeStats,
  168. getLoginTimeDistribution,
  169. getCourseHeat,
  170. getCollegeCourseDetails,
  171. searchStudents
  172. } from '@/api/statisticalAnalysis/analysisLearningBehaviors'
  173. // 当前活动标签
  174. const activeTab = ref('college')
  175. // 学院维度筛选条件
  176. const collegeFilters = reactive({
  177. collegeId: '',
  178. timeRange: 30
  179. })
  180. // 学院列表
  181. const collegeList = ref([])
  182. // 学院统计数据
  183. const collegeStats = ref({
  184. totalCourses: 156,
  185. activeCourses: 142,
  186. courseAccessRate: 91.0,
  187. totalLogins: 12456,
  188. uniqueUsers: 3234,
  189. avgLoginPerUser: 3.85,
  190. totalOnlineTime: 2456,
  191. avgSessionTime: 45.2,
  192. peakOnlineUsers: 234,
  193. activeCourseCount : 0,
  194. allCourseCount : 0,
  195. courseVisitCount : 0,
  196. allLoginCount : 0,
  197. avgLoginCount: 0,
  198. userCount :0,
  199. avgStayTime:'',
  200. peakWatchUserCount : 0,
  201. userAllStayTime : ''
  202. })
  203. // 图表引用
  204. const loginTimeChart = ref(null)
  205. const courseHeatChart = ref(null)
  206. let loginTimeChartInstance = null
  207. let courseHeatChartInstance = null
  208. // 学院表格列定义
  209. const collegeColumns = [
  210. {
  211. title: '学院名称',
  212. dataIndex: 'collegeIdName',
  213. key: 'collegeIdName'
  214. },
  215. {
  216. title: '课程数量',
  217. dataIndex: 'courseCount',
  218. key: 'courseCount'
  219. },
  220. {
  221. title: '总访问量',
  222. dataIndex: 'watchCount',
  223. key: 'watchCount'
  224. },
  225. {
  226. title: '平均完成率',
  227. dataIndex: 'completeRate',
  228. key: 'completeRate',
  229. customRender: ({ text }) => `${text}%`
  230. },
  231. {
  232. title: '作业提交率',
  233. dataIndex: 'homeworkFinishRate',
  234. key: 'homeworkFinishRate',
  235. customRender: ({ text }) => `${text}%`
  236. },
  237. // {
  238. // title: '退课率',
  239. // dataIndex: 'homeworkFinishRate',
  240. // key: 'homeworkFinishRate',
  241. // customRender: ({ text }) => `${text}%`
  242. // }
  243. ]
  244. // 学院表格数据
  245. const collegeTableData = ref([
  246. {
  247. collegeId: 1,
  248. collegeIdName: '计算机学院',
  249. courseCount: 45,
  250. totalVisits: 5234,
  251. completeRate: 78.5,
  252. assignmentSubmissionRate: 85.2,
  253. dropoutRate: 10.2
  254. },
  255. {
  256. id: 2,
  257. name: '商学院',
  258. courseCount: 38,
  259. totalVisits: 4567,
  260. avgCompletionRate: 72.3,
  261. assignmentSubmissionRate: 79.8,
  262. dropoutRate: 12.5
  263. },
  264. {
  265. id: 3,
  266. name: '艺术学院',
  267. courseCount: 28,
  268. totalVisits: 3123,
  269. avgCompletionRate: 68.9,
  270. assignmentSubmissionRate: 76.4,
  271. dropoutRate: 15.2
  272. },
  273. {
  274. id: 4,
  275. name: '理学院',
  276. courseCount: 35,
  277. totalVisits: 3890,
  278. avgCompletionRate: 75.2,
  279. assignmentSubmissionRate: 82.1,
  280. dropoutRate: 13.8
  281. }
  282. ])
  283. // 学员搜索
  284. const studentSearch = ref('')
  285. // 学员数据
  286. const studentsData = ref([
  287. // {
  288. // id: 1,
  289. // name: '张三',
  290. // studentId: '2021001',
  291. // college: '计算机学院',
  292. // major: '计算机科学与技术',
  293. // grade: '大三',
  294. // overallProgress: 85.6,
  295. // highlighted: false,
  296. // courses: [
  297. // {
  298. // id: 1,
  299. // name: 'JavaScript程序设计',
  300. // progress: 92,
  301. // completedAssignments: 8,
  302. // totalAssignments: 10,
  303. // discussionParticipation: 15,
  304. // questionCount: 5
  305. // },
  306. // {
  307. // id: 2,
  308. // name: '数据结构与算法',
  309. // progress: 78,
  310. // completedAssignments: 6,
  311. // totalAssignments: 8,
  312. // discussionParticipation: 12,
  313. // questionCount: 3
  314. // }
  315. // ]
  316. // },
  317. // {
  318. // id: 2,
  319. // name: '李四',
  320. // studentId: '2021002',
  321. // college: '商学院',
  322. // major: '工商管理',
  323. // grade: '大二',
  324. // overallProgress: 72.3,
  325. // highlighted: false,
  326. // courses: [
  327. // {
  328. // id: 3,
  329. // name: '管理学原理',
  330. // progress: 85,
  331. // completedAssignments: 7,
  332. // totalAssignments: 9,
  333. // discussionParticipation: 8,
  334. // questionCount: 2
  335. // },
  336. // {
  337. // id: 4,
  338. // name: '市场营销学',
  339. // progress: 65,
  340. // completedAssignments: 4,
  341. // totalAssignments: 7,
  342. // discussionParticipation: 6,
  343. // questionCount: 1
  344. // }
  345. // ]
  346. // },
  347. // {
  348. // id: 3,
  349. // name: '王五',
  350. // studentId: '2021003',
  351. // college: '艺术学院',
  352. // major: '视觉传达设计',
  353. // grade: '大一',
  354. // overallProgress: 91.2,
  355. // highlighted: false,
  356. // courses: [
  357. // {
  358. // id: 5,
  359. // name: '设计基础',
  360. // progress: 95,
  361. // completedAssignments: 10,
  362. // totalAssignments: 10,
  363. // discussionParticipation: 20,
  364. // questionCount: 8
  365. // },
  366. // {
  367. // id: 6,
  368. // name: '色彩构成',
  369. // progress: 88,
  370. // completedAssignments: 8,
  371. // totalAssignments: 9,
  372. // discussionParticipation: 15,
  373. // questionCount: 6
  374. // }
  375. // ]
  376. // }
  377. ])
  378. // 过滤后的学员数据
  379. const filteredStudents = computed(() => {
  380. if (!studentSearch.value.trim()) {
  381. return studentsData.value.map((student) => ({ ...student, highlighted: false }))
  382. }
  383. const searchTerm = studentSearch.value.trim().toLowerCase()
  384. return studentsData.value
  385. .filter((student) => {
  386. const matchName = student.userIdName.toLowerCase().includes(searchTerm)
  387. const matchId = student.userId.includes(searchTerm)
  388. return matchName || matchId
  389. })
  390. .map((student) => ({ ...student, highlighted: true }))
  391. })
  392. // 切换标签
  393. const switchTab = (tabName) => {
  394. activeTab.value = tabName
  395. if (tabName === 'college') {
  396. nextTick(async () => {
  397. await initCollegeCharts()
  398. })
  399. }
  400. }
  401. const formatDateWithDays = (days = 0) => {
  402. const date = new Date();
  403. date.setDate(date.getDate() + days); // 设置天数偏移
  404. const year = date.getFullYear();
  405. const month = String(date.getMonth() + 1).padStart(2, '0');
  406. const day = String(date.getDate()).padStart(2, '0');
  407. return `${year}-${month}-${day}`;
  408. }
  409. // 更新学院数据
  410. const updateCollegeData = async () => {
  411. try {
  412. // 获取学院统计数据 船锚
  413. const statsResponse = await getCollegeStats({
  414. orgId: collegeFilters.collegeId,
  415. startTime : formatDateWithDays(0),
  416. endTime : formatDateWithDays(collegeFilters.timeRange)
  417. })
  418. console.log("asdasd",statsResponse.data)
  419. // Object.assign(collegeStats, statsResponse.data)
  420. collegeStats.value = {...collegeStats,...statsResponse.data}
  421. // 获取课程详细统计
  422. const detailsResponse = await getCollegeCourseDetails({
  423. orgId: collegeFilters.collegeId,
  424. startTime : formatDateWithDays(0),
  425. endTime : formatDateWithDays(collegeFilters.timeRange)
  426. })
  427. collegeTableData.value = detailsResponse.data
  428. // 重新初始化图表
  429. await initCollegeCharts()
  430. } catch (error) {
  431. console.error('获取学院数据失败:', error)
  432. }
  433. }
  434. // 搜索学员
  435. const searchStudent = async () => {
  436. try {
  437. const response = await searchStudents({
  438. name: studentSearch.value.trim(),
  439. current: 1,
  440. size: 99
  441. })
  442. studentsData.value = response.data.map((student) => ({
  443. ...student,
  444. highlighted: !!studentSearch.value.trim()
  445. }))
  446. console.log('看看呢',studentsData.value)
  447. if (response.length === 0 && studentSearch.value.trim()) {
  448. alert(`未找到包含"${studentSearch.value}"的学员`)
  449. }
  450. } catch (error) {
  451. console.error('搜索学员失败:', error)
  452. }
  453. }
  454. // 清除搜索
  455. const clearSearch = async () => {
  456. studentSearch.value = ''
  457. await searchStudent()
  458. }
  459. // 初始化学院维度图表
  460. const initCollegeCharts = async () => {
  461. await initLoginTimeChart()
  462. await initCourseHeatChart()
  463. }
  464. // 登录时段分布图表
  465. const initLoginTimeChart = async () => {
  466. if (!loginTimeChart.value) return
  467. if (loginTimeChartInstance) {
  468. loginTimeChartInstance.dispose()
  469. }
  470. loginTimeChartInstance = echarts.init(loginTimeChart.value)
  471. try {
  472. const response = await getLoginTimeDistribution({
  473. orgId: collegeFilters.collegeId,
  474. startTime : formatDateWithDays(0),
  475. endTime : formatDateWithDays(1),
  476. current : 1,
  477. size : 24
  478. })
  479. console.log('结果呢',response)
  480. const { hours, loginCounts } = response
  481. const option = {
  482. title: {
  483. text: '24小时登录时段分布',
  484. left: 'center',
  485. textStyle: {
  486. color: '#2c3e50',
  487. fontSize: 16,
  488. fontWeight: 'bold'
  489. }
  490. },
  491. tooltip: {
  492. trigger: 'axis',
  493. backgroundColor: 'rgba(255, 255, 255, 0.95)',
  494. borderColor: '#3498db',
  495. borderWidth: 1,
  496. textStyle: {
  497. color: '#333'
  498. }
  499. },
  500. xAxis: {
  501. type: 'category',
  502. data: hours,
  503. axisLine: {
  504. lineStyle: {
  505. color: '#bdc3c7'
  506. }
  507. },
  508. axisLabel: {
  509. color: '#2c3e50'
  510. }
  511. },
  512. yAxis: {
  513. type: 'value',
  514. name: '登录人次',
  515. nameTextStyle: {
  516. color: '#2c3e50'
  517. },
  518. axisLine: {
  519. lineStyle: {
  520. color: '#bdc3c7'
  521. }
  522. },
  523. axisLabel: {
  524. color: '#2c3e50'
  525. },
  526. splitLine: {
  527. lineStyle: {
  528. color: '#ecf0f1'
  529. }
  530. }
  531. },
  532. series: [
  533. {
  534. name: '登录人次',
  535. type: 'bar',
  536. data: loginCounts,
  537. itemStyle: {
  538. color: {
  539. type: 'linear',
  540. x: 0,
  541. y: 0,
  542. x2: 0,
  543. y2: 1,
  544. colorStops: [
  545. {
  546. offset: 0,
  547. color: '#3498db'
  548. },
  549. {
  550. offset: 1,
  551. color: '#2980b9'
  552. }
  553. ]
  554. }
  555. },
  556. emphasis: {
  557. itemStyle: {
  558. color: '#e74c3c'
  559. }
  560. }
  561. }
  562. ]
  563. }
  564. loginTimeChartInstance.setOption(option)
  565. } catch (error) {
  566. console.error('获取登录时段数据失败:', error)
  567. }
  568. }
  569. // 课程访问热度图表
  570. const initCourseHeatChart = async () => {
  571. if (!courseHeatChart.value) return
  572. if (courseHeatChartInstance) {
  573. courseHeatChartInstance.dispose()
  574. }
  575. courseHeatChartInstance = echarts.init(courseHeatChart.value)
  576. try {
  577. const response = await getCourseHeat({
  578. orgId: collegeFilters.collegeId,
  579. startTime : formatDateWithDays(0),
  580. endTime : formatDateWithDays(1),
  581. current : 1,
  582. size : 8
  583. })
  584. const { courses, visits } = response
  585. const option = {
  586. title: {
  587. text: '课程访问热度TOP8',
  588. left: 'center',
  589. textStyle: {
  590. color: '#2c3e50',
  591. fontSize: 16,
  592. fontWeight: 'bold'
  593. }
  594. },
  595. tooltip: {
  596. trigger: 'axis',
  597. backgroundColor: 'rgba(255, 255, 255, 0.95)',
  598. borderColor: '#3498db',
  599. borderWidth: 1,
  600. textStyle: {
  601. color: '#333'
  602. }
  603. },
  604. xAxis: {
  605. type: 'value',
  606. name: '访问量',
  607. nameTextStyle: {
  608. color: '#2c3e50'
  609. },
  610. axisLine: {
  611. lineStyle: {
  612. color: '#bdc3c7'
  613. }
  614. },
  615. axisLabel: {
  616. color: '#2c3e50'
  617. },
  618. splitLine: {
  619. lineStyle: {
  620. color: '#ecf0f1'
  621. }
  622. }
  623. },
  624. yAxis: {
  625. type: 'category',
  626. data: courses,
  627. axisLine: {
  628. lineStyle: {
  629. color: '#bdc3c7'
  630. }
  631. },
  632. axisLabel: {
  633. color: '#2c3e50'
  634. }
  635. },
  636. series: [
  637. {
  638. name: '访问量',
  639. type: 'bar',
  640. data: visits,
  641. itemStyle: {
  642. color: {
  643. type: 'linear',
  644. x: 0,
  645. y: 0,
  646. x2: 1,
  647. y2: 0,
  648. colorStops: [
  649. {
  650. offset: 0,
  651. color: '#e74c3c'
  652. },
  653. {
  654. offset: 1,
  655. color: '#f39c12'
  656. }
  657. ]
  658. }
  659. },
  660. emphasis: {
  661. itemStyle: {
  662. color: '#3498db'
  663. }
  664. }
  665. }
  666. ]
  667. }
  668. courseHeatChartInstance.setOption(option)
  669. } catch (error) {
  670. console.error('获取课程热度数据失败:', error)
  671. }
  672. }
  673. // 响应式处理
  674. const handleResize = () => {
  675. loginTimeChartInstance?.resize()
  676. courseHeatChartInstance?.resize()
  677. }
  678. // 初始化数据
  679. const initData = async () => {
  680. try {
  681. // 获取学院列表
  682. const colleges = await getCollegeList()
  683. collegeList.value = colleges
  684. collegeFilters.collegeId = colleges.length > 0 ? colleges[0].id : undefined
  685. // 获取初始学员数据
  686. // await searchStudent()
  687. // 获取学院数据
  688. await updateCollegeData()
  689. } catch (error) {
  690. console.error('初始化数据失败:', error)
  691. }
  692. }
  693. // 组件挂载后初始化
  694. onMounted(() => {
  695. nextTick(async () => {
  696. await initData()
  697. window.addEventListener('resize', handleResize)
  698. })
  699. })
  700. // 组件卸载时清理
  701. onUnmounted(() => {
  702. window.removeEventListener('resize', handleResize)
  703. loginTimeChartInstance?.dispose()
  704. courseHeatChartInstance?.dispose()
  705. })
  706. </script>
  707. <style scoped>
  708. .learning-behavior-analysis {
  709. padding: 20px;
  710. }
  711. .header {
  712. background: rgba(255, 255, 255, 0.95);
  713. backdrop-filter: blur(10px);
  714. border-radius: 15px;
  715. padding: 30px;
  716. margin-bottom: 30px;
  717. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  718. text-align: center;
  719. }
  720. .header h1 {
  721. color: #2c3e50;
  722. font-size: 2.5em;
  723. margin-bottom: 10px;
  724. }
  725. .header p {
  726. color: #7f8c8d;
  727. font-size: 1.1em;
  728. }
  729. .nav-tabs {
  730. display: flex;
  731. background: rgba(255, 255, 255, 0.95);
  732. backdrop-filter: blur(10px);
  733. border-radius: 15px;
  734. padding: 5px;
  735. margin-bottom: 30px;
  736. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  737. }
  738. .nav-tab {
  739. flex: 1;
  740. padding: 15px 20px;
  741. text-align: center;
  742. cursor: pointer;
  743. border-radius: 10px;
  744. transition: all 0.3s ease;
  745. font-weight: 600;
  746. color: #7f8c8d;
  747. }
  748. .nav-tab.active {
  749. background: linear-gradient(135deg, #3498db, #2980b9);
  750. color: white;
  751. box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
  752. }
  753. .nav-tab:hover:not(.active) {
  754. background: rgba(52, 152, 219, 0.1);
  755. color: #3498db;
  756. }
  757. .tab-content {
  758. display: block;
  759. }
  760. .filter-section {
  761. background: rgba(255, 255, 255, 0.95);
  762. backdrop-filter: blur(10px);
  763. border-radius: 15px;
  764. padding: 25px;
  765. margin-bottom: 30px;
  766. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  767. }
  768. .filter-section h3 {
  769. color: #2c3e50;
  770. margin-bottom: 20px;
  771. font-size: 1.5em;
  772. }
  773. .filter-controls {
  774. display: grid;
  775. grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  776. gap: 15px;
  777. align-items: end;
  778. }
  779. .filter-group {
  780. display: flex;
  781. flex-direction: column;
  782. }
  783. .filter-group label {
  784. margin-bottom: 8px;
  785. color: #2c3e50;
  786. font-weight: 600;
  787. }
  788. .stats-grid {
  789. display: grid;
  790. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  791. gap: 25px;
  792. margin-bottom: 30px;
  793. }
  794. .stat-card {
  795. background: rgba(255, 255, 255, 0.95);
  796. backdrop-filter: blur(10px);
  797. border-radius: 15px;
  798. padding: 25px;
  799. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  800. transition: transform 0.3s ease, box-shadow 0.3s ease;
  801. }
  802. .stat-card:hover {
  803. transform: translateY(-5px);
  804. box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  805. }
  806. .stat-card h3 {
  807. color: #2c3e50;
  808. margin-bottom: 15px;
  809. font-size: 1.2em;
  810. border-bottom: 2px solid #3498db;
  811. padding-bottom: 10px;
  812. }
  813. .stat-number {
  814. font-size: 2.2em;
  815. font-weight: bold;
  816. color: #3498db;
  817. margin-bottom: 8px;
  818. }
  819. .stat-label {
  820. color: #7f8c8d;
  821. font-size: 0.9em;
  822. }
  823. .chart-container {
  824. background: rgba(255, 255, 255, 0.95);
  825. backdrop-filter: blur(10px);
  826. border-radius: 15px;
  827. padding: 25px;
  828. margin-bottom: 30px;
  829. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  830. }
  831. .chart-container h3 {
  832. color: #2c3e50;
  833. margin-bottom: 20px;
  834. font-size: 1.5em;
  835. }
  836. .chart {
  837. height: 400px;
  838. border-radius: 10px;
  839. }
  840. .data-table {
  841. background: rgba(255, 255, 255, 0.95);
  842. backdrop-filter: blur(10px);
  843. border-radius: 15px;
  844. padding: 25px;
  845. margin-bottom: 30px;
  846. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  847. }
  848. .data-table h3 {
  849. color: #2c3e50;
  850. margin-bottom: 20px;
  851. font-size: 1.5em;
  852. }
  853. .student-cards {
  854. display: flex;
  855. flex-direction: column;
  856. gap: 20px;
  857. }
  858. .student-card {
  859. background: rgba(255, 255, 255, 0.95);
  860. backdrop-filter: blur(10px);
  861. border-radius: 15px;
  862. padding: 20px;
  863. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  864. transition: transform 0.3s ease;
  865. }
  866. .student-card:hover {
  867. transform: translateY(-3px);
  868. }
  869. .student-card.highlighted {
  870. border: 2px solid #3498db;
  871. box-shadow: 0 8px 32px rgba(52, 152, 219, 0.2);
  872. }
  873. .student-header {
  874. display: flex;
  875. justify-content: space-between;
  876. align-items: center;
  877. margin-bottom: 15px;
  878. padding-bottom: 10px;
  879. border-bottom: 2px solid #ecf0f1;
  880. }
  881. .student-info h4 {
  882. color: #2c3e50;
  883. font-size: 1.3em;
  884. margin-bottom: 5px;
  885. }
  886. .student-meta {
  887. color: #7f8c8d;
  888. font-size: 0.9em;
  889. }
  890. .course-progress {
  891. margin-bottom: 15px;
  892. }
  893. .course-item {
  894. display: flex;
  895. justify-content: space-between;
  896. align-items: center;
  897. padding: 10px 0;
  898. border-bottom: 1px solid #ecf0f1;
  899. }
  900. .course-name {
  901. font-weight: 600;
  902. color: #2c3e50;
  903. }
  904. .course-stats {
  905. display: flex;
  906. gap: 20px;
  907. font-size: 0.9em;
  908. }
  909. .stat-item {
  910. text-align: center;
  911. }
  912. .stat-value {
  913. font-weight: bold;
  914. color: #3498db;
  915. }
  916. .stat-label {
  917. color: #7f8c8d;
  918. font-size: 0.8em;
  919. }
  920. :deep(.completion-rate) {
  921. color: #27ae60;
  922. font-weight: bold;
  923. }
  924. :deep(.low-engagement) {
  925. color: #e74c3c;
  926. font-weight: bold;
  927. }
  928. @media (max-width: 768px) {
  929. .stats-grid {
  930. grid-template-columns: 1fr;
  931. }
  932. .filter-controls {
  933. grid-template-columns: 1fr;
  934. }
  935. .header h1 {
  936. font-size: 2em;
  937. }
  938. .nav-tabs {
  939. flex-direction: column;
  940. }
  941. .student-header {
  942. flex-direction: column;
  943. align-items: flex-start;
  944. }
  945. .course-stats {
  946. flex-direction: column;
  947. gap: 10px;
  948. }
  949. }
  950. </style>