|
@@ -1,17 +1,33 @@
|
|
|
<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
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form
|
|
|
+ v-show="showSearch"
|
|
|
+ :model="queryParams"
|
|
|
+ ref="queryForm"
|
|
|
+ :inline="true"
|
|
|
+ size="small"
|
|
|
+ @submit.native.prevent
|
|
|
+ >
|
|
|
+ <el-form-item label="券包名称" prop="title">
|
|
|
+ <el-input
|
|
|
v-model="queryParams.title"
|
|
|
- placeholder="请输入券名称"
|
|
|
+ placeholder="请输入券包名称"
|
|
|
clearable
|
|
|
- @keyup.enter.native="queryParams.pageNum = 1;getList()"
|
|
|
+ size="small"
|
|
|
+ style="width: 240px"
|
|
|
+ @keyup.enter.native="handleQuery"
|
|
|
/>
|
|
|
</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-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-search"
|
|
|
+ @click="handleQuery"
|
|
|
+ >搜索</el-button
|
|
|
+ >
|
|
|
+ <el-button icon="el-icon-refresh" @click="resetQuery"
|
|
|
+ >重置</el-button
|
|
|
+ >
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<el-row :gutter="10" class="mb8">
|
|
@@ -22,108 +38,187 @@
|
|
|
size="mini"
|
|
|
@click="$router.push({ name: 'CouponPkgAdd' })"
|
|
|
v-hasPermi="['business:couponPkg:add']"
|
|
|
- >生成券包</el-button>
|
|
|
+ >生成券包</el-button
|
|
|
+ >
|
|
|
</el-col>
|
|
|
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ <right-toolbar
|
|
|
+ :showSearch.sync="showSearch"
|
|
|
+ @queryTable="getList"
|
|
|
+ ></right-toolbar>
|
|
|
</el-row>
|
|
|
- <el-table v-loading="loading" :data="tableData">
|
|
|
- <el-table-column label="券包编号" prop="id" width="80" />
|
|
|
- <el-table-column label="券包名称" prop="title" />
|
|
|
+ <el-table v-loading="loading" :data="list">
|
|
|
+ <el-table-column label="券包编号" prop="id" width="80" align="center" />
|
|
|
+ <el-table-column label="券包名称" prop="title" align="center" />
|
|
|
<el-table-column label="券数量" prop="couponNum" />
|
|
|
- <el-table-column label="总面值" prop="facePrice">
|
|
|
- <template slot-scope="{row}">
|
|
|
- ¥{{$numberFormat(row.discount)}}
|
|
|
+ <el-table-column label="总面值">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ ¥{{ $numberFormat(row.facePrice) }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="状态" prop="status">
|
|
|
- <template slot-scope="{row}">
|
|
|
- <el-tag v-if="row.status == 0">待上架</el-tag>
|
|
|
- <el-tag v-else-if="row.status == 1">上架</el-tag>
|
|
|
- <el-tag v-else-if="row.status == 2">下架</el-tag>
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag v-if="row.status == 0" type="info">待上架</el-tag>
|
|
|
+ <el-tag v-else-if="row.status == 1" type="success">上架</el-tag>
|
|
|
+ <el-tag v-else-if="row.status == 2" type="info">下架</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column fixed="right" align="right" label="操作" width="150">
|
|
|
- <template slot-scope="{row}">
|
|
|
- <el-button v-hasPermi="['business:couponPkg:query']" type="text" @click="$router.push({ name: 'CouponPkgQuery', query: { id: row.couponId } })">查看</el-button>
|
|
|
- <el-button v-if="row.status === 0" v-hasPermi="['business:couponPkg:edit']" type="text" @click="$router.push({ name: 'CouponPkgEdit', 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:couponPkg:on']" type="text" @click="setStatus(row, 'on')">上架</el-button>
|
|
|
- <el-button v-if="JSON.parse(row.status).value === 'on'" v-hasPermi="['business:couponPkg:off']" type="text" @click="setStatus(row, 'off')">下架</el-button>
|
|
|
- <el-button v-if="JSON.parse(row.status).value === 'init'" v-hasPermi="['business:couponPkg:remove']" class="del" type="text" @click="del(row)">删除</el-button>
|
|
|
+ <el-table-column fixed="right" align="center" label="操作" width="230">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-button
|
|
|
+ v-hasPermi="['business:couponPkg:query']"
|
|
|
+ type="text"
|
|
|
+ @click="
|
|
|
+ $router.push({
|
|
|
+ name: 'CouponPkgQuery',
|
|
|
+ query: { id: row.id },
|
|
|
+ })
|
|
|
+ "
|
|
|
+ >查看</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="row.status === 0"
|
|
|
+ v-hasPermi="['business:couponPkg:edit']"
|
|
|
+ type="text"
|
|
|
+ @click="
|
|
|
+ $router.push({
|
|
|
+ name: 'CouponPkgEdit',
|
|
|
+ query: { id: row.id },
|
|
|
+ })
|
|
|
+ "
|
|
|
+ >编辑</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="row.status === 0 || row.status === 2"
|
|
|
+ v-hasPermi="['business:couponPkg:on']"
|
|
|
+ type="text"
|
|
|
+ @click="setStatus(row, 1)"
|
|
|
+ >上架</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="row.status === 1"
|
|
|
+ v-hasPermi="['business:couponPkg:off']"
|
|
|
+ type="text"
|
|
|
+ @click="setStatus(row, 2)"
|
|
|
+ >下架</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="row.status === 0"
|
|
|
+ v-hasPermi="['business:couponPkg: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()" />
|
|
|
+ <pagination
|
|
|
+ :total="total"
|
|
|
+ :page.sync="queryParams.pageNum"
|
|
|
+ :limit.sync="queryParams.pageSize"
|
|
|
+ @pagination="getList()"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { getCouponList, delCoupon, setCouponStatus } from '@/api/business/couponPkg'
|
|
|
-import { accDiv } from '@/utils/util'
|
|
|
+import {
|
|
|
+ getCouponList,
|
|
|
+ delCoupon,
|
|
|
+ setCouponPkgStatus,
|
|
|
+} from "@/api/business/couponPkg";
|
|
|
export default {
|
|
|
+ name: 'ListCouponPkg',
|
|
|
data() {
|
|
|
return {
|
|
|
loading: false,
|
|
|
showSearch: true,
|
|
|
- queryParams: {},
|
|
|
- tableData: [],
|
|
|
- total: 0
|
|
|
+ queryParams: {
|
|
|
+ title: "",
|
|
|
+ },
|
|
|
+ // 分页
|
|
|
+ pageParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ },
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ list: [],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
- this.getList(true)
|
|
|
+ this.getList();
|
|
|
},
|
|
|
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) {
|
|
|
- console.log(res)
|
|
|
- this.tableData = res.rows
|
|
|
- this.total = res.total
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ getCouponList(
|
|
|
+ "pageNum=" +
|
|
|
+ this.pageParams.pageNum +
|
|
|
+ "&pageSize=" +
|
|
|
+ this.pageParams.pageSize +
|
|
|
+ "&",
|
|
|
+ this.queryParams
|
|
|
+ )
|
|
|
+ .then((res) => {
|
|
|
+ this.loading = false;
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.list = res.rows;
|
|
|
+ this.total = res.total;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
+ //搜索
|
|
|
+ handleQuery() {
|
|
|
+ this.pageParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 重置
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm("queryForm");
|
|
|
+ this.pageParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
},
|
|
|
|
|
|
setStatus(item, status) {
|
|
|
- this.$confirm(`确认${status === 'on' ? '上架' : '下架'}券 “${item.title}” 吗?`, `${status === 'on' ? '上架' : '下架'}券`, {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- setCouponStatus({
|
|
|
- couponId: item.couponId,
|
|
|
- status
|
|
|
- }).then(res => {
|
|
|
+ this.$confirm(
|
|
|
+ `确认${status === "on" ? "上架" : "下架"}券包 “${item.title}” 吗?`,
|
|
|
+ `${status === "on" ? "上架" : "下架"}券包`,
|
|
|
+ {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ setCouponPkgStatus({
|
|
|
+ id: item.id,
|
|
|
+ status,
|
|
|
+ }).then((res) => {
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success('操作已完成!')
|
|
|
- this.getList()
|
|
|
+ this.$message.success("操作已完成!");
|
|
|
+ this.getList();
|
|
|
}
|
|
|
- })
|
|
|
- })
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
del(item) {
|
|
|
- this.$confirm(`确认删除券 “${item.title}” 吗?`, '删除券', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
+ this.$confirm(`确认删除券包 “${item.title}” 吗?`, "删除券", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
}).then(() => {
|
|
|
- delCoupon(item.couponId).then(res => {
|
|
|
+ delCoupon(item.id).then((res) => {
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success('操作已完成!')
|
|
|
- this.getList()
|
|
|
+ this.$message.success("操作已完成!");
|
|
|
+ this.getList();
|
|
|
}
|
|
|
- })
|
|
|
- })
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
},
|
|
|
};
|