deptWatchLog.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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="会员ID" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入会员ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="会员昵称" prop="nickName">
  14. <el-input
  15. v-model="queryParams.nickName"
  16. placeholder="请输入会员昵称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="企微客户昵称" prop="nickName" >
  23. <el-input
  24. v-model="queryParams.externalUserName"
  25. placeholder="请输入企微客户昵称"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="所属销售" prop="companyUserId">
  32. <el-select v-model="queryParams.companyUserId" clearable filterable remote
  33. placeholder="请输入关键词" :remote-method="loadCompanyUserOptions"
  34. v-select-load-more="loadMoreCompanyUserOptions"
  35. :loading="companyUserOptionsLoading">
  36. <el-option
  37. v-for="item in companyUserOptions"
  38. :key="item.value"
  39. :label="item.label"
  40. :value="item.value">
  41. </el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="课程" prop="courseId">
  45. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  46. <el-option
  47. v-for="dict in courseLists"
  48. :key="dict.dictValue"
  49. :label="dict.dictLabel"
  50. :value="dict.dictValue"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="小节" prop="videoId">
  55. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  56. <el-option
  57. v-for="dict in videoList"
  58. :key="dict.dictValue"
  59. :label="dict.dictLabel"
  60. :value="dict.dictValue"
  61. />
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="企微ID" prop="qwUserUserId">
  65. <el-input
  66. v-model="queryParams.qwUserUserId"
  67. placeholder="请输入所属企微ID"
  68. clearable
  69. size="small"
  70. @keyup.enter.native="handleQuery"
  71. />
  72. </el-form-item>
  73. <el-form-item label="企微员工名称" prop="qwUserName">
  74. <el-input
  75. v-model="queryParams.qwUserName"
  76. placeholder="请输入所属企微员工名称"
  77. clearable
  78. size="small"
  79. @keyup.enter.native="handleQuery"
  80. />
  81. </el-form-item>
  82. <!-- <el-form-item label="部门名称" prop="deptName">-->
  83. <!-- <el-input-->
  84. <!-- v-model="queryParams.deptName"-->
  85. <!-- placeholder="请输入部门名称"-->
  86. <!-- clearable-->
  87. <!-- size="small"-->
  88. <!-- @keyup.enter.native="handleQuery"-->
  89. <!-- />-->
  90. <!-- </el-form-item>-->
  91. <el-form-item label="营期时间" prop="scheduleTime">
  92. <el-date-picker
  93. v-model="scheduleTime"
  94. type="daterange"
  95. size="small"
  96. style="width: 240px"
  97. value-format="yyyy-MM-dd"
  98. range-separator="-"
  99. start-placeholder="开始日期"
  100. end-placeholder="结束日期"
  101. @change="handleScheduleTimeChange">
  102. </el-date-picker>
  103. </el-form-item>
  104. <el-form-item label="创建时间" prop="createTime">
  105. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  106. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="createChange"></el-date-picker>
  107. </el-form-item>
  108. <el-form-item label="最新更新时间" prop="updateTime">
  109. <el-date-picker v-model="updateTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  110. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="updateChange"></el-date-picker>
  111. </el-form-item>
  112. <el-form-item label="进线时间" prop="updateTime">
  113. <el-date-picker
  114. v-model="qecCreateTime"
  115. size="small"
  116. style="width: 220px"
  117. value-format="yyyy-MM-dd"
  118. type="daterange"
  119. range-separator="-"
  120. start-placeholder="开始日期"
  121. end-placeholder="结束日期"
  122. @change="qecCreateTimeChange"
  123. :picker-options="pickerOptions"
  124. ></el-date-picker>
  125. </el-form-item>
  126. <el-form-item>
  127. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  128. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  129. </el-form-item>
  130. </el-form>
  131. <!-- <el-row :gutter="10" class="mb8">-->
  132. <!-- <el-col :span="1.5">-->
  133. <!-- <el-button-->
  134. <!-- type="warning"-->
  135. <!-- plain-->
  136. <!-- icon="el-icon-download"-->
  137. <!-- size="mini"-->
  138. <!-- :loading="exportLoading"-->
  139. <!-- @click="handleExport"-->
  140. <!-- v-hasPermi="['course:courseWatchLog:export']"-->
  141. <!-- >导出</el-button>-->
  142. <!-- </el-col>-->
  143. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
  144. <!-- </el-row>-->
  145. <el-tabs type="card" v-model="activeName" @tab-click="handleClickX">
  146. <el-tab-pane label="全部" name="00"></el-tab-pane>
  147. <el-tab-pane v-for="(item,index) in logTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  148. </el-tabs>
  149. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange">
  150. <el-table-column type="selection" width="55" align="center" />
  151. <el-table-column label="记录编号" align="center" prop="logId" />
  152. <el-table-column label="企微客户" align="center" prop="externalUserName"/>
  153. <el-table-column label="客户头像" align="center" prop="externalUserAvatar">
  154. <template slot-scope="scope">
  155. <el-popover
  156. placement="right"
  157. trigger="hover">
  158. <img slot="reference" :src="scope.row.externalUserAvatar" style="width: 40px;height: 40px">
  159. <img :src="scope.row.externalUserAvatar" style="max-width: 250px;max-height: 250px">
  160. </el-popover>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="会员ID" align="center" prop="userId" />
  164. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  165. <template slot-scope="scope">
  166. <div style="display: flex;white-space: nowrap">
  167. <div style="margin: auto">
  168. {{scope.row.fsNickName}}
  169. </div>
  170. <el-popover
  171. placement="right"
  172. title=""
  173. trigger="hover">
  174. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  175. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  176. </el-popover>
  177. </div>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="课程名称" align="center" prop="courseName" />
  181. <el-table-column label="小节名称" align="center" prop="videoName" />
  182. <el-table-column label="记录类型" align="center" prop="logType">
  183. <template slot-scope="scope">
  184. <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="播放时长" align="center" prop="duration" />
  188. <el-table-column label="所属销售" align="center" prop="companyUserName" />
  189. <!-- <el-table-column label="所属公司" align="center" prop="companyName" />-->
  190. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  191. <!-- <el-table-column label="所属发送方式" align="center" prop="sendType" />-->
  192. <el-table-column label="创建时间" align="center" prop="createTime" />
  193. <el-table-column label="更新时间" align="center" prop="updateTime" />
  194. <el-table-column label="完课时间" align="center" prop="finishTime" />
  195. <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
  196. <el-table-column label="进线时间" align="center" prop="qecCreateTime" />
  197. </el-table>
  198. <pagination
  199. v-show="total>0"
  200. :total="total"
  201. :page.sync="queryParams.pageNum"
  202. :limit.sync="queryParams.pageSize"
  203. @pagination="getList"
  204. />
  205. </div>
  206. </template>
  207. <script>
  208. import { deptListCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog } from "@/api/course/courseWatchLog";
  209. import { courseList,videoList } from '../../../api/course/courseRedPacketLog'
  210. import { getCompanyUserListLikeName } from "@/api/company/companyUser";
  211. import {getTask} from "@/api/common";
  212. export default {
  213. name: "CourseWatchLog",
  214. data() {
  215. return {
  216. activeName:"00",
  217. createTime:null,
  218. updateTime:null,
  219. courseLists:[],
  220. videoList:[],
  221. logTypeOptions:[],
  222. // 遮罩层
  223. loading: true,
  224. // 导出遮罩层
  225. exportLoading: false,
  226. // 选中数组
  227. ids: [],
  228. // 非单个禁用
  229. single: true,
  230. // 非多个禁用
  231. multiple: true,
  232. // 显示搜索条件
  233. showSearch: true,
  234. // 总条数
  235. total: 0,
  236. // 短链课程看课记录表格数据
  237. courseWatchLogList: [],
  238. // 弹出层标题
  239. title: "",
  240. // 是否显示弹出层
  241. open: false,
  242. qecCreateTime:null,
  243. pickerOptions: {
  244. disabledDate(time) {
  245. // 获取6天前的日期(加上今天就是7天)
  246. const sixDaysAgo = new Date();
  247. sixDaysAgo.setDate(sixDaysAgo.getDate() - 6);
  248. sixDaysAgo.setHours(0, 0, 0, 0);
  249. // 获取明天的日期(不包括今天)
  250. const tomorrow = new Date();
  251. tomorrow.setDate(tomorrow.getDate() + 1);
  252. tomorrow.setHours(0, 0, 0, 0);
  253. return time.getTime() < sixDaysAgo.getTime() || time.getTime() >= tomorrow.getTime();
  254. }
  255. },
  256. // 查询参数
  257. queryParams: {
  258. pageNum: 1,
  259. pageSize: 10,
  260. userId: null,
  261. nickName: null,
  262. videoId: null,
  263. logType: null,
  264. qwExternalContactId: null,
  265. externalUserName:null,
  266. duration: null,
  267. qwUserId: null,
  268. qwUserName: null, //企微名称
  269. qwUserUserId: null, //企微id
  270. deptName: null, //部门名称
  271. companyUserId: null,
  272. companyId: null,
  273. courseId: null,
  274. sTime:null,
  275. eTime:null,
  276. upSTime:null,
  277. upETime:null,
  278. qecSTime:null,
  279. qecETime:null,
  280. scheduleStartTime: null,
  281. scheduleEndTime: null,
  282. },
  283. // 表单参数
  284. form: {},
  285. // 表单校验
  286. rules: {
  287. },
  288. scheduleTime: null,
  289. // 员工选项列表
  290. companyUserOptionsParams: {
  291. name: undefined,
  292. hasNextPage: false,
  293. pageNum: 1,
  294. pageSize: 10
  295. },
  296. companyUserOptionsLoading: false,
  297. companyUserOptions: [],
  298. };
  299. },
  300. created() {
  301. courseList().then(response => {
  302. this.courseLists = response.list;
  303. });
  304. this.getList();
  305. this.getDicts("sys_course_watch_log_type").then(response => {
  306. this.logTypeOptions = response.data;
  307. });
  308. },
  309. methods: {
  310. courseChange(row){
  311. this.queryParams.videoId=null;
  312. if(row === ''){
  313. this.videoList=[];
  314. return
  315. }
  316. videoList(row).then(response => {
  317. this.videoList=response.list
  318. });
  319. },
  320. createChange() {
  321. if (this.createTime != null) {
  322. this.queryParams.sTime = this.createTime[0];
  323. this.queryParams.eTime = this.createTime[1];
  324. } else {
  325. this.queryParams.sTime = null;
  326. this.queryParams.eTime = null;
  327. }
  328. },
  329. updateChange(){
  330. if (this.updateTime != null) {
  331. this.queryParams.upSTime = this.updateTime[0];
  332. this.queryParams.upETime = this.updateTime[1];
  333. } else {
  334. this.queryParams.upSTime = null;
  335. this.queryParams.upETime = null;
  336. }
  337. },
  338. qecCreateTimeChange(){
  339. if (this.qecCreateTime != null) {
  340. this.queryParams.qecSTime = this.qecCreateTime[0];
  341. this.queryParams.qecETime = this.qecCreateTime[1];
  342. } else {
  343. this.queryParams.qecSTime = null;
  344. this.queryParams.qecETime = null;
  345. }
  346. },
  347. handleClickX(tab,event){
  348. this.activeName=tab.name;
  349. if(tab.name=="00"){
  350. this.queryParams.logType=null;
  351. }else{
  352. this.queryParams.logType=tab.name;
  353. }
  354. this.getList()
  355. },
  356. /** 查询短链课程看课记录列表 */
  357. getList() {
  358. this.loading = true;
  359. if(this.queryParams.logType == "10"){
  360. this.queryParams.logType = null;
  361. }
  362. deptListCourseWatchLog(this.queryParams).then(response => {
  363. this.courseWatchLogList = response.rows;
  364. this.total = response.total;
  365. this.loading = false;
  366. });
  367. },
  368. // 取消按钮
  369. cancel() {
  370. this.open = false;
  371. this.reset();
  372. },
  373. // 表单重置
  374. reset() {
  375. this.form = {
  376. logId: null,
  377. userId: null,
  378. videoId: null,
  379. logType: null,
  380. createTime: null,
  381. updateTime: null,
  382. qwExternalContactId: null,
  383. externalUserName:null,
  384. duration: null,
  385. qwUserId: null,
  386. companyUserId: null,
  387. companyId: null,
  388. courseId: null,
  389. scheduleStartTime: null,
  390. scheduleEndTime: null,
  391. };
  392. this.scheduleTime=null;
  393. this.resetForm("form");
  394. },
  395. /** 搜索按钮操作 */
  396. handleQuery() {
  397. this.queryParams.pageNum = 1;
  398. this.getList();
  399. },
  400. /** 重置按钮操作 */
  401. resetQuery() {
  402. this.resetForm("queryForm");
  403. this.createTime = null;
  404. this.scheduleTime = null;
  405. this.qecCreateTime=null;
  406. this.queryParams.sTime = null;
  407. this.queryParams.eTime = null;
  408. this.queryParams.upSTime = null;
  409. this.queryParams.upETime = null;
  410. this.queryParams.qecSTime = null;
  411. this.queryParams.qecETime = null;
  412. this.queryParams.scheduleStartTime = null;
  413. this.queryParams.scheduleEndTime = null;
  414. this.scheduleTime=null;
  415. this.updateTime=null;
  416. this.handleQuery();
  417. },
  418. // 多选框选中数据
  419. handleSelectionChange(selection) {
  420. this.ids = selection.map(item => item.logId)
  421. this.single = selection.length!==1
  422. this.multiple = !selection.length
  423. },
  424. /** 新增按钮操作 */
  425. handleAdd() {
  426. this.reset();
  427. this.open = true;
  428. this.title = "添加短链课程看课记录";
  429. },
  430. /** 修改按钮操作 */
  431. handleUpdate(row) {
  432. this.reset();
  433. const logId = row.logId || this.ids
  434. getCourseWatchLog(logId).then(response => {
  435. this.form = response.data;
  436. this.open = true;
  437. this.title = "修改短链课程看课记录";
  438. });
  439. },
  440. /** 提交按钮 */
  441. submitForm() {
  442. this.$refs["form"].validate(valid => {
  443. if (valid) {
  444. if (this.form.logId != null) {
  445. updateCourseWatchLog(this.form).then(response => {
  446. this.msgSuccess("修改成功");
  447. this.open = false;
  448. this.getList();
  449. });
  450. } else {
  451. addCourseWatchLog(this.form).then(response => {
  452. this.msgSuccess("新增成功");
  453. this.open = false;
  454. this.getList();
  455. });
  456. }
  457. }
  458. });
  459. },
  460. /** 删除按钮操作 */
  461. handleDelete(row) {
  462. const logIds = row.logId || this.ids;
  463. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  464. confirmButtonText: "确定",
  465. cancelButtonText: "取消",
  466. type: "warning"
  467. }).then(function() {
  468. return delCourseWatchLog(logIds);
  469. }).then(() => {
  470. this.getList();
  471. this.msgSuccess("删除成功");
  472. }).catch(() => {});
  473. },
  474. /** 导出按钮操作 */
  475. handleExport() {
  476. const that = this
  477. const queryParams = this.queryParams;
  478. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  479. confirmButtonText: "确定",
  480. cancelButtonText: "取消",
  481. type: "warning"
  482. }).then(() => {
  483. this.exportLoading = true;
  484. return exportCourseWatchLog(queryParams);
  485. }).then(response => {
  486. if (response.code === 200){
  487. that.msgSuccess(response.msg);
  488. that.taskId = response.data;
  489. that.time = setInterval(function(){
  490. //查订单
  491. getTask(that.taskId).then(res => {
  492. if(res.data.status === 1){
  493. that.exportLoading = false;
  494. clearTimeout(that.time)
  495. that.time = null;
  496. that.download(res.data.fileUrl);
  497. }
  498. });
  499. },10000);
  500. } else {
  501. that.msgError(response.msg)
  502. that.exportLoading = false
  503. }
  504. }).catch(() => {});
  505. },
  506. handleScheduleTimeChange(val) {
  507. if (val) {
  508. this.queryParams.scheduleStartTime = val[0];
  509. this.queryParams.scheduleEndTime = val[1];
  510. } else {
  511. this.queryParams.scheduleStartTime = null;
  512. this.queryParams.scheduleEndTime = null;
  513. }
  514. },
  515. /**
  516. * 根据名称模糊查询用户列表
  517. * @param query 参数
  518. */
  519. loadCompanyUserOptions(query) {
  520. this.companyUserOptions = [];
  521. if (query === '') {
  522. return;
  523. }
  524. this.companyUserOptionsParams.pageNum = 1
  525. this.companyUserOptionsParams.name = query
  526. this.companyUserOptionsLoading = true;
  527. this.getCompanyUserListLikeName()
  528. },
  529. /**
  530. * 获取员工列表
  531. */
  532. getCompanyUserListLikeName() {
  533. getCompanyUserListLikeName(this.companyUserOptionsParams).then(response => {
  534. this.companyUserOptions = [...this.companyUserOptions, ...response.data.list]
  535. this.companyUserOptionsParams.hasNextPage = response.data.hasNextPage
  536. this.companyUserOptionsLoading = false;
  537. });
  538. },
  539. /**
  540. * 加载更多员工选项
  541. */
  542. loadMoreCompanyUserOptions() {
  543. if (!this.companyUserOptionsParams.hasNextPage) {
  544. return;
  545. }
  546. this.companyUserOptionsParams.pageNum += 1
  547. this.getCompanyUserListLikeName()
  548. },
  549. }
  550. };
  551. </script>