index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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="courseId">
  5. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  6. <el-option
  7. v-for="dict in courseLists"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="小节" prop="videoId">
  15. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  16. <el-option
  17. v-for="dict in videoList"
  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="scheduleTime">
  25. <el-date-picker
  26. v-model="scheduleTime"
  27. type="daterange"
  28. size="small"
  29. style="width: 240px"
  30. value-format="yyyy-MM-dd"
  31. range-separator="-"
  32. start-placeholder="开始日期"
  33. end-placeholder="结束日期"
  34. @change="handleScheduleTimeChange">
  35. </el-date-picker>
  36. </el-form-item>
  37. <el-form-item label="创建时间" prop="createTime">
  38. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  39. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="createChange"></el-date-picker>
  40. </el-form-item>
  41. <el-form-item label="最新更新时间" prop="updateTime">
  42. <el-date-picker v-model="updateTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  43. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="updateChange"></el-date-picker>
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  47. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  48. </el-form-item>
  49. </el-form>
  50. <el-row :gutter="10" class="mb8">
  51. <el-col :span="1.5">
  52. <el-button
  53. type="warning"
  54. plain
  55. icon="el-icon-download"
  56. size="mini"
  57. :loading="exportLoading"
  58. @click="handleExport"
  59. v-hasPermi="['course:courseWatchLog:export']"
  60. >导出</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  63. </el-row>
  64. <el-tabs type="card" v-model="activeName" @tab-click="handleClickX">
  65. <el-tab-pane label="全部" name="00"></el-tab-pane>
  66. <el-tab-pane v-for="(item,index) in logTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  67. </el-tabs>
  68. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange">
  69. <el-table-column type="selection" width="55" align="center" />
  70. <el-table-column label="记录编号" align="center" prop="logId" />
  71. <el-table-column label="用户账号" align="center" prop="qwUserName" />
  72. <el-table-column label="企微客户" align="center" prop="externalUserName">
  73. <template slot-scope="scope">
  74. <div style="display: flex;white-space: nowrap">
  75. <div style="margin: auto">
  76. {{scope.row.externalUserName}}
  77. </div>
  78. <el-popover
  79. placement="right"
  80. title=""
  81. trigger="hover">
  82. <img slot="reference" :src="scope.row.externalUserAvatar" style="width: 30px;height: 30px">
  83. <img :src="scope.row.externalUserAvatar" style="max-width: 200px;max-height: 200px">
  84. </el-popover>
  85. </div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  89. <template slot-scope="scope">
  90. <div style="display: flex;white-space: nowrap">
  91. <div style="margin: auto">
  92. {{scope.row.fsNickName}}
  93. </div>
  94. <el-popover
  95. placement="right"
  96. title=""
  97. trigger="hover">
  98. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  99. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  100. </el-popover>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="项目" align="center" prop="projectName" />
  105. <el-table-column label="课程名称" align="center" prop="courseName" />
  106. <el-table-column label="小节名称" align="center" prop="videoName" />
  107. <el-table-column label="企微员工名称" align="center" prop="qwUserName" v-if="queryParams.sourceType == 2"/>
  108. <el-table-column label="记录类型" align="center" prop="logType">
  109. <template slot-scope="scope">
  110. <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="播放时长" align="center" prop="duration" />
  114. <el-table-column label="所属销售" align="center" prop="companyUserName" />
  115. <!-- <el-table-column label="所属公司" align="center" prop="companyName" />-->
  116. <!-- <el-table-column label="企微员工名称" align="center" prop="qwUserName" />-->
  117. <el-table-column label="所属发送方式" align="center" prop="sendType" />
  118. <el-table-column label="创建时间" align="center" prop="createTime" />
  119. <el-table-column label="更新时间" align="center" prop="updateTime" />
  120. <el-table-column label="完课时间" align="center" prop="finishTime" />
  121. <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
  122. </el-table>
  123. <pagination
  124. v-show="total>0"
  125. :total="total"
  126. :page.sync="queryParams.pageNum"
  127. :limit.sync="queryParams.pageSize"
  128. @pagination="getList"
  129. />
  130. </div>
  131. </template>
  132. <script>
  133. import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog } from "@/api/course/courseWatchLog";
  134. import {allList}from "@/api/company/company";
  135. import { courseList,videoList } from '@/api/course/courseRedPacketLog'
  136. import {getUserList} from "@/api/company/companyUser";
  137. import {getFsUserList} from "@/api/users/user";
  138. export default {
  139. name: "CourseWatchLog",
  140. data() {
  141. return {
  142. userSourceTypeOptions: [],
  143. activeName:"00",
  144. createTime:null,
  145. updateTime:null,
  146. courseLists:[],
  147. videoList:[],
  148. logTypeOptions:[],
  149. queryUserLoading: false,
  150. // 遮罩层
  151. loading: true,
  152. // 导出遮罩层
  153. exportLoading: false,
  154. // 选中数组
  155. ids: [],
  156. // 非单个禁用
  157. single: true,
  158. // 非多个禁用
  159. multiple: true,
  160. // 显示搜索条件
  161. showSearch: true,
  162. // 总条数
  163. total: 0,
  164. companyUserList: [],
  165. // 短链课程看课记录表格数据
  166. courseWatchLogList: [],
  167. fsUserList: [],
  168. // 弹出层标题
  169. title: "",
  170. // 是否显示弹出层
  171. open: false,
  172. // 查询参数
  173. queryParams: {
  174. pageNum: 1,
  175. pageSize: 10,
  176. userId: null,
  177. nickName: null,
  178. videoId: null,
  179. logType: null,
  180. qwExternalContactId: null,
  181. externalUserName:null,
  182. duration: null,
  183. qwUserId: null,
  184. companyUserId: null,
  185. companyId: null,
  186. courseId: null,
  187. sTime:null,
  188. eTime:null,
  189. upSTime:null,
  190. upETime:null,
  191. scheduleStartTime: null,
  192. scheduleEndTime: null,
  193. sourceType: 1
  194. },
  195. // 表单参数
  196. form: {},
  197. // 表单校验
  198. rules: {
  199. },
  200. scheduleTime: null,
  201. };
  202. },
  203. created() {
  204. courseList().then(response => {
  205. this.courseLists = response.list;
  206. });
  207. this.getList();
  208. this.getDicts("sys_course_watch_log_type").then(response => {
  209. this.logTypeOptions = response.data;
  210. });
  211. this.getDicts('user_source_type').then(response => {
  212. this.userSourceTypeOptions = response.data;
  213. })
  214. },
  215. computed: {
  216. sourceTypeModel: {
  217. get() {
  218. return this.queryParams.sourceType !== null && this.queryParams.sourceType !== undefined ? this.queryParams.sourceType.toString() : null;
  219. },
  220. set(newVal) {
  221. this.queryParams.sourceType = newVal;
  222. }
  223. }
  224. },
  225. methods: {
  226. handleClear(){
  227. this.queryUserLoading = false;
  228. this.fsUserList = [];
  229. },
  230. remoteGetFsUserList(query){
  231. if(query){
  232. this.queryUserLoading = true;
  233. const isNumeric = /^\d+$/.test(query);
  234. let payload = {
  235. username: query,
  236. nickname: query
  237. }
  238. if(isNumeric) {
  239. payload = {
  240. userId: query,
  241. username: query,
  242. phone: query
  243. }
  244. }
  245. getFsUserList(payload).then(res=>{
  246. if(res.code === 200) {
  247. this.fsUserList = res.data
  248. }
  249. }).finally(()=>{
  250. this.queryUserLoading = false;
  251. })
  252. }
  253. },
  254. courseChange(row){
  255. this.queryParams.videoId=null;
  256. if(row === ''){
  257. this.videoList=[];
  258. return
  259. }
  260. videoList(row).then(response => {
  261. this.videoList=response.list
  262. });
  263. },
  264. createChange() {
  265. if (this.createTime != null) {
  266. this.queryParams.sTime = this.createTime[0];
  267. this.queryParams.eTime = this.createTime[1];
  268. } else {
  269. this.queryParams.sTime = null;
  270. this.queryParams.eTime = null;
  271. }
  272. },
  273. updateChange(){
  274. if (this.updateTime != null) {
  275. this.queryParams.upSTime = this.updateTime[0];
  276. this.queryParams.upETime = this.updateTime[1];
  277. } else {
  278. this.queryParams.upSTime = null;
  279. this.queryParams.upETime = null;
  280. }
  281. },
  282. handleClickX(tab,event){
  283. this.activeName=tab.name;
  284. if(tab.name=="00"){
  285. this.queryParams.logType=null;
  286. }else{
  287. this.queryParams.logType=tab.name;
  288. }
  289. this.getList()
  290. },
  291. /** 查询短链课程看课记录列表 */
  292. getList() {
  293. this.loading = true;
  294. if(this.queryParams.logType == "10"){
  295. this.queryParams.logType = null;
  296. }
  297. listCourseWatchLog(this.queryParams).then(response => {
  298. this.courseWatchLogList = response.rows;
  299. this.total = response.total;
  300. this.loading = false;
  301. });
  302. },
  303. // 取消按钮
  304. cancel() {
  305. this.open = false;
  306. this.reset();
  307. },
  308. // 表单重置
  309. reset() {
  310. this.form = {
  311. logId: null,
  312. userId: null,
  313. videoId: null,
  314. logType: null,
  315. createTime: null,
  316. updateTime: null,
  317. qwExternalContactId: null,
  318. externalUserName:null,
  319. duration: null,
  320. qwUserId: null,
  321. companyUserId: null,
  322. companyId: null,
  323. courseId: null,
  324. scheduleStartTime: null,
  325. scheduleEndTime: null,
  326. };
  327. this.scheduleTime=null;
  328. this.resetForm("form");
  329. },
  330. /** 搜索按钮操作 */
  331. handleQuery() {
  332. this.queryParams.pageNum = 1;
  333. this.getList();
  334. },
  335. /** 重置按钮操作 */
  336. resetQuery() {
  337. this.resetForm("queryForm");
  338. this.createTime = null;
  339. this.scheduleTime = null;
  340. this.queryParams.sTime = null;
  341. this.queryParams.eTime = null;
  342. this.queryParams.upSTime = null;
  343. this.queryParams.upETime = null;
  344. this.queryParams.scheduleStartTime = null;
  345. this.queryParams.scheduleEndTime = null;
  346. this.scheduleTime=null;
  347. this.updateTime=null;
  348. this.handleQuery();
  349. },
  350. // 多选框选中数据
  351. handleSelectionChange(selection) {
  352. this.ids = selection.map(item => item.logId)
  353. this.single = selection.length!==1
  354. this.multiple = !selection.length
  355. },
  356. /** 新增按钮操作 */
  357. handleAdd() {
  358. this.reset();
  359. this.open = true;
  360. this.title = "添加短链课程看课记录";
  361. },
  362. /** 修改按钮操作 */
  363. handleUpdate(row) {
  364. this.reset();
  365. const logId = row.logId || this.ids
  366. getCourseWatchLog(logId).then(response => {
  367. this.form = response.data;
  368. this.open = true;
  369. this.title = "修改短链课程看课记录";
  370. });
  371. },
  372. /** 提交按钮 */
  373. submitForm() {
  374. this.$refs["form"].validate(valid => {
  375. if (valid) {
  376. if (this.form.logId != null) {
  377. updateCourseWatchLog(this.form).then(response => {
  378. this.msgSuccess("修改成功");
  379. this.open = false;
  380. this.getList();
  381. });
  382. } else {
  383. addCourseWatchLog(this.form).then(response => {
  384. this.msgSuccess("新增成功");
  385. this.open = false;
  386. this.getList();
  387. });
  388. }
  389. }
  390. });
  391. },
  392. /** 删除按钮操作 */
  393. handleDelete(row) {
  394. const logIds = row.logId || this.ids;
  395. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  396. confirmButtonText: "确定",
  397. cancelButtonText: "取消",
  398. type: "warning"
  399. }).then(function() {
  400. return delCourseWatchLog(logIds);
  401. }).then(() => {
  402. this.getList();
  403. this.msgSuccess("删除成功");
  404. }).catch(() => {});
  405. },
  406. /** 导出按钮操作 */
  407. handleExport() {
  408. const queryParams = this.queryParams;
  409. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  410. confirmButtonText: "确定",
  411. cancelButtonText: "取消",
  412. type: "warning"
  413. }).then(() => {
  414. this.exportLoading = true;
  415. return exportCourseWatchLog(queryParams);
  416. }).then(response => {
  417. this.download(response.msg);
  418. this.exportLoading = false;
  419. }).catch(() => {});
  420. },
  421. handleScheduleTimeChange(val) {
  422. if (val) {
  423. this.queryParams.scheduleStartTime = val[0];
  424. this.queryParams.scheduleEndTime = val[1];
  425. } else {
  426. this.queryParams.scheduleStartTime = null;
  427. this.queryParams.scheduleEndTime = null;
  428. }
  429. },
  430. }
  431. };
  432. </script>