list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div>
  3. <el-form ref="LotteryForm" :inline="true" :model="lotteryForm" class="top-search">
  4. <el-form-item label="类型" prop="type">
  5. <el-select v-model="lotteryForm.actType" clearable>
  6. <el-option value="1" label="抽奖"></el-option>
  7. <el-option value="2" label="转盘"></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="">
  11. <el-button type="primary" :loading="loading" @click="initList">查询</el-button>
  12. </el-form-item>
  13. </el-form>
  14. <div class="g-card">
  15. <div class="mid-action">
  16. <el-button type="primary" @click="addLottery">新增活动</el-button>
  17. </div>
  18. <el-table
  19. :data="tableData"
  20. >
  21. <el-table-column type="index" label="序号" width="55"></el-table-column>
  22. <el-table-column prop="actName" label="活动名称"></el-table-column>
  23. <el-table-column prop="createTime" label="新建时间"></el-table-column>
  24. <el-table-column prop="actType" label="活动类型">
  25. <template slot-scope="scope">
  26. {{ scope.row.actType == '1'?'抽奖':scope.row.actType == '2'?'转盘':'' }}
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="a" label="奖品"></el-table-column>
  30. <el-table-column prop="a" label="参与用户"></el-table-column>
  31. <el-table-column label="活动时间" width="160">
  32. <template slot-scope="scope">
  33. {{ scope.row.actStartTime&&scope.row.actEndTime?`${scope.row.actStartTime}-${scope.row.actEndTime}`:'' }}
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="winNum" label="中奖人数">
  37. <template slot-scope="scope">
  38. <el-button type="text" @click="showNumber(scope.row)">{{ scope.row.winNum?scope.row.winNum:0 }}</el-button>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="actStatus" label="状态">
  42. <template slot-scope="scope">
  43. {{ scope.row.actStatus == '1'?'开启':scope.row.actStatus == '2'?'关闭':'' }}
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="updateBy" label="操作人"></el-table-column>
  47. <el-table-column label="操作" width="200">
  48. <template slot-scope="scope">
  49. <el-button type="text" @click="handleClose(scope.row)">关闭</el-button>
  50. <el-button type="text" @click="handleStart(scope.row)">开启</el-button>
  51. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  52. <el-button type="text" @click="handleShare(scope.row)">转发企微</el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <pagination
  57. v-show="total > 0"
  58. :total="total"
  59. :page.sync="lotteryForm.pageNum"
  60. :limit.sync="lotteryForm.pageSize"
  61. @pagination="initList"
  62. />
  63. </div>
  64. <el-dialog
  65. :visible.sync="numberShow"
  66. width="400"
  67. >
  68. <el-table
  69. :data="numbersData"
  70. >
  71. <el-table-column label="序号" type="index"></el-table-column>
  72. <el-table-column label="用户名称" prop="userNickName"></el-table-column>
  73. <el-table-column label="手机号" prop="userPhone"></el-table-column>
  74. </el-table>
  75. </el-dialog>
  76. <pagination
  77. v-show="total1 > 0"
  78. :total="total1"
  79. :page.sync="numberForm.pageNum"
  80. :limit.sync="numberForm.pageSize"
  81. @pagination="getWinningRecord"
  82. />
  83. </div>
  84. </template>
  85. <script>
  86. import * as api from '@/api/lottery'
  87. import {getWinningRecord} from "@/api/lottery";
  88. export default {
  89. name: "lotteryList",
  90. data() {
  91. return {
  92. lotteryForm: {
  93. actType: '',
  94. pageNum: 1,
  95. pageSize: 10
  96. },
  97. total: 1,
  98. loading: false,
  99. tableData: [],
  100. numberShow: false,
  101. numbersData: [],
  102. total1: 0,
  103. numberForm: {
  104. pageNum: 1,
  105. pageSize: 10
  106. },
  107. numberId: ''
  108. }
  109. },
  110. created() {
  111. this.initList();
  112. },
  113. methods: {
  114. initList() {
  115. this.loading = true
  116. api.listActivity({
  117. actTypeList: this.lotteryForm.actType?[this.lotteryForm.actType]:['1','2'],
  118. pageNum: this.lotteryForm.pageNum,
  119. pageSize: this.lotteryForm.pageSize
  120. }).then(res => {
  121. this.loading = false
  122. if(res.code == 200) {
  123. this.tableData = res.rows
  124. this.total = Number(res.total)
  125. } else {
  126. this.tableData = []
  127. this.total = 0
  128. this.$message.error(res.msg)
  129. }
  130. })
  131. },
  132. addLottery() {
  133. this.$router.push({
  134. path: 'add'
  135. })
  136. },
  137. showNumber(row) {
  138. // if(row.winNum) {
  139. // this.numberShow = true
  140. // }
  141. this.numberShow = true
  142. this.numberId = row.actId
  143. this.getWinningRecord()
  144. },
  145. getWinningRecord() {
  146. api.getWinningRecord({
  147. actId: this.numberId,
  148. ...this.numberForm
  149. }).then(res => {
  150. if(res.code == 200) {
  151. this.numbersData = res.rows
  152. this.total1 = res.total
  153. }
  154. })
  155. },
  156. handleClose(row) {
  157. api.editActivityStatus({
  158. actId: row.actId,
  159. actStatus: 2
  160. }).then(res => {
  161. if(res.code == 200) {
  162. this.$message.success(res.msg)
  163. this.initList()
  164. } else {
  165. this.$message.error(res.msg)
  166. }
  167. })
  168. },
  169. handleStart(row) {
  170. api.editActivityStatus({
  171. actId: row.actId,
  172. actStatus: 1
  173. }).then(res => {
  174. if(res.code == 200) {
  175. this.$message.success(res.msg)
  176. this.initList()
  177. } else {
  178. this.$message.error(res.msg)
  179. }
  180. })
  181. },
  182. handleEdit(row) {
  183. this.$router.push({
  184. path: `add?id=${row.actId}`
  185. })
  186. },
  187. handleShare(row) {
  188. let inputs=document.createElement("input") //创建节点
  189. inputs.value = row.actType == 1?`https://test.baoxianzhanggui.com/custh5/#/packageB/pages/activity/act-nineGrid?id=${row.actId}`: row.actType == 2?`https://test.baoxianzhanggui.com/custh5/#/packageB/pages/activity/act-wheel?id=${row.actId}`: '' //给节点赋值
  190. document.body.appendChild(inputs) //渲染节点(要不然不起作用,可以添加隐藏属性)
  191. inputs.select() //选中节点
  192. let actions = document.execCommand("Copy") //指定复制命令(返回的是一个boolean类型)
  193. if(actions) {
  194. this.$message.success('复制成功!')
  195. }
  196. }
  197. }
  198. }
  199. </script>
  200. <style scoped>
  201. </style>