statistics.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange" show-summary>
  42. <el-table-column type="selection" width="55" align="center" />
  43. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  44. <el-table-column label="发课时间" align="center" prop="createTime"/>
  45. <el-table-column label="课程名称" align="center" prop="courseName" />
  46. <el-table-column label="小节名称" align="center" prop="videoName" />
  47. <el-table-column label="待看课" align="center" prop="type3" />
  48. <el-table-column label="看课中" align="center" prop="type1" />
  49. <el-table-column label="已完课" align="center" prop="type2" />
  50. <el-table-column label="看课中断" align="center" prop="type4" />
  51. </el-table>
  52. <pagination
  53. v-show="total>0"
  54. :total="total"
  55. :page.sync="queryParams.pageNum"
  56. :limit.sync="queryParams.pageSize"
  57. @pagination="getList"
  58. />
  59. </div>
  60. </template>
  61. <script>
  62. import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog,statisticsList } from "@/api/course/qw/courseWatchLog";
  63. import { courseList,videoList } from '@/api/course/courseRedPacketLog'
  64. import { getDateRange } from '@/utils/common'
  65. export default {
  66. name: "CourseWatchLog",
  67. data() {
  68. return {
  69. activeName:"00",
  70. createTime:null,
  71. courseLists:[],
  72. videoList:[],
  73. logTypeOptions:[],
  74. // 遮罩层
  75. loading: true,
  76. // 导出遮罩层
  77. exportLoading: false,
  78. // 选中数组
  79. ids: [],
  80. // 非单个禁用
  81. single: true,
  82. // 非多个禁用
  83. multiple: true,
  84. // 显示搜索条件
  85. showSearch: true,
  86. // 总条数
  87. total: 0,
  88. // 短链课程看课记录表格数据
  89. courseWatchLogList: [],
  90. // 弹出层标题
  91. title: "",
  92. // 是否显示弹出层
  93. open: false,
  94. // 查询参数
  95. queryParams: {
  96. pageNum: 1,
  97. pageSize: 10,
  98. userId: null,
  99. nickName: null,
  100. videoId: null,
  101. logType: null,
  102. qwExternalContactId: null,
  103. duration: null,
  104. qwUserId: null,
  105. companyUserId: null,
  106. companyId: null,
  107. courseId: null,
  108. sTime:null,
  109. eTime:null,
  110. scheduleStartTime: null,
  111. scheduleEndTime: null,
  112. },
  113. // 表单参数
  114. form: {},
  115. // 表单校验
  116. rules: {
  117. },
  118. scheduleTime: null,
  119. };
  120. },
  121. created() {
  122. // 设置默认时间范围为最近7天
  123. this.createTime = getDateRange(7);
  124. // 设置查询参数的时间
  125. this.queryParams.sTime = this.createTime[0];
  126. this.queryParams.eTime = this.createTime[1];
  127. courseList().then(response => {
  128. this.courseLists = response.list;
  129. });
  130. this.getList();
  131. this.getDicts("sys_course_watch_log_type").then(response => {
  132. this.logTypeOptions = response.data;
  133. });
  134. },
  135. methods: {
  136. courseChange(row){
  137. this.queryParams.videoId=null;
  138. if(row === ''){
  139. this.videoList=[];
  140. return
  141. }
  142. videoList(row).then(response => {
  143. this.videoList=response.list
  144. });
  145. },
  146. change() {
  147. if (this.createTime != null) {
  148. this.queryParams.sTime = this.createTime[0];
  149. this.queryParams.eTime = this.createTime[1];
  150. } else {
  151. this.queryParams.sTime = null;
  152. this.queryParams.eTime = null;
  153. }
  154. },
  155. handleClickX(tab,event){
  156. this.activeName=tab.name;
  157. if(tab.name=="00"){
  158. this.queryParams.logType=null;
  159. }else{
  160. this.queryParams.logType=tab.name;
  161. }
  162. this.getList()
  163. },
  164. /** 查询短链课程看课记录列表 */
  165. getList() {
  166. if (!this.queryParams.sTime || !this.queryParams.eTime) {
  167. this.$message.warning("请选择创建时间");
  168. return;
  169. }
  170. this.loading = true;
  171. statisticsList(this.queryParams).then(response => {
  172. this.courseWatchLogList = response.rows;
  173. this.total = response.total;
  174. this.loading = false;
  175. });
  176. },
  177. // 取消按钮
  178. cancel() {
  179. this.open = false;
  180. this.reset();
  181. },
  182. // 表单重置
  183. reset() {
  184. this.form = {
  185. logId: null,
  186. userId: null,
  187. videoId: null,
  188. logType: null,
  189. createTime: null,
  190. updateTime: null,
  191. qwExternalContactId: null,
  192. duration: null,
  193. qwUserId: null,
  194. companyUserId: null,
  195. companyId: null,
  196. courseId: null
  197. };
  198. this.resetForm("form");
  199. },
  200. /** 搜索按钮操作 */
  201. handleQuery() {
  202. this.queryParams.pageNum = 1;
  203. this.getList();
  204. },
  205. /** 重置按钮操作 */
  206. resetQuery() {
  207. this.resetForm("queryForm");
  208. this.createTime = null;
  209. this.scheduleTime = null;
  210. this.queryParams.sTime = null;
  211. this.queryParams.eTime = null;
  212. this.queryParams.scheduleStartTime = null;
  213. this.queryParams.scheduleEndTime = null;
  214. this.handleQuery();
  215. },
  216. // 多选框选中数据
  217. handleSelectionChange(selection) {
  218. this.ids = selection.map(item => item.logId)
  219. this.single = selection.length!==1
  220. this.multiple = !selection.length
  221. },
  222. /** 新增按钮操作 */
  223. handleAdd() {
  224. this.reset();
  225. this.open = true;
  226. this.title = "添加短链课程看课记录";
  227. },
  228. /** 修改按钮操作 */
  229. handleUpdate(row) {
  230. this.reset();
  231. const logId = row.logId || this.ids
  232. getCourseWatchLog(logId).then(response => {
  233. this.form = response.data;
  234. this.open = true;
  235. this.title = "修改短链课程看课记录";
  236. });
  237. },
  238. /** 提交按钮 */
  239. submitForm() {
  240. this.$refs["form"].validate(valid => {
  241. if (valid) {
  242. if (this.form.logId != null) {
  243. updateCourseWatchLog(this.form).then(response => {
  244. this.msgSuccess("修改成功");
  245. this.open = false;
  246. this.getList();
  247. });
  248. } else {
  249. addCourseWatchLog(this.form).then(response => {
  250. this.msgSuccess("新增成功");
  251. this.open = false;
  252. this.getList();
  253. });
  254. }
  255. }
  256. });
  257. },
  258. /** 删除按钮操作 */
  259. handleDelete(row) {
  260. const logIds = row.logId || this.ids;
  261. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  262. confirmButtonText: "确定",
  263. cancelButtonText: "取消",
  264. type: "warning"
  265. }).then(function() {
  266. return delCourseWatchLog(logIds);
  267. }).then(() => {
  268. this.getList();
  269. this.msgSuccess("删除成功");
  270. }).catch(() => {});
  271. },
  272. /** 导出按钮操作 */
  273. handleExport() {
  274. const queryParams = this.queryParams;
  275. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  276. confirmButtonText: "确定",
  277. cancelButtonText: "取消",
  278. type: "warning"
  279. }).then(() => {
  280. this.exportLoading = true;
  281. return exportCourseWatchLog(queryParams);
  282. }).then(response => {
  283. this.download(response.msg);
  284. this.exportLoading = false;
  285. }).catch(() => {});
  286. },
  287. handleScheduleTimeChange(val) {
  288. if (val) {
  289. this.queryParams.scheduleStartTime = val[0];
  290. this.queryParams.scheduleEndTime = val[1];
  291. } else {
  292. this.queryParams.scheduleStartTime = null;
  293. this.queryParams.scheduleEndTime = null;
  294. }
  295. },
  296. }
  297. };
  298. </script>