Skip to content

Commit 7c89159

Browse files
committed
promotion:增加优惠劵的前端分页界面 80%
1 parent 27f63dc commit 7c89159

File tree

4 files changed

+179
-2
lines changed

4 files changed

+179
-2
lines changed

src/api/mall/promotion/coupon.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import request from '@/utils/request'
2+
3+
// 删除优惠劵
4+
export function deleteCoupon(id) {
5+
return request({
6+
url: '/promotion/coupon/delete?id=' + id,
7+
method: 'delete'
8+
})
9+
}
10+
11+
// 获得优惠劵分页
12+
export function getCouponPage(query) {
13+
return request({
14+
url: '/promotion/coupon/page',
15+
method: 'get',
16+
params: query
17+
})
18+
}

src/utils/dict.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export const DICT_TYPE = {
6363
// ========== MALL - PROMOTION 模块 ==========
6464
PROMOTION_DISCOUNT_TYPE: 'promotion_discount_type', // 优惠类型
6565
PROMOTION_PRODUCT_SCOPE: 'promotion_product_scope', // 营销的商品范围
66-
COUPON_TEMPLATE_VALIDITY_TYPE: 'coupon_template_validity_type', // 优惠劵模板的有限期类型
66+
PROMOTION_COUPON_TEMPLATE_VALIDITY_TYPE: 'promotion_coupon_template_validity_type', // 优惠劵模板的有限期类型
67+
PROMOTION_COUPON_STATUS: 'promotion_coupon_status', // 优惠劵的状态
6768
}
6869

6970
/**
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<template>
2+
<div class="app-container">
3+
<!-- 搜索工作栏 -->
4+
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5+
<el-form-item label="会员昵称" prop="nickname">
6+
<el-input v-model="queryParams.nickname" placeholder="请输入会员昵称" clearable @keyup.enter.native="handleQuery"/>
7+
</el-form-item>
8+
<el-form-item label="创建时间" prop="createTime">
9+
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
10+
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
11+
</el-form-item>
12+
<el-form-item>
13+
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
14+
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
15+
</el-form-item>
16+
</el-form>
17+
18+
<!-- 操作工具栏 -->
19+
<el-row :gutter="10" class="mb8">
20+
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
21+
</el-row>
22+
23+
<!-- Tab 选项:真正的内容在 Lab -->
24+
<el-tabs v-model="activeTab" type="card" @tab-click="tabClick" style="margin-top: -40px;">
25+
<el-tab-pane v-for="tab in statusTabs" :key="tab.value" :label="tab.label" :name="tab.value" />
26+
</el-tabs>
27+
28+
<!-- 列表 -->
29+
<el-table v-loading="loading" :data="list">
30+
<el-table-column label="会员信息" align="center" prop="nickname" /> <!-- TODO 芋艿:以后支持头像,支持跳转 -->
31+
<el-table-column label="优惠劵" align="center" prop="name" />
32+
<el-table-column label="优惠码状态" align="center" prop="status" />
33+
<el-table-column label="生效开始时间" align="center" prop="validStartTime" width="180">
34+
<template slot-scope="scope">
35+
<span>{{ parseTime(scope.row.validStartTime) }}</span>
36+
</template>
37+
</el-table-column>
38+
<el-table-column label="生效结束时间" align="center" prop="validEndTime" width="180">
39+
<template slot-scope="scope">
40+
<span>{{ parseTime(scope.row.validEndTime) }}</span>
41+
</template>
42+
</el-table-column>
43+
<el-table-column label="使用时间" align="center" prop="useTime" width="180">
44+
<template slot-scope="scope">
45+
<span>{{ parseTime(scope.row.useTime) }}</span>
46+
</template>
47+
</el-table-column>
48+
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
49+
<template slot-scope="scope">
50+
<span>{{ parseTime(scope.row.createTime) }}</span>
51+
</template>
52+
</el-table-column>
53+
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
54+
<template slot-scope="scope">
55+
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
56+
v-hasPermi="['promotion:coupon:delete']">删除</el-button>
57+
</template>
58+
</el-table-column>
59+
</el-table>
60+
<!-- 分页组件 -->
61+
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
62+
@pagination="getList"/>
63+
</div>
64+
</template>
65+
66+
<script>
67+
import { deleteCoupon, getCouponPage } from "@/api/mall/promotion/coupon";
68+
import { DICT_TYPE, getDictDatas} from "@/utils/dict";
69+
70+
export default {
71+
name: "Coupon",
72+
components: {
73+
},
74+
data() {
75+
return {
76+
// 遮罩层
77+
loading: true,
78+
// 导出遮罩层
79+
exportLoading: false,
80+
// 显示搜索条件
81+
showSearch: true,
82+
// 总条数
83+
total: 0,
84+
// 优惠劵列表
85+
list: [],
86+
// 弹出层标题
87+
title: "",
88+
// 是否显示弹出层
89+
open: false,
90+
// 查询参数
91+
queryParams: {
92+
pageNo: 1,
93+
pageSize: 10,
94+
createTime: [],
95+
status: undefined,
96+
},
97+
// Tab 想选
98+
activeTab: 'all',
99+
statusTabs: [{
100+
label: '全部',
101+
value: 'all'
102+
}],
103+
};
104+
},
105+
created() {
106+
this.getList();
107+
// 设置 statuses 过滤
108+
for (const dict of getDictDatas(DICT_TYPE.PROMOTION_COUPON_STATUS)) {
109+
this.statusTabs.push({
110+
label: dict.label,
111+
value: dict.value
112+
})
113+
}
114+
},
115+
methods: {
116+
/** 查询列表 */
117+
getList() {
118+
this.loading = true;
119+
// 执行查询
120+
getCouponPage(this.queryParams).then(response => {
121+
this.list = response.data.list;
122+
this.total = response.data.total;
123+
this.loading = false;
124+
});
125+
},
126+
/** 取消按钮 */
127+
cancel() {
128+
this.open = false;
129+
this.reset();
130+
},
131+
/** 搜索按钮操作 */
132+
handleQuery() {
133+
this.queryParams.pageNo = 1;
134+
this.getList();
135+
},
136+
/** 重置按钮操作 */
137+
resetQuery() {
138+
this.resetForm("queryForm");
139+
this.handleQuery();
140+
},
141+
/** 删除按钮操作 */
142+
handleDelete(row) {
143+
const id = row.id;
144+
this.$modal.confirm('是否确认删除优惠劵编号为"' + id + '"的数据项?').then(function() {
145+
return deleteCoupon(id);
146+
}).then(() => {
147+
this.getList();
148+
this.$modal.msgSuccess("删除成功");
149+
}).catch(() => {});
150+
},
151+
tabClick(tab) {
152+
this.queryParams.status = tab.name === 'all' ? undefined : tab.name;
153+
this.list = [];
154+
this.getList();
155+
}
156+
}
157+
};
158+
</script>

src/views/mall/promotion/couponTemplate/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
</el-form-item>
118118
<el-form-item label="有效期类型" prop="validityType">
119119
<el-radio-group v-model="form.validityType">
120-
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COUPON_TEMPLATE_VALIDITY_TYPE)"
120+
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_COUPON_TEMPLATE_VALIDITY_TYPE)"
121121
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
122122
</el-radio-group>
123123
</el-form-item>

0 commit comments

Comments
 (0)