index.vue 13 KB

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