style:产品分类/物料档案-产品类型才展示工艺路线选项

main
黄伟杰 2 days ago
parent b5a5f6e4c3
commit d63eb8ed24

@ -38,7 +38,11 @@
<el-form-item :label="t('FactoryModeling.ProductCategory.dialogNameLabel')" prop="name">
<el-input v-model="formData.name" :placeholder="t('FactoryModeling.ProductCategory.dialogNamePlaceholder')" />
</el-form-item>
<el-form-item :label="t('FactoryModeling.ProductCategory.dialogProcessRouteLabel')" prop="processRouteId">
<el-form-item
v-if="isProductType"
:label="t('FactoryModeling.ProductCategory.dialogProcessRouteLabel')"
prop="processRouteId"
>
<el-input
:model-value="processRouteDisplayName"
:placeholder="t('FactoryModeling.ProductCategory.dialogProcessRoutePlaceholder')"
@ -257,6 +261,8 @@ const processRouteDisplayName = computed(() => {
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()
}

@ -363,6 +363,19 @@ const groupTreeData = ref<any[]>([])
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)
}
})
})

Loading…
Cancel
Save