商品品类没有展示父级品类的信息,需要携带查询父级品类的名称
parent
edb3978432
commit
f5fa296f79
|
@ -68,7 +68,7 @@
|
|||
<image-preview :src="scope.row.image" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="父级品类" align="center" prop="parentId" />
|
||||
<el-table-column label="父级品类" align="center" prop="parentIds" />
|
||||
<el-table-column label="是否启用" align="center" prop="start">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/>
|
||||
|
@ -263,7 +263,21 @@ export default {
|
|||
getList() {
|
||||
this.loading = true;
|
||||
listCategory(this.queryParams).then(response => {
|
||||
this.categoryList = this.handleTree(response.data, "id", "parentId");
|
||||
const idToName = response.data.reduce((acc, node) => {
|
||||
acc[node.id] = node.name;
|
||||
return acc;
|
||||
}, {});
|
||||
console.log(idToName);
|
||||
const updatedTreeData = response.data.map(node => {
|
||||
// 如果 parentId 为 null,说明没有父节点,不需要替换
|
||||
const parentName = node.parentId !== null ? idToName[node.parentId] : null;
|
||||
console.log(parentName);
|
||||
return {
|
||||
...node,
|
||||
parentIds: parentName
|
||||
};
|
||||
});
|
||||
this.categoryList = this.handleTree(updatedTreeData, "id", "parentId");
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue