my.vue 17 KB

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