index.vue 7.5 KB

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