index.vue 10 KB

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