userStaticAll.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div class="statistics-container">
  3. <!-- 营期课程选择 -->
  4. <div class="fixed-header">
  5. <!-- 统计数据展示 -->
  6. <el-row :gutter="20" class="statistics-row">
  7. <el-col :span="4">
  8. <div class="statistics-item">
  9. <div class="statistics-title">到课数</div>
  10. <div class="statistics-value">{{ statistics.courseCompleteNum || 0 }}次</div>
  11. </div>
  12. </el-col>
  13. <el-col :span="4">
  14. <div class="statistics-item">
  15. <div class="statistics-title">总学习时长</div>
  16. <div class="statistics-value">{{ statistics.courseWatchNum || 0 }}分钟</div>
  17. </div>
  18. </el-col>
  19. <el-col :span="4">
  20. <div class="statistics-item">
  21. <div class="statistics-title">正确答题数</div>
  22. <div class="statistics-value">{{ statistics.correctAnswerNum || 0 }}次</div>
  23. </div>
  24. </el-col>
  25. <el-col :span="4">
  26. <div class="statistics-item">
  27. <div class="statistics-title">获得红包数</div>
  28. <div class="statistics-value">{{ statistics.redPacketCount || 0 }}次</div>
  29. </div>
  30. </el-col>
  31. <el-col :span="4">
  32. <div class="statistics-item">
  33. <div class="statistics-title">红包总金额</div>
  34. <div class="statistics-value">{{ statistics.redPacketAmount || 0 }}元</div>
  35. </div>
  36. </el-col>
  37. </el-row>
  38. </div>
  39. <!-- 列表统计展示 -->
  40. <div class="table-wrapper">
  41. <el-table v-loading="loading" :data="list">
  42. <el-table-column type="index" label="序号" width="50" align="center" fixed/>
  43. <el-table-column prop="courseName" label="课程名称" align="center" min-width="100" fixed/>
  44. <el-table-column prop="videoName" label="课节名称" align="center" min-width="100" fixed/>
  45. <el-table-column label="记录类型" align="center" prop="logType">
  46. <template slot-scope="scope">
  47. <el-tag prop="type" v-for="(item, index) in typeOptions" v-if="scope.row.logType==item.dictValue">{{item.dictLabel}}</el-tag>
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="duration" label="播放时长" align="center" min-width="100"/>
  51. <el-table-column prop="finishTime" label="完课时间" align="center" min-width="120"/>
  52. </el-table>
  53. <!-- 分页 -->
  54. <div class="custom-pagination-container">
  55. <pagination
  56. v-show="total > 0"
  57. :total="total"
  58. :page.sync="queryParams.pageNum"
  59. :limit.sync="queryParams.pageSize"
  60. @pagination="getCountList"
  61. />
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import {periodCourseStatisticCount} from "@/api/course/userCoursePeriod";
  68. import { listBytrainingCampId } from "@/api/course/qw/courseWatchLog";
  69. export default {
  70. name: "userStaticAll",
  71. props: {
  72. periodId: {
  73. type: [String, Number],
  74. default: ''
  75. },
  76. active: {
  77. type: Boolean,
  78. default: false
  79. }
  80. },
  81. data() {
  82. return {
  83. typeOptions: [],
  84. // 遮罩层
  85. loading: false,
  86. // 总条数
  87. total: 0,
  88. // 统计数据
  89. statistics: {
  90. courseCompleteNum: 0,
  91. courseWatchNum: 0,
  92. redPacketCount: 0,
  93. correctAnswerNum: 0,
  94. redPacketAmount: 0
  95. },
  96. // 列表数据
  97. list: [],
  98. // 查询参数
  99. queryParams: {
  100. pageNum: 1,
  101. pageSize: 10,
  102. // videoId: '',
  103. periodId: '',
  104. trainingCampId:null,
  105. userId:null,
  106. },
  107. };
  108. },
  109. created() {
  110. this.getDicts("sys_course_watch_log_type").then((response) => {
  111. this.typeOptions = response.data;
  112. });
  113. },
  114. methods: {
  115. getDetails(camp,userid) {
  116. this.queryParams.trainingCampId = camp.trainingCampId;
  117. this.camp = camp;
  118. this.userId=userid;
  119. this.queryParams.userId=userid;
  120. this.user=null;
  121. if (this.queryParams.trainingCampId){
  122. this.getCountList();
  123. this.calculateTotalStatistics();
  124. }
  125. },
  126. /** 获取列表数据 */
  127. getCountList() {
  128. this.loading = true;
  129. if (!this.queryParams.trainingCampId || !this.queryParams.userId){
  130. return
  131. }
  132. listBytrainingCampId(this.queryParams).then(response => {
  133. if (response.code === 200) {
  134. // 设置列表数据
  135. this.list = response.rows;
  136. this.total = response.total || 0;
  137. } else {
  138. this.$message.error(response.msg || '获取数据失败');
  139. }
  140. this.loading = false;
  141. }).catch(error => {
  142. console.error('获取数据失败:', error);
  143. this.$message.error('获取数据失败');
  144. this.loading = false;
  145. });
  146. },
  147. /** 计算总统计数据 */
  148. calculateTotalStatistics() {
  149. console.log("this.queryParams:",this.queryParams)
  150. periodCourseStatisticCount(this.queryParams).then(response => {
  151. if (response.code === 200) {
  152. // 设置列表数据
  153. this.statistics.courseCompleteNum = response.data.courseCompleteNum || 0;
  154. this.statistics.courseWatchNum = response.data.courseWatchNum || 0;
  155. this.statistics.courseWatchTimes = response.data.courseWatchTimes || 0;
  156. this.statistics.redPacketCount = response.data.redPacketCount || 0;
  157. this.statistics.correctAnswerNum = response.data.correctAnswerNum || 0;
  158. this.statistics.redPacketAmount = response.data.redPacketAmount || 0;
  159. } else {
  160. this.$message.error(response.msg || '获取数据失败');
  161. }
  162. this.loading = false;
  163. }).catch(error => {
  164. console.error('获取数据失败:', error);
  165. this.$message.error('获取数据失败');
  166. this.loading = false;
  167. });
  168. }
  169. }
  170. };
  171. </script>
  172. <style scoped>
  173. .statistics-container {
  174. height: 100%;
  175. overflow: hidden;
  176. position: relative;
  177. }
  178. .fixed-header {
  179. position: sticky;
  180. top: 0;
  181. z-index: 10;
  182. background-color: #fff;
  183. padding: 10px 0;
  184. border-bottom: 1px solid #EBEEF5;
  185. }
  186. .table-wrapper {
  187. height: calc(100% - 220px);
  188. overflow: visible;
  189. position: relative;
  190. }
  191. .custom-pagination-container {
  192. padding: 10px 0 12px 0;
  193. text-align: right;
  194. background-color: #fff;
  195. position: relative;
  196. z-index: 1;
  197. }
  198. /* 覆盖原有的pagination-container样式 */
  199. :deep(.pagination-container) {
  200. height: auto !important;
  201. margin-bottom: 0 !important;
  202. margin-top: 0 !important;
  203. padding: 0 !important;
  204. }
  205. .statistics-row {
  206. margin: 20px 0;
  207. }
  208. .statistics-item {
  209. background-color: #f5f7fa;
  210. border-radius: 4px;
  211. padding: 15px;
  212. text-align: center;
  213. height: 100px;
  214. display: flex;
  215. flex-direction: column;
  216. justify-content: center;
  217. }
  218. .statistics-title {
  219. font-size: 14px;
  220. color: #606266;
  221. margin-bottom: 10px;
  222. }
  223. .statistics-value {
  224. font-size: 20px;
  225. font-weight: bold;
  226. color: #303133;
  227. }
  228. </style>