index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. /** 与后端 cate_type 一致:0-评论(课程),1-公域看课评论 */
  235. pageCateType: 0,
  236. // 弹幕状态选项
  237. barrageStatusOptions: [
  238. { dictValue: 0, dictLabel: "正常" },
  239. { dictValue: 1, dictLabel: "屏蔽" },
  240. { dictValue: 2, dictLabel: "人工" }
  241. ],
  242. // 遮罩层
  243. loading: true,
  244. // 导出遮罩层
  245. exportLoading: false,
  246. // 选中数组
  247. ids: [],
  248. // 非单个禁用
  249. single: true,
  250. // 非多个禁用
  251. multiple: true,
  252. // 显示搜索条件
  253. showSearch: true,
  254. // 总条数
  255. total: 0,
  256. // 看课评论表格数据
  257. courseWatchCommentList: [],
  258. //下拉状态
  259. statusOptions:[],
  260. // 弹出层标题
  261. title: "",
  262. // 是否显示弹出层
  263. open: false,
  264. updateStatus: false,
  265. // 查询参数
  266. queryParams: {
  267. pageNum: 1,
  268. pageSize: 10,
  269. keywords: null,
  270. isAll: true, //判断是否属于全局查询
  271. status: '',
  272. userStatus: '',
  273. cateType: 0,
  274. // userId: null,
  275. // userType: null,
  276. // courseId: null,
  277. // videoId: null,
  278. // type: null,
  279. // parentId: null,
  280. // content: null,
  281. // isRevoke: null
  282. },
  283. // 表单参数
  284. form: {},
  285. // 表单校验
  286. rules: {
  287. keyword: [
  288. { required: true, message: "关键字不能为空", trigger: "blur" }
  289. ]
  290. }
  291. };
  292. },
  293. created() {
  294. this.getDicts("sys_barrage_clean_type").then((response) => {
  295. this.statusOptions = response.data;
  296. });
  297. this.getList();
  298. },
  299. methods: {
  300. /** 查询看课评论列表 */
  301. getList() {
  302. this.loading = true;
  303. this.queryParams.cateType = this.pageCateType;
  304. listCourseWatchComment(this.queryParams).then(response => {
  305. this.courseWatchCommentList = response.rows.list;
  306. this.total = response.rows.total;
  307. this.loading = false;
  308. });
  309. },
  310. // 获取状态标签类型
  311. getStatusTagType(status) {
  312. switch(status) {
  313. case 0: return 'success';
  314. case 1: return 'danger';
  315. case 2: return 'primary';
  316. default: return 'info';
  317. }
  318. },
  319. // 格式化状态显示
  320. formatBarrageStatus(status) {
  321. const dict = this.barrageStatusOptions.find(item => item.dictValue === status);
  322. return dict ? dict.dictLabel : status;
  323. },
  324. // 取消按钮
  325. cancel() {
  326. this.open = false;
  327. this.updateStatus = false;
  328. this.reset();
  329. },
  330. // 表单重置
  331. reset() {
  332. this.form = {
  333. commentId: null,
  334. userId: null,
  335. userType: null,
  336. courseId: null,
  337. videoId: null,
  338. type: null,
  339. parentId: null,
  340. content: null,
  341. createTime: null,
  342. updateTime: null,
  343. isRevoke: null,
  344. keyword: null,
  345. status: '',
  346. userStatus: ''
  347. };
  348. this.resetForm("form");
  349. },
  350. /** 搜索按钮操作 */
  351. handleQuery() {
  352. this.queryParams.pageNum = 1;
  353. this.getList();
  354. },
  355. /** 重置按钮操作 */
  356. resetQuery() {
  357. this.resetForm("queryForm");
  358. this.queryParams.cateType = this.pageCateType;
  359. this.handleQuery();
  360. },
  361. // 多选框选中数据
  362. handleSelectionChange(selection) {
  363. this.ids = selection.map(item => item.commentId)
  364. this.single = selection.length!==1
  365. this.multiple = !selection.length
  366. },
  367. /** 添加关键字按钮操作 */
  368. handleAddKeyWords(row) {
  369. this.reset();
  370. this.form.keyword = row.content; // 将评论内容设置为关键字
  371. this.open = true;
  372. this.title = "添加到关键字";
  373. },
  374. handleUpdateStatus(row) {
  375. this.reset();
  376. this.form.status = row.status;
  377. this.form.commentId = row.commentId;
  378. this.form.cateType = this.pageCateType;
  379. this.updateStatus = true;
  380. this.title = "修改弹幕状态";
  381. },
  382. /** 解除拉黑用户按钮操作 */
  383. handleClearBlack(row) {
  384. this.$confirm(`谨慎操作,确定要解除"${row.nickName}"用户拉黑吗`, "警告", {
  385. confirmButtonText: "确定",
  386. cancelButtonText: "取消",
  387. type: "warning"
  388. }).then(() => {
  389. const data = {
  390. fsUserId: row.userId,
  391. commentStatus: 0
  392. };
  393. clearBlack(data).then(response => {
  394. this.msgSuccess("操作成功");
  395. this.getList(); // 重新加载列表
  396. }).catch(() => {
  397. this.msgError("操作失败");
  398. });
  399. }).catch(() => {
  400. // 用户取消操作
  401. });
  402. },
  403. /** 拉黑用户按钮操作 */
  404. handleAddBlack(row) {
  405. this.$confirm(`谨慎操作,确定要拉黑用户"${row.nickName}"吗`, "警告", {
  406. confirmButtonText: "确定",
  407. cancelButtonText: "取消",
  408. type: "warning"
  409. }).then(() => {
  410. const data = {
  411. fsUserId: row.userId,
  412. commentStatus: 1
  413. };
  414. addBlack(data).then(response => {
  415. this.msgSuccess("操作成功");
  416. this.getList(); // 重新加载列表
  417. }).catch(() => {
  418. this.msgError("操作失败");
  419. });
  420. }).catch(() => {
  421. // 用户取消操作
  422. });
  423. },
  424. updateForm() {
  425. this.$refs["form"].validate(valid => {
  426. if (valid) {
  427. console.log(this.form)
  428. updateBarrageStatus({ ...this.form, cateType: this.pageCateType }).then(response => {
  429. this.msgSuccess("修改成功");
  430. this.updateStatus = false;
  431. this.getList();
  432. }).catch(() => {
  433. this.msgError("修改失败");
  434. });
  435. }
  436. })
  437. },
  438. /** 提交按钮 */
  439. submitForm() {
  440. this.$refs["form"].validate(valid => {
  441. if (valid) {
  442. const data = {
  443. keyword: this.form.keyword
  444. };
  445. addKeyword(data).then(response => {
  446. this.msgSuccess("操作成功");
  447. this.open = false;
  448. this.getList();
  449. }).catch(() => {
  450. this.msgError("操作失败");
  451. });
  452. }
  453. });
  454. },
  455. // /** 新增按钮操作 */
  456. // handleAdd() {
  457. // this.reset();
  458. // this.open = true;
  459. // this.title = "添加看课评论";
  460. // },
  461. // /** 修改按钮操作 */
  462. // handleUpdate(row) {
  463. // this.reset();
  464. // const commentId = row.commentId || this.ids
  465. // getCourseWatchComment(commentId).then(response => {
  466. // this.form = response.data;
  467. // this.open = true;
  468. // this.title = "修改看课评论";
  469. // });
  470. // },
  471. /** 删除按钮操作 */
  472. handleDelete(row) {
  473. const commentIds = row.commentId || this.ids;
  474. this.$confirm('是否确认删除此看课评论?删除后不可恢复', "警告", {
  475. confirmButtonText: "确定",
  476. cancelButtonText: "取消",
  477. type: "warning"
  478. }).then(function() {
  479. return delCourseWatchComment(commentIds);
  480. }).then(() => {
  481. this.getList();
  482. this.msgSuccess("删除成功");
  483. }).catch(() => {});
  484. },
  485. /** 导出按钮操作 */
  486. handleExport() {
  487. const queryParams = { ...this.queryParams, cateType: this.pageCateType };
  488. this.$confirm('是否确认导出当前看课评论数据项?', "警告", {
  489. confirmButtonText: "确定",
  490. cancelButtonText: "取消",
  491. type: "warning"
  492. }).then(() => {
  493. this.exportLoading = true;
  494. return exportCourseWatchComment(queryParams);
  495. }).then(response => {
  496. this.download(response.msg);
  497. this.exportLoading = false;
  498. }).catch(() => {});
  499. }
  500. }
  501. };
  502. </script>