parent
							
								
									2d88367e61
								
							
						
					
					
						commit
						9d8e0d507b
					
				| 
						 | 
				
			
			@ -104,7 +104,7 @@ const getDetail = async () => {
 | 
			
		|||
    formLoading.value = true
 | 
			
		||||
    try {
 | 
			
		||||
      const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu
 | 
			
		||||
      res.skus!.forEach((item) => {
 | 
			
		||||
      res.skus?.forEach((item) => {
 | 
			
		||||
        // 回显价格分转元
 | 
			
		||||
        item.price = formatToFraction(item.price)
 | 
			
		||||
        item.marketPrice = formatToFraction(item.marketPrice)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -256,7 +256,7 @@ watch(
 | 
			
		|||
      return
 | 
			
		||||
    }
 | 
			
		||||
    copyValueToTarget(formData, data)
 | 
			
		||||
    formData.sliderPicUrls = data['sliderPicUrls'].map((item) => ({
 | 
			
		||||
    formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({
 | 
			
		||||
      url: item
 | 
			
		||||
    }))
 | 
			
		||||
    // 只有是多规格才处理
 | 
			
		||||
| 
						 | 
				
			
			@ -265,16 +265,16 @@ watch(
 | 
			
		|||
    }
 | 
			
		||||
    //  直接拿返回的 skus 属性逆向生成出 propertyList
 | 
			
		||||
    const properties = []
 | 
			
		||||
    formData.skus.forEach((sku) => {
 | 
			
		||||
      sku.properties.forEach(({ propertyId, propertyName, valueId, valueName }) => {
 | 
			
		||||
    formData.skus?.forEach((sku) => {
 | 
			
		||||
      sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
 | 
			
		||||
        // 添加属性
 | 
			
		||||
        if (!properties.some((item) => item.id === propertyId)) {
 | 
			
		||||
        if (!properties?.some((item) => item.id === propertyId)) {
 | 
			
		||||
          properties.push({ id: propertyId, name: propertyName, values: [] })
 | 
			
		||||
        }
 | 
			
		||||
        // 添加属性值
 | 
			
		||||
        const index = properties.findIndex((item) => item.id === propertyId)
 | 
			
		||||
        if (!properties[index].values.some((value) => value.id === valueId)) {
 | 
			
		||||
          properties[index].values.push({ id: valueId, name: valueName })
 | 
			
		||||
        const index = properties?.findIndex((item) => item.id === propertyId)
 | 
			
		||||
        if (!properties[index].values?.some((value) => value.id === valueId)) {
 | 
			
		||||
          properties[index].values?.push({ id: valueId, name: valueName })
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue