index.vue
6.69 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!--
* @FileDescription: 渠道管理
* @Author: kahu
* @Date: 2022/8/25
* @LastEditors: kahu
* @LastEditTime: 2022/8/25
-->
<template>
<div style="padding: 10px;background-color:#F2F3F5">
<div class="content">
<el-button
type="primary"
@click="handleEditForm"
size="mini" style="background-color: #3F9B6A;color: #fff;"
>新增
</el-button>
<el-table
ref="multipleTable"
v-loading="loading"
class="table"
stripe
border
:header-cell-style="{fontSize: '12px', backgroundColor: '#FAFAFA',color:'#000',fontWeight: 'normal'}"
:data="list"
>
<el-table-column
type="selection"
align="center"
width="55"
/>
<el-table-column
prop="id"
align="center"
label="渠道ID"
show-overflow-tooltip
/>
<el-table-column
prop="channelName"
align="center"
label="渠道名称"
show-overflow-tooltip
/>
<el-table-column
prop="registerUrl"
align="center"
label="渠道注册链接"
show-overflow-tooltip
>
<template v-slot="scope">
<span
v-if="scope.row.registerUrl"
>{{ scope.row.registerUrl }}
</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column
prop="channelCode"
align="center"
label="渠道码"
width="130"
show-overflow-tooltip
/>
<el-table-column
prop="registerCount"
label="渠道注册人数"
align="center"
width="130"
show-overflow-tooltip
/>
<el-table-column
prop="orderUserCount"
label="渠道下单人数"
width="130"
align="center"
show-overflow-tooltip
/>
<el-table-column
prop="orderCount"
label="渠道下单笔数"
width="130"
align="center"
show-overflow-tooltip
/>
<el-table-column
prop="orderAmount"
align="center"
label="渠道下单总金额"
width="130"
show-overflow-tooltip
/>
<el-table-column
align="center"
label="操作"
width="260"
fixed="right"
>
<template v-slot="scope">
<el-button
@click="handleCopeLink(scope.row)"
size="mini" style="background-color: transparent;color: #3F9B6A;;border: none;"
>复制链接
</el-button>
<el-button
size="mini"
@click="handleEditForm(scope.row)"
style="background-color: transparent;color: #3F9B6A;;border: none;"
>编辑
</el-button>
<el-button
size="mini"
style="background-color: transparent;color: #3F9B6A;;border: none;"
@click="handleDelete(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:current-page="queryOptions.page"
:page-size="queryOptions.pageSize"
:page-sizes="tableOptions.pageSizes"
:total="tableOptions.total"
small
@size-change="(val)=>handlePageChange(val,1)"
@current-change="(val)=>handlePageChange(val,2)"
/>
<!-- 表单 -->
<ChannelForm
v-model="showForm"
:item="formItem"
@confirm="handleResetTable"
@cancel="handleResetTable"
/>
</div>
</div>
</template>
<script>
import ChannelForm from './form'
import { getList, del } from '@/api/channel';
export default {
name: 'Index',
components: { ChannelForm },
data () {
return {
showForm: false,
formItem: {},
loading: false,
list: [],
queryOptions: {
page: 1,
pageSize: 10
},
tableOptions: {
headStyle: { background: '#EEF3FF', color: '#333333' },
pageSizes: [5, 10, 30, 50, 100],
total: 0
}
}
},
created () {
this.handleGetTable()
},
methods: {
handleResetTable () {
this.queryOptions.page = 1
this.handleGetTable()
},
async handleGetTable () {
this.loading = true
const { data } = await getList(this.queryOptions);
this.list = data.list
this.tableOptions.total = data.total
this.loading = false
},
/**
* 分页
* @param val
* @param type 1page 2pageSize
*/
handlePageChange (val, type) {
type === 1 ? this.queryOptions.page = val : this.queryOptions.pageSize = val
this.handleGetTable()
},
handleEditForm (item) {
if (!item) {
this.formItem = {}
} else {
this.formItem = item
}
this.showForm = true
},
handleCopeLink (item) {
const htmlInputElement = document.createElement('input');
htmlInputElement.value = item.registerUrl
document.body.appendChild(htmlInputElement);
htmlInputElement.select()
document.execCommand('copy')
document.body.removeChild(htmlInputElement)
this.$message.success('复制成功')
},
handleDelete (item) {
const message = `是否删除渠道${item.channelName}`
this.$confirm(message, '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.loading = true
// TODO 删除逻辑
await del({ id: item.id, channelName: item.channelName })
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
}).finally(() => {
this.loading = false
this.handleGetTable()
});
}
}
}
</script>
<style
lang="scss"
scoped
>
::v-deep .el-form-item__label{
font-weight: normal;
font-size: 12px;
}
::v-deep .btn .el-button:focus,
.el-button:hover {
border: 1px solid #3F9B6A;
}
::v-deep .el-button {
border: 1px solid #3F9B6A;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
background-color: #3F9B6A;
}
::v-deep .el-input__inner:focus {
border: #3F9B6A 1px solid;
}
.content {
padding: 20px;
box-sizing: border-box;
min-height: calc(100vh - 50px - 20px);
background-color:#fff;
.table {
margin: 20px 0;
}
}
</style>