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

main
黄伟杰 2 weeks ago
parent b5a5f6e4c3
commit d63eb8ed24

@ -38,7 +38,11 @@
<el-form-item :label="t('FactoryModeling.ProductCategory.dialogNameLabel')" prop="name"> <el-form-item :label="t('FactoryModeling.ProductCategory.dialogNameLabel')" prop="name">
<el-input v-model="formData.name" :placeholder="t('FactoryModeling.ProductCategory.dialogNamePlaceholder')" /> <el-input v-model="formData.name" :placeholder="t('FactoryModeling.ProductCategory.dialogNamePlaceholder')" />
</el-form-item> </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 <el-input
:model-value="processRouteDisplayName" :model-value="processRouteDisplayName"
:placeholder="t('FactoryModeling.ProductCategory.dialogProcessRoutePlaceholder')" :placeholder="t('FactoryModeling.ProductCategory.dialogProcessRoutePlaceholder')"
@ -257,6 +261,8 @@ const processRouteDisplayName = computed(() => {
return formData.value.processRouteName || String(formData.value.processRouteId) 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) => { const open = async (type: string, id?: number, defaultData?: any) => {
dialogVisible.value = true dialogVisible.value = true
@ -333,6 +339,9 @@ const getProductCategoryTree = async () => {
const handleTypeChange = async () => { const handleTypeChange = async () => {
formData.value.parentId = undefined formData.value.parentId = undefined
if (!isProductType.value) {
clearProcessRoute()
}
await getProductCategoryTree() await getProductCategoryTree()
} }

@ -363,6 +363,19 @@ const groupTreeData = ref<any[]>([])
const treeRef = ref() const treeRef = ref()
const typeDict = computed(() => getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)) 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(() => { const treeData = computed(() => {
return (groupTreeData.value || []).map((group: any) => { return (groupTreeData.value || []).map((group: any) => {
const dictItem = typeDict.value.find((d: any) => d.value === group.type) const dictItem = typeDict.value.find((d: any) => d.value === group.type)
@ -372,11 +385,7 @@ const treeData = computed(() => {
name, name,
type: group.type, type: group.type,
isType: true, isType: true,
children: (group.children || []).map((child: any) => ({ children: normalizeCategoryTree(group.children || [], group.type)
...child,
nodeKey: `cat_${child.id}`,
isType: false
}))
} }
}) })
}) })

Loading…
Cancel
Save