index.vue 8.1 KB

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