index.vue 15 KB

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