index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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="用户id" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入用户id"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="评论类型" prop="type">
  14. <el-select v-model="queryParams.type" placeholder="请选择评论类型" clearable size="small">
  15. <el-option
  16. v-for="dict in typeOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row :gutter="10" class="mb8">
  29. <el-col :span="1.5">
  30. <el-button
  31. type="primary"
  32. plain
  33. icon="el-icon-plus"
  34. size="mini"
  35. @click="handleAdd"
  36. v-hasPermi="['course:userVideoComment:add']"
  37. >新增</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="success"
  42. plain
  43. icon="el-icon-edit"
  44. size="mini"
  45. :disabled="single"
  46. @click="handleUpdate"
  47. v-hasPermi="['course:userVideoComment:edit']"
  48. >修改</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="danger"
  53. plain
  54. icon="el-icon-delete"
  55. size="mini"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. v-hasPermi="['course:userVideoComment:remove']"
  59. >删除</el-button>
  60. </el-col>
  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:userVideoComment:export']"
  70. >导出</el-button>
  71. </el-col>
  72. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  73. </el-row>
  74. <el-table v-loading="loading" :data="userVideoCommentList" @selection-change="handleSelectionChange">
  75. <el-table-column type="selection" width="55" align="center" />
  76. <el-table-column label="评论id" align="center" prop="commentId" />
  77. <el-table-column label="用户id" align="center" prop="userId" />
  78. <el-table-column label="视频id" align="center" prop="videoId" />
  79. <el-table-column label="评论类型" align="center" prop="type">
  80. <template slot-scope="scope">
  81. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="父评论id" align="center" prop="parentId" />
  85. <el-table-column label="评论内容" align="center" prop="content" />
  86. <el-table-column label="回复数量" align="center" prop="replyCount" />
  87. <el-table-column label="点赞数" align="center" prop="likes" />
  88. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  89. <template slot-scope="scope">
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-edit"
  94. @click="handleUpdate(scope.row)"
  95. v-hasPermi="['course:userVideoComment:edit']"
  96. >修改</el-button>
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-delete"
  101. @click="handleDelete(scope.row)"
  102. v-hasPermi="['course:userVideoComment:remove']"
  103. >删除</el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <pagination
  108. v-show="total>0"
  109. :total="total"
  110. :page.sync="queryParams.pageNum"
  111. :limit.sync="queryParams.pageSize"
  112. @pagination="getList"
  113. />
  114. <!-- 添加或修改课堂视频评论对话框 -->
  115. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  116. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  117. <el-form-item label="用户id" prop="userId">
  118. <el-input v-model="form.userId" placeholder="请输入用户id" />
  119. </el-form-item>
  120. <el-form-item label="视频id" prop="videoId">
  121. <el-input v-model="form.videoId" placeholder="请输入视频id" />
  122. </el-form-item>
  123. <el-form-item label="评论类型" prop="type">
  124. <el-select v-model="form.type" placeholder="请选择评论类型">
  125. <el-option
  126. v-for="dict in typeOptions"
  127. :key="dict.dictValue"
  128. :label="dict.dictLabel"
  129. :value="parseInt(dict.dictValue)"
  130. ></el-option>
  131. </el-select>
  132. </el-form-item>
  133. <el-form-item label="父评论id" prop="parentId">
  134. <el-input v-model="form.parentId" placeholder="请输入父评论id" />
  135. </el-form-item>
  136. <el-form-item label="评论内容">
  137. <el-input type="textarea" v-model="form.content" placeholder="请输入父评论id" />
  138. </el-form-item>
  139. <el-form-item label="点赞数" prop="likes">
  140. <el-input v-model="form.likes" placeholder="请输入点赞数" />
  141. </el-form-item>
  142. </el-form>
  143. <div slot="footer" class="dialog-footer">
  144. <el-button type="primary" @click="submitForm">确 定</el-button>
  145. <el-button @click="cancel">取 消</el-button>
  146. </div>
  147. </el-dialog>
  148. </div>
  149. </template>
  150. <script>
  151. import { listUserVideoComment, getUserVideoComment, delUserVideoComment, addUserVideoComment, updateUserVideoComment, exportUserVideoComment } from "@/api/course/userVideoComment";
  152. export default {
  153. name: "UserVideoComment",
  154. data() {
  155. return {
  156. // 遮罩层
  157. loading: true,
  158. // 导出遮罩层
  159. exportLoading: false,
  160. // 选中数组
  161. ids: [],
  162. // 非单个禁用
  163. single: true,
  164. // 非多个禁用
  165. multiple: true,
  166. // 显示搜索条件
  167. showSearch: true,
  168. // 总条数
  169. total: 0,
  170. // 课堂视频评论表格数据
  171. userVideoCommentList: [],
  172. // 弹出层标题
  173. title: "",
  174. // 是否显示弹出层
  175. open: false,
  176. // 评论类型 1:评论,2:回复字典
  177. typeOptions: [],
  178. // 查询参数
  179. queryParams: {
  180. pageNum: 1,
  181. pageSize: 10,
  182. userId: null,
  183. videoId: null,
  184. type: null,
  185. parentId: null,
  186. content: null,
  187. replyCount: null,
  188. likes: null
  189. },
  190. // 表单参数
  191. form: {},
  192. // 表单校验
  193. rules: {
  194. }
  195. };
  196. },
  197. created() {
  198. this.getList();
  199. this.getDicts("sys_video_comment_type").then(response => {
  200. this.typeOptions = response.data;
  201. });
  202. },
  203. methods: {
  204. /** 查询课堂视频评论列表 */
  205. getList() {
  206. this.loading = true;
  207. listUserVideoComment(this.queryParams).then(response => {
  208. this.userVideoCommentList = response.rows;
  209. this.total = response.total;
  210. this.loading = false;
  211. });
  212. },
  213. // 取消按钮
  214. cancel() {
  215. this.open = false;
  216. this.reset();
  217. },
  218. // 表单重置
  219. reset() {
  220. this.form = {
  221. commentId: null,
  222. userId: null,
  223. videoId: null,
  224. type: null,
  225. parentId: null,
  226. content: null,
  227. replyCount: null,
  228. createTime: null,
  229. updateTime: null,
  230. likes: null
  231. };
  232. this.resetForm("form");
  233. },
  234. /** 搜索按钮操作 */
  235. handleQuery() {
  236. this.queryParams.pageNum = 1;
  237. this.getList();
  238. },
  239. /** 重置按钮操作 */
  240. resetQuery() {
  241. this.resetForm("queryForm");
  242. this.handleQuery();
  243. },
  244. // 多选框选中数据
  245. handleSelectionChange(selection) {
  246. this.ids = selection.map(item => item.commentId)
  247. this.single = selection.length!==1
  248. this.multiple = !selection.length
  249. },
  250. /** 新增按钮操作 */
  251. handleAdd() {
  252. this.reset();
  253. this.open = true;
  254. this.title = "添加课堂视频评论";
  255. },
  256. /** 修改按钮操作 */
  257. handleUpdate(row) {
  258. this.reset();
  259. const commentId = row.commentId || this.ids
  260. getUserVideoComment(commentId).then(response => {
  261. this.form = response.data;
  262. this.open = true;
  263. this.title = "修改课堂视频评论";
  264. });
  265. },
  266. /** 提交按钮 */
  267. submitForm() {
  268. this.$refs["form"].validate(valid => {
  269. if (valid) {
  270. if (this.form.commentId != null) {
  271. updateUserVideoComment(this.form).then(response => {
  272. this.msgSuccess("修改成功");
  273. this.open = false;
  274. this.getList();
  275. });
  276. } else {
  277. addUserVideoComment(this.form).then(response => {
  278. this.msgSuccess("新增成功");
  279. this.open = false;
  280. this.getList();
  281. });
  282. }
  283. }
  284. });
  285. },
  286. /** 删除按钮操作 */
  287. handleDelete(row) {
  288. const commentIds = row.commentId || this.ids;
  289. this.$confirm('是否确认删除课堂视频评论编号为"' + commentIds + '"的数据项?', "警告", {
  290. confirmButtonText: "确定",
  291. cancelButtonText: "取消",
  292. type: "warning"
  293. }).then(function() {
  294. return delUserVideoComment(commentIds);
  295. }).then(() => {
  296. this.getList();
  297. this.msgSuccess("删除成功");
  298. }).catch(() => {});
  299. },
  300. /** 导出按钮操作 */
  301. handleExport() {
  302. const queryParams = this.queryParams;
  303. this.$confirm('是否确认导出所有课堂视频评论数据项?', "警告", {
  304. confirmButtonText: "确定",
  305. cancelButtonText: "取消",
  306. type: "warning"
  307. }).then(() => {
  308. this.exportLoading = true;
  309. return exportUserVideoComment(queryParams);
  310. }).then(response => {
  311. this.download(response.msg);
  312. this.exportLoading = false;
  313. }).catch(() => {});
  314. }
  315. }
  316. };
  317. </script>