diff --git a/src/views/erp/product/category/ProductCategoryForm.vue b/src/views/erp/product/category/ProductCategoryForm.vue index 6b39e62f..af83af42 100644 --- a/src/views/erp/product/category/ProductCategoryForm.vue +++ b/src/views/erp/product/category/ProductCategoryForm.vue @@ -38,7 +38,11 @@ - + { return formData.value.processRouteName || String(formData.value.processRouteId) }) +const isProductType = computed(() => Number(formData.value.type) === 1) + /** 打开弹窗 */ const open = async (type: string, id?: number, defaultData?: any) => { dialogVisible.value = true @@ -333,6 +339,9 @@ const getProductCategoryTree = async () => { const handleTypeChange = async () => { formData.value.parentId = undefined + if (!isProductType.value) { + clearProcessRoute() + } await getProductCategoryTree() } diff --git a/src/views/erp/product/product/index.vue b/src/views/erp/product/product/index.vue index c9213789..401db34f 100644 --- a/src/views/erp/product/product/index.vue +++ b/src/views/erp/product/product/index.vue @@ -363,6 +363,19 @@ const groupTreeData = ref([]) const treeRef = ref() const typeDict = computed(() => getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)) +const normalizeCategoryTree = (children: any[] = [], fallbackType?: number) => { + return children.map((child: any) => { + const type = child.type ?? fallbackType + return { + ...child, + type, + nodeKey: `cat_${child.id}`, + isType: false, + children: normalizeCategoryTree(child.children || [], type) + } + }) +} + const treeData = computed(() => { return (groupTreeData.value || []).map((group: any) => { const dictItem = typeDict.value.find((d: any) => d.value === group.type) @@ -372,11 +385,7 @@ const treeData = computed(() => { name, type: group.type, isType: true, - children: (group.children || []).map((child: any) => ({ - ...child, - nodeKey: `cat_${child.id}`, - isType: false - })) + children: normalizeCategoryTree(group.children || [], group.type) } }) })