index.vue
4.14 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
<!--
* @FileDescription: 品牌管理
* @Author: kahu
* @Date: 2022/8/29
* @LastEditors: kahu
* @LastEditTime: 2022/8/29
-->
<template>
<div style="background-color:#f7f7f7;padding:10px 10px;">
<div class="content">
<div style="height:58px;line-height:58px;">
<div style="color:#0006"> <span>商品管理</span> <span style="padding:0 5px;">></span> <span style="color:#000000e6">品牌管理</span></div>
</div>
<el-row :gutter="10" class="padding-bottom">
<el-col :span="24">
<el-button style="background-color: #3F9B6A;color: #fff" @click="formOption.show = true">新增</el-button>
</el-col>
</el-row>
<el-table
v-loading="loading"
:data="list"
:header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
>
<el-table-column
header-align="center"
align="center"
prop="brandName"
label="品牌名称"
width="180"
/>
<el-table-column
header-align="center"
align="center"
prop="brandLogo"
label="Logo"
>
<template v-slot="scope">
<el-image :src="$baseURL+scope.row.brandLogo" :preview-src-list="[`${$baseURL+scope.row.brandLogo}`]" style="width: 100px;height: 100px" />
</template>
</el-table-column>
<el-table-column
align="center"
label="相关操作"
header-align="center"
>
<template v-slot="scope">
<div class="tableBtn greens" @click="handleUpdate(scope.row)">修改</div>
<el-popconfirm
title="确定删除吗?"
@confirm="handleDelete(scope.row)"
>
<div slot="reference" class="tableBtn greens">删除</div>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="query.page"
:page-sizes="tableOptions.pageSizes"
:page-size="query.pageSize"
:layout="tableOptions.layout"
:total="tableOptions.total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
<Form v-model="formOption.show" :item="formOption.item" @confirm="getList" @cancel="getList" />
</div>
</div>
</template>
<script>
import { getBrandAll, deleteBrand } from '@/api/renovation';
import Form from './form'
export default {
name: 'Brand',
components: { Form },
data () {
return {
list: [],
query: {
page: 0,
pageSize: 10
},
tableOptions: {
total: 0,
layout: 'total, sizes, prev, pager, next, jumper',
pageSizes: [10, 30, 50, 100, 200]
},
formOption: {
show: false,
item: null
}
}
},
created () {
this.getList()
},
methods: {
async getList () {
this.loading = true
const { data } = await getBrandAll(this.query);
this.loading = false
this.list = data.list
this.tableOptions.total = data.total
},
handleSizeChange (val) {
this.query.pageSize = val
this.getList()
},
handleCurrentChange (val) {
this.query.page = val
this.getList()
},
handleUpdate (item) {
this.formOption.item = item
this.formOption.show = true
},
async handleDelete (item) {
this.loading = true
await deleteBrand(item)
this.loading = false
this.$message.success('删除成功')
this.getList()
}
}
}
</script>
<style
lang="scss"
scoped
>
.content{
padding: 0 20px 20px 20px;
min-height: calc(100vh - 50px - 20px);
background-color: #Fff;
}
.padding-bottom{
padding-bottom: 30px;
}
.tableBtn {
display: inline-block;
margin-right: 10px;
}
.greens {
color: #3F9B6A ;
}
::v-deep .buttonHover:hover{
color:#3f9b6a !important;
border-color: #c5e1d2 !important;
background-color: #ecf5f0 !important;
outline: none;
}
::v-deep .el-pagination__total {
position: absolute;
left: 10px;
}
</style>