index.vue 8.7 KB

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