coupon-select.vue
4.02 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
<template>
<div class="product-select">
<el-form :inline="true" :model="formData" class="demo-form-inline">
<el-form-item label="">
<el-input v-model="formData.keyword" placeholder="请输入优惠券名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
</el-form-item>
</el-form>
<el-table
:data="tableData"
max-height="500"
border
style="width: 100%"
ref="couponTable"
row-key="productId"
@selection-change="handleSelectionChange"
>
<el-table-column
width="40"
type="selection"
:reserve-selection="true"
fixed="left"
>
</el-table-column>
<el-table-column
prop="couponName"
label="优惠券名称"
width="180">
</el-table-column>
<el-table-column
prop="content"
label="内容">
</el-table-column>
<el-table-column
prop="effectiveStart"
label="活动开始时间">
</el-table-column>
<el-table-column
prop="effectiveEnd"
label="活动结束时间">
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:hide-on-single-page="true"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</template>
<script>
import api from '@@/components/canvasShow/config/api'
import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
import Cookies from 'js-cookie'
import { mapGetters } from 'vuex'
export default {
name: 'coupon-select',
mixins: [sendReqMixin],
data () {
return {
tableRadio: '',
formData: {
keyword: ''
},
currentPage: 1,
total: 0,
pageSize: 10,
multipleSelection: [],
tableData: [{
id: 100,
name: '测试'
}]
}
},
mounted () {
this.getTableData()
},
computed: {
...mapGetters([
'typeId'
])
},
methods: {
// 获取优惠券
getTableData () {
var _this = this
let _url = ''
if(this.typeId===1){
_url = `${api.getCoupons}?page=${this.currentPage}&pageSize=${this.pageSize}`
} else if(this.typeId===3){
_url = `${api.getShopCoupons}?page=${this.currentPage}&pageSize=${this.pageSize}&shopId=${Cookies.get('cereShopId')}`
}
if (this.formData.keyword) {
_url += `&search=${this.formData.keyword}`
}
let params = {
url: _url,
method: 'GET'
}
this.sendReq(params, (res) => {
_this.tableData = res.data.list
if(this.typeId===1){
_this.tableData.map(function(value){
value.couponName = value.activityName
value.effectiveStart = value.activityStartTime
value.effectiveEnd = value.activityEndTime
return value;
});
}
_this.total = res.data.total
})
},
// 搜索
onSubmit () {
this.getTableData()
},
// 每页条数改变
handleSizeChange (val) {
this.pageSize = val
this.getTableData()
},
// 当前页改变
handleCurrentChange (val) {
this.currentPage = val
this.getTableData()
},
// 多选改变
handleSelectionChange (val) {
this.multipleSelection = val
},
// 多选改变
resetTableData (list) {
this.$refs.couponTable.clearSelection();
this.$refs.couponTable.toggleRowSelection(list,true);
}
}
}
</script>
<style lang="scss" scoped>
.product-select{
.el-pagination{
padding: 0px;
margin-top: 30px;
}
.el-table{
.img{
width: 80px;
height: 80px;
}
}
}
</style>