userStaticAll.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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-column prop="companyUserName" label="所属销售" align="center" min-width="100"/>
  53. </el-table>
  54. <!-- 分页 -->
  55. <div class="custom-pagination-container">
  56. <pagination
  57. v-show="total > 0"
  58. :total="total"
  59. :page.sync="queryParams.pageNum"
  60. :limit.sync="queryParams.pageSize"
  61. @pagination="getCountList"
  62. />
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. import {periodCourseStatisticCount} from "@/api/course/userCoursePeriod";
  69. import { listBytrainingCampId } from "@/api/course/qw/courseWatchLog";
  70. export default {
  71. name: "userStaticAll",
  72. props: {
  73. periodId: {
  74. type: [String, Number],
  75. default: ''
  76. },
  77. active: {
  78. type: Boolean,
  79. default: false
  80. }
  81. },
  82. data() {
  83. return {
  84. typeOptions: [],
  85. // 遮罩层
  86. loading: false,
  87. // 总条数
  88. total: 0,
  89. // 统计数据
  90. statistics: {
  91. courseCompleteNum: 0,
  92. courseWatchNum: 0,
  93. redPacketCount: 0,
  94. correctAnswerNum: 0,
  95. redPacketAmount: 0
  96. },
  97. // 列表数据
  98. list: [],
  99. // 查询参数
  100. queryParams: {
  101. pageNum: 1,
  102. pageSize: 10,
  103. // videoId: '',
  104. periodId: '',
  105. trainingCampId:null,
  106. userId:null,
  107. },
  108. };
  109. },
  110. created() {
  111. this.getDicts("sys_course_watch_log_type").then((response) => {
  112. this.typeOptions = response.data;
  113. });
  114. },
  115. methods: {
  116. getDetails(camp,userid) {
  117. this.queryParams.trainingCampId = camp.trainingCampId;
  118. this.camp = camp;
  119. this.userId=userid;
  120. this.queryParams.userId=userid;
  121. this.user=null;
  122. if (this.queryParams.trainingCampId){
  123. this.getCountList();
  124. this.calculateTotalStatistics();
  125. }
  126. },
  127. /** 获取列表数据 */
  128. getCountList() {
  129. this.loading = true;
  130. if (!this.queryParams.trainingCampId || !this.queryParams.userId){
  131. return
  132. }
  133. listBytrainingCampId(this.queryParams).then(response => {
  134. if (response.code === 200) {
  135. // 设置列表数据
  136. this.list = response.rows;
  137. this.total = response.total || 0;
  138. } else {
  139. this.$message.error(response.msg || '获取数据失败');
  140. }
  141. this.loading = false;
  142. }).catch(error => {
  143. console.error('获取数据失败:', error);
  144. this.$message.error('获取数据失败');
  145. this.loading = false;
  146. });
  147. },
  148. /** 计算总统计数据 */
  149. calculateTotalStatistics() {
  150. console.log("this.queryParams:",this.queryParams)
  151. periodCourseStatisticCount(this.queryParams).then(response => {
  152. if (response.code === 200) {
  153. // 设置列表数据
  154. this.statistics.courseCompleteNum = response.data.courseCompleteNum || 0;
  155. this.statistics.courseWatchNum = response.data.courseWatchNum || 0;
  156. this.statistics.courseWatchTimes = response.data.courseWatchTimes || 0;
  157. this.statistics.redPacketCount = response.data.redPacketCount || 0;
  158. this.statistics.correctAnswerNum = response.data.correctAnswerNum || 0;
  159. this.statistics.redPacketAmount = response.data.redPacketAmount || 0;
  160. } else {
  161. this.$message.error(response.msg || '获取数据失败');
  162. }
  163. this.loading = false;
  164. }).catch(error => {
  165. console.error('获取数据失败:', error);
  166. this.$message.error('获取数据失败');
  167. this.loading = false;
  168. });
  169. }
  170. }
  171. };
  172. </script>
  173. <style scoped>
  174. .statistics-container {
  175. height: 100%;
  176. overflow: hidden;
  177. position: relative;
  178. }
  179. .fixed-header {
  180. position: sticky;
  181. top: 0;
  182. z-index: 10;
  183. background-color: #fff;
  184. padding: 10px 0;
  185. border-bottom: 1px solid #EBEEF5;
  186. }
  187. .table-wrapper {
  188. height: calc(100% - 220px);
  189. overflow: visible;
  190. position: relative;
  191. }
  192. .custom-pagination-container {
  193. padding: 10px 0 12px 0;
  194. text-align: right;
  195. background-color: #fff;
  196. position: relative;
  197. z-index: 1;
  198. }
  199. /* 覆盖原有的pagination-container样式 */
  200. :deep(.pagination-container) {
  201. height: auto !important;
  202. margin-bottom: 0 !important;
  203. margin-top: 0 !important;
  204. padding: 0 !important;
  205. }
  206. .statistics-row {
  207. margin: 20px 0;
  208. }
  209. .statistics-item {
  210. background-color: #f5f7fa;
  211. border-radius: 4px;
  212. padding: 15px;
  213. text-align: center;
  214. height: 100px;
  215. display: flex;
  216. flex-direction: column;
  217. justify-content: center;
  218. }
  219. .statistics-title {
  220. font-size: 14px;
  221. color: #606266;
  222. margin-bottom: 10px;
  223. }
  224. .statistics-value {
  225. font-size: 20px;
  226. font-weight: bold;
  227. color: #303133;
  228. }
  229. </style>