statistics.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="课程" prop="courseId">
  5. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  6. <el-option
  7. v-for="dict in courseLists"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="小节" prop="videoId">
  15. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  16. <el-option
  17. v-for="dict in videoList"
  18. :key="dict.dictValue"
  19. :label="dict.dictLabel"
  20. :value="dict.dictValue"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="企微昵称" prop="nickName">
  25. <el-input
  26. v-model="queryParams.nickName"
  27. placeholder="请输入企微昵称"
  28. clearable
  29. size="small"
  30. @keyup.enter.native="handleQuery"
  31. />
  32. </el-form-item>
  33. <el-form-item label="创建时间" prop="createTime">
  34. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="warning"
  45. plain
  46. icon="el-icon-download"
  47. size="mini"
  48. :loading="exportLoading"
  49. @click="handleExport"
  50. v-hasPermi="['qw:user:export']"
  51. >导出</el-button>
  52. </el-col>
  53. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange" show-summary>
  56. <el-table-column type="selection" width="55" align="center" />
  57. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  58. <el-table-column label="发课时间" align="center" prop="createTime"/>
  59. <el-table-column label="课程名称" align="center" prop="courseName" />
  60. <el-table-column label="小节名称" align="center" prop="videoName" />
  61. <el-table-column label="待看课" align="center" prop="type3" />
  62. <el-table-column label="看课中" align="center" prop="type1" />
  63. <el-table-column label="已完课" align="center" prop="type2" />
  64. <el-table-column label="看课中断" align="center" prop="type4" />
  65. <el-table-column label="发课数" align="center" prop="sendNumber" />
  66. <el-table-column label="注册用户待看课数" align="center" prop="isUserWaitNumber" />
  67. <el-table-column label="未注册用户待看课数" align="center" prop="noUserWaitNumber" />
  68. <el-table-column label="上线率" align="center" prop="onLineRate" />
  69. <el-table-column label="完课率" align="center" prop="finishedRate" />
  70. <el-table-column label="消耗红包金额" align="center" prop="redAmount" />
  71. </el-table>
  72. <pagination
  73. v-show="total>0"
  74. :total="total"
  75. :page.sync="queryParams.pageNum"
  76. :limit.sync="queryParams.pageSize"
  77. @pagination="getList"
  78. />
  79. </div>
  80. </template>
  81. <script>
  82. import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog,statisticsList,statisticsExport } from "@/api/course/qw/courseWatchLog";
  83. import { courseList,videoList } from '@/api/course/courseRedPacketLog'
  84. import { getDateRange } from '@/utils/common'
  85. export default {
  86. name: "CourseWatchLog",
  87. data() {
  88. return {
  89. activeName:"00",
  90. createTime:null,
  91. courseLists:[],
  92. videoList:[],
  93. logTypeOptions:[],
  94. // 遮罩层
  95. loading: true,
  96. // 导出遮罩层
  97. exportLoading: false,
  98. // 选中数组
  99. ids: [],
  100. // 非单个禁用
  101. single: true,
  102. // 非多个禁用
  103. multiple: true,
  104. // 显示搜索条件
  105. showSearch: true,
  106. // 总条数
  107. total: 0,
  108. // 短链课程看课记录表格数据
  109. courseWatchLogList: [],
  110. // 弹出层标题
  111. title: "",
  112. // 是否显示弹出层
  113. open: false,
  114. // 查询参数
  115. queryParams: {
  116. pageNum: 1,
  117. pageSize: 10,
  118. userId: null,
  119. nickName: null,
  120. videoId: null,
  121. logType: null,
  122. qwExternalContactId: null,
  123. duration: null,
  124. qwUserId: null,
  125. companyUserId: null,
  126. companyId: null,
  127. courseId: null,
  128. sTime:null,
  129. eTime:null,
  130. scheduleStartTime: null,
  131. scheduleEndTime: null,
  132. },
  133. // 表单参数
  134. form: {},
  135. // 表单校验
  136. rules: {
  137. },
  138. scheduleTime: null,
  139. };
  140. },
  141. created() {
  142. // // 设置默认时间范围为最近7天
  143. // this.createTime = getDateRange(7);
  144. // // 设置查询参数的时间
  145. // this.queryParams.sTime = this.createTime[0];
  146. // this.queryParams.eTime = this.createTime[1];
  147. courseList().then(response => {
  148. this.courseLists = response.list;
  149. });
  150. this.getList();
  151. this.getDicts("sys_course_watch_log_type").then(response => {
  152. this.logTypeOptions = response.data;
  153. });
  154. },
  155. methods: {
  156. courseChange(row){
  157. this.queryParams.videoId=null;
  158. if(row === ''){
  159. this.videoList=[];
  160. return
  161. }
  162. videoList(row).then(response => {
  163. this.videoList=response.list
  164. });
  165. },
  166. change() {
  167. if (this.createTime != null) {
  168. this.queryParams.sTime = this.createTime[0];
  169. this.queryParams.eTime = this.createTime[1];
  170. } else {
  171. this.queryParams.sTime = null;
  172. this.queryParams.eTime = null;
  173. }
  174. },
  175. handleClickX(tab,event){
  176. this.activeName=tab.name;
  177. if(tab.name=="00"){
  178. this.queryParams.logType=null;
  179. }else{
  180. this.queryParams.logType=tab.name;
  181. }
  182. this.getList()
  183. },
  184. /** 查询短链课程看课记录列表 */
  185. getList() {
  186. this.loading = true;
  187. statisticsList(this.queryParams).then(response => {
  188. this.courseWatchLogList = response.rows;
  189. this.total = response.total;
  190. this.loading = false;
  191. });
  192. },
  193. // 取消按钮
  194. cancel() {
  195. this.open = false;
  196. this.reset();
  197. },
  198. // 表单重置
  199. reset() {
  200. this.form = {
  201. logId: null,
  202. userId: null,
  203. videoId: null,
  204. logType: null,
  205. createTime: null,
  206. updateTime: null,
  207. qwExternalContactId: null,
  208. duration: null,
  209. qwUserId: null,
  210. companyUserId: null,
  211. companyId: null,
  212. courseId: null
  213. };
  214. this.resetForm("form");
  215. },
  216. /** 搜索按钮操作 */
  217. handleQuery() {
  218. if (!this.queryParams.sTime || !this.queryParams.eTime) {
  219. this.$message.warning("请选择创建时间");
  220. return;
  221. }
  222. this.queryParams.pageNum = 1;
  223. this.getList();
  224. },
  225. /** 重置按钮操作 */
  226. resetQuery() {
  227. this.resetForm("queryForm");
  228. this.createTime = null;
  229. this.scheduleTime = null;
  230. this.queryParams.sTime = null;
  231. this.queryParams.eTime = null;
  232. this.queryParams.scheduleStartTime = null;
  233. this.queryParams.scheduleEndTime = null;
  234. this.handleQuery();
  235. },
  236. // 多选框选中数据
  237. handleSelectionChange(selection) {
  238. this.ids = selection.map(item => item.logId)
  239. this.single = selection.length!==1
  240. this.multiple = !selection.length
  241. },
  242. /** 新增按钮操作 */
  243. handleAdd() {
  244. this.reset();
  245. this.open = true;
  246. this.title = "添加短链课程看课记录";
  247. },
  248. /** 修改按钮操作 */
  249. handleUpdate(row) {
  250. this.reset();
  251. const logId = row.logId || this.ids
  252. getCourseWatchLog(logId).then(response => {
  253. this.form = response.data;
  254. this.open = true;
  255. this.title = "修改短链课程看课记录";
  256. });
  257. },
  258. /** 提交按钮 */
  259. submitForm() {
  260. this.$refs["form"].validate(valid => {
  261. if (valid) {
  262. if (this.form.logId != null) {
  263. updateCourseWatchLog(this.form).then(response => {
  264. this.msgSuccess("修改成功");
  265. this.open = false;
  266. this.getList();
  267. });
  268. } else {
  269. addCourseWatchLog(this.form).then(response => {
  270. this.msgSuccess("新增成功");
  271. this.open = false;
  272. this.getList();
  273. });
  274. }
  275. }
  276. });
  277. },
  278. /** 删除按钮操作 */
  279. handleDelete(row) {
  280. const logIds = row.logId || this.ids;
  281. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  282. confirmButtonText: "确定",
  283. cancelButtonText: "取消",
  284. type: "warning"
  285. }).then(function() {
  286. return delCourseWatchLog(logIds);
  287. }).then(() => {
  288. this.getList();
  289. this.msgSuccess("删除成功");
  290. }).catch(() => {});
  291. },
  292. /** 导出按钮操作 */
  293. handleExport() {
  294. // 检查是否选择了时间范围
  295. if (!this.queryParams.sTime || !this.queryParams.eTime) {
  296. this.$message.warning("请选择创建时间后才能导出");
  297. return;
  298. }
  299. const queryParams = this.queryParams;
  300. this.$confirm('是否确认导出所有企微看课记录数据项?', "警告", {
  301. confirmButtonText: "确定",
  302. cancelButtonText: "取消",
  303. type: "warning"
  304. }).then(() => {
  305. this.exportLoading = true;
  306. return statisticsExport(queryParams);
  307. }).then(response => {
  308. this.download(response.msg);
  309. this.exportLoading = false;
  310. }).catch(() => {});
  311. },
  312. handleScheduleTimeChange(val) {
  313. if (val) {
  314. this.queryParams.scheduleStartTime = val[0];
  315. this.queryParams.scheduleEndTime = val[1];
  316. } else {
  317. this.queryParams.scheduleStartTime = null;
  318. this.queryParams.scheduleEndTime = null;
  319. }
  320. },
  321. }
  322. };
  323. </script>