mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-09-20 20:02:05 +08:00
fix(goodsOperationSec): 修复商品编辑页店内分类无法回填的问题
- 初始化店内分类 ID 列表时过滤空值 - 分类树数据加载完成后调用 setCheckedKeys 回填勾选状态 - 使用 const 声明 shopCategories 提升可读性
This commit is contained in:
@@ -1341,22 +1341,24 @@ export default {
|
||||
GET_ShopGoodsLabel() {
|
||||
API_GOODS.getShopGoodsLabelListSeller().then((res) => {
|
||||
if (res.success) {
|
||||
let shopCategories = !this.baseInfoForm.storeCategoryPath
|
||||
const shopCategories = !this.baseInfoForm.storeCategoryPath
|
||||
? []
|
||||
: this.baseInfoForm.storeCategoryPath.split(",");
|
||||
: this.baseInfoForm.storeCategoryPath.split(",").filter(Boolean);
|
||||
|
||||
this.shopCategory = res.result.map((i) => {
|
||||
i.title = i.labelName;
|
||||
i.expand = false;
|
||||
i.checked = shopCategories.some((o) => o === i.id);
|
||||
i.children = i.children.map((j) => {
|
||||
j.title = j.labelName;
|
||||
j.expand = false;
|
||||
j.checked = shopCategories.some((o) => o === j.id);
|
||||
return j;
|
||||
});
|
||||
return i;
|
||||
});
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs.tree?.setCheckedKeys(shopCategories);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user