statistics.vue 14 KB

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