feat: 🚀 addLabelValue方法抽离
This commit is contained in:
@@ -88,6 +88,8 @@ import {
|
||||
} from "@/api/modules/downloadClass";
|
||||
//深拷贝方法
|
||||
import { cloneDeep } from "lodash-es";
|
||||
import { addLabelValue } from "@/utils/addLabelValue";
|
||||
|
||||
//表格和搜索條件
|
||||
import { RULE_FORM, FORM_DATA, COLUMNS, EDIT_FORM_DATA, EDIT_RULE_FORM, RULES } from "./constant/index";
|
||||
|
||||
@@ -130,20 +132,6 @@ const handleSelectChangeEmits = (params: any) => {
|
||||
dataStore.editRuleForm.pid = id;
|
||||
};
|
||||
|
||||
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 getCategorys = async () => {
|
||||
const result = await getCategorysApi();
|
||||
|
||||
Reference in New Issue
Block a user