Merge branch 'feature/1.8.0-uniapp' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/1.8.0-uniapp

This commit is contained in:
LAPTOP-CNV4CMCJ\cheng 2022-10-27 16:49:53 +08:00
commit e035e66ffd
12 changed files with 176 additions and 168 deletions

View File

@ -12,6 +12,6 @@ public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO
@ApiModelProperty(value = "主键", required = true, example = "1024")
@NotNull(message = "主键不能为空")
private Integer id;
private Long id;
}

View File

@ -55,9 +55,8 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
}
// TODO @luowenfeng: categoryIds => categoryIdexample 也要改下哈
@ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "[1,2,4]")
private Long categoryIds;
@ApiModelProperty(value = "分类 id 数组,一直递归到一级父节点", example = "4")
private Long categoryId;
// TODO @芋艿在瞅瞅~
@ApiModelProperty(value = "规格属性修改和详情展示组合", example = "[{\"propertyId\":2,\"name\":\"内存\",\"propertyValues\":[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]},{\"propertyId\":3,\"name\":\"尺寸\",\"propertyValues\":[{\"v1\":16,\"v2\":\"6.1\"},{\"v1\":15,\"v2\":\"5.7\"}]}]")

View File

@ -64,6 +64,4 @@ public class ProductCategoryDO extends BaseDO {
*/
private Integer status;
// TODO 芋艿is_recommend 是否首页推荐1-0-
}

View File

@ -25,10 +25,9 @@ public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
.orderByDesc(ProductPropertyDO::getId));
}
// TODO @luowenfeng: selectByNameLike这样更清晰哈
default ProductPropertyDO selectByName(String name) {
return selectOne(new LambdaQueryWrapperX<ProductPropertyDO>()
.likeIfPresent(ProductPropertyDO::getName, name));
.eqIfPresent(ProductPropertyDO::getName, name));
}
}

View File

@ -17,8 +17,7 @@ import java.util.List;
@Mapper
public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> {
// TODO @luowenfeng: selectListByPropertyId 是不是就可以啦
default List<ProductPropertyValueDO> selectListByPropertyValueListByPropertyId(List<Long> propertyIds) {
default List<ProductPropertyValueDO> selectListByPropertyId(List<Long> propertyIds) {
return selectList(new LambdaQueryWrapperX<ProductPropertyValueDO>()
.inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds));
}

View File

@ -19,6 +19,7 @@ import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_EXISTS;
@ -58,8 +59,8 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
// 校验存在
this.validatePropertyExists(updateReqVO.getId());
// TODO @luowenfeng如果是自己的情况下名字相同也是 ok 的呀~
if (productPropertyMapper.selectByName(updateReqVO.getName()) != null) {
ProductPropertyDO productPropertyDO = productPropertyMapper.selectByName(updateReqVO.getName());
if (productPropertyDO != null && !productPropertyDO.getId().equals(updateReqVO.getId())) {
throw exception(PROPERTY_EXISTS);
}
// 更新
@ -97,10 +98,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
return ProductPropertyConvert.INSTANCE.convertPage(pageResult);
}
private List<ProductPropertyValueDO> getPropertyValueListByPropertyId(List<Long> propertyIds) {
return productPropertyValueMapper.selectListByPropertyValueListByPropertyId(propertyIds);
}
@Override
public ProductPropertyRespVO getProperty(Long id) {
ProductPropertyDO property = productPropertyMapper.selectById(id);
@ -117,7 +114,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
List<ProductPropertyRespVO> propertyList = getPropertyList(listReqVO);
// 查询属性值
List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyValueListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId));
List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId));
Map<Long, List<ProductPropertyValueDO>> valueDOMap = CollectionUtils.convertMultiMap(valueDOList, ProductPropertyValueDO::getPropertyId);
return CollectionUtils.convertList(propertyList, m -> {
ProductPropertyAndValueRespVO productPropertyAndValueRespVO = ProductPropertyConvert.INSTANCE.convert(m);

View File

@ -14,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS;
@ -42,8 +43,8 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
@Override
public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) {
// TODO @luowenfeng如果是自己的情况下名字相同也是 ok 的呀~
if (productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName()) != null) {
ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectByName(updateReqVO.getPropertyId(), updateReqVO.getName());
if (productPropertyValueDO != null && !productPropertyValueDO.getId().equals(updateReqVO.getId())) {
throw exception(PROPERTY_VALUE_EXISTS);
}
ProductPropertyValueDO convert = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO);

View File

@ -162,7 +162,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
});
respVO.setProductPropertyViews(productPropertyViews);
}
respVO.setCategoryIds(respVO.getCategoryId());
}
return respVO;
}

View File

@ -1,8 +1,11 @@
package cn.iocoder.yudao.module.product.service.spu;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
@ -29,16 +32,16 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
// TODO @芋艿review 下单元测试
/**
* {@link ProductSpuServiceImpl} 的单元测试类
*
@ -69,6 +72,13 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
@MockBean
private ProductPropertyValueService productPropertyValueService;
public String generateNo() {
return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999);
}
public Long generateId() {
return RandomUtil.randomLong(100000, 999999);
}
@Test
public void testCreateSpu_success() {
@ -208,34 +218,119 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
Assertions.assertIterableEquals(createReqVO, spuList);
}
// TODO @luowenfeng单测要分情况类似你这个可以分 2 个单测一个是有预存预警的一个是没库存预警的
// 然后参考其它模块的 getPage 类型的方法的单测
@Test
void getSpuPage() {
// 准备参数
ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class);
productSpuMapper.insert(createReqVO);
ArrayList<ProductSkuDO> remindSpuIds = Lists.newArrayList(
// randomPojo(ProductSkuDO.class, o -> o.setSpuId(createReqVO.getId())),
// randomPojo(ProductSkuDO.class, o -> o.setSpuId(createReqVO.getId()))
);
Mockito.when(productSkuService.getRemindSpuIds()).thenReturn(remindSpuIds);
void getSpuPage_alarmStock_empty() {
// 调用
ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO();
productSpuPageReqVO.setTabStatus(2);
productSpuPageReqVO.setAlarmStock(true);
PageResult<ProductSpuRespVO> spuPage = productSpuService.getSpuPage(productSpuPageReqVO);
ArrayList<Long> resultRemindSpuIds = new ArrayList<>();
resultRemindSpuIds.add(null);
PageResult<ProductSpuRespVO> result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO, resultRemindSpuIds));
PageResult<Object> result = PageResult.empty();
Assertions.assertIterableEquals(result.getList(), spuPage.getList());
Assertions.assertEquals(spuPage.getTotal(), result.getTotal());
}
@Test
void getSpuPage_alarmStock() {
// mock 数据
Long brandId = generateId();
Long categoryId = generateId();
String code = generateNo();
// 准备参数
ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class, o->{
o.setStatus(ProductSpuStatusEnum.ENABLE.getStatus());
o.setTotalStock(500);
o.setMinPrice(1);
o.setMaxPrice(50);
o.setMarketPrice(25);
o.setSpecType(ProductSpuSpecTypeEnum.RECYCLE.getType());
o.setBrandId(brandId);
o.setCategoryId(categoryId);
o.setClickCount(100);
o.setCode(code);
o.setDescription("测试商品");
o.setPicUrls(new ArrayList<>());
o.setName("测试");
o.setSalesCount(100);
o.setSellPoint("超级加倍");
o.setShowStock(true);
o.setVideoUrl("");
});
productSpuMapper.insert(createReqVO);
Set<Long> alarmStockSpuIds = SetUtils.asSet(createReqVO.getId());
List<ProductSkuDO> productSpuDOS = Arrays.asList(randomPojo(ProductSkuDO.class, o -> {
o.setSpuId(createReqVO.getId());
}), randomPojo(ProductSkuDO.class, o -> {
o.setSpuId(createReqVO.getId());
}));
Mockito.when(productSkuService.getSkusByAlarmStock()).thenReturn(productSpuDOS);
// 调用
ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO();
productSpuPageReqVO.setAlarmStock(true);
PageResult<ProductSpuRespVO> spuPage = productSpuService.getSpuPage(productSpuPageReqVO);
PageResult<ProductSpuRespVO> result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO, alarmStockSpuIds));
Assertions.assertIterableEquals(result.getList(), spuPage.getList());
Assertions.assertEquals(spuPage.getTotal(), result.getTotal());
}
@Test
void getSpuPage() {
// mock 数据
Long brandId = generateId();
Long categoryId = generateId();
// 准备参数
ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class, o->{
o.setStatus(ProductSpuStatusEnum.ENABLE.getStatus());
o.setTotalStock(1);
o.setMinPrice(1);
o.setMaxPrice(1);
o.setMarketPrice(1);
o.setSpecType(ProductSpuSpecTypeEnum.RECYCLE.getType());
o.setBrandId(brandId);
o.setCategoryId(categoryId);
o.setClickCount(1);
o.setCode(generateNo());
o.setDescription("测试商品");
o.setPicUrls(new ArrayList<>());
o.setName("测试");
o.setSalesCount(1);
o.setSellPoint("卖点");
o.setShowStock(true);
});
// 准备参数
productSpuMapper.insert(createReqVO);
// 测试 status 不匹配
productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setStatus(ProductSpuStatusEnum.DISABLE.getStatus())));
productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setStatus(ProductSpuStatusEnum.RECYCLE.getStatus())));
// 测试 SpecType 不匹配
productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setSpecType(ProductSpuSpecTypeEnum.DISABLE.getType())));
// 测试 BrandId 不匹配
productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setBrandId(generateId())));
// 测试 CategoryId 不匹配
productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setCategoryId(generateId())));
// 调用
ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO();
productSpuPageReqVO.setAlarmStock(false);
productSpuPageReqVO.setBrandId(brandId);
productSpuPageReqVO.setStatus(ProductSpuStatusEnum.ENABLE.getStatus());
productSpuPageReqVO.setCategoryId(categoryId);
PageResult<ProductSpuRespVO> spuPage = productSpuService.getSpuPage(productSpuPageReqVO);
PageResult<ProductSpuRespVO> result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO, (Set<Long>) null));
Assertions.assertEquals(result, spuPage);
}
@Test
void testGetSpuPage() {
// 准备参数
@ -244,13 +339,6 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
});
productSpuMapper.insert(createReqVO);
ArrayList<ProductSkuDO> remindSpuIds = Lists.newArrayList(
// randomPojo(ProductSkuDO.class, o -> o.setSpuId(createReqVO.getId())),
// randomPojo(ProductSkuDO.class, o -> o.setSpuId(createReqVO.getId()))
);
Mockito.when(productSkuService.getRemindSpuIds()).thenReturn(remindSpuIds);
// 调用
AppSpuPageReqVO appSpuPageReqVO = new AppSpuPageReqVO();
appSpuPageReqVO.setCategoryId(2L);

View File

@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.product.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
@ -38,7 +37,7 @@ public class TradeOrderDO extends BaseDO {
*
* 例如说1146347329394184195
*/
private String sn;
private String no;
/**
* 订单类型
*
@ -113,44 +112,38 @@ public class TradeOrderDO extends BaseDO {
// 价格文档 - 京东到家https://openo2o.jddj.com/api/getApiDetail/182/4d1494c5e7ac4679bfdaaed950c5bc7f.htm
// 价格文档 - 有赞https://doc.youzanyun.com/detail/API/0/906
// TODO promotion_details(订单优惠信息明细商品和订单级优惠一般都在里面)
/**
* 商品原价单位
*
* 基于 {@link TradeOrderItemDO#getTotalOriginalPrice()} 求和
*/
// niu - goods_money
private Integer skuOriginalPrice;
/**
* 商品优惠单位
*
* 基于 {@link TradeOrderItemDO#getTotalPromotionPrice()} 求和
*/
private Integer skuPromotionPrice;
private Integer originalPrice;
/**
* 订单优惠单位
*
* 例如说满减折扣不包括优惠劵商品优惠
* 例如说满减折扣不包括优惠劵商品优惠TODO
*/
// niu - promotion_moneytaobao - discount_fee主订单优惠
private Integer orderPromotionPrice;
private Integer promotionPrice;
/**
* 运费金额单位
*/
// niu - delivery_moneytaobao - post_fee订单邮费
private Integer deliveryPrice;
// TODO 芋艿taobao trade.adjust_fee/order.adjust_fee调整金额卖家手动修改订单价格官方数据修复等等
/**
* 订单调价单位
*
* 正数加价负数减价
*/
private Integer adjustPrice;
/**
* 应付金额单位
*
* = {@link #skuOriginalPrice}
* = {@link #originalPrice}
* + {@link #deliveryPrice}
* - {@link #skuPromotionPrice}
* - {@link #orderPromotionPrice}
* + {@link #adjustPrice}
* - {@link #promotionPrice}
* - {@link #couponPrice}
* - {@link #pointPrice}
*/
// niu - pay_moneytaobao - payment主订单实付金额 | trade.total_fee主订单应付金额参考使用
// * - {@link #couponPrice} // TODO 芋艿靠营销表记录
private Integer payPrice;
/**
* 支付订单编号
@ -166,21 +159,6 @@ public class TradeOrderDO extends BaseDO {
private Integer payChannel;
// ========== 收件 + 物流基本信息 ==========
/**
* 配送方式
* 会员用户下单时选择的配送方式
*
* 枚举 {@link DeliveryTypeEnum}
*/
private Integer deliveryType;
/**
* 实际的配送方式
* 管理后台发货时选择的配送方式
*
* 0 - 无需物流
* 枚举 {@link DeliveryTypeEnum}
*/
private Integer actualDeliveryType; // like - shipping_status
/**
* 配置模板的编号
*
@ -247,58 +225,13 @@ public class TradeOrderDO extends BaseDO {
* 优惠劵编号
*/
private Long couponId;
// /**
// * 优惠劵减免金额单位 // TODO 芋艿靠营销表记录
// */
// // niu - coupon_money
// private Integer couponPrice;
// /**
// * 积分抵扣的金额单位
// */
// private Integer integralPrice;
// /**
// * 使用的积分
// */
// private Integer useIntegral;
// TODO ========== 待定字段yv =========
// TODO cart_id购物车 id
// TODO refund_reason_wap_img退款图片
// TODO refund_reason_wap_explain退款用户说明
// TODO refund_reason_time退款时间
// TODO refund_reason_wap前台退款原因
// TODO refund_reason不退款的理由
// TODO gain_integral消费赚取积分
// TODO back_integral给用户退了多少积分
// TODO combination_id拼团产品id
// TODO pink_id拼团id
// TODO seckill_id秒杀产品ID
// TODO bargain_id砍价id
// TODO cost成本价
// TODO verify_code核销码
// TODO store_id门店id
// TODO ========== 待定字段cf =========
// TODO before_pay_price改价前支付金额
// TODO is_alter_price是否改价
// TODO out_trade_no商户系统内部的订单号 String
// TODO ========== 待定字段lf =========
// TODO settle_id未结算
// TODO settle_amount结算金额
// TODO team_found_id: 拼团id
// TODO team_id: 拼团活动id
// TODO delivery_id: 发货单ID
// TODO attach_values: 附带的值(赠送时机赠送积分成长值什么的)Json格式
// TODO ========== 待定字段nf =========
// TODO delivery_code整体提货编码
// TODO ========== 待定字段niu =========
// TODO adjust_money '订单调整金额'
// TODO balance_money ''余额支付金额''
/**
* 优惠劵减免金额单位
*/
private Integer couponPrice;
/**
* 积分抵扣的金额单位
*/
private Integer pointPrice;
}

View File

@ -123,7 +123,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
Long loginUserId, String clientIp) {
tradeOrderDO.setUserId(loginUserId);
tradeOrderDO.setUserIp(clientIp);
tradeOrderDO.setSn(IdUtil.getSnowflakeNextId() + ""); // TODO @LeeYan9: 思考下, 怎么生成好点哈; 这个是会展示给用户的;
tradeOrderDO.setNo(IdUtil.getSnowflakeNextId() + ""); // TODO @LeeYan9: 思考下, 怎么生成好点哈; 这个是会展示给用户的;
tradeOrderDO.setStatus(TradeOrderStatusEnum.WAITING_PAYMENT.getStatus());
tradeOrderDO.setType(TradeOrderTypeEnum.NORMAL.getType());
tradeOrderDO.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());

View File

@ -1,11 +1,14 @@
<template>
<div class="container">
<!-- TODO 样式优化表单宽度表单项对齐hr 粗细 -->
<el-tabs v-model="activeName" class="tabs">
<!-- 基础设置 -->
<!-- TODO @luowenfeng基础设置分成基础信息配送信息 -->
<!-- TODO @luowenfengbase=basic 会更好哈 -->
<el-tab-pane label="基础设置" name="base">
<el-form ref="base" :model="baseForm" :rules="rules" label-width="100px" style="width: 95%">
<el-form-item label="商品名称" prop="name">
<el-input v-model="baseForm.name" placeholder="请输入商品名称"/>
<el-input v-model="baseForm.name" placeholder="请输入商品名称" />
</el-form-item>
<el-form-item label="促销语">
<el-input type="textarea" v-model="baseForm.sellPoint" placeholder="请输入促销语"/>
@ -16,7 +19,6 @@
<el-form-item label="商品视频" prop="videoUrl">
<VideoUpload v-model="baseForm.videoUrl" :value="baseForm.videoUrl"/>
</el-form-item>
<el-form-item label="商品品牌" prop="brandId">
<el-select v-model="baseForm.brandId" placeholder="请选择商品品牌">
<el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id"/>
@ -28,20 +30,20 @@
</el-form-item>
<el-form-item label="是否上架" prop="status">
<el-radio-group v-model="baseForm.status">
<el-radio :label="0">立即上架</el-radio>
<el-radio :label="1">放入仓库</el-radio>
<el-radio :label="1">立即上架</el-radio>
<el-radio :label="0">放入仓库</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
</el-tab-pane>
<!-- 价格库存 -->
<!-- TODO @luowenfengrates=priceStack 会更好哈 -->
<el-tab-pane label="价格库存" name="rates" class="rates">
<el-form ref="rates" :model="ratesForm" :rules="rules">
<el-form-item label="启用多规格">
<el-switch v-model="specSwitch" @change="changeSpecSwitch"></el-switch>
<el-switch v-model="specSwitch" @change="changeSpecSwitch"/>
</el-form-item>
<!-- 动态添加规格属性 -->
<div v-show="ratesForm.spec === 2">
<div v-for="(specs, index) in dynamicSpec" :key="index" class="dynamic-spec">
@ -59,8 +61,7 @@
</template>
</div>
</div>
<el-button type="primary" @click="dynamicSpec.push({specValue: []}); ratesForm.rates = []">添加规格项目
</el-button>
<el-button type="primary" @click="dynamicSpec.push({specValue: []}); ratesForm.rates = []">添加规格项目</el-button>
</div>
<!-- 规格明细 -->
@ -76,15 +77,13 @@
</template>
<el-table-column label="规格图片" width="120px" :render-header="addRedStar" key="90">
<template slot-scope="scope">
<ImageUpload v-model="scope.row.picUrl" :limit="1" :isShowTip="false"
style="width: 100px; height: 50px"/>
<ImageUpload v-model="scope.row.picUrl" :limit="1" :isShowTip="false" style="width: 100px; height: 50px"/>
</template>
</el-table-column>
<template v-if="this.specSwitch">
<el-table-column label="sku名称" :render-header="addRedStar" key="91">
<template slot-scope="scope">
<el-form-item :prop="'rates.'+ scope.$index + '.name'"
:rules="[{required: true, trigger: 'change'}]">
<el-form-item :prop="'rates.'+ scope.$index + '.name'" :rules="[{required: true, trigger: 'change'}]">
<el-input v-model="scope.row.name"/>
</el-form-item>
</template>
@ -92,8 +91,7 @@
</template>
<el-table-column label="市场价(元)" :render-header="addRedStar" key="92">
<template slot-scope="scope">
<el-form-item :prop="'rates.'+ scope.$index + '.marketPrice'"
:rules="[{required: true, trigger: 'change'}]">
<el-form-item :prop="'rates.'+ scope.$index + '.marketPrice'" :rules="[{required: true, trigger: 'change'}]">
<el-input v-model="scope.row.marketPrice"
oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"/>
</el-form-item>
@ -104,7 +102,7 @@
<el-form-item :prop="'rates.'+ scope.$index + '.price'"
:rules="[{required: true, trigger: 'change'}]">
<el-input v-model="scope.row.price"
oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"></el-input>
oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
</el-form-item>
</template>
</el-table-column>
@ -112,17 +110,14 @@
<template slot-scope="scope">
<el-form-item :prop="'rates.'+ scope.$index + '.costPrice'"
:rules="[{required: true, trigger: 'change'}]">
<el-input
v-model="scope.row.costPrice"
oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"
></el-input>
<el-input v-model="scope.row.costPrice"
oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="库存" :render-header="addRedStar" key="95">
<template slot-scope="scope">
<el-form-item :prop="'rates.'+ scope.$index + '.stock'"
:rules="[{required: true, trigger: 'change'}]">
<el-form-item :prop="'rates.'+ scope.$index + '.stock'" :rules="[{required: true, trigger: 'change'}]">
<el-input v-model="scope.row.stock" oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"></el-input>
</el-form-item>
</template>
@ -134,17 +129,17 @@
</el-table-column>
<el-table-column label="体积" key="97">
<template slot-scope="scope">
<el-input v-model="scope.row.volume"></el-input>
<el-input v-model="scope.row.volume" />
</template>
</el-table-column>
<el-table-column label="重量" key="98">
<template slot-scope="scope">
<el-input v-model="scope.row.weight"></el-input>
<el-input v-model="scope.row.weight" />
</template>
</el-table-column>
<el-table-column label="条码" key="99">
<template slot-scope="scope">
<el-input v-model="scope.row.barCode"></el-input>
<el-input v-model="scope.row.barCode" />
</template>
</el-table-column>
<template v-if="this.specSwitch">
@ -169,6 +164,7 @@
</el-tab-pane>
<!-- 商品详情 -->
<!-- TODO @luowenfengthird=detail 会更好哈 -->
<el-tab-pane label="商品详情" name="third">
<el-form ref="third" :model="baseForm" :rules="rules">
<el-form-item prop="description">
@ -178,6 +174,7 @@
</el-tab-pane>
<!-- 销售设置 -->
<!-- TODO @luowenfengfourth=senior 会更好哈 -->
<el-tab-pane label="高级设置" name="fourth">
<el-form ref="fourth" :model="baseForm" :rules="rules" label-width="100px" style="width: 95%">
<el-form-item label="排序字段">
@ -421,15 +418,13 @@ export default {
if (form.id == null) {
createSpu(form).then(() => {
this.$modal.msgSuccess("新增成功");
})
.then(()=>{
}).then(()=>{
this.cancel();
})
} else {
updateSpu(form).then(() => {
this.$modal.msgSuccess("修改成功");
})
.then(()=>{
}).then(()=>{
this.cancel();
})
}
@ -458,7 +453,7 @@ export default {
this.baseForm.id = data.id;
this.baseForm.name = data.name;
this.baseForm.sellPoint = data.sellPoint;
this.baseForm.categoryIds = data.categoryIds;
this.baseForm.categoryIds = data.categoryId;
this.baseForm.videoUrl = data.videoUrl;
this.baseForm.sort = data.sort;
this.baseForm.description = data.description;