index.vue
7.27 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
<!-- -->
<template>
<div>
<div class="pending">
<!-- 搜索 -->
<div class="formSearch">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="活动名称">
<el-input v-model="formInline.activityName" placeholder="请输入活动名称" />
</el-form-item>
<el-form-item label="活动状态">
<el-select v-model="formInline.state" placeholder="请选择活动状态">
<el-option label="报名未开始" value="0" />
<el-option label="报名进行中" value="1" />
<el-option label="活动待开始" value="2" />
<el-option label="活动进行中" value="3" />
<el-option label="活动已结束" value="4" />
</el-select>
</el-form-item>
<el-form-item label="营销方式">
<el-select v-model="formInline.discountMode" placeholder="请选择营销方式">
<el-option label="满减" value="1" />
<el-option label="优惠券" value="2" />
</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="addActive">新建活动</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 label="活动名称" width="220">
<template slot-scope="scope">{{ scope.row.activityName }}</template>
</el-table-column>
<el-table-column label="活动状态">
<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="discountMode" label="营销方式">
<template slot-scope="scope">
<span v-if="scope.row.discountMode == 1">满减</span>
<span v-if="scope.row.discountMode == 2">优惠券</span>
</template>
</el-table-column>
<el-table-column prop="shopNumber" label="商家数" />
<el-table-column prop="productNumber" label="商品数量" />
<el-table-column label="操作" 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="edit(scope.row)">编辑</el-button>
<el-button v-if="scope.row.state != 4" type="text" @click="del(scope.row)">结束</el-button>
<el-button v-if="scope.row.state == 4" type="text" @click="deleteA(scope.row)">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
<div class="fenye">
<el-pagination
:current-page="currentPage"
: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>
</div>
<el-dialog
:title="'直播间信息'"
:visible.sync="activityVisible"
width="50%"
center
:close-on-click-modal="false"
>
<AddActive />
</el-dialog>
</div>
</template>
<script>
import AddActive from '@/views/active/addActive.vue'
import { activeGetAll, activeEnd, activeDelete } from '@/api/active'
export default {
components: {
AddActive
},
data() {
// 这里存放数据
return {
formInline: {
activityName: '',
// 活动状态 0-报名未开始 1-报名进行中 2-活动待开始 3-活动进行中 4-活动已结束
state: '',
discountMode: '', // 优惠方式 1-满减 2-优惠券
page: 1,
pageSize: 10
},
total: 1,
tableData: [],
currentPage: 1,
activityVisible: false
}
},
// 监听属性 类似于data概念
computed: {},
// 监控data中的数据变化
watch: {},
// 生命周期 - 创建完成(可以访问当前this实例)
created() {},
// 生命周期 - 挂载完成(可以访问DOM元素)
mounted() {
this.getAll(this.formInline)
},
// 方法集合
methods: {
handleSizeChange(val) {
this.formInline.pageSize = val
this.getAll(this.formInline)
},
handleCurrentChange(val) {
this.formInline.page = val
this.getAll(this.formInline)
},
// 新建活动
addActive() {
// this.$router.push({
// name: 'addActive'
// })
this.activityVisible = true
},
// 查询
search() {
this.total = 1
this.formInline.page = 1
this.getAll(this.formInline)
},
// 重置
clear() {
this.formInline = {
activityName: '',
// 活动状态 0-报名未开始 1-报名进行中 2-活动待开始 3-活动进行中 4-活动已结束
state: '',
discountMode: '', // 优惠方式 1-满减 2-优惠券
page: 1,
pageSize: 10
}
this.getAll(this.formInline)
},
// 详情
details(row) {
// this.$router.push({ name: 'activeDetails', query: { info: row }})
},
// 编辑
edit(item) {
// this.$router.push({
// name: 'addActive',
// query: { info: item }
// })
},
// 删除活动
async deleteA(row) {
const res = await activeDelete({ activityId: row.activityId })
if (res.code === '') {
this.$message({
message: '删除成功',
type: 'success'
})
this.getAll(this.formInline)
}
},
// 结束
async del(row) {
const res = await activeEnd({ activityId: row.activityId })
if (res.code === '') {
this.$message({
message: '结束成功',
type: 'success'
})
this.getAll(this.formInline)
}
},
// 初始化查询所有数据
async getAll(formInline) {
const res = await activeGetAll(formInline)
console.log(res)
this.tableData = res.data.list
this.total = res.data.total
}
}
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
@import url("../../styles/elDialog.scss");
.pending {
padding: 30px;
}
.fenye {
margin-top: 20px;
}
.detail_title {
font-size: 24px;
color: #333333;
position: relative;
margin: 50px 20px 20px;
&:before {
content: "";
display: block;
position: absolute;
top: 5px;
left: -20px;
width: 4px;
height: 24px;
background-color: #3a68f2;
}
}
</style>