index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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="lotteryId">
  5. <el-input
  6. v-model="queryParams.lotteryId"
  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="liveId">
  14. <el-input
  15. v-model="queryParams.liveId"
  16. placeholder="请输入直播间ID"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="商品ID" prop="productId">
  23. <el-input
  24. v-model="queryParams.productId"
  25. placeholder="请输入商品ID"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="奖品等级" prop="prizeLevel">
  32. <el-input
  33. v-model="queryParams.prizeLevel"
  34. placeholder="请输入奖品等级"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="单次中奖商品数量" prop="perLotteryNum">
  41. <el-input
  42. v-model="queryParams.perLotteryNum"
  43. placeholder="请输入单次中奖商品数量"
  44. clearable
  45. size="small"
  46. @keyup.enter.native="handleQuery"
  47. />
  48. </el-form-item>
  49. <el-form-item label="奖励总份数" prop="totalLots">
  50. <el-input
  51. v-model="queryParams.totalLots"
  52. placeholder="请输入奖励总份数"
  53. clearable
  54. size="small"
  55. @keyup.enter.native="handleQuery"
  56. />
  57. </el-form-item>
  58. <el-form-item label="实际发放奖励份数" prop="totalSend">
  59. <el-input
  60. v-model="queryParams.totalSend"
  61. placeholder="请输入实际发放奖励份数"
  62. clearable
  63. size="small"
  64. @keyup.enter.native="handleQuery"
  65. />
  66. </el-form-item>
  67. <el-form-item label="创建日期" prop="createTime">
  68. <el-date-picker clearable size="small"
  69. v-model="queryParams.createTime"
  70. type="date"
  71. value-format="yyyy-MM-dd"
  72. placeholder="选择创建日期">
  73. </el-date-picker>
  74. </el-form-item>
  75. <el-form-item>
  76. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  77. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  78. </el-form-item>
  79. </el-form>
  80. <el-row :gutter="10" class="mb8">
  81. <el-col :span="1.5">
  82. <el-button
  83. type="primary"
  84. plain
  85. icon="el-icon-plus"
  86. size="mini"
  87. @click="handleAdd"
  88. v-hasPermi="['live:liveLotteryProductConf:add']"
  89. >新增</el-button>
  90. </el-col>
  91. <el-col :span="1.5">
  92. <el-button
  93. type="success"
  94. plain
  95. icon="el-icon-edit"
  96. size="mini"
  97. :disabled="single"
  98. @click="handleUpdate"
  99. v-hasPermi="['live:liveLotteryProductConf:edit']"
  100. >修改</el-button>
  101. </el-col>
  102. <el-col :span="1.5">
  103. <el-button
  104. type="danger"
  105. plain
  106. icon="el-icon-delete"
  107. size="mini"
  108. :disabled="multiple"
  109. @click="handleDelete"
  110. v-hasPermi="['live:liveLotteryProductConf:remove']"
  111. >删除</el-button>
  112. </el-col>
  113. <el-col :span="1.5">
  114. <el-button
  115. type="warning"
  116. plain
  117. icon="el-icon-download"
  118. size="mini"
  119. :loading="exportLoading"
  120. @click="handleExport"
  121. v-hasPermi="['live:liveLotteryProductConf:export']"
  122. >导出</el-button>
  123. </el-col>
  124. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  125. </el-row>
  126. <el-table border v-loading="loading" :data="liveLotteryProductConfList" @selection-change="handleSelectionChange">
  127. <el-table-column type="selection" width="55" align="center" />
  128. <el-table-column label="ID" align="center" prop="id" />
  129. <el-table-column label="抽奖ID" align="center" prop="lotteryId" />
  130. <el-table-column label="直播间ID" align="center" prop="liveId" />
  131. <el-table-column label="商品ID" align="center" prop="productId" />
  132. <el-table-column label="奖品等级" align="center" prop="prizeLevel" />
  133. <el-table-column label="单次中奖商品数量" align="center" prop="perLotteryNum" />
  134. <el-table-column label="奖励总份数" align="center" prop="totalLots" />
  135. <el-table-column label="实际发放奖励份数" align="center" prop="totalSend" />
  136. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  137. <template slot-scope="scope">
  138. <el-button
  139. size="mini"
  140. type="text"
  141. icon="el-icon-edit"
  142. @click="handleUpdate(scope.row)"
  143. v-hasPermi="['live:liveLotteryProductConf:edit']"
  144. >修改</el-button>
  145. <el-button
  146. size="mini"
  147. type="text"
  148. icon="el-icon-delete"
  149. @click="handleDelete(scope.row)"
  150. v-hasPermi="['live:liveLotteryProductConf:remove']"
  151. >删除</el-button>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <pagination
  156. v-show="total>0"
  157. :total="total"
  158. :page.sync="queryParams.pageNum"
  159. :limit.sync="queryParams.pageSize"
  160. @pagination="getList"
  161. />
  162. <!-- 添加或修改直播抽奖记录对话框 -->
  163. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  164. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  165. <el-form-item label="抽奖ID" prop="lotteryId">
  166. <el-input v-model="form.lotteryId" placeholder="请输入抽奖ID" />
  167. </el-form-item>
  168. <el-form-item label="直播间ID" prop="liveId">
  169. <el-input v-model="form.liveId" placeholder="请输入直播间ID" />
  170. </el-form-item>
  171. <el-form-item label="商品ID" prop="productId">
  172. <el-input v-model="form.productId" placeholder="请输入商品ID" />
  173. </el-form-item>
  174. <el-form-item label="奖品等级" prop="prizeLevel">
  175. <el-input v-model="form.prizeLevel" placeholder="请输入奖品等级" />
  176. </el-form-item>
  177. <el-form-item label="单次中奖商品数量" prop="perLotteryNum">
  178. <el-input v-model="form.perLotteryNum" placeholder="请输入单次中奖商品数量" />
  179. </el-form-item>
  180. <el-form-item label="奖励总份数" prop="totalLots">
  181. <el-input v-model="form.totalLots" placeholder="请输入奖励总份数" />
  182. </el-form-item>
  183. <el-form-item label="实际发放奖励份数" prop="totalSend">
  184. <el-input v-model="form.totalSend" placeholder="请输入实际发放奖励份数" />
  185. </el-form-item>
  186. </el-form>
  187. <div slot="footer" class="dialog-footer">
  188. <el-button type="primary" @click="submitForm">确 定</el-button>
  189. <el-button @click="cancel">取 消</el-button>
  190. </div>
  191. </el-dialog>
  192. </div>
  193. </template>
  194. <script>
  195. import { listLiveLotteryProductConf, getLiveLotteryProductConf, delLiveLotteryProductConf, addLiveLotteryProductConf, updateLiveLotteryProductConf, exportLiveLotteryProductConf } from "@/api/live/liveLotteryProductConf";
  196. export default {
  197. name: "LiveLotteryProductConf",
  198. data() {
  199. return {
  200. // 遮罩层
  201. loading: true,
  202. // 导出遮罩层
  203. exportLoading: false,
  204. // 选中数组
  205. ids: [],
  206. // 非单个禁用
  207. single: true,
  208. // 非多个禁用
  209. multiple: true,
  210. // 显示搜索条件
  211. showSearch: true,
  212. // 总条数
  213. total: 0,
  214. // 直播抽奖记录表格数据
  215. liveLotteryProductConfList: [],
  216. // 弹出层标题
  217. title: "",
  218. // 是否显示弹出层
  219. open: false,
  220. // 查询参数
  221. queryParams: {
  222. pageNum: 1,
  223. pageSize: 10,
  224. lotteryId: null,
  225. liveId: null,
  226. productId: null,
  227. prizeLevel: null,
  228. perLotteryNum: null,
  229. totalLots: null,
  230. totalSend: null,
  231. createTime: null,
  232. },
  233. // 表单参数
  234. form: {},
  235. // 表单校验
  236. rules: {
  237. lotteryId: [
  238. { required: true, message: "抽奖ID不能为空", trigger: "blur" }
  239. ],
  240. liveId: [
  241. { required: true, message: "直播间ID不能为空", trigger: "blur" }
  242. ],
  243. productId: [
  244. { required: true, message: "商品ID不能为空", trigger: "blur" }
  245. ],
  246. prizeLevel: [
  247. { required: true, message: "奖品等级不能为空", trigger: "blur" }
  248. ],
  249. perLotteryNum: [
  250. { required: true, message: "单次中奖商品数量不能为空", trigger: "blur" }
  251. ],
  252. totalLots: [
  253. { required: true, message: "奖励总份数不能为空", trigger: "blur" }
  254. ],
  255. totalSend: [
  256. { required: true, message: "实际发放奖励份数不能为空", trigger: "blur" }
  257. ],
  258. }
  259. };
  260. },
  261. created() {
  262. this.getList();
  263. },
  264. methods: {
  265. /** 查询直播抽奖记录列表 */
  266. getList() {
  267. this.loading = true;
  268. listLiveLotteryProductConf(this.queryParams).then(response => {
  269. this.liveLotteryProductConfList = response.rows;
  270. this.total = response.total;
  271. this.loading = false;
  272. });
  273. },
  274. // 取消按钮
  275. cancel() {
  276. this.open = false;
  277. this.reset();
  278. },
  279. // 表单重置
  280. reset() {
  281. this.form = {
  282. id: null,
  283. lotteryId: null,
  284. liveId: null,
  285. productId: null,
  286. prizeLevel: null,
  287. perLotteryNum: null,
  288. totalLots: null,
  289. totalSend: null,
  290. createTime: null,
  291. updateTime: null,
  292. createBy: null,
  293. updateBy: null
  294. };
  295. this.resetForm("form");
  296. },
  297. /** 搜索按钮操作 */
  298. handleQuery() {
  299. this.queryParams.pageNum = 1;
  300. this.getList();
  301. },
  302. /** 重置按钮操作 */
  303. resetQuery() {
  304. this.resetForm("queryForm");
  305. this.handleQuery();
  306. },
  307. // 多选框选中数据
  308. handleSelectionChange(selection) {
  309. this.ids = selection.map(item => item.id)
  310. this.single = selection.length!==1
  311. this.multiple = !selection.length
  312. },
  313. /** 新增按钮操作 */
  314. handleAdd() {
  315. this.reset();
  316. this.open = true;
  317. this.title = "添加直播抽奖记录";
  318. },
  319. /** 修改按钮操作 */
  320. handleUpdate(row) {
  321. this.reset();
  322. const id = row.id || this.ids
  323. getLiveLotteryProductConf(id).then(response => {
  324. this.form = response.data;
  325. this.open = true;
  326. this.title = "修改直播抽奖记录";
  327. });
  328. },
  329. /** 提交按钮 */
  330. submitForm() {
  331. this.$refs["form"].validate(valid => {
  332. if (valid) {
  333. if (this.form.id != null) {
  334. updateLiveLotteryProductConf(this.form).then(response => {
  335. this.msgSuccess("修改成功");
  336. this.open = false;
  337. this.getList();
  338. });
  339. } else {
  340. addLiveLotteryProductConf(this.form).then(response => {
  341. this.msgSuccess("新增成功");
  342. this.open = false;
  343. this.getList();
  344. });
  345. }
  346. }
  347. });
  348. },
  349. /** 删除按钮操作 */
  350. handleDelete(row) {
  351. const ids = row.id || this.ids;
  352. this.$confirm('是否确认删除直播抽奖记录编号为"' + ids + '"的数据项?', "警告", {
  353. confirmButtonText: "确定",
  354. cancelButtonText: "取消",
  355. type: "warning"
  356. }).then(function() {
  357. return delLiveLotteryProductConf(ids);
  358. }).then(() => {
  359. this.getList();
  360. this.msgSuccess("删除成功");
  361. }).catch(() => {});
  362. },
  363. /** 导出按钮操作 */
  364. handleExport() {
  365. const queryParams = this.queryParams;
  366. this.$confirm('是否确认导出所有直播抽奖记录数据项?', "警告", {
  367. confirmButtonText: "确定",
  368. cancelButtonText: "取消",
  369. type: "warning"
  370. }).then(() => {
  371. this.exportLoading = true;
  372. return exportLiveLotteryProductConf(queryParams);
  373. }).then(response => {
  374. this.download(response.msg);
  375. this.exportLoading = false;
  376. }).catch(() => {});
  377. }
  378. }
  379. };
  380. </script>