index.vue 16 KB

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