Commit 9bda343f authored by 吴春's avatar 吴春

11

parent 15a62820
<template> <template>
<div class="brandClassification"> <div class="brandClassification">
<div class="head-title"> <div class="head-title">
<span>品牌分类管理</span> 品牌分类管理
<el-button style="float: right; margin-top: -5px" size="small" type="primary" @click="goAdd"> <div>
<el-button style="float: right; margin-top: -25px" size="small" type="primary" @click="goAdd">
新增分类 新增分类
</el-button> </el-button>
</div> </div>
</div>
<div style="margin-top: 10px; background: #fff; padding: 20px"> <div style="margin-top: 10px; background: #fff; padding: 20px">
<div v-loading="loading" class="cat-container"> <div v-loading="loading" class="cat-container">
<el-card class="card-item-box" shadow="never"> <el-card class="card-item-box" shadow="never">
...@@ -56,8 +58,10 @@ ...@@ -56,8 +58,10 @@
</div> </div>
</div> </div>
<div class="item-actions"> <div class="item-actions">
<el-button @click.stop="editChildNews(item)" type="text" size="small" class="action-btn edit">编辑</el-button> <el-button @click.stop="editChildNews(item)" type="text" size="small" class="action-btn edit">编辑
<el-button @click.stop="delChildNews(item)" type="text" size="small" class="action-btn delete">删除</el-button> </el-button>
<el-button @click.stop="delChildNews(item)" type="text" size="small" class="action-btn delete">删除
</el-button>
</div> </div>
</div> </div>
<div v-if="childTableData.length == 0" class="empty-state"> <div v-if="childTableData.length == 0" class="empty-state">
...@@ -84,7 +88,7 @@ ...@@ -84,7 +88,7 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="上级分类" v-if="addLevel === 2" class="is-required" prop="ParentId"> <el-form-item label="上级分类" v-if="addLevel === 2" class="is-required" prop="ParentId">
<el-select v-model="addMsg.ParentId" placeholder="请选择上级分类" size="small" style="width: 100%"> <el-select v-model="addMsg.ParentId" placeholder="请选择上级分类" size="small" style="width: 100%" filterable>
<el-option v-for="item in tableData" :key="item.ID" :label="item.ClassName" :value="item.ID"></el-option> <el-option v-for="item in tableData" :key="item.ID" :label="item.ClassName" :value="item.ID"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -92,7 +96,8 @@ ...@@ -92,7 +96,8 @@
<el-input type="text" v-model="addMsg.ClassName" size="small" placeholder="品牌分类名称" maxlength="100"> <el-input type="text" v-model="addMsg.ClassName" size="small" placeholder="品牌分类名称" maxlength="100">
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="Logo" class="is-required" prop="Logo"> <!--class="is-required" prop="Logo"-->
<el-form-item label="Logo" >
<el-button @click="isShowImage = true" size="small">选择文件</el-button> <el-button @click="isShowImage = true" size="small">选择文件</el-button>
<div style="position: relative; width: 100px; margin-top: 10px; border: none"> <div style="position: relative; width: 100px; margin-top: 10px; border: none">
<img v-if="!addMsg.Logo || addMsg.Logo == ''" src="../../assets/img/default.png" <img v-if="!addMsg.Logo || addMsg.Logo == ''" src="../../assets/img/default.png"
...@@ -114,19 +119,14 @@ ...@@ -114,19 +119,14 @@
<script> <script>
import ChooseImg from "@/components/global/ChooseImg.vue"; import ChooseImg from "@/components/global/ChooseImg.vue";
import draggable from "vuedraggable";
export default { export default {
name: "brandClassification", name: "brandClassification",
components: { components: {
ChooseImg, ChooseImg,
draggable,
}, },
data() { data() {
return { return {
val: "", val: "",
dragState: false,
checkAll1: false,
checkAll2: false,
loading: false, loading: false,
msg: { msg: {
ClassName: "", ClassName: "",
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
ClassName: "", ClassName: "",
ParentId: 0, ParentId: 0,
BrandCategory: 3, BrandCategory: 3,
SortNum:0, SortNum: 0,
}, },
rules: { rules: {
ClassName: [{ ClassName: [{
...@@ -173,16 +173,6 @@ ...@@ -173,16 +173,6 @@
this.getList(); this.getList();
}, },
methods: { methods: {
handleCheckAll1(val) {
this.tableData.forEach((item) => {
item.checked = val;
});
},
handleCheckAll2(val) {
this.childTableData.forEach((item) => {
item.checked = val;
});
},
goAdd() { goAdd() {
this.addMsg.ID = 0; this.addMsg.ID = 0;
this.addMsg.Logo = ""; this.addMsg.Logo = "";
...@@ -201,18 +191,6 @@ ...@@ -201,18 +191,6 @@
} }
} }
}, },
goAddChild() {
if (!this.currentParentId) {
this.Error("请先选择一级分类");
return;
}
this.addMsg.ID = 0;
this.addMsg.Logo = "";
this.addMsg.ClassName = "";
this.addMsg.ParentId = this.currentParentId;
this.addLevel = 2;
this.dialogVisible = true;
},
SelectId(msg) { SelectId(msg) {
let url = this.getIconLink(msg.url); let url = this.getIconLink(msg.url);
this.addMsg.Logo = url; this.addMsg.Logo = url;
...@@ -222,46 +200,43 @@ ...@@ -222,46 +200,43 @@
this.activeIndex = item.ID; this.activeIndex = item.ID;
this.currentParentId = item.ID; this.currentParentId = item.ID;
this.currentParentName = item.ClassName; this.currentParentName = item.ClassName;
this.getChildList(); // 从树形数据的 subList 获取二级分类
this.childTableData = item.subList || [];
}, },
getList() { getList() {
this.loading = true; this.loading = true;
this.apipost("/api/Trade/GetBrandClassList", this.msg, (res) => { this.apipost("/api/Trade/GetBrandClassTreeEdit", this.msg, (res) => {
this.loading = false; this.loading = false;
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
let pageData = res.data.data || []; let pageData = res.data.data || [];
pageData.forEach((item) => { pageData.forEach((item) => {
item.checked = false; item.checked = false;
if (item.subList && item.subList.length > 0) {
item.subList.forEach((child) => {
child.checked = false;
}); });
this.tableData = pageData;
if (pageData.length > 0 && !this.activeIndex) {
this.getChild(pageData[0], 0);
}
} }
}); });
}, this.tableData = pageData;
getChildList() { // 刷新后保持之前选中的分类
if (!this.currentParentId) { if (this.currentParentId) {
// 找到之前选中的一级分类
const selectedItem = pageData.find((item) => item.ID === this.currentParentId);
if (selectedItem) {
this.getChild(selectedItem, 0);
} else if (pageData.length > 0) {
// 之前选中的被删了,选中第一个
this.getChild(pageData[0], 0);
} else {
this.childTableData = []; this.childTableData = [];
return; this.activeIndex = 0;
} }
this.loading = true; } else if (pageData.length > 0) {
this.apipost( // 首次加载默认选中第一大类
"/api/Trade/GetBrandClassList", { this.getChild(pageData[0], 0);
BrandCategory:this.msg.BrandCategory,
ParentId: this.currentParentId
},
(res) => {
this.loading = false;
if (res.data.resultCode == 1) {
let pageData = res.data.data || [];
pageData.forEach((item) => {
item.checked = false;
});
this.childTableData = pageData;
} }
} }
); });
}, },
delNews(item) { delNews(item) {
let that = this; let that = this;
...@@ -314,7 +289,7 @@ ...@@ -314,7 +289,7 @@
(res) => { (res) => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
that.Success(res.data.message); that.Success(res.data.message);
that.getChildList(); that.getList();
} else { } else {
that.Error(res.data.message); that.Error(res.data.message);
} }
...@@ -349,11 +324,7 @@ ...@@ -349,11 +324,7 @@
this.apipost("/api/Trade/GetSetBrandClass", this.addMsg, (res) => { this.apipost("/api/Trade/GetSetBrandClass", this.addMsg, (res) => {
if (res.data.resultCode == 1) { if (res.data.resultCode == 1) {
this.dialogVisible = false; this.dialogVisible = false;
if (this.addLevel === 1) {
this.getList(); this.getList();
} else {
this.getChildList();
}
this.Success(res.data.message); this.Success(res.data.message);
} else { } else {
this.Error(res.data.message); this.Error(res.data.message);
...@@ -370,50 +341,44 @@ ...@@ -370,50 +341,44 @@
</script> </script>
<style> <style>
.brandClassification .head-title {
font-size: 16px;
color: #303133;
padding: 0 0 15px 0;
font-weight: 600;
}
.brandClassification .cat-container { .brandClassification .cat-container {
display: flex; display: flex;
gap: 16px; gap: 16px;
min-height: 400px; min-height: 400px;
} }
.brandClassification .card-item-box { .brandClassification .card-item-box {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
.brandClassification .card-header { .brandClassification .card-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.brandClassification .header-title { .brandClassification .header-title {
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: #303133; color: #303133;
} }
.brandClassification .header-count { .brandClassification .header-count {
font-size: 12px; font-size: 12px;
color: #909399; color: #909399;
background: #f4f4f5; background: #f4f4f5;
padding: 2px 8px; padding: 2px 8px;
border-radius: 10px; border-radius: 10px;
} }
.brandClassification .card-body { .brandClassification .card-body {
max-height: 500px; max-height: 500px;
overflow-y: auto; overflow-y: auto;
} }
.brandClassification .list-item { .brandClassification .list-item {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
...@@ -421,28 +386,28 @@ ...@@ -421,28 +386,28 @@
border-bottom: 1px solid #f0f2f5; border-bottom: 1px solid #f0f2f5;
transition: background-color 0.2s; transition: background-color 0.2s;
cursor: pointer; cursor: pointer;
} }
.brandClassification .list-item:hover { .brandClassification .list-item:hover {
background-color: #f5f7fa; background-color: #f5f7fa;
} }
.brandClassification .list-item.active { .brandClassification .list-item.active {
background-color: #ecf5ff; background-color: #ecf5ff;
} }
.brandClassification .list-item:last-child { .brandClassification .list-item:last-child {
border-bottom: none; border-bottom: none;
} }
.brandClassification .item-left { .brandClassification .item-left {
display: flex; display: flex;
align-items: center; align-items: center;
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
.brandClassification .item-logo { .brandClassification .item-logo {
width: 36px; width: 36px;
height: 36px; height: 36px;
border-radius: 6px; border-radius: 6px;
...@@ -451,74 +416,75 @@ ...@@ -451,74 +416,75 @@
margin-right: 12px; margin-right: 12px;
flex-shrink: 0; flex-shrink: 0;
border: 1px solid #ebeef5; border: 1px solid #ebeef5;
} }
.brandClassification .item-logo.noIcon { .brandClassification .item-logo.noIcon {
background-image: url("../../assets/img/default.png"); background-image: url("../../assets/img/default.png");
background-size: 100% 100%; background-size: 100% 100%;
} }
.brandClassification .item-info { .brandClassification .item-info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-width: 0; min-width: 0;
} }
.brandClassification .item-name { .brandClassification .item-name {
font-size: 14px; font-size: 14px;
color: #303133; color: #303133;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
max-width: 150px; max-width: 150px;
} }
.brandClassification .item-id { .brandClassification .item-id {
font-size: 12px; font-size: 12px;
color: #909399; color: #909399;
margin-top: 2px; margin-top: 2px;
} }
.brandClassification .item-actions { .brandClassification .item-actions {
display: flex; display: flex;
gap: 8px; gap: 8px;
flex-shrink: 0; flex-shrink: 0;
} }
.brandClassification .action-btn { .brandClassification .action-btn {
padding: 4px 8px; padding: 4px 8px;
font-size: 13px; font-size: 13px;
border-radius: 4px; border-radius: 4px;
transition: all 0.2s; transition: all 0.2s;
} }
.brandClassification .action-btn.edit { .brandClassification .action-btn.edit {
color: #409eff; color: #409eff;
} }
.brandClassification .action-btn.edit:hover { .brandClassification .action-btn.edit:hover {
background-color: #ecf5ff; background-color: #ecf5ff;
} }
.brandClassification .action-btn.delete { .brandClassification .action-btn.delete {
color: #f56c6c; color: #f56c6c;
} }
.brandClassification .action-btn.delete:hover { .brandClassification .action-btn.delete:hover {
background-color: #fef0f0; background-color: #fef0f0;
} }
.brandClassification .empty-state { .brandClassification .empty-state {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 60px 0; padding: 60px 0;
color: #909399; color: #909399;
} }
.brandClassification .empty-state p { .brandClassification .empty-state p {
margin-top: 12px; margin-top: 12px;
font-size: 14px; font-size: 14px;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment