| | |
| | | }); |
| | | |
| | | const getPinnedProductPrefill = async () => { |
| | | if (!pinnedProductTemplate.value) return {}; |
| | | await getProductOptions(); |
| | | if (!pinnedProductTemplate.value) { |
| | | const models = await modelList({}); |
| | | modelOptions.value = models || []; |
| | | return {}; |
| | | } |
| | | if (pinnedProductTemplate.value.__productCategoryId) { |
| | | const models = await modelList({ |
| | | id: pinnedProductTemplate.value.__productCategoryId, |
| | | }); |
| | | modelOptions.value = models || []; |
| | | } else { |
| | | const models = await modelList({}); |
| | | modelOptions.value = models || []; |
| | | } |
| | | return { ...pinnedProductTemplate.value }; |
| | |
| | | }; |
| | | // 获取tree子数据 |
| | | const getModels = value => { |
| | | // 产品大类变化时,重置规格型号与厚度,避免旧值残留 |
| | | productForm.value.productModelId = null; |
| | | productForm.value.specificationModel = ""; |
| | | productForm.value.thickness = null; |
| | | |
| | | if (!value) { |
| | | productForm.value.productCategory = ""; |
| | | modelOptions.value = []; |
| | | modelList({}).then(res => { |
| | | modelOptions.value = res || []; |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | productForm.value.productCategory = findNodeById(productOptions.value, value); |
| | | modelList({ id: value }).then(res => { |
| | | modelOptions.value = res || []; |
| | | const currentModelId = productForm.value.productModelId; |
| | | if (currentModelId) { |
| | | const isValid = modelOptions.value.some(item => item.id === currentModelId); |
| | | if (!isValid) { |
| | | productForm.value.productModelId = null; |
| | | productForm.value.specificationModel = ""; |
| | | productForm.value.thickness = null; |
| | | } |
| | | } else { |
| | | productForm.value.productModelId = null; |
| | | productForm.value.specificationModel = ""; |
| | | productForm.value.thickness = null; |
| | | } |
| | | }); |
| | | }; |
| | | const getProductModel = value => { |
| | |
| | | modelThickness === "" |
| | | ? null |
| | | : Number(modelThickness); |
| | | |
| | | const categoryId = selectedModel?.productId; |
| | | if (categoryId && productForm.value.__productCategoryId !== categoryId) { |
| | | productForm.value.__productCategoryId = categoryId; |
| | | productForm.value.productCategory = findNodeById(productOptions.value, categoryId); |
| | | } |
| | | } else { |
| | | productForm.value.specificationModel = null; |
| | | productForm.value.thickness = null; |