watchLog.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="用户" prop="qwUserId">
  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="courseId">
  20. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small"
  21. @change="courseChange(queryParams.courseId)">
  22. <el-option
  23. v-for="dict in courseLists"
  24. :key="dict.dictValue"
  25. :label="dict.dictLabel"
  26. :value="dict.dictValue"
  27. />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="小节" prop="videoId">
  31. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  32. <el-option
  33. v-for="dict in videoList"
  34. :key="dict.dictValue"
  35. :label="dict.dictLabel"
  36. :value="dict.dictValue"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="营期时间" prop="scheduleTime">
  41. <el-date-picker
  42. v-model="scheduleTime"
  43. type="daterange"
  44. size="small"
  45. style="width: 240px"
  46. value-format="yyyy-MM-dd"
  47. range-separator="-"
  48. start-placeholder="开始日期"
  49. end-placeholder="结束日期"
  50. @change="handleScheduleTimeChange">
  51. </el-date-picker>
  52. </el-form-item>
  53. <el-form-item label="创建时间" prop="createTime">
  54. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"
  55. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
  56. @change="createChange"></el-date-picker>
  57. </el-form-item>
  58. <el-form-item label="最新更新时间" prop="updateTime">
  59. <el-date-picker v-model="updateTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  60. range-separator="-" start-placeholder="开始日期"
  61. end-placeholder="结束日期" @change="updateChange"></el-date-picker>
  62. </el-form-item>
  63. <el-form-item label="类型" prop="type">
  64. <el-select filterable v-model="sourceTypeModel" placeholder="请选择小节" clearable size="small">
  65. <el-option
  66. v-for="dict in userSourceTypeOptions"
  67. :key="dict.dictValue"
  68. :label="dict.dictLabel"
  69. :value="dict.dictValue"
  70. />
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item>
  74. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  75. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  76. </el-form-item>
  77. </el-form>
  78. <el-row :gutter="10" class="mb8">
  79. <el-col :span="1.5">
  80. <el-button
  81. type="warning"
  82. plain
  83. icon="el-icon-download"
  84. size="mini"
  85. :loading="exportLoading"
  86. @click="handleExport"
  87. v-hasPermi="['course:courseWatchLog:myExport']"
  88. >导出
  89. </el-button>
  90. </el-col>
  91. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  92. </el-row>
  93. <el-tabs type="card" v-model="activeName" @tab-click="handleClickX">
  94. <el-tab-pane label="全部" name="00"></el-tab-pane>
  95. <el-tab-pane v-for="(item,index) in logTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  96. </el-tabs>
  97. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange">
  98. <el-table-column type="selection" width="55" align="center"/>
  99. <el-table-column label="记录编号" align="center" prop="logId"/>
  100. <!-- <el-table-column label="企微客户" align="center" prop="externalUserName"/>-->
  101. <el-table-column label="用户账号" align="center" prop="userName" />
  102. <el-table-column label="企微客户" align="center" prop="externalUserName" v-if="queryParams.sourceType == 2"/>
  103. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  104. <template slot-scope="scope">
  105. <div style="display: flex;white-space: nowrap">
  106. <div style="margin: auto">
  107. {{ scope.row.fsNickName }}
  108. </div>
  109. <el-popover
  110. placement="right"
  111. title=""
  112. trigger="hover">
  113. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  114. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  115. </el-popover>
  116. </div>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="项目" align="center" prop="projectName" />
  120. <el-table-column label="课程名称" align="center" prop="courseName"/>
  121. <el-table-column label="小节名称" align="center" prop="videoName"/>
  122. <el-table-column label="记录类型" align="center" prop="logType">
  123. <template slot-scope="scope">
  124. <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="播放时长" align="center" prop="duration"/>
  128. <el-table-column label="所属销售" align="center" prop="companyUserName"/>
  129. <!-- <el-table-column label="所属公司" align="center" prop="companyName"/>-->
  130. <!-- <el-table-column label="企微员工名称" align="center" prop="qwUserName"/>-->
  131. <!-- <el-table-column label="企微账号" align="center" prop="qwUserName"/>-->
  132. <!-- <el-table-column label="所属发送方式" align="center" prop="sendType"/>-->
  133. <el-table-column label="企微员工名称" align="center" prop="qwUserName" v-if="queryParams.sourceType == 2"/>
  134. <el-table-column label="创建时间" align="center" prop="createTime" width="100px"/>
  135. <el-table-column label="更新时间" align="center" prop="updateTime" width="100px" />
  136. <el-table-column label="完课时间" align="center" prop="finishTime" width="100px" />
  137. <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
  138. <el-table-column
  139. fixed="right"
  140. label="操作"
  141. width="100">
  142. <template slot-scope="scope">
  143. <el-button @click="openAnswerLogFun(scope.row)" type="text" size="small">答题记录</el-button>
  144. <el-button @click="openRedLogFun(scope.row)" type="text" size="small">红包记录</el-button>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <pagination
  149. v-show="total>0"
  150. :total="total"
  151. :page.sync="queryParams.pageNum"
  152. :limit.sync="queryParams.pageSize"
  153. @pagination="getList"
  154. />
  155. <el-drawer title="做题记录" :visible.sync="openAnswerLog" size="70%" append-to-body>
  156. <el-table border v-loading="" :data="answerLogsList">
  157. <el-table-column label="小程序用户名" align="center" prop="userName">
  158. <template slot-scope="scope">
  159. <div style="display: flex;white-space: nowrap">
  160. <div style="margin: auto">
  161. {{ scope.row.userName }}
  162. </div>
  163. <el-popover
  164. placement="right"
  165. title=""
  166. trigger="hover">
  167. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  168. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  169. </el-popover>
  170. </div>
  171. </template>
  172. </el-table-column>
  173. <el-table-column label="课程名称" align="center" prop="courseName"/>
  174. <el-table-column label="小节名称" align="center" prop="videoName"/>
  175. <el-table-column label="是否全部正确" align="center" prop="isRight">
  176. <template slot-scope="scope">
  177. <dict-tag :options="sysCompanyOr" :value="scope.row.isRight"></dict-tag>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="销售名称" align="center" prop="companyUserName"/>
  181. <el-table-column label="企微员工名称" align="center" prop="qwUserName"/>
  182. <el-table-column label="公司名称" align="center" prop="companyName"/>
  183. <el-table-column label="创建时间" align="center" prop="createTime"/>
  184. </el-table>
  185. <pagination
  186. v-show="answerLogTotal>0"
  187. :total="answerLogTotal"
  188. :page.sync="answerLogQueryParams.pageNum"
  189. :limit.sync="answerLogQueryParams.pageSize"
  190. @pagination="answerLogList"
  191. />
  192. </el-drawer>
  193. <el-drawer title="红包记录" :visible.sync="openRedLog" size="70%" append-to-body>
  194. <el-table border v-loading="" :data="redLogsList">
  195. <el-table-column type="selection" width="55" align="center" />
  196. <el-table-column label="记录编号" align="center" prop="logId" />
  197. <el-table-column label="批次单号" align="center" prop="outBatchNo" />
  198. <el-table-column label="课程名称" align="center" prop="courseId" >
  199. <template slot-scope="scope">
  200. <span prop="status" v-for="(item, index) in courseLists" v-if="scope.row.courseId==item.dictValue">{{item.dictLabel}}</span>
  201. </template>
  202. </el-table-column>
  203. <el-table-column label="小节名称" align="center" prop="title" />
  204. <el-table-column label="会员id" align="center" prop="userId" />
  205. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  206. <template slot-scope="scope">
  207. <div style="display: flex;white-space: nowrap">
  208. <div style="margin: auto">
  209. {{scope.row.fsNickName}}
  210. </div>
  211. <el-popover
  212. placement="right"
  213. title=""
  214. trigger="hover">
  215. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  216. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  217. </el-popover>
  218. </div>
  219. </template>
  220. </el-table-column>
  221. <el-table-column label="会员电话" align="center" prop="phone" />
  222. <el-table-column label="所属销售" align="center" prop="companyUserName" />
  223. <el-table-column label="所属公司" align="center" prop="companyName" />
  224. <el-table-column label="转帐金额" align="center" prop="amount" />
  225. <el-table-column label="状态" align="center" prop="status" >
  226. <template slot-scope="scope">
  227. <el-tag>{{ scope.row.status === 0 ? "发送中" : "已完成" }}</el-tag>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  231. <el-table-column label="创建时间" align="center" prop="createTime" />
  232. </el-table>
  233. <pagination
  234. v-show="redLogTotal>0"
  235. :total="redLogTotal"
  236. :page.sync="redLogQueryParams.pageNum"
  237. :limit.sync="redLogQueryParams.pageSize"
  238. @pagination="redLogList"
  239. />
  240. </el-drawer>
  241. </div>
  242. </template>
  243. <script>
  244. import {
  245. addCourseWatchLog,
  246. delCourseWatchLog,
  247. exportCourseWatchLog,
  248. getCourseWatchLog,
  249. myListCourseWatchLog,
  250. updateCourseWatchLog
  251. } from "@/api/course/courseWatchLog";
  252. import {courseList, myListCourseRedPacketLog, videoList} from '@/api/course/courseRedPacketLog'
  253. import {myListLogs} from "@/api/course/courseAnswerlogs";
  254. import {getMyQwUserList} from "@/api/qw/user";
  255. import {getFsUserList} from "@/api/users/user";
  256. export default {
  257. name: "CourseWatchLog",
  258. data() {
  259. return {
  260. userSourceTypeOptions: [],
  261. activeName:"00",
  262. createTime: null,
  263. updateTime:null,
  264. courseLists: [],
  265. videoList: [],
  266. myQwUserList: [],
  267. logTypeOptions: [],
  268. // 遮罩层
  269. loading: true,
  270. // 导出遮罩层
  271. exportLoading: false,
  272. queryUserLoading: false,
  273. // 选中数组
  274. ids: [],
  275. // 非单个禁用
  276. single: true,
  277. scheduleTime: null,
  278. // 非多个禁用
  279. multiple: true,
  280. // 显示搜索条件
  281. showSearch: true,
  282. sysCompanyOr: [],
  283. // 总条数
  284. total: 0,
  285. // 短链课程看课记录表格数据
  286. courseWatchLogList: [],
  287. fsUserList: [],
  288. openAnswerLog: false,
  289. loadingAnswerLog: true,
  290. answerLogsList: [],
  291. answerLogTotal: 0,
  292. answerLogQueryParams: {
  293. pageNum: 1,
  294. pageSize: 10,
  295. },
  296. openRedLog: false,
  297. loadingRedLog: true,
  298. redLogsList: [],
  299. redLogTotal: 0,
  300. redLogQueryParams: {
  301. pageNum: 1,
  302. pageSize: 10,
  303. },
  304. // 弹出层标题
  305. title: "",
  306. // 是否显示弹出层
  307. open: false,
  308. // 查询参数
  309. queryParams: {
  310. pageNum: 1,
  311. pageSize: 10,
  312. userId: null,
  313. videoId: null,
  314. nickName: null,
  315. logType: "10",
  316. qwExternalContactId: null,
  317. externalUserName:null,
  318. duration: null,
  319. qwUserId: null,
  320. companyUserId: null,
  321. companyId: null,
  322. courseId: null,
  323. sTime: null,
  324. eTime: null,
  325. upSTime:null,
  326. upETime:null,
  327. scheduleStartTime: null,
  328. scheduleEndTime: null,
  329. sourceType: 1
  330. },
  331. // 表单参数
  332. form: {},
  333. // 表单校验
  334. rules: {}
  335. };
  336. },
  337. computed: {
  338. sourceTypeModel: {
  339. get() {
  340. return this.queryParams.sourceType !== null && this.queryParams.sourceType !== undefined ? this.queryParams.sourceType.toString() : null;
  341. },
  342. set(newVal) {
  343. this.queryParams.sourceType = newVal;
  344. }
  345. }
  346. },
  347. created() {
  348. this.getDicts('user_source_type').then(response => {
  349. this.userSourceTypeOptions = response.data;
  350. })
  351. courseList().then(response => {
  352. this.courseLists = response.list;
  353. });
  354. this.getList();
  355. this.getDicts("sys_course_watch_log_type").then(response => {
  356. this.logTypeOptions = response.data;
  357. });
  358. this.getDicts("sys_company_or").then(response => {
  359. this.sysCompanyOr = response.data;
  360. });
  361. getMyQwUserList().then(response => {
  362. this.myQwUserList = response.data;
  363. });
  364. },
  365. methods: {
  366. handleClear(){
  367. this.queryUserLoading = false;
  368. this.fsUserList = [];
  369. },
  370. remoteGetFsUserList(query){
  371. if(query){
  372. this.queryUserLoading = true;
  373. const isNumeric = /^\d+$/.test(query);
  374. let payload = {
  375. username: query,
  376. nickname: query
  377. }
  378. if(isNumeric) {
  379. payload = {
  380. userId: query,
  381. username: query,
  382. phone: query
  383. }
  384. }
  385. getFsUserList(payload).then(res=>{
  386. if(res.code === 200) {
  387. this.fsUserList = res.data
  388. }
  389. }).finally(()=>{
  390. this.queryUserLoading = false;
  391. })
  392. }
  393. },
  394. courseChange(row) {
  395. this.queryParams.videoId = null;
  396. if (row === '') {
  397. this.videoList = [];
  398. return
  399. }
  400. videoList(row).then(response => {
  401. this.videoList = response.list
  402. });
  403. },
  404. updateQwuser() {
  405. for (const user of this.myQwUserList) {
  406. if (user.dictValue == this.queryParams.qwUserId) {
  407. this.queryParams.corpId = user.corpId;
  408. break;
  409. }
  410. }
  411. this.getList();
  412. },
  413. createChange() {
  414. if (this.createTime != null) {
  415. this.queryParams.sTime = this.createTime[0];
  416. this.queryParams.eTime = this.createTime[1];
  417. } else {
  418. this.queryParams.sTime = null;
  419. this.queryParams.eTime = null;
  420. }
  421. },
  422. updateChange(){
  423. if (this.updateTime != null) {
  424. this.queryParams.upSTime = this.updateTime[0];
  425. this.queryParams.upETime = this.updateTime[1];
  426. } else {
  427. this.queryParams.upSTime = null;
  428. this.queryParams.upETime = null;
  429. }
  430. },
  431. handleClickX(tab) {
  432. this.activeName=tab.name;
  433. if(tab.name=="00"){
  434. this.queryParams.logType=null;
  435. }else{
  436. this.queryParams.logType=tab.name;
  437. }
  438. this.getList()
  439. },
  440. handleScheduleTimeChange(val) {
  441. if (val) {
  442. this.queryParams.scheduleStartTime = val[0];
  443. this.queryParams.scheduleEndTime = val[1];
  444. } else {
  445. this.queryParams.scheduleStartTime = null;
  446. this.queryParams.scheduleEndTime = null;
  447. }
  448. },
  449. /** 查询短链课程看课记录列表 */
  450. getList() {
  451. this.loading = true;
  452. let param = JSON.parse(JSON.stringify(this.queryParams));
  453. if (param.logType == "10") {
  454. param.logType = null;
  455. }
  456. myListCourseWatchLog(param).then(response => {
  457. this.courseWatchLogList = response.rows;
  458. this.total = response.total;
  459. this.loading = false;
  460. });
  461. },
  462. // 取消按钮
  463. cancel() {
  464. this.open = false;
  465. this.reset();
  466. },
  467. // 表单重置
  468. reset() {
  469. this.form = {
  470. logId: null,
  471. userId: null,
  472. videoId: null,
  473. logType: null,
  474. createTime: null,
  475. updateTime: null,
  476. qwExternalContactId: null,
  477. externalUserName:null,
  478. duration: null,
  479. qwUserId: null,
  480. companyUserId: null,
  481. companyId: null,
  482. courseId: null,
  483. scheduleStartTime: null,
  484. scheduleEndTime: null,
  485. };
  486. this.scheduleTime=null;
  487. this.resetForm("form");
  488. },
  489. /** 搜索按钮操作 */
  490. handleQuery() {
  491. this.queryParams.pageNum = 1;
  492. this.getList();
  493. },
  494. /** 重置按钮操作 */
  495. resetQuery() {
  496. this.resetForm("queryForm");
  497. this.createTime = null;
  498. this.queryParams.sTime = null;
  499. this.queryParams.eTime = null;
  500. this.queryParams.upSTime = null;
  501. this.queryParams.upETime = null;
  502. this.queryParams.scheduleStartTime = null;
  503. this.queryParams.scheduleEndTime = null;
  504. this.scheduleTime=null;
  505. this.updateTime=null;
  506. this.handleQuery();
  507. },
  508. // 多选框选中数据
  509. handleSelectionChange(selection) {
  510. this.ids = selection.map(item => item.logId)
  511. this.single = selection.length !== 1
  512. this.multiple = !selection.length
  513. },
  514. /** 新增按钮操作 */
  515. handleAdd() {
  516. this.reset();
  517. this.open = true;
  518. this.title = "添加短链课程看课记录";
  519. },
  520. /** 修改按钮操作 */
  521. handleUpdate(row) {
  522. this.reset();
  523. const logId = row.logId || this.ids
  524. getCourseWatchLog(logId).then(response => {
  525. this.form = response.data;
  526. this.open = true;
  527. this.title = "修改短链课程看课记录";
  528. });
  529. },
  530. /** 提交按钮 */
  531. submitForm() {
  532. this.$refs["form"].validate(valid => {
  533. if (valid) {
  534. if (this.form.logId != null) {
  535. updateCourseWatchLog(this.form).then(response => {
  536. this.msgSuccess("修改成功");
  537. this.open = false;
  538. this.getList();
  539. });
  540. } else {
  541. addCourseWatchLog(this.form).then(response => {
  542. this.msgSuccess("新增成功");
  543. this.open = false;
  544. this.getList();
  545. });
  546. }
  547. }
  548. });
  549. },
  550. /** 删除按钮操作 */
  551. handleDelete(row) {
  552. const logIds = row.logId || this.ids;
  553. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  554. confirmButtonText: "确定",
  555. cancelButtonText: "取消",
  556. type: "warning"
  557. }).then(function () {
  558. return delCourseWatchLog(logIds);
  559. }).then(() => {
  560. this.getList();
  561. this.msgSuccess("删除成功");
  562. }).catch(() => {
  563. });
  564. },
  565. /** 导出按钮操作 */
  566. handleExport() {
  567. const queryParams = this.queryParams;
  568. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  569. confirmButtonText: "确定",
  570. cancelButtonText: "取消",
  571. type: "warning"
  572. }).then(() => {
  573. this.exportLoading = true;
  574. return exportCourseWatchLog(queryParams);
  575. }).then(response => {
  576. this.download(response.msg);
  577. this.exportLoading = false;
  578. }).catch(() => {
  579. });
  580. },
  581. openAnswerLogFun(row) {
  582. this.openAnswerLog = true;
  583. this.answerLogQueryParams.watchLogId = row.logId;
  584. this.answerLogList();
  585. },
  586. answerLogList() {
  587. this.loadingAnswerLog = true;
  588. myListLogs(this.answerLogQueryParams).then(e => {
  589. this.answerLogsList = e.rows;
  590. this.answerLogTotal = e.total;
  591. this.loadingAnswerLog = false;
  592. })
  593. },
  594. openRedLogFun(row) {
  595. this.openRedLog = true;
  596. this.redLogQueryParams.watchLogId = row.logId;
  597. this.redLogList();
  598. },
  599. redLogList() {
  600. this.loadingRedLog = true;
  601. console.info(this.redLogQueryParams)
  602. myListCourseRedPacketLog(this.redLogQueryParams).then(e => {
  603. this.redLogsList = e.rows;
  604. this.redLogTotal = e.total;
  605. this.loadingRedLog = false;
  606. })
  607. },
  608. }
  609. };
  610. </script>