index.vue 15 KB

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