index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="搜索" prop="keywords">
  5. <el-input
  6. v-model="queryParams.keywords"
  7. placeholder="请输入用户昵称/课程名称/视频名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. style="width: 280px"
  12. />
  13. </el-form-item>
  14. <el-form-item label="状态" prop="status">
  15. <el-select
  16. v-model="queryParams.status"
  17. placeholder="操作状态"
  18. clearable
  19. size="small"
  20. style="width: 240px"
  21. >
  22. <el-option
  23. v-for="dict in statusOptions"
  24. :key="dict.dictValue"
  25. :label="dict.dictLabel"
  26. :value="dict.dictValue"
  27. />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-row :gutter="10" class="mb8">
  36. <!-- <el-col :span="1.5">-->
  37. <!-- <el-button-->
  38. <!-- type="primary"-->
  39. <!-- plain-->
  40. <!-- icon="el-icon-plus"-->
  41. <!-- size="mini"-->
  42. <!-- @click="handleAdd"-->
  43. <!-- v-hasPermi="['course:courseWatchComment:add']"-->
  44. <!-- >新增</el-button>-->
  45. <!-- </el-col>-->
  46. <!-- <el-col :span="1.5">-->
  47. <!-- <el-button-->
  48. <!-- type="success"-->
  49. <!-- plain-->
  50. <!-- icon="el-icon-edit"-->
  51. <!-- size="mini"-->
  52. <!-- :disabled="single"-->
  53. <!-- @click="handleUpdate"-->
  54. <!-- v-hasPermi="['course:courseWatchComment:edit']"-->
  55. <!-- >修改</el-button>-->
  56. <!-- </el-col>-->
  57. <el-col :span="1.5">
  58. <el-button
  59. type="danger"
  60. plain
  61. icon="el-icon-delete"
  62. size="mini"
  63. :disabled="multiple"
  64. @click="handleDelete"
  65. v-hasPermi="['course:courseWatchComment:remove']"
  66. >删除</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="warning"
  71. plain
  72. icon="el-icon-download"
  73. size="mini"
  74. :loading="exportLoading"
  75. @click="handleExport"
  76. v-hasPermi="['course:courseWatchComment:export']"
  77. >导出</el-button>
  78. </el-col>
  79. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  80. </el-row>
  81. <el-table border v-loading="loading" :data="courseWatchCommentList" @selection-change="handleSelectionChange">
  82. <el-table-column type="selection" width="55" align="center" />
  83. <!-- <el-table-column label="评论id" align="center" prop="commentId" />-->
  84. <!-- <el-table-column label="用户id" align="center" prop="userId" />-->
  85. <el-table-column label="用户昵称" align="center" prop="nickName" width="130px" />
  86. <!-- <el-table-column label="用户类型,1-管理员,2-用户" align="center" prop="userType" />-->
  87. <!-- <el-table-column label="评论类型 1:评论,2:回复" align="center" prop="type" />-->
  88. <!-- <el-table-column label="父评论id" align="center" prop="parentId" />-->
  89. <el-table-column label="评论内容" align="center" prop="content" />
  90. <el-table-column label="所属课程" align="center" prop="courseName" />
  91. <el-table-column label="所属小节" align="center" prop="title" />
  92. <el-table-column label="弹幕状态" align="center" prop="status">
  93. <template slot-scope="scope">
  94. <el-tag :type="getStatusTagType(scope.row.status)">
  95. {{ formatBarrageStatus(scope.row.status) }}
  96. </el-tag>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="评论时间" align="center" prop="createTime" width="160px"/>
  100. <!-- <el-table-column label="是否是撤回的消息,1-是,0-否" align="center" prop="isRevoke" />-->
  101. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  102. <template slot-scope="scope">
  103. <!-- <el-button-->
  104. <!-- size="mini"-->
  105. <!-- type="text"-->
  106. <!-- icon="el-icon-edit"-->
  107. <!-- @click="handleUpdate(scope.row)"-->
  108. <!-- v-hasPermi="['course:courseWatchComment:edit']"-->
  109. <!-- >修改</el-button>-->
  110. <el-button
  111. size="mini"
  112. type="text"
  113. icon="el-icon-edit"
  114. @click="handleUpdateStatus(scope.row)"
  115. >修改弹幕状态</el-button>
  116. <el-button
  117. size="mini"
  118. type="text"
  119. icon="el-icon-edit"
  120. @click="handleAddKeyWords(scope.row)"
  121. >添加关键字</el-button>
  122. <el-button
  123. v-if="scope.row.userStatus === 1 "
  124. size="mini"
  125. type="text"
  126. icon="el-icon-edit"
  127. @click="handleAddBlack(scope.row)"
  128. >拉黑</el-button>
  129. <el-button
  130. v-if="scope.row.userStatus === 0 "
  131. size="mini"
  132. type="text"
  133. icon="el-icon-edit"
  134. @click="handleClearBlack(scope.row)"
  135. >解除拉黑</el-button>
  136. <el-button
  137. size="mini"
  138. type="text"
  139. icon="el-icon-delete"
  140. @click="handleDelete(scope.row)"
  141. v-hasPermi="['course:courseWatchComment:remove']"
  142. >删除</el-button>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <pagination
  147. v-show="total>0"
  148. :total="total"
  149. :page.sync="queryParams.pageNum"
  150. :limit.sync="queryParams.pageSize"
  151. @pagination="getList"
  152. />
  153. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  154. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  155. <el-form-item label="关键字" prop="keyword">
  156. <el-input v-model="form.keyword" placeholder="请输入关键字" />
  157. </el-form-item>
  158. </el-form>
  159. <div slot="footer" class="dialog-footer">
  160. <el-button type="primary" @click="submitForm">确 定</el-button>
  161. <el-button @click="cancel">取 消</el-button>
  162. </div>
  163. </el-dialog>
  164. <el-dialog :title="title" :visible.sync="updateStatus" width="500px" append-to-body>
  165. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  166. <el-form-item label="弹幕状态" prop="barrageStatus">
  167. <el-radio-group v-model="form.status">
  168. <el-radio
  169. v-for="dict in barrageStatusOptions"
  170. :key="dict.dictValue"
  171. :label="dict.dictValue"
  172. v-if="dict.dictValue !== 2"
  173. >
  174. <el-tag :type="getStatusTagType(dict.dictValue)" size="small">
  175. {{dict.dictLabel}}
  176. </el-tag>
  177. </el-radio>
  178. </el-radio-group>
  179. </el-form-item>
  180. </el-form>
  181. <div slot="footer" class="dialog-footer">
  182. <el-button type="primary" @click="updateForm">确 定</el-button>
  183. <el-button @click="cancel">取 消</el-button>
  184. </div>
  185. </el-dialog>
  186. <!-- &lt;!&ndash; 添加或修改看课评论对话框 &ndash;&gt;-->
  187. <!-- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>-->
  188. <!-- <el-form ref="form" :model="form" :rules="rules" label-width="80px">-->
  189. <!-- <el-form-item label="用户id" prop="userId">-->
  190. <!-- <el-input v-model="form.userId" placeholder="请输入用户id" />-->
  191. <!-- </el-form-item>-->
  192. <!-- <el-form-item label="用户类型,1-管理员,2-用户" prop="userType">-->
  193. <!-- <el-select v-model="form.userType" placeholder="请选择用户类型,1-管理员,2-用户">-->
  194. <!-- <el-option label="请选择字典生成" value="" />-->
  195. <!-- </el-select>-->
  196. <!-- </el-form-item>-->
  197. <!-- <el-form-item label="课程id" prop="courseId">-->
  198. <!-- <el-input v-model="form.courseId" placeholder="请输入课程id" />-->
  199. <!-- </el-form-item>-->
  200. <!-- <el-form-item label="视频id" prop="videoId">-->
  201. <!-- <el-input v-model="form.videoId" placeholder="请输入视频id" />-->
  202. <!-- </el-form-item>-->
  203. <!-- <el-form-item label="评论类型 1:评论,2:回复" prop="type">-->
  204. <!-- <el-select v-model="form.type" placeholder="请选择评论类型 1:评论,2:回复">-->
  205. <!-- <el-option label="请选择字典生成" value="" />-->
  206. <!-- </el-select>-->
  207. <!-- </el-form-item>-->
  208. <!-- <el-form-item label="父评论id" prop="parentId">-->
  209. <!-- <el-input v-model="form.parentId" placeholder="请输入父评论id" />-->
  210. <!-- </el-form-item>-->
  211. <!-- <el-form-item label="评论内容" prop="content">-->
  212. <!-- <el-input v-model="form.content" type="textarea" placeholder="请输入内容" />-->
  213. <!-- </el-form-item>-->
  214. <!-- <el-form-item label="是否是撤回的消息,1-是,0-否" prop="isRevoke">-->
  215. <!-- <el-select v-model="form.isRevoke" placeholder="请选择是否是撤回的消息,1-是,0-否">-->
  216. <!-- <el-option label="请选择字典生成" value="" />-->
  217. <!-- </el-select>-->
  218. <!-- </el-form-item>-->
  219. <!-- </el-form>-->
  220. <!-- <div slot="footer" class="dialog-footer">-->
  221. <!-- <el-button type="primary" @click="submitForm">确 定</el-button>-->
  222. <!-- <el-button @click="cancel">取 消</el-button>-->
  223. <!-- </div>-->
  224. <!-- </el-dialog>-->
  225. </div>
  226. </template>
  227. <script>
  228. import { listCourseWatchComment, delCourseWatchComment, exportCourseWatchComment, addBlack,clearBlack,updateBarrageStatus } from "@/api/course/courseWatchComment";
  229. import { addKeyword } from "@/api/system/keyword";
  230. export default {
  231. name: "CourseWatchComment",
  232. data() {
  233. return {
  234. // 弹幕状态选项
  235. barrageStatusOptions: [
  236. { dictValue: 0, dictLabel: "正常" },
  237. { dictValue: 1, dictLabel: "屏蔽" },
  238. { dictValue: 2, dictLabel: "人工" }
  239. ],
  240. // 遮罩层
  241. loading: true,
  242. // 导出遮罩层
  243. exportLoading: false,
  244. // 选中数组
  245. ids: [],
  246. // 非单个禁用
  247. single: true,
  248. // 非多个禁用
  249. multiple: true,
  250. // 显示搜索条件
  251. showSearch: true,
  252. // 总条数
  253. total: 0,
  254. // 看课评论表格数据
  255. courseWatchCommentList: [],
  256. //下拉状态
  257. statusOptions:[],
  258. // 弹出层标题
  259. title: "",
  260. // 是否显示弹出层
  261. open: false,
  262. updateStatus: false,
  263. // 查询参数
  264. queryParams: {
  265. pageNum: 1,
  266. pageSize: 10,
  267. keywords: null,
  268. isAll: true, //判断是否属于全局查询
  269. status: '',
  270. userStatus: '',
  271. // userId: null,
  272. // userType: null,
  273. // courseId: null,
  274. // videoId: null,
  275. // type: null,
  276. // parentId: null,
  277. // content: null,
  278. // isRevoke: null
  279. },
  280. // 表单参数
  281. form: {},
  282. // 表单校验
  283. rules: {
  284. keyword: [
  285. { required: true, message: "关键字不能为空", trigger: "blur" }
  286. ]
  287. }
  288. };
  289. },
  290. created() {
  291. this.getDicts("sys_barrage_clean_type").then((response) => {
  292. this.statusOptions = response.data;
  293. });
  294. this.getList();
  295. },
  296. methods: {
  297. /** 查询看课评论列表 */
  298. getList() {
  299. this.loading = true;
  300. listCourseWatchComment(this.queryParams).then(response => {
  301. this.courseWatchCommentList = response.rows.list;
  302. this.total = response.rows.total;
  303. this.loading = false;
  304. });
  305. },
  306. // 获取状态标签类型
  307. getStatusTagType(status) {
  308. switch(status) {
  309. case 0: return 'success';
  310. case 1: return 'danger';
  311. case 2: return 'primary';
  312. default: return 'info';
  313. }
  314. },
  315. // 格式化状态显示
  316. formatBarrageStatus(status) {
  317. const dict = this.barrageStatusOptions.find(item => item.dictValue === status);
  318. return dict ? dict.dictLabel : status;
  319. },
  320. // 取消按钮
  321. cancel() {
  322. this.open = false;
  323. this.updateStatus = false;
  324. this.reset();
  325. },
  326. // 表单重置
  327. reset() {
  328. this.form = {
  329. commentId: null,
  330. userId: null,
  331. userType: null,
  332. courseId: null,
  333. videoId: null,
  334. type: null,
  335. parentId: null,
  336. content: null,
  337. createTime: null,
  338. updateTime: null,
  339. isRevoke: null,
  340. keyword: null,
  341. status: '',
  342. userStatus: ''
  343. };
  344. this.resetForm("form");
  345. },
  346. /** 搜索按钮操作 */
  347. handleQuery() {
  348. this.queryParams.pageNum = 1;
  349. this.getList();
  350. },
  351. /** 重置按钮操作 */
  352. resetQuery() {
  353. this.resetForm("queryForm");
  354. this.handleQuery();
  355. },
  356. // 多选框选中数据
  357. handleSelectionChange(selection) {
  358. this.ids = selection.map(item => item.commentId)
  359. this.single = selection.length!==1
  360. this.multiple = !selection.length
  361. },
  362. /** 添加关键字按钮操作 */
  363. handleAddKeyWords(row) {
  364. this.reset();
  365. this.form.keyword = row.content; // 将评论内容设置为关键字
  366. this.open = true;
  367. this.title = "添加到关键字";
  368. },
  369. handleUpdateStatus(row) {
  370. this.reset();
  371. this.form.status = row.status;
  372. this.form.commentId = row.commentId;
  373. this.updateStatus = true;
  374. this.title = "修改弹幕状态";
  375. },
  376. /** 解除拉黑用户按钮操作 */
  377. handleClearBlack(row) {
  378. this.$confirm(`谨慎操作,确定要解除"${row.nickName}"用户拉黑吗`, "警告", {
  379. confirmButtonText: "确定",
  380. cancelButtonText: "取消",
  381. type: "warning"
  382. }).then(() => {
  383. const data = {
  384. fsUserId: row.userId,
  385. commentStatus: 0
  386. };
  387. clearBlack(data).then(response => {
  388. this.msgSuccess("操作成功");
  389. this.getList(); // 重新加载列表
  390. }).catch(() => {
  391. this.msgError("操作失败");
  392. });
  393. }).catch(() => {
  394. // 用户取消操作
  395. });
  396. },
  397. /** 拉黑用户按钮操作 */
  398. handleAddBlack(row) {
  399. this.$confirm(`谨慎操作,确定要拉黑用户"${row.nickName}"吗`, "警告", {
  400. confirmButtonText: "确定",
  401. cancelButtonText: "取消",
  402. type: "warning"
  403. }).then(() => {
  404. const data = {
  405. fsUserId: row.userId,
  406. commentStatus: 1
  407. };
  408. addBlack(data).then(response => {
  409. this.msgSuccess("操作成功");
  410. this.getList(); // 重新加载列表
  411. }).catch(() => {
  412. this.msgError("操作失败");
  413. });
  414. }).catch(() => {
  415. // 用户取消操作
  416. });
  417. },
  418. updateForm() {
  419. this.$refs["form"].validate(valid => {
  420. if (valid) {
  421. console.log(this.form)
  422. updateBarrageStatus(this.form).then(response => {
  423. this.msgSuccess("修改成功");
  424. this.updateStatus = false;
  425. this.getList();
  426. }).catch(() => {
  427. this.msgError("修改失败");
  428. });
  429. }
  430. })
  431. },
  432. /** 提交按钮 */
  433. submitForm() {
  434. this.$refs["form"].validate(valid => {
  435. if (valid) {
  436. const data = {
  437. keyword: this.form.keyword
  438. };
  439. addKeyword(data).then(response => {
  440. this.msgSuccess("操作成功");
  441. this.open = false;
  442. this.getList();
  443. }).catch(() => {
  444. this.msgError("操作失败");
  445. });
  446. }
  447. });
  448. },
  449. // /** 新增按钮操作 */
  450. // handleAdd() {
  451. // this.reset();
  452. // this.open = true;
  453. // this.title = "添加看课评论";
  454. // },
  455. // /** 修改按钮操作 */
  456. // handleUpdate(row) {
  457. // this.reset();
  458. // const commentId = row.commentId || this.ids
  459. // getCourseWatchComment(commentId).then(response => {
  460. // this.form = response.data;
  461. // this.open = true;
  462. // this.title = "修改看课评论";
  463. // });
  464. // },
  465. /** 删除按钮操作 */
  466. handleDelete(row) {
  467. const commentIds = row.commentId || this.ids;
  468. this.$confirm('是否确认删除此看课评论?删除后不可恢复', "警告", {
  469. confirmButtonText: "确定",
  470. cancelButtonText: "取消",
  471. type: "warning"
  472. }).then(function() {
  473. return delCourseWatchComment(commentIds);
  474. }).then(() => {
  475. this.getList();
  476. this.msgSuccess("删除成功");
  477. }).catch(() => {});
  478. },
  479. /** 导出按钮操作 */
  480. handleExport() {
  481. const queryParams = this.queryParams;
  482. this.$confirm('是否确认导出当前看课评论数据项?', "警告", {
  483. confirmButtonText: "确定",
  484. cancelButtonText: "取消",
  485. type: "warning"
  486. }).then(() => {
  487. this.exportLoading = true;
  488. return exportCourseWatchComment(queryParams);
  489. }).then(response => {
  490. this.download(response.msg);
  491. this.exportLoading = false;
  492. }).catch(() => {});
  493. }
  494. }
  495. };
  496. </script>