fix(goodsOperationSec): 修复商品编辑页店内分类无法回填的问题

- 初始化店内分类 ID 列表时过滤空值
- 分类树数据加载完成后调用 setCheckedKeys 回填勾选状态
- 使用 const 声明 shopCategories 提升可读性
This commit is contained in:
田香琪
2026-08-13 16:37:52 +08:00
parent d4cd6e0936
commit 420e8a84e5

View File

@@ -1341,22 +1341,24 @@ export default {
GET_ShopGoodsLabel() { GET_ShopGoodsLabel() {
API_GOODS.getShopGoodsLabelListSeller().then((res) => { API_GOODS.getShopGoodsLabelListSeller().then((res) => {
if (res.success) { 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) => { this.shopCategory = res.result.map((i) => {
i.title = i.labelName; i.title = i.labelName;
i.expand = false; i.expand = false;
i.checked = shopCategories.some((o) => o === i.id);
i.children = i.children.map((j) => { i.children = i.children.map((j) => {
j.title = j.labelName; j.title = j.labelName;
j.expand = false; j.expand = false;
j.checked = shopCategories.some((o) => o === j.id);
return j; return j;
}); });
return i; return i;
}); });
this.$nextTick(() => {
this.$refs.tree?.setCheckedKeys(shopCategories);
});
} }
}); });
}, },