2022-08-02 10:16:07 +08:00
|
|
|
<template>
|
2022-08-06 20:03:35 +08:00
|
|
|
<div class="conent">
|
|
|
|
|
<!-- 新增按钮 -->
|
|
|
|
|
<div class="btn">
|
|
|
|
|
<el-button type="primary" @click="handAdd">新增</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<div class="table">
|
|
|
|
|
<el-table
|
|
|
|
|
ref="multipleTable"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
tooltip-effect="dark"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column type="selection" width="55"> </el-table-column>
|
|
|
|
|
<el-table-column prop="name" label="商品品牌"> </el-table-column>
|
|
|
|
|
<el-table-column prop="" label="操作">
|
2022-08-02 10:16:07 +08:00
|
|
|
<template slot-scope="scope">
|
2022-08-06 20:03:35 +08:00
|
|
|
<el-button type="primary" @click="handEdit(scope.row.id, scope.row)"
|
|
|
|
|
>编辑</el-button
|
|
|
|
|
>
|
|
|
|
|
<el-button type="danger" @click="handdel(scope.row.id)"
|
|
|
|
|
>删除</el-button
|
|
|
|
|
>
|
2022-08-02 10:16:07 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
2022-08-06 20:03:35 +08:00
|
|
|
</div>
|
|
|
|
|
|
2022-08-15 19:55:44 +08:00
|
|
|
<!-- 新增品牌对话框 -->
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="新增品牌"
|
|
|
|
|
:visible.sync="dialogFormVisible"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
>
|
2022-08-02 10:16:07 +08:00
|
|
|
<el-form :model="form">
|
2022-08-12 18:26:27 +08:00
|
|
|
<el-form-item label="商品品牌" :label-width="formLabelWidth">
|
2022-08-15 19:55:44 +08:00
|
|
|
<el-input v-model="form.kindName"></el-input>
|
2022-08-02 10:16:07 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2022-08-06 20:03:35 +08:00
|
|
|
<div slot="footer" class="dialog-footer">
|
2022-08-02 10:16:07 +08:00
|
|
|
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
2022-08-06 20:03:35 +08:00
|
|
|
<el-button type="primary" @click="addSubmit">确 定</el-button>
|
2022-08-02 10:16:07 +08:00
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
2022-08-06 20:03:35 +08:00
|
|
|
|
2022-08-02 10:16:07 +08:00
|
|
|
<!-- 编辑 -->
|
2022-08-15 19:55:44 +08:00
|
|
|
<el-dialog
|
|
|
|
|
title="编辑"
|
|
|
|
|
:visible.sync="dialogFormVisible1"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
>
|
2022-08-02 10:16:07 +08:00
|
|
|
<el-form :model="form1">
|
2022-08-15 19:55:44 +08:00
|
|
|
<el-form-item label="编辑品牌" :label-width="formLabelWidth1">
|
|
|
|
|
<el-input v-model="form1.kindName1"></el-input>
|
2022-08-02 10:16:07 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2022-08-06 20:03:35 +08:00
|
|
|
<div slot="footer" class="dialog-footer">
|
2022-08-02 10:16:07 +08:00
|
|
|
<el-button @click="dialogFormVisible1 = false">取 消</el-button>
|
2022-08-06 20:03:35 +08:00
|
|
|
<el-button type="primary" @click="EditSubmit">确 定</el-button>
|
2022-08-02 10:16:07 +08:00
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
2022-08-06 20:03:35 +08:00
|
|
|
|
|
|
|
|
<!-- 分页功能 -->
|
|
|
|
|
<div class="block">
|
|
|
|
|
<el-pagination
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
:current-page="current_page"
|
|
|
|
|
:page-sizes="[15, 50, 100]"
|
|
|
|
|
:page-size="per_page"
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
:total="Paginationdata.total"
|
|
|
|
|
>
|
|
|
|
|
</el-pagination>
|
|
|
|
|
</div>
|
2022-08-02 10:16:07 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
2022-08-12 18:26:27 +08:00
|
|
|
Brand_goods_types,
|
2022-08-02 10:16:07 +08:00
|
|
|
DelBrand_goods_types,
|
|
|
|
|
AddBrandgoods_types,
|
|
|
|
|
editBrand_types,
|
2022-08-06 20:03:35 +08:00
|
|
|
} from "../../api/rankingData";
|
2022-08-19 19:28:37 +08:00
|
|
|
// import axios from "axios";
|
2022-08-02 10:16:07 +08:00
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2022-08-06 20:03:35 +08:00
|
|
|
id: "", //每一项的id
|
2022-08-02 10:16:07 +08:00
|
|
|
tableData: [],
|
|
|
|
|
multipleSelection: [],
|
|
|
|
|
dialogFormVisible: false,
|
|
|
|
|
dialogFormVisible1: false,
|
|
|
|
|
form: {
|
2022-08-06 20:03:35 +08:00
|
|
|
kindName: "", //种类名
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
form1: {
|
2022-08-06 20:03:35 +08:00
|
|
|
kindName1: "", //种类名
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
2022-08-06 20:03:35 +08:00
|
|
|
formLabelWidth: "120px",
|
|
|
|
|
formLabelWidth1: "120px",
|
2022-08-02 10:16:07 +08:00
|
|
|
newKind: [],
|
2022-08-06 20:03:35 +08:00
|
|
|
Paginationdata: {}, //分页相关数据
|
|
|
|
|
current_page: 1, //当前页
|
|
|
|
|
per_page: 15, //每页显示数量
|
|
|
|
|
};
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
created() {
|
2022-08-06 20:03:35 +08:00
|
|
|
this.getGoods_types();
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 复选框按钮
|
|
|
|
|
handleSelectionChange(val) {
|
2022-08-06 20:03:35 +08:00
|
|
|
console.log(val);
|
|
|
|
|
this.multipleSelection = val;
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
2022-08-06 20:03:35 +08:00
|
|
|
//分页功能
|
2022-08-02 10:16:07 +08:00
|
|
|
handleSizeChange(val) {
|
2022-08-06 20:03:35 +08:00
|
|
|
//当前条数
|
|
|
|
|
this.per_page = val;
|
|
|
|
|
this.getGoods_types();
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
handleCurrentChange(val) {
|
2022-08-06 20:03:35 +08:00
|
|
|
//当前页
|
|
|
|
|
this.current_page = val;
|
|
|
|
|
this.getGoods_types();
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
// 新增
|
|
|
|
|
handAdd() {
|
2022-08-06 20:03:35 +08:00
|
|
|
this.form.kindName = "";
|
|
|
|
|
this.dialogFormVisible = true;
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
// 确认新增
|
|
|
|
|
addSubmit() {
|
2022-08-06 20:03:35 +08:00
|
|
|
var string;
|
|
|
|
|
string = this.form.kindName.replace(/\s/g, ",").split(",");
|
|
|
|
|
console.log(string, "lkkkk");
|
2022-08-02 10:16:07 +08:00
|
|
|
AddBrandgoods_types({
|
|
|
|
|
names: string,
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.$message({
|
2022-08-06 20:03:35 +08:00
|
|
|
type: "success",
|
|
|
|
|
message: "添加成功",
|
|
|
|
|
});
|
|
|
|
|
this.getGoods_types();
|
|
|
|
|
});
|
|
|
|
|
this.dialogFormVisible = false;
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
// 编辑
|
|
|
|
|
handEdit(id, item) {
|
2022-08-06 20:03:35 +08:00
|
|
|
this.id = id;
|
2022-08-12 18:26:27 +08:00
|
|
|
// console.log("item", item);
|
2022-08-06 20:03:35 +08:00
|
|
|
this.form1.kindName1 = item.name;
|
|
|
|
|
this.dialogFormVisible1 = true;
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
// 编辑确定按钮
|
|
|
|
|
EditSubmit() {
|
|
|
|
|
editBrand_types(this.id, {
|
|
|
|
|
name: this.form1.kindName1,
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.$message({
|
2022-08-06 20:03:35 +08:00
|
|
|
type: "success",
|
|
|
|
|
message: "编辑成功",
|
|
|
|
|
});
|
|
|
|
|
this.getGoods_types();
|
|
|
|
|
});
|
|
|
|
|
this.dialogFormVisible1 = false;
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
// 删除
|
|
|
|
|
handdel(id) {
|
2022-08-12 18:26:27 +08:00
|
|
|
this.$confirm("确定删除此条商品品牌吗?", "确认删除", {
|
2022-08-06 20:03:35 +08:00
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
|
type: "warning",
|
2022-08-02 10:16:07 +08:00
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
DelBrand_goods_types(id).then((res) => {
|
2022-08-06 20:03:35 +08:00
|
|
|
this.getGoods_types();
|
|
|
|
|
});
|
2022-08-02 10:16:07 +08:00
|
|
|
this.$message({
|
2022-08-06 20:03:35 +08:00
|
|
|
type: "success",
|
|
|
|
|
message: "删除成功!",
|
|
|
|
|
});
|
2022-08-02 10:16:07 +08:00
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
this.$message({
|
2022-08-06 20:03:35 +08:00
|
|
|
type: "info",
|
|
|
|
|
message: "已取消删除",
|
|
|
|
|
});
|
|
|
|
|
});
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
// 获取列表
|
|
|
|
|
getGoods_types() {
|
2022-08-12 18:26:27 +08:00
|
|
|
let page = {
|
|
|
|
|
page: this.current_page,
|
|
|
|
|
per_page: this.per_page,
|
|
|
|
|
};
|
|
|
|
|
Brand_goods_types(page).then((res) => {
|
|
|
|
|
this.tableData = res.data.data;
|
|
|
|
|
this.Paginationdata = res.data.meta;
|
|
|
|
|
});
|
2022-08-02 10:16:07 +08:00
|
|
|
},
|
|
|
|
|
},
|
2022-08-06 20:03:35 +08:00
|
|
|
};
|
2022-08-02 10:16:07 +08:00
|
|
|
</script>
|
|
|
|
|
|
2022-08-06 20:03:35 +08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.conent {
|
|
|
|
|
width: 100%;
|
|
|
|
|
min-height: calc(100vh - 200px);
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
.btn {
|
|
|
|
|
height: 104px;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
.el-button {
|
|
|
|
|
width: 114px;
|
|
|
|
|
height: 44px;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.table {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.block {
|
|
|
|
|
margin-top: 30px;
|
|
|
|
|
}
|
2022-08-02 10:16:07 +08:00
|
|
|
</style>
|