mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-09-20 20:02:05 +08:00
refactor(GoodsClassNav): 优化品牌ID处理与选择逻辑
- 重构品牌ID的获取方式,使用新方法 appendBrandIdsByNames 简化逻辑 - 更新多选确认逻辑,避免重复选择相同类型 - 调整标签内容显示逻辑,确保品牌标签在选择时正确显示 - 修复商品列表页的分页参数,确保从第一页开始加载数据
This commit is contained in:
@@ -291,8 +291,12 @@ export default {
|
||||
this.multSelected.push(item);
|
||||
}
|
||||
} else {
|
||||
const type = this.tagsContent[index].key;
|
||||
if (this.selectedItem.some((selected) => selected.type === type)) {
|
||||
return;
|
||||
}
|
||||
this.selectedItem.push({
|
||||
type: this.tagsContent[index].key,
|
||||
type,
|
||||
name: item
|
||||
});
|
||||
|
||||
@@ -300,12 +304,7 @@ export default {
|
||||
|
||||
if (index === 0) {
|
||||
// 如果是品牌,获取品牌id
|
||||
|
||||
let brands = this.tagsContent[0].values;
|
||||
|
||||
brands.forEach((val) => {
|
||||
if (val.name === item) this.brandIds.push(val.value);
|
||||
});
|
||||
this.appendBrandIdsByNames([item]);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -336,19 +335,19 @@ export default {
|
||||
},
|
||||
sure (index) {
|
||||
// 多选确认按钮
|
||||
const type = this.tagsContent[index].key;
|
||||
if (this.selectedItem.some((selected) => selected.type === type)) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
this.selectedItem.push({
|
||||
type: this.tagsContent[index].key,
|
||||
type,
|
||||
name: this.multSelected.join('、')
|
||||
});
|
||||
|
||||
if (index === 0) {
|
||||
// 如果是品牌,获取品牌id
|
||||
|
||||
let brands = this.tagsContent[0].values;
|
||||
|
||||
brands.forEach((val) => {
|
||||
if (this.multSelected.includes(val.name)) this.brandIds.push(val.value);
|
||||
});
|
||||
this.appendBrandIdsByNames(this.multSelected);
|
||||
}
|
||||
|
||||
this.tagsContent[index].show = false;
|
||||
@@ -360,22 +359,30 @@ export default {
|
||||
this.tagsContent[0].more = false;
|
||||
this.multiple = false;
|
||||
},
|
||||
appendBrandIdsByNames (names) {
|
||||
const selectedNames = names || [];
|
||||
const brands = this.tagsContent[0] && this.tagsContent[0].values ? this.tagsContent[0].values : [];
|
||||
brands.forEach((val) => {
|
||||
if (selectedNames.includes(val.name) && val.value && !this.brandIds.includes(val.value)) {
|
||||
this.brandIds.push(val.value);
|
||||
}
|
||||
});
|
||||
},
|
||||
getFilterList (params) {
|
||||
// 筛选、分类 列表
|
||||
APIGoods.filterList(params).then((res) => {
|
||||
if (res.success) {
|
||||
const data = res.result;
|
||||
const hiddenKeys = new Set(this.selectedItem.map((item) => item.type));
|
||||
this.tagsContent = [{
|
||||
key: '品牌',
|
||||
more: false,
|
||||
show: true,
|
||||
values: []
|
||||
}]
|
||||
this.tagsContent[0].values = data.brands;
|
||||
this.tagsContent = this.tagsContent.concat(data.paramOptions);
|
||||
show: !hiddenKeys.has('品牌'),
|
||||
values: data.brands || []
|
||||
}].concat(data.paramOptions || []);
|
||||
this.tagsContent.forEach((item) => {
|
||||
item['show'] = true
|
||||
item['more'] = false
|
||||
item.show = !hiddenKeys.has(item.key);
|
||||
item.more = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ export default {
|
||||
total: 0, // 列表总数
|
||||
params: {
|
||||
// 请求参数
|
||||
pageNumber: 0,
|
||||
pageNumber: 1,
|
||||
pageSize: 20,
|
||||
categoryId: "",
|
||||
},
|
||||
@@ -179,7 +179,7 @@ export default {
|
||||
handleSearch(key) {
|
||||
this.params.keyword = key;
|
||||
this.$route.query.keyword = key
|
||||
this.params.pageNumber = 0;
|
||||
this.params.pageNumber = 1;
|
||||
this.getGoodsList();
|
||||
},
|
||||
orderBy(data, index) {
|
||||
|
||||
Reference in New Issue
Block a user