mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-01 01:50:04 +08:00
feature(uniapp商品): 商品修改
This commit is contained in:
parent
96db6b97ad
commit
198b1189e8
@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: ProductPropertyViewRespVO
|
* @Description: ProductPropertyViewRespVO
|
||||||
@ -25,16 +25,17 @@ public class ProductPropertyViewRespVO {
|
|||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
@ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]")
|
@ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]")
|
||||||
public Set<Tuple2> propertyValues;
|
public List<Tuple2> propertyValues;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "规格属性值元组")
|
@ApiModel(value = "规格属性值元组")
|
||||||
public static class Tuple2 {
|
public static class Tuple2 {
|
||||||
private final long v1;
|
private final long id;
|
||||||
private final String v2;
|
private final String name;
|
||||||
public Tuple2(Long v1, String v2) {
|
|
||||||
this.v1 = v1;
|
public Tuple2(Long id, String name) {
|
||||||
this.v2 = v2;
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@TableName("product_sku")
|
@TableName(value = "product_sku",autoResultMap = true)
|
||||||
@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ -30,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -142,7 +143,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
ProductPropertyViewRespVO productPropertyViewRespVO = new ProductPropertyViewRespVO();
|
ProductPropertyViewRespVO productPropertyViewRespVO = new ProductPropertyViewRespVO();
|
||||||
productPropertyViewRespVO.setPropertyId(p.getId());
|
productPropertyViewRespVO.setPropertyId(p.getId());
|
||||||
productPropertyViewRespVO.setName(p.getName());
|
productPropertyViewRespVO.setName(p.getName());
|
||||||
Set<ProductPropertyViewRespVO.Tuple2> propertyValues = new HashSet<>();
|
List<ProductPropertyViewRespVO.Tuple2> propertyValues = new ArrayList<>();
|
||||||
Map<Long, ProductPropertyValueRespVO> propertyValueMaps = p.getPropertyValueList().stream().collect(Collectors.toMap(ProductPropertyValueRespVO::getId, pv -> pv));
|
Map<Long, ProductPropertyValueRespVO> propertyValueMaps = p.getPropertyValueList().stream().collect(Collectors.toMap(ProductPropertyValueRespVO::getId, pv -> pv));
|
||||||
propertyMaps.get(p.getId()).forEach(pv -> {
|
propertyMaps.get(p.getId()).forEach(pv -> {
|
||||||
ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName());
|
ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName());
|
||||||
|
@ -471,6 +471,23 @@ export default {
|
|||||||
this.baseForm.showStock=data.showStock;
|
this.baseForm.showStock=data.showStock;
|
||||||
this.baseForm.brandId=data.brandId;
|
this.baseForm.brandId=data.brandId;
|
||||||
this.ratesForm.spec=data.specType;
|
this.ratesForm.spec=data.specType;
|
||||||
|
if(this.ratesForm.spec == 2){
|
||||||
|
data.productPropertyViews.forEach(p=>{
|
||||||
|
let obj = {};
|
||||||
|
obj.specId = p.propertyId;
|
||||||
|
obj.specName = p.name;
|
||||||
|
obj.specValue = p.propertyValues;
|
||||||
|
this.dynamicSpec.push(obj);
|
||||||
|
})
|
||||||
|
data.skus.forEach(s=>{
|
||||||
|
s.spec = [];
|
||||||
|
s.properties.forEach(sp=>{
|
||||||
|
let spec = data.productPropertyViews.find(o=>o.propertyId == sp.propertyId).propertyValues.find(v=>v.id == sp.valueId).name;
|
||||||
|
s.spec.push(spec)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log(data.skus);
|
||||||
this.ratesForm.rates=data.skus
|
this.ratesForm.rates=data.skus
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user