feat: 🚀 addLabelValue方法抽离

This commit is contained in:
2025-05-09 16:40:41 +08:00
parent ab003714bf
commit f2ee833412
15 changed files with 37 additions and 149 deletions

View File

@@ -100,7 +100,7 @@ import {
getArticleCategorySortApi,
getProductClassTcoTreeApi
} from "@/api/modules/productClass";
import { addLabelValue } from "../list/utils/common/addLabelValue";
import { addLabelValue } from "@/utils/addLabelValue";
import { useMsg } from "@/hooks/useMsg";

View File

@@ -16,7 +16,7 @@
</el-tab-pane>
<el-tab-pane label="产品详情" name="third">
<div style="width: 1280px; margin: 0 auto">
<Editor v-model:value="dataStore.detail" />
<Editor v-model:content="dataStore.detail" />
</div>
</el-tab-pane>
<el-tab-pane label="相关信息" name="related">
@@ -56,7 +56,8 @@ import { messageBox } from "@/utils/messageBox";
import { useMsg } from "@/hooks/useMsg";
import { handleSubmit, handleReset, initDetailParams } from "./utils/edit/index";
import { addLabelValue } from "./utils/common/addLabelValue";
import { addLabelValue } from "@/utils/addLabelValue";
//组件引入
import basicInfo from "./components/basicInfo.vue";
import imgInfo from "./components/imgInfo.vue";

View File

@@ -63,7 +63,7 @@ import {
getProductCategoryListApi
} from "@/api/modules/productList";
// import { getProductCategoryListApi } from "@/api/modules/productClass";
import { addLabelValue } from "./utils/common/addLabelValue";
import { addLabelValue } from "@/utils/addLabelValue";
//深拷贝方法
import { cloneDeep } from "lodash-es";
@@ -153,4 +153,3 @@ const handleBtnClick = (type: any, row: any) => {
</script>
<style scoped></style>
./utils/common/addLabelValue

View File

@@ -1,14 +0,0 @@
export 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;
});
};

View File

@@ -37,6 +37,7 @@ import { useMsg } from "@/hooks/useMsg";
import { getProductCategoryListApi } from "@/api/modules/productClass";
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTableRef = ref<any>(null);
import { addLabelValue } from "@/utils/addLabelValue";
// 数据源
const dataStore = reactive<any>({
@@ -75,20 +76,6 @@ const handleBtnClick = (type: any, row: any) => {
}
};
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({ page: 1, size: 500 });