statistics.vue 13 KB

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