index.vue
6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<template>
<div class="zhekouPage">
<!-- 搜索 -->
<div class="formSearch">
<!-- 搜索条件 -->
<el-form :inline="true" :model="query" class="demo-form-inline">
<el-form-item label="活动名称">
<el-input v-model="query.discountName" placeholder="请输入活动名称" />
</el-form-item>
<el-form-item label="活动状态">
<el-select v-model="query.state" placeholder="请选择活动状态">
<el-option
v-for="item in activityStatusSelect"
:key="item.index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" plain @click="search">查询</el-button>
<el-button plain @click="clear">重置</el-button>
<el-button type="primary" plain @click="addActivity">新建活动</el-button>
</el-form-item>
</el-form>
</div>
<!-- 表格 -->
<div class="tableBox">
<el-table
ref="multipleTable"
:data="tableData"
border
:header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
tooltip-effect="dark"
style="width: 100%"
>
<el-table-column prop="discountName" label="活动名称" align="center" width="220" />
<el-table-column prop="content" label="活动内容" align="center" />
<el-table-column label="活动状态" align="center">
<template slot-scope="scope">
<span v-if="scope.row.state == 0">报名未开始</span>
<span v-if="scope.row.state == 1">报名进行中</span>
<span v-if="scope.row.state == 2">活动待开始</span>
<span v-if="scope.row.state == 3">活动进行中</span>
<span v-if="scope.row.state == 4">活动已结束</span>
</template>
</el-table-column>
<el-table-column prop="signTime" label="报名时间" align="center" />
<el-table-column prop="time" label="起止时间" align="center" />
<el-table-column prop="shops" label="商家数" align="center" />
<el-table-column prop="products" label="商品数量" align="center" />
<el-table-column label="操作" align="center" show-overflow-tooltip>
<template slot-scope="scope">
<div class="btnList">
<el-button type="text" @click="details(scope.row)">详情</el-button>
<el-button v-if="scope.row.state != 4" type="text" @click="editActivity(scope.row)">编辑</el-button>
<el-button v-if="scope.row.state != 4" type="text" @click="endActivity(scope.row)">结束</el-button>
<el-button v-if="scope.row.state == 4" type="text" @click="delActivity(scope.row)">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
<div class="fenye">
<el-pagination
:current-page="query.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="10"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</div>
<el-dialog
:title="editForm ? '修改优惠券活动' : '新增优惠券活动'"
:visible.sync="activityVisible"
width="50%"
center
:close-on-click-modal="false"
>
<AddActive
:activity-form="activityForm"
:is-edit="editForm"
@cancel="activityVisible = false"
@refersh="refersh('activityVisible')"
/>
</el-dialog>
<el-dialog
:title="'限时折扣活动详情'"
:visible.sync="activityDetailVisible"
width="74%"
center
:close-on-click-modal="false"
@close="cleanForm('activityDetailVisible')"
>
<ActivityDetail :activity-id="activityForm.discountId" />
</el-dialog>
</div>
</template>
<script>
import AddActive from '@/views/active/discountlist/discountAdd.vue'
import ActivityDetail from '@/views/active/discountlist/discountDetail.vue'
import {
getDiscountData,
stopDiscountData,
delDiscountData
} from '@/api/active/active_discount.js'
export default {
components: {
AddActive,
ActivityDetail
},
data () {
return {
query: {
discountName: '', // 活动名称
// 活动状态 0-报名未开始 1-报名进行中 2-活动待开始 3-活动进行中 4-活动已结束
state: '',
page: 1,
pageSize: 10
},
total: 1,
tableData: [],
activityStatusSelect: [
{
index: 0,
label: '报名未开始',
value: 0
},
{
index: 1,
label: '报名进行中',
value: 1
},
{
index: 2,
label: '活动待开始',
value: 2
},
{
index: 3,
label: '活动进行中',
value: 3
},
{
index: 4,
label: '活动已结束',
value: 4
}
],
activityVisible: false,
editForm: 0,
activityDetailVisible: false,
activityForm: {}
}
},
created() {
this.getAll()
},
methods: {
async getAll() {
const res = await getDiscountData(this.query)
this.tableData = res.data.list
this.total = res.data.total
},
handleSizeChange(val) {
this.query.pageSize = val
this.getAll()
},
handleCurrentChange(val) {
this.query.page = val
this.getAll()
},
search() {
this.total = 1
this.query.page = 1
this.getAll()
},
// 重置
clear() {
this.query = {
discountName: '',
state: '',
page: 1,
pageSize: 10
}
this.getAll()
},
// 活动详情
details(row) {
this.activityForm = row
this.activityDetailVisible = true
},
// 添加活动
addActivity () {
this.editForm = 0
this.activityVisible = true
},
editActivity (row) {
this.editForm = 1
this.activityForm = row
this.activityVisible = true
},
async endActivity(item) {
const res = await stopDiscountData({ discountId: item.discountId })
if (res.code === '') {
this.$message.success('结束成功')
} else {
this.$message.error(res.message)
}
this.getAll()
},
async delActivity(item) {
const res = await delDiscountData({ discountId: item.discountId })
if (res.code === '') {
this.$message({
message: '结束成功',
type: 'success'
})
} else {
this.$message.error(res.message)
}
this.getAll()
},
cleanForm (attr) {
attr = false
},
refersh (attr) {
this[attr] = false
this.getAll()
}
}
}
</script>
<style lang="scss" scoped>
.zhekouPage{
padding: 30px;
.tableBox{
.fenye{
margin: 20px;
}
}
}
</style>