feat: 🚀 addLabelValue方法抽离
This commit is contained in:
@@ -98,7 +98,8 @@ import {
|
||||
getBannerListExportApi,
|
||||
getBannerClassListApi
|
||||
} from "@/api/modules/banner";
|
||||
// import { getBannerClassListApi } from "@/api/modules/bannerClass";
|
||||
import { addLabelValue } from "@/utils/addLabelValue";
|
||||
|
||||
import { getSystemUrlsApi } from "@/api/modules/home";
|
||||
// 深拷贝方法
|
||||
import { cloneDeep } from "lodash-es";
|
||||
@@ -132,20 +133,7 @@ const treeProps = {
|
||||
label: "label",
|
||||
value: "value"
|
||||
};
|
||||
const addLabelValue = (arr: any) => {
|
||||
return arr.map((item: any) => {
|
||||
// 为当前对象添加 label 和 value 属性
|
||||
const newItem = { ...item };
|
||||
newItem.label = newItem.name;
|
||||
newItem.value = newItem.id;
|
||||
|
||||
// 如果有子对象,递归调用 addLabelValue 处理子对象
|
||||
if (newItem.children && Array.isArray(newItem.children)) {
|
||||
newItem.children = addLabelValue(newItem.children);
|
||||
}
|
||||
return newItem;
|
||||
});
|
||||
};
|
||||
//产品分类(后端大佬说直接掉列表接口)
|
||||
const getProductCategoryList = async () => {
|
||||
const result = await getProductCategoryListApi();
|
||||
|
||||
Reference in New Issue
Block a user