index.vue 14 KB

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