feat: 🚀 addLabelValue方法抽离
This commit is contained in:
@@ -43,6 +43,9 @@ import {
|
||||
import { cloneDeep } from "lodash-es";
|
||||
//表格和搜索條件
|
||||
import { RULE_FORM, FORM_DATA, COLUMNS } from "./constant/index";
|
||||
|
||||
import { addLabelValue } from "@/utils/addLabelValue";
|
||||
|
||||
//图片地址
|
||||
import { h } from "@/utils/url";
|
||||
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
|
||||
@@ -57,20 +60,7 @@ const dataStore = reactive<any>({
|
||||
formData: FORM_DATA, //搜索配置项
|
||||
selectRow: {} //当前选择的row
|
||||
});
|
||||
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 getArticleClassData = async () => {
|
||||
const result = await getArticleClassDataApi();
|
||||
|
||||
Reference in New Issue
Block a user