feature(uniapp商品): 商品修改

pull/2/head
luowenfeng 2022-09-01 11:00:40 +08:00
parent 96db6b97ad
commit 198b1189e8
4 changed files with 28 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Set;
import java.util.List;
/**
* @Description: ProductPropertyViewRespVO
@ -25,16 +25,17 @@ public class ProductPropertyViewRespVO {
public String name;
@ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]")
public Set<Tuple2> propertyValues;
public List<Tuple2> propertyValues;
@Data
@ApiModel(value = "规格属性值元组")
public static class Tuple2 {
private final long v1;
private final String v2;
public Tuple2(Long v1, String v2) {
this.v1 = v1;
this.v2 = v2;
private final long id;
private final String name;
public Tuple2(Long id, String name) {
this.id = id;
this.name = name;
}
}

View File

@ -20,7 +20,7 @@ import java.util.List;
*
* @author
*/
@TableName("product_sku")
@TableName(value = "product_sku",autoResultMap = true)
@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)

View File

@ -30,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
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.setPropertyId(p.getId());
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));
propertyMaps.get(p.getId()).forEach(pv -> {
ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName());

View File

@ -471,6 +471,23 @@ export default {
this.baseForm.showStock=data.showStock;
this.baseForm.brandId=data.brandId;
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
})
}