statistics.vue 15 KB

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