index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="app-container coupon-list">
  3. <el-form v-show="showSearch" :model="queryParams" ref="queryForm" :inline="true" size="small">
  4. <el-form-item label="活动名称">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入活动名称"
  8. clearable @clear="queryParams.pageNum = 1;getList()"
  9. @keyup.enter.native="queryParams.pageNum = 1;getList()"
  10. />
  11. </el-form-item>
  12. <el-form-item label="活动状态">
  13. <el-select v-model="queryParams.status" placeholder="请选择活动状态" clearable @change="queryParams.pageNum = 1;getList()">
  14. <el-option label="全部" value="" />
  15. <el-option label="进行中" value="init" />
  16. <el-option label="已结束" value="on" />
  17. <el-option label="草稿" value="off" />
  18. <el-option label="未开始" value="off" />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" icon="el-icon-search" @click="queryParams.pageNum = 1;getList()">搜索</el-button>
  23. <el-button icon="el-icon-refresh" @click="getList(true)">重置</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-row :gutter="10" class="mb8">
  27. <el-col :span="10">
  28. <el-button
  29. type="primary"
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="$router.push({ name: 'MarketingAdd' })"
  33. v-hasPermi="['business:marketing:add']"
  34. >创建活动</el-button>
  35. <el-button
  36. type="infor"
  37. plain
  38. icon="el-icon-download"
  39. size="small"
  40. @click="handleExportDraw"
  41. v-hasPermi="['order:userTicket:export']"
  42. >导出中奖数据</el-button>
  43. </el-col>
  44. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  45. </el-row>
  46. <el-table v-loading="loading" :data="tableData">
  47. <el-table-column label="活动编号" prop="couponId" width="80" />
  48. <el-table-column label="活动名称" prop="title" />
  49. <el-table-column label="参与人数" prop="discount"/>
  50. <el-table-column label="开始时间" prop="type" >
  51. <template slot-scope="{row}">
  52. {{ JSON.parse(row.type).desc }}
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="结束时间" prop="type" >
  56. <template slot-scope="{row}">
  57. {{ JSON.parse(row.type).desc }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="状态" prop="status">
  61. <template slot-scope="{row}">
  62. <el-tag :type="JSON.parse(row.status).value === 'on' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
  63. </template>
  64. </el-table-column>
  65. <el-table-column fixed="right" align="right" label="操作" width="240">
  66. <template slot-scope="{row}">
  67. <el-button v-hasPermi="['business:marketing:query']" type="text" @click="$router.push({ name: 'MarketingQuery', query: { id: row.couponId } })">查看</el-button>
  68. <el-button v-if="JSON.parse(row.status).value === 'init'" v-hasPermi="['business:marketing:edit']" type="text" @click="$router.push({ name: 'MarketingEdit', query: { id: row.couponId } })">编辑</el-button>
  69. <el-button v-if="JSON.parse(row.status).value === 'init'" v-hasPermi="['business:marketing:edit']" type="text" @click="$router.push({ name: 'MarketingEdit', query: { id: row.couponId } })">活动数据</el-button>
  70. <el-button v-if="JSON.parse(row.status).value === 'off' || JSON.parse(row.status).value === 'init'" v-hasPermi="['business:coupon:on']" type="text" @click="setStatus(row, 'on')">上架</el-button>
  71. <el-button v-if="JSON.parse(row.status).value === 'on'" v-hasPermi="['business:coupon:off']" type="text" @click="setStatus(row, 'off')">下架</el-button>
  72. <el-button v-if="JSON.parse(row.status).value === 'init'" v-hasPermi="['business:coupon:remove']" class="del" type="text" @click="del(row)">删除</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList()" />
  77. </div>
  78. </template>
  79. <script>
  80. import { getCouponList, delCoupon, setCouponStatus } from '@/api/business/coupon'
  81. import { accDiv } from '@/utils/util'
  82. export default {
  83. name: 'CouponList',
  84. data() {
  85. return {
  86. loading: false,
  87. showSearch: true,
  88. tableData: [],
  89. queryParams: {},
  90. total: 0
  91. }
  92. },
  93. created() {
  94. this.getList(true)
  95. },
  96. methods: {
  97. getList(reset) {
  98. if (this.loading) {
  99. return
  100. }
  101. this.loading = true
  102. if (reset) {
  103. this.queryParams = { pageNum: 1, pageSize: 20 }
  104. }
  105. getCouponList('pageNum='+this.queryParams.pageNum + '&pageSize='+this.queryParams.pageSize+'&', this.queryParams).then(res => {
  106. this.loading = false
  107. if (res.code === 0) {
  108. this.tableData = res.rows
  109. this.total = res.total
  110. }
  111. }).catch(() => {
  112. this.loading = false
  113. })
  114. },
  115. setStatus(item, status) {
  116. this.$confirm(`确认${status === 'on' ? '上架' : '下架'}券 “${item.title}” 吗?`, `${status === 'on' ? '上架' : '下架'}券`, {
  117. confirmButtonText: '确定',
  118. cancelButtonText: '取消',
  119. type: 'warning'
  120. }).then(() => {
  121. setCouponStatus({
  122. couponId: item.couponId,
  123. status
  124. }).then(res => {
  125. if (res.code === 0) {
  126. this.$message.success('操作已完成!')
  127. this.getList()
  128. }
  129. })
  130. })
  131. },
  132. del(item) {
  133. this.$confirm(`确认删除券 “${item.title}” 吗?`, '删除券', {
  134. confirmButtonText: '确定',
  135. cancelButtonText: '取消',
  136. type: 'warning'
  137. }).then(() => {
  138. delCoupon(item.couponId).then(res => {
  139. if (res.code === 0) {
  140. this.$message.success('操作已完成!')
  141. this.getList()
  142. }
  143. })
  144. })
  145. },
  146. // 导出订单
  147. handleExportDraw() {
  148. this.$confirm("是否确认导出订单?", "提示", {
  149. confirmButtonText: "确定",
  150. cancelButtonText: "取消",
  151. type: "warning",
  152. })
  153. .then(() => {
  154. this.vloading = this.$loading({
  155. lock: true,
  156. text: "正在导出订单.....",
  157. background: "rgba(0, 0, 0, 0.7)",
  158. });
  159. return ticketOrderExport(this.queryParams);
  160. })
  161. .then((response) => {
  162. this.vloading.close();
  163. this.download(response.msg);
  164. })
  165. .catch(() => {
  166. this.vloading.close();
  167. });
  168. },
  169. }
  170. }
  171. </script>