|
@@ -0,0 +1,172 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container coupon-list">
|
|
|
+ <el-form v-show="showSearch" :model="queryParams" ref="queryForm" :inline="true" size="small">
|
|
|
+ <el-form-item label="活动名称">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.title"
|
|
|
+ placeholder="请输入活动名称"
|
|
|
+ clearable @clear="queryParams.pageNum = 1;getList()"
|
|
|
+ @keyup.enter.native="queryParams.pageNum = 1;getList()"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="活动状态">
|
|
|
+ <el-select v-model="queryParams.status" placeholder="请选择活动状态" clearable @change="queryParams.pageNum = 1;getList()">
|
|
|
+ <el-option label="全部" value="" />
|
|
|
+ <el-option label="进行中" value="init" />
|
|
|
+ <el-option label="已结束" value="on" />
|
|
|
+ <el-option label="草稿" value="off" />
|
|
|
+ <el-option label="未开始" value="off" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="el-icon-search" @click="queryParams.pageNum = 1;getList()">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" @click="getList(true)">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="$router.push({ name: 'MarketingAdd' })"
|
|
|
+ v-hasPermi="['business:marketing:add']"
|
|
|
+ >创建活动</el-button>
|
|
|
+ <el-button
|
|
|
+ type="infor"
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ size="small"
|
|
|
+ @click="handleExportDraw"
|
|
|
+ v-hasPermi="['order:userTicket:export']"
|
|
|
+ >导出中奖数据</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+ <el-table v-loading="loading" :data="tableData">
|
|
|
+ <el-table-column label="活动编号" prop="couponId" width="80" />
|
|
|
+ <el-table-column label="活动名称" prop="title" />
|
|
|
+ <el-table-column label="参与人数" prop="discount"/>
|
|
|
+ <el-table-column label="开始时间" prop="type" >
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ {{ JSON.parse(row.type).desc }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="结束时间" prop="type" >
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ {{ JSON.parse(row.type).desc }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" prop="status">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-tag :type="JSON.parse(row.status).value === 'on' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column fixed="right" align="right" label="操作" width="240">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-button v-hasPermi="['business:marketing:query']" type="text" @click="$router.push({ name: 'MarketingQuery', query: { id: row.couponId } })">查看</el-button>
|
|
|
+ <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>
|
|
|
+ <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>
|
|
|
+ <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>
|
|
|
+ <el-button v-if="JSON.parse(row.status).value === 'on'" v-hasPermi="['business:coupon:off']" type="text" @click="setStatus(row, 'off')">下架</el-button>
|
|
|
+ <el-button v-if="JSON.parse(row.status).value === 'init'" v-hasPermi="['business:coupon:remove']" class="del" type="text" @click="del(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList()" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { getCouponList, delCoupon, setCouponStatus } from '@/api/business/coupon'
|
|
|
+import { accDiv } from '@/utils/util'
|
|
|
+export default {
|
|
|
+ name: 'CouponList',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ showSearch: true,
|
|
|
+ tableData: [],
|
|
|
+ queryParams: {},
|
|
|
+ total: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getList(true)
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getList(reset) {
|
|
|
+ if (this.loading) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ if (reset) {
|
|
|
+ this.queryParams = { pageNum: 1, pageSize: 20 }
|
|
|
+ }
|
|
|
+ getCouponList('pageNum='+this.queryParams.pageNum + '&pageSize='+this.queryParams.pageSize+'&', this.queryParams).then(res => {
|
|
|
+ this.loading = false
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.tableData = res.rows
|
|
|
+ this.total = res.total
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setStatus(item, status) {
|
|
|
+ this.$confirm(`确认${status === 'on' ? '上架' : '下架'}券 “${item.title}” 吗?`, `${status === 'on' ? '上架' : '下架'}券`, {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ setCouponStatus({
|
|
|
+ couponId: item.couponId,
|
|
|
+ status
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('操作已完成!')
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ del(item) {
|
|
|
+ this.$confirm(`确认删除券 “${item.title}” 吗?`, '删除券', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ delCoupon(item.couponId).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('操作已完成!')
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 导出订单
|
|
|
+ handleExportDraw() {
|
|
|
+ this.$confirm("是否确认导出订单?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.vloading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "正在导出订单.....",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+ return ticketOrderExport(this.queryParams);
|
|
|
+ })
|
|
|
+ .then((response) => {
|
|
|
+ this.vloading.close();
|
|
|
+ this.download(response.msg);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.vloading.close();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|