statistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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="nickName">
  5. <el-select v-model="queryParams.userId" remote placeholder="用户名/手机号" filterable clearable style="width: 100%;"
  6. @keyup.enter.native="handleQuery"
  7. :remote-method="remoteGetFsUserList"
  8. :loading="queryUserLoading"
  9. >
  10. <el-option
  11. v-for="dict in fsUserList"
  12. :key="`${dict.nickname} - ${dict.userId}`"
  13. :label="`${dict.nickname} - ${dict.userId}`"
  14. :value="dict.userId">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="销售" prop="nickName">
  19. <el-select v-model="queryParams.companyUserId" remote placeholder="请选择" filterable clearable style="width: 100%;" @keyup.enter.native="handleQuery">
  20. <el-option
  21. v-for="dict in companyUserList"
  22. :key="`${dict.nickName} - ${dict.userName}`"
  23. :label="`${dict.nickName} - ${dict.userName}`"
  24. :value="dict.userId">
  25. </el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="项目" prop="courseId">
  29. <el-select filterable v-model="queryParams.project" placeholder="请选择项目" clearable size="small">
  30. <el-option
  31. v-for="dict in projectLists"
  32. :key="dict.dictValue"
  33. :label="dict.dictLabel"
  34. :value="parseInt(dict.dictValue)"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="课程" prop="courseId">
  39. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  40. <el-option
  41. v-for="dict in courseLists"
  42. :key="dict.dictValue"
  43. :label="dict.dictLabel"
  44. :value="dict.dictValue"
  45. />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="小节" prop="videoId">
  49. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  50. <el-option
  51. v-for="dict in videoList"
  52. :key="dict.dictValue"
  53. :label="dict.dictLabel"
  54. :value="dict.dictValue"
  55. />
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item label="创建时间" prop="createTime">
  59. <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>
  60. </el-form-item>
  61. <el-form-item>
  62. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  63. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  64. </el-form-item>
  65. </el-form>
  66. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange" show-summary>
  67. <el-table-column type="selection" width="55" align="center" />
  68. <el-table-column label="用户" align="center" prop="userName" />
  69. <el-table-column label="对应销售" align="center" prop="companyUserName" />
  70. <el-table-column label="发课时间" align="center" prop="createTime"/>
  71. <el-table-column label="项目" align="center" prop="projectName" />
  72. <el-table-column label="课程名称" align="center" prop="courseName" />
  73. <el-table-column label="小节名称" align="center" prop="videoName" />
  74. <el-table-column label="待看课" align="center" prop="type3" />
  75. <el-table-column label="看课中" align="center" prop="type1" />
  76. <el-table-column label="已完课" align="center" prop="type2" />
  77. <el-table-column label="看课中断" align="center" prop="type4" />
  78. </el-table>
  79. <pagination
  80. v-show="total>0"
  81. :total="total"
  82. :page.sync="queryParams.pageNum"
  83. :limit.sync="queryParams.pageSize"
  84. @pagination="getList"
  85. />
  86. </div>
  87. </template>
  88. <script>
  89. import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog,statisticsList } from "@/api/course/courseWatchLog";
  90. import { courseList,videoList } from '@/api/course/courseRedPacketLog'
  91. import {getUserList} from "@/api/company/companyUser";
  92. import {getFsUserList} from "@/api/users/user";
  93. export default {
  94. name: "CourseWatchLog",
  95. data() {
  96. return {
  97. activeName:"00",
  98. createTime:null,
  99. courseLists:[],
  100. videoList:[],
  101. logTypeOptions:[],
  102. // 遮罩层
  103. loading: true,
  104. // 导出遮罩层
  105. exportLoading: false,
  106. // 选中数组
  107. ids: [],
  108. // 非单个禁用
  109. single: true,
  110. // 非多个禁用
  111. multiple: true,
  112. // 显示搜索条件
  113. showSearch: true,
  114. // 总条数
  115. total: 0,
  116. // 短链课程看课记录表格数据
  117. companyUserList: [],
  118. courseWatchLogList: [],
  119. // 弹出层标题
  120. title: "",
  121. // 是否显示弹出层
  122. open: false,
  123. projectLists: [],
  124. fsUserList: [],
  125. queryUserLoading: false,
  126. // 查询参数
  127. queryParams: {
  128. pageNum: 1,
  129. pageSize: 10,
  130. userId: null,
  131. nickName: null,
  132. videoId: null,
  133. logType: null,
  134. qwExternalContactId: null,
  135. duration: null,
  136. qwUserId: null,
  137. companyUserId: null,
  138. companyId: null,
  139. courseId: null,
  140. sTime:null,
  141. eTime:null,
  142. scheduleStartTime: null,
  143. scheduleEndTime: null,
  144. },
  145. // 表单参数
  146. form: {},
  147. // 表单校验
  148. rules: {
  149. },
  150. scheduleTime: null,
  151. };
  152. },
  153. created() {
  154. courseList().then(response => {
  155. this.courseLists = response.list;
  156. });
  157. this.getList();
  158. this.getDicts("sys_course_watch_log_type").then(response => {
  159. this.logTypeOptions = response.data;
  160. });
  161. this.getDicts("sys_course_project").then(response => {
  162. this.projectLists = response.data;
  163. })
  164. getUserList().then(res=>{
  165. if(res.code === 200) {
  166. this.companyUserList = res.data
  167. }
  168. })
  169. getFsUserList({}).then(res=>{
  170. if(res.code === 200) {
  171. this.fsUserList = res.data
  172. }
  173. })
  174. },
  175. methods: {
  176. handleClear(){
  177. this.queryUserLoading = false;
  178. this.fsUserList = [];
  179. },
  180. remoteGetFsUserList(query){
  181. if(query){
  182. this.queryUserLoading = true;
  183. const isNumeric = /^\d+$/.test(query);
  184. let payload = {
  185. username: query,
  186. nickname: query
  187. }
  188. if(isNumeric) {
  189. payload = {
  190. userId: query,
  191. username: query,
  192. phone: query
  193. }
  194. }
  195. getFsUserList(payload).then(res=>{
  196. if(res.code === 200) {
  197. this.fsUserList = res.data
  198. }
  199. }).finally(()=>{
  200. this.queryUserLoading = false;
  201. })
  202. }
  203. },
  204. courseChange(row){
  205. this.queryParams.videoId=null;
  206. if(row === ''){
  207. this.videoList=[];
  208. return
  209. }
  210. videoList(row).then(response => {
  211. this.videoList=response.list
  212. });
  213. },
  214. change() {
  215. if (this.createTime != null) {
  216. this.queryParams.sTime = this.createTime[0];
  217. this.queryParams.eTime = this.createTime[1];
  218. } else {
  219. this.queryParams.sTime = null;
  220. this.queryParams.eTime = null;
  221. }
  222. },
  223. handleClickX(tab,event){
  224. this.activeName=tab.name;
  225. if(tab.name=="00"){
  226. this.queryParams.logType=null;
  227. }else{
  228. this.queryParams.logType=tab.name;
  229. }
  230. this.getList()
  231. },
  232. /** 查询短链课程看课记录列表 */
  233. getList() {
  234. this.loading = true;
  235. statisticsList(this.queryParams).then(response => {
  236. this.courseWatchLogList = response.rows;
  237. this.total = response.total;
  238. this.loading = false;
  239. });
  240. },
  241. // 取消按钮
  242. cancel() {
  243. this.open = false;
  244. this.reset();
  245. },
  246. // 表单重置
  247. reset() {
  248. this.form = {
  249. logId: null,
  250. userId: null,
  251. videoId: null,
  252. logType: null,
  253. createTime: null,
  254. updateTime: null,
  255. qwExternalContactId: null,
  256. duration: null,
  257. qwUserId: null,
  258. companyUserId: null,
  259. companyId: null,
  260. courseId: null
  261. };
  262. this.resetForm("form");
  263. },
  264. /** 搜索按钮操作 */
  265. handleQuery() {
  266. this.queryParams.pageNum = 1;
  267. this.getList();
  268. },
  269. /** 重置按钮操作 */
  270. resetQuery() {
  271. this.resetForm("queryForm");
  272. this.createTime = null;
  273. this.scheduleTime = null;
  274. this.queryParams.sTime = null;
  275. this.queryParams.eTime = null;
  276. this.queryParams.scheduleStartTime = null;
  277. this.queryParams.scheduleEndTime = null;
  278. this.handleQuery();
  279. },
  280. // 多选框选中数据
  281. handleSelectionChange(selection) {
  282. this.ids = selection.map(item => item.logId)
  283. this.single = selection.length!==1
  284. this.multiple = !selection.length
  285. },
  286. /** 新增按钮操作 */
  287. handleAdd() {
  288. this.reset();
  289. this.open = true;
  290. this.title = "添加短链课程看课记录";
  291. },
  292. /** 修改按钮操作 */
  293. handleUpdate(row) {
  294. this.reset();
  295. const logId = row.logId || this.ids
  296. getCourseWatchLog(logId).then(response => {
  297. this.form = response.data;
  298. this.open = true;
  299. this.title = "修改短链课程看课记录";
  300. });
  301. },
  302. /** 提交按钮 */
  303. submitForm() {
  304. this.$refs["form"].validate(valid => {
  305. if (valid) {
  306. if (this.form.logId != null) {
  307. updateCourseWatchLog(this.form).then(response => {
  308. this.msgSuccess("修改成功");
  309. this.open = false;
  310. this.getList();
  311. });
  312. } else {
  313. addCourseWatchLog(this.form).then(response => {
  314. this.msgSuccess("新增成功");
  315. this.open = false;
  316. this.getList();
  317. });
  318. }
  319. }
  320. });
  321. },
  322. /** 删除按钮操作 */
  323. handleDelete(row) {
  324. const logIds = row.logId || this.ids;
  325. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  326. confirmButtonText: "确定",
  327. cancelButtonText: "取消",
  328. type: "warning"
  329. }).then(function() {
  330. return delCourseWatchLog(logIds);
  331. }).then(() => {
  332. this.getList();
  333. this.msgSuccess("删除成功");
  334. }).catch(() => {});
  335. },
  336. /** 导出按钮操作 */
  337. handleExport() {
  338. const queryParams = this.queryParams;
  339. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  340. confirmButtonText: "确定",
  341. cancelButtonText: "取消",
  342. type: "warning"
  343. }).then(() => {
  344. this.exportLoading = true;
  345. return exportCourseWatchLog(queryParams);
  346. }).then(response => {
  347. this.download(response.msg);
  348. this.exportLoading = false;
  349. }).catch(() => {});
  350. },
  351. handleScheduleTimeChange(val) {
  352. if (val) {
  353. this.queryParams.scheduleStartTime = val[0];
  354. this.queryParams.scheduleEndTime = val[1];
  355. } else {
  356. this.queryParams.scheduleStartTime = null;
  357. this.queryParams.scheduleEndTime = null;
  358. }
  359. },
  360. }
  361. };
  362. </script>