<template>
|
<div class="BannerList">
|
<div class="header">轮播图</div>
|
<div class="buttonArea">
|
<div class="addButton" @click="addProduct">
|
<span class="icon">+</span>
|
添加
|
</div>
|
</div>
|
<div class="content">
|
<div class="table-area">
|
<el-table
|
id="multipleTable"
|
ref="multipleTable"
|
:data="dataList"
|
tooltip-effect="dark"
|
:fit="true"
|
>
|
<el-table-column label="序号" width="68">
|
<template slot-scope="scope">{{ scope.$index + 1 }}</template>
|
</el-table-column>
|
<el-table-column prop="name" label="产品名称"></el-table-column>
|
|
<el-table-column label="图片">
|
<template slot-scope="scope">
|
<ImageShow :src="scope.row.pic" alt=""> </ImageShow>
|
</template>
|
</el-table-column>
|
|
<el-table-column prop="sort">
|
<template slot="header">
|
<div class="label">
|
排序 <span class="des">(数值越小越靠前)</span>
|
</div>
|
</template>
|
</el-table-column>
|
|
<el-table-column label="隐藏/显示">
|
<template slot-scope="scope">
|
<el-switch
|
v-model="scope.row.isShow"
|
active-color="#0064FF"
|
inactive-color="#C0C5CC"
|
@change="toggleIsShow($event, scope.row.id)"
|
>
|
</el-switch>
|
</template>
|
</el-table-column>
|
|
<el-table-column label="操作">
|
<template slot-scope="scope">
|
<span class="link" @click="edit(scope.row)">编辑</span>
|
<span class="del" @click="chooseDelete(scope.row.id)">
|
删除
|
</span>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
|
<DelBox
|
v-if="showDelBox"
|
@close="showDelBox = false"
|
@confirm="deleteProduct"
|
></DelBox>
|
<AddBanner
|
v-if="showAddBox"
|
:editObj="editObj"
|
@close="cancel"
|
@addSuccess="reflesh"
|
></AddBanner>
|
</div>
|
</template>
|
|
<script>
|
import DelBox from "@/views/operateManage/productManage/DelBox";
|
import AddBanner from "@/views/operateManage/productManage/AddBanner";
|
import {
|
getIndexPicList,
|
setIndexPicIsShow,
|
deleteIndexPic,
|
} from "@/api/product";
|
|
export default {
|
components: {
|
DelBox,
|
AddBanner,
|
},
|
created() {
|
this.getBannerList();
|
},
|
data() {
|
return {
|
input: "",
|
time: "",
|
dataList: [],
|
showDelBox: false,
|
delId: null,
|
showAddBox: false,
|
editObj: null,
|
};
|
},
|
methods: {
|
async getBannerList() {
|
const res = await getIndexPicList();
|
if (res && res.success) {
|
this.dataList = res.data.list;
|
}
|
},
|
edit(obj) {
|
this.editObj = obj;
|
this.showAddBox = true;
|
},
|
chooseDelete(id) {
|
this.delId = id;
|
this.showDelBox = true;
|
},
|
async deleteProduct() {
|
this.showDelBox = false;
|
const res = await deleteIndexPic({
|
id: this.delId,
|
});
|
if (res && res.success) {
|
this.getBannerList();
|
this.$notify({
|
type: "success",
|
message: "删除成功",
|
});
|
}
|
},
|
addProduct() {
|
this.editObj = null;
|
this.showAddBox = true;
|
},
|
|
async toggleIsShow(val, id) {
|
await setIndexPicIsShow({
|
id: id,
|
isShow: val,
|
});
|
},
|
reflesh() {
|
this.getBannerList();
|
this.cancel();
|
},
|
cancel() {
|
this.showAddBox = false;
|
this.editObj = null;
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.BannerList {
|
position: relative;
|
background-color: rgb(243, 245, 248);
|
.header {
|
margin-bottom: 24px;
|
padding: 0 24px;
|
height: 50px;
|
font-size: 16px;
|
color: #666666;
|
line-height: 50px;
|
background: #ffffff;
|
vertical-align: middle;
|
font-weight: 700;
|
|
.iconfont {
|
margin-right: 10px;
|
font-size: 18px;
|
cursor: pointer;
|
}
|
}
|
|
.buttonArea {
|
display: flex;
|
justify-content: flex-end;
|
margin: 20px 20px 0 0px;
|
.addButton {
|
width: 84px;
|
height: 32px;
|
border-radius: 3px;
|
background: #0064ff;
|
color: #fff;
|
font-size: 14px;
|
vertical-align: middle;
|
text-align: center;
|
line-height: 32px;
|
cursor: pointer;
|
|
.iconfont {
|
font-size: 16px;
|
font-weight: 700;
|
}
|
}
|
}
|
|
.content {
|
margin: 24px;
|
padding: 20px;
|
background-color: #fff;
|
|
.link {
|
margin-right: 10px;
|
color: #0064ff;
|
cursor: pointer;
|
}
|
|
.del {
|
color: #ff4a32;
|
cursor: pointer;
|
}
|
|
.des {
|
font-size: 14px;
|
color: #666666;
|
font-weight: normal;
|
}
|
|
img {
|
width: 136px;
|
height: 76px;
|
}
|
}
|
}
|
</style>
|