statistics.vue 10.0 KB

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