my.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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-input
  6. v-model="queryParams.nickName"
  7. placeholder="请输入企微昵称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="添加时间" prop="createTime">
  14. <el-date-picker v-model="createTime" size="small"
  15. style="width: 220px"
  16. value-format="yyyy-MM-dd"
  17. type="daterange" range-separator="-"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. :picker-options="pickerOptions"
  21. @change="change"></el-date-picker>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-table
  29. border
  30. v-loading="loading"
  31. :data="courseWatchLogList"
  32. @selection-change="handleSelectionChange"
  33. :show-summary="true"
  34. :summary-method="getSummaries"
  35. ref="table1">
  36. <el-table-column type="selection" width="55" align="center" />
  37. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  38. <!-- 发课时间 -->
  39. <el-table-column label="进线时间" align="center" prop="createTime"/>
  40. <!-- 进线数 -->
  41. <el-table-column label="进线数" align="center" prop="line" />
  42. <!-- 先导课上线 -->
  43. <el-table-column label="先导课上线" align="center" prop="firstOnline">
  44. <template slot-scope="scope">
  45. <span>{{ scope.row.firstOnline }}</span>
  46. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.firstOnline / scope.row.line) * 100).toFixed(2) }}%)</span>
  47. </template>
  48. </el-table-column>
  49. <!-- 先导课完课 -->
  50. <el-table-column label="先导课完课" align="center" prop="firstOver">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.firstOver }}</span>
  53. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.firstOver / scope.row.line) * 100).toFixed(2) }}%)</span>
  54. </template>
  55. </el-table-column>
  56. <!-- 首日上线 -->
  57. <el-table-column label="首日上线" align="center" prop="d1Online">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.d1Online }}</span>
  60. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d1Online / scope.row.line) * 100).toFixed(2) }}%)</span>
  61. </template>
  62. </el-table-column>
  63. <!-- 首日完课 -->
  64. <el-table-column label="首日完课" align="center" prop="d1Over">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.d1Over }}</span>
  67. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d1Over / scope.row.line) * 100).toFixed(2) }}%)</span>
  68. </template>
  69. </el-table-column>
  70. <!-- 综合报名数 -->
  71. <el-table-column label="综合报名数" align="center" prop="sign">
  72. <template slot-scope="scope">
  73. <span>{{ scope.row.sign }}</span>
  74. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.sign / scope.row.line) * 100).toFixed(2) }}%)</span>
  75. </template>
  76. </el-table-column>
  77. <!-- 互动数 -->
  78. <el-table-column label="互动数" align="center" prop="interact">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.interact }}</span>
  81. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.interact / scope.row.line) * 100).toFixed(2) }}%)</span>
  82. </template>
  83. </el-table-column>
  84. <!-- A级客户 -->
  85. <el-table-column label="A级客户" align="center" prop="a">
  86. <template slot-scope="scope">
  87. <span>{{ scope.row.a }}</span>
  88. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.a / scope.row.line) * 100).toFixed(2) }}%)</span>
  89. </template>
  90. </el-table-column>
  91. <!-- B级客户 -->
  92. <el-table-column label="B级客户" align="center" prop="b">
  93. <template slot-scope="scope">
  94. <span>{{ scope.row.b }}</span>
  95. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.b / scope.row.line) * 100).toFixed(2) }}%)</span>
  96. </template>
  97. </el-table-column>
  98. <!-- C级客户 -->
  99. <el-table-column label="C级客户" align="center" prop="c">
  100. <template slot-scope="scope">
  101. <span>{{ scope.row.c }}</span>
  102. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.c / scope.row.line) * 100).toFixed(2) }}%)</span>
  103. </template>
  104. </el-table-column>
  105. <!-- D级客户 -->
  106. <el-table-column label="D级客户" align="center" prop="d">
  107. <template slot-scope="scope">
  108. <span>{{ scope.row.d }}</span>
  109. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d / scope.row.line) * 100).toFixed(2) }}%)</span>
  110. </template>
  111. </el-table-column>
  112. <!-- 流失数 -->
  113. <el-table-column label="流失数" align="center" prop="los">
  114. <template slot-scope="scope">
  115. <span>{{ scope.row.los }}</span>
  116. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.los / scope.row.line) * 100).toFixed(2) }}%)</span>
  117. </template>
  118. </el-table-column>
  119. <!-- 删除数 -->
  120. <el-table-column label="删除数" align="center" prop="del">
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.del }}</span>
  123. <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.del / scope.row.line) * 100).toFixed(2) }}%)</span>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. <pagination
  128. v-show="total>0"
  129. :total="total"
  130. :page.sync="queryParams.pageNum"
  131. :limit.sync="queryParams.pageSize"
  132. @pagination="getList"
  133. />
  134. </div>
  135. </template>
  136. <script>
  137. import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog,statisticsList,qwWatchLogStatisticsList,myQwWatchLogStatisticsList } from "@/api/course/qw/courseWatchLog";
  138. import { courseList,videoList } from '@/api/course/courseRedPacketLog'
  139. export default {
  140. name: "CourseWatchLog",
  141. data() {
  142. return {
  143. activeName:"00",
  144. createTime:null,
  145. courseLists:[],
  146. videoList:[],
  147. logTypeOptions:[],
  148. // 遮罩层
  149. loading: true,
  150. // 导出遮罩层
  151. exportLoading: false,
  152. // 选中数组
  153. ids: [],
  154. // 非单个禁用
  155. single: true,
  156. // 非多个禁用
  157. multiple: true,
  158. // 显示搜索条件
  159. showSearch: true,
  160. // 总条数
  161. total: 0,
  162. // 短链课程看课记录表格数据
  163. courseWatchLogList: [],
  164. // 弹出层标题
  165. title: "",
  166. // 是否显示弹出层
  167. open: false,
  168. // 查询参数
  169. queryParams: {
  170. pageNum: 1,
  171. pageSize: 10,
  172. userId: null,
  173. nickName: null,
  174. videoId: null,
  175. logType: null,
  176. qwExternalContactId: null,
  177. duration: null,
  178. qwUserId: null,
  179. companyUserId: null,
  180. companyId: null,
  181. courseId: null,
  182. sTime:null,
  183. eTime:null,
  184. scheduleStartTime: null,
  185. scheduleEndTime: null,
  186. },
  187. // 表单参数
  188. form: {},
  189. // 表单校验
  190. rules: {
  191. },
  192. scheduleTime: null,
  193. pickerOptions: {
  194. disabledDate(time) {
  195. // 获取6天前的日期(加上今天就是7天)
  196. const sixDaysAgo = new Date();
  197. sixDaysAgo.setDate(sixDaysAgo.getDate() - 6);
  198. sixDaysAgo.setHours(0, 0, 0, 0);
  199. // 获取明天的日期(不包括今天)
  200. const tomorrow = new Date();
  201. tomorrow.setDate(tomorrow.getDate() + 1);
  202. tomorrow.setHours(0, 0, 0, 0);
  203. return time.getTime() < sixDaysAgo.getTime() || time.getTime() >= tomorrow.getTime();
  204. }
  205. },
  206. };
  207. },
  208. created() {
  209. courseList().then(response => {
  210. this.courseLists = response.list;
  211. });
  212. const today = new Date();
  213. const sevenDaysAgo = new Date();
  214. sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6);
  215. this.queryParams.sTime = this.formatDate(sevenDaysAgo);
  216. this.queryParams.eTime = this.formatDate(today);
  217. this.getDicts("sys_course_watch_log_type").then(response => {
  218. this.logTypeOptions = response.data;
  219. });
  220. setTimeout(() => {
  221. this.getList();
  222. }, 200);
  223. },
  224. methods: {
  225. formatDate(date) {
  226. const year = date.getFullYear();
  227. const month = String(date.getMonth() + 1).padStart(2, '0');
  228. const day = String(date.getDate()).padStart(2, '0');
  229. return `${year}-${month}-${day}`;
  230. },
  231. getSummaries(param) {
  232. let totalNum = 0;
  233. const { columns, data } = param;
  234. const sums = [];
  235. columns.forEach((column, index) => {
  236. if (index === 0) {
  237. sums[index] = "总计";
  238. return;
  239. }
  240. const values = data.map((item) => Number(item[column.property]));
  241. if (!values.every((value) => isNaN(value))) {
  242. sums[index] = values.reduce((prev, curr) => {
  243. const value = Number(curr);
  244. if (!isNaN(value)) {
  245. return prev + curr;
  246. } else {
  247. return prev;
  248. }
  249. }, 0);
  250. //第三列计数为进线数量和
  251. if(index === 3){
  252. totalNum = sums[index];
  253. }
  254. if(index > 3 && totalNum != 0){
  255. sums[index] = sums[index] + "("+ ((sums[index] / totalNum) * 100).toFixed(2) + "%)"
  256. }
  257. if (
  258. column.property === "firstOnline" ||
  259. column.property === "firstOver" ||
  260. column.property === "d1Online" ||
  261. column.property === "d1Over" ||
  262. column.property === "sign" ||
  263. column.property === "interact" ||
  264. column.property === "a" ||
  265. column.property === "b" ||
  266. column.property === "c" ||
  267. column.property === "d" ||
  268. column.property === "e" ||
  269. column.property === "black" ||
  270. column.property === "los" ||
  271. column.property === "del"
  272. ) {
  273. }
  274. } else {
  275. sums[index] = "";
  276. }
  277. });
  278. return sums;
  279. },
  280. courseChange(row){
  281. this.queryParams.videoId=null;
  282. if(row === ''){
  283. this.videoList=[];
  284. return
  285. }
  286. videoList(row).then(response => {
  287. this.videoList=response.list
  288. });
  289. },
  290. change() {
  291. if (this.createTime != null) {
  292. this.queryParams.sTime = this.createTime[0];
  293. this.queryParams.eTime = this.createTime[1];
  294. } else {
  295. this.queryParams.sTime = null;
  296. this.queryParams.eTime = null;
  297. }
  298. },
  299. handleClickX(tab,event){
  300. this.activeName=tab.name;
  301. if(tab.name=="00"){
  302. this.queryParams.logType=null;
  303. }else{
  304. this.queryParams.logType=tab.name;
  305. }
  306. this.getList()
  307. },
  308. /** 查询短链课程看课记录列表 */
  309. getList() {
  310. this.loading = true;
  311. myQwWatchLogStatisticsList(this.queryParams).then(response => {
  312. this.courseWatchLogList = response.rows;
  313. this.total = response.total;
  314. this.loading = false;
  315. });
  316. this.$nextTick(() => {
  317. setTimeout(() => {
  318. this.$refs.table1?.doLayout();
  319. }, 2000);
  320. });
  321. },
  322. // 取消按钮
  323. cancel() {
  324. this.open = false;
  325. this.reset();
  326. },
  327. // 表单重置
  328. reset() {
  329. this.form = {
  330. logId: null,
  331. userId: null,
  332. videoId: null,
  333. logType: null,
  334. createTime: null,
  335. updateTime: null,
  336. qwExternalContactId: null,
  337. duration: null,
  338. qwUserId: null,
  339. companyUserId: null,
  340. companyId: null,
  341. courseId: null
  342. };
  343. this.resetForm("form");
  344. },
  345. /** 搜索按钮操作 */
  346. handleQuery() {
  347. this.queryParams.pageNum = 1;
  348. this.getList();
  349. },
  350. /** 重置按钮操作 */
  351. resetQuery() {
  352. this.resetForm("queryForm");
  353. this.createTime = null;
  354. this.scheduleTime = null;
  355. const today = new Date();
  356. const sevenDaysAgo = new Date();
  357. sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6);
  358. this.queryParams.sTime = this.formatDate(sevenDaysAgo);
  359. this.queryParams.eTime = this.formatDate(today);
  360. this.queryParams.scheduleStartTime = null;
  361. this.queryParams.scheduleEndTime = null;
  362. this.handleQuery();
  363. },
  364. // 多选框选中数据
  365. handleSelectionChange(selection) {
  366. this.ids = selection.map(item => item.logId)
  367. this.single = selection.length!==1
  368. this.multiple = !selection.length
  369. },
  370. /** 新增按钮操作 */
  371. handleAdd() {
  372. this.reset();
  373. this.open = true;
  374. this.title = "添加短链课程看课记录";
  375. },
  376. /** 修改按钮操作 */
  377. handleUpdate(row) {
  378. this.reset();
  379. const logId = row.logId || this.ids
  380. getCourseWatchLog(logId).then(response => {
  381. this.form = response.data;
  382. this.open = true;
  383. this.title = "修改短链课程看课记录";
  384. });
  385. },
  386. /** 提交按钮 */
  387. submitForm() {
  388. this.$refs["form"].validate(valid => {
  389. if (valid) {
  390. if (this.form.logId != null) {
  391. updateCourseWatchLog(this.form).then(response => {
  392. this.msgSuccess("修改成功");
  393. this.open = false;
  394. this.getList();
  395. });
  396. } else {
  397. addCourseWatchLog(this.form).then(response => {
  398. this.msgSuccess("新增成功");
  399. this.open = false;
  400. this.getList();
  401. });
  402. }
  403. }
  404. });
  405. },
  406. /** 删除按钮操作 */
  407. handleDelete(row) {
  408. const logIds = row.logId || this.ids;
  409. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  410. confirmButtonText: "确定",
  411. cancelButtonText: "取消",
  412. type: "warning"
  413. }).then(function() {
  414. return delCourseWatchLog(logIds);
  415. }).then(() => {
  416. this.getList();
  417. this.msgSuccess("删除成功");
  418. }).catch(() => {});
  419. },
  420. /** 导出按钮操作 */
  421. handleExport() {
  422. const queryParams = this.queryParams;
  423. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  424. confirmButtonText: "确定",
  425. cancelButtonText: "取消",
  426. type: "warning"
  427. }).then(() => {
  428. this.exportLoading = true;
  429. return exportCourseWatchLog(queryParams);
  430. }).then(response => {
  431. this.download(response.msg);
  432. this.exportLoading = false;
  433. }).catch(() => {});
  434. },
  435. handleScheduleTimeChange(val) {
  436. if (val) {
  437. this.queryParams.scheduleStartTime = val[0];
  438. this.queryParams.scheduleEndTime = val[1];
  439. } else {
  440. this.queryParams.scheduleStartTime = null;
  441. this.queryParams.scheduleEndTime = null;
  442. }
  443. },
  444. }
  445. };
  446. </script>