提交 e50520a3 authored 作者: zgy's avatar zgy

完成商品参数

上级 56c9274d
package com.platform.controller;
import com.platform.entity.TbCfItemParamEntity;
import com.platform.service.TbCfItemParamService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.utils.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 商品参数Controller
*
* @author lipengjun
* @date 2020-05-20 10:50:25
*/
@Controller
@RequestMapping("tbcfitemparam")
public class TbCfItemParamController {
@Autowired
private TbCfItemParamService tbCfItemParamService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("tbcfitemparam:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<TbCfItemParamEntity> tbCfItemParamList = tbCfItemParamService.queryList(query);
int total = tbCfItemParamService.queryTotal(query);
PageUtils pageUtil = new PageUtils(tbCfItemParamList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("tbcfitemparam:info")
@ResponseBody
public R info(@PathVariable("id") String id) {
TbCfItemParamEntity tbCfItemParam = tbCfItemParamService.queryObject(id);
return R.ok().put("tbCfItemParam", tbCfItemParam);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("tbcfitemparam:save")
@ResponseBody
public R save(@RequestBody TbCfItemParamEntity tbCfItemParam) {
tbCfItemParamService.save(tbCfItemParam);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("tbcfitemparam:update")
@ResponseBody
public R update(@RequestBody TbCfItemParamEntity tbCfItemParam) {
tbCfItemParamService.update(tbCfItemParam);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("tbcfitemparam:delete")
@ResponseBody
public R delete(@RequestBody String[] ids) {
tbCfItemParamService.deleteBatch(ids);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<TbCfItemParamEntity> list = tbCfItemParamService.queryList(params);
return R.ok().put("list", list);
}
/**
* 查看所有列表
*/
@RequestMapping("/queryParamByItemId")
@ResponseBody
public R queryParamByItemId(@RequestParam("itemId") String itemId) {
List<TbCfItemParamEntity> list;
if (!StringUtils.isBlank(itemId)) {
list = tbCfItemParamService.queryParamByItemId(itemId);
} else {
return R.error("参数不能为空");
}
return R.ok().put("list", list);
}
}
...@@ -2,6 +2,9 @@ package com.platform.dao; ...@@ -2,6 +2,9 @@ package com.platform.dao;
import com.platform.entity.TbCfItemParamEntity; import com.platform.entity.TbCfItemParamEntity;
import java.util.List;
/** /**
* 商品参数Dao * 商品参数Dao
* *
...@@ -10,4 +13,7 @@ import com.platform.entity.TbCfItemParamEntity; ...@@ -10,4 +13,7 @@ import com.platform.entity.TbCfItemParamEntity;
*/ */
public interface TbCfItemParamDao extends BaseDao<TbCfItemParamEntity> { public interface TbCfItemParamDao extends BaseDao<TbCfItemParamEntity> {
List<TbCfItemParamEntity> queryParamByItemId(String itemId);
int deleteByItemId(String itemId);
} }
...@@ -24,6 +24,18 @@ public class ItemDescSkus extends TbCfStationItemEntity { ...@@ -24,6 +24,18 @@ public class ItemDescSkus extends TbCfStationItemEntity {
* 商品规格信息 * 商品规格信息
*/ */
private List<TbCfCategoryEntity> tree; private List<TbCfCategoryEntity> tree;
/**
* 商品参数
*/
private List<TbCfItemParamEntity> paramster;
public List<TbCfItemParamEntity> getParamster() {
return paramster;
}
public void setParamster(List<TbCfItemParamEntity> paramster) {
this.paramster = paramster;
}
public String getItemDesc() { public String getItemDesc() {
return itemDesc; return itemDesc;
......
...@@ -12,6 +12,15 @@ public class ItemInfo { ...@@ -12,6 +12,15 @@ public class ItemInfo {
private TbCfItemDescEntity itemDesc; private TbCfItemDescEntity itemDesc;
private List<TbCfItemSkusEntity> itemSkusList; private List<TbCfItemSkusEntity> itemSkusList;
private List<TbCfCategoryEntity> categoryList; private List<TbCfCategoryEntity> categoryList;
private List<TbCfItemParamEntity> paramList;
public List<TbCfItemParamEntity> getParamList() {
return paramList;
}
public void setParamList(List<TbCfItemParamEntity> paramList) {
this.paramList = paramList;
}
public TbCfStationItemEntity getItem() { public TbCfStationItemEntity getItem() {
return item; return item;
......
...@@ -68,4 +68,6 @@ public interface TbCfItemParamService { ...@@ -68,4 +68,6 @@ public interface TbCfItemParamService {
* @return 删除条数 * @return 删除条数
*/ */
int deleteBatch(String[] ids); int deleteBatch(String[] ids);
List<TbCfItemParamEntity> queryParamByItemId(String itemId);
} }
...@@ -56,4 +56,9 @@ public class TbCfItemParamServiceImpl implements TbCfItemParamService { ...@@ -56,4 +56,9 @@ public class TbCfItemParamServiceImpl implements TbCfItemParamService {
public int deleteBatch(String[] ids) { public int deleteBatch(String[] ids) {
return tbCfItemParamDao.deleteBatch(ids); return tbCfItemParamDao.deleteBatch(ids);
} }
public List<TbCfItemParamEntity> queryParamByItemId(String itemId){
return tbCfItemParamDao.queryParamByItemId(itemId);
}
} }
...@@ -48,6 +48,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -48,6 +48,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
@Autowired @Autowired
private SysUserDao sysUserDao; private SysUserDao sysUserDao;
@Autowired
private TbCfItemParamDao tbCfItemParamDao;
@Override @Override
public ItemInfo queryItemInfoById(String itemId) { public ItemInfo queryItemInfoById(String itemId) {
//查询商品主体信息 //查询商品主体信息
...@@ -57,11 +61,12 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -57,11 +61,12 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
//查询商品描述 //查询商品描述
TbCfItemDescEntity itemDesc = tbCfItemDescDao.queryObject(itemId); TbCfItemDescEntity itemDesc = tbCfItemDescDao.queryObject(itemId);
List<TbCfCategoryEntity> categoryList = tbCfCategoryDao.queryByItemId(itemId); List<TbCfCategoryEntity> categoryList = tbCfCategoryDao.queryByItemId(itemId);
List<TbCfItemParamEntity> paramList = tbCfItemParamDao.queryParamByItemId(itemId);
ItemInfo itemInfo = new ItemInfo(); ItemInfo itemInfo = new ItemInfo();
itemInfo.setItem(item); itemInfo.setItem(item);
itemInfo.setCategoryList(categoryList); itemInfo.setCategoryList(categoryList);
itemInfo.setItemSkusList(itemSkusList); itemInfo.setItemSkusList(itemSkusList);
itemInfo.setParamList(paramList);
itemInfo.setItemDesc(itemDesc); itemInfo.setItemDesc(itemDesc);
return itemInfo; return itemInfo;
...@@ -102,7 +107,15 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -102,7 +107,15 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
count += entity.getSkuCount(); count += entity.getSkuCount();
orederNum++; orederNum++;
} }
//商品参数
List<TbCfItemParamEntity> paramsterList = itemSkus.getParamster();
for (TbCfItemParamEntity param : paramsterList) {
param.setId(IdUtil.createIdbyUUID());
param.setCreateTime(new Date());
param.setUpdateTime(new Date());
param.setItemId(itemId);
tbCfItemParamDao.save(param);
}
//商品主体信息 //商品主体信息
TbCfStationItemEntity tbCfStationItem = new TbCfStationItemEntity(); TbCfStationItemEntity tbCfStationItem = new TbCfStationItemEntity();
tbCfStationItem.setItemId(itemId); tbCfStationItem.setItemId(itemId);
...@@ -206,7 +219,17 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -206,7 +219,17 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
count += entity.getSkuCount(); count += entity.getSkuCount();
orederNum++; orederNum++;
} }
//先删除之前的商品参数
tbCfItemParamDao.deleteByItemId(itemId);
//商品参数
List<TbCfItemParamEntity> paramsterList = itemSkus.getParamster();
for (TbCfItemParamEntity param : paramsterList) {
param.setId(IdUtil.createIdbyUUID());
param.setCreateTime(new Date());
param.setUpdateTime(new Date());
param.setItemId(itemId);
tbCfItemParamDao.save(param);
}
/*for (int i = 0; i < itemList.size(); i++) { /*for (int i = 0; i < itemList.size(); i++) {
TbCfItemSkusEntity skusEntity = tbCfItemSkusDao.queryByOrderNum(i + 1, itemId); TbCfItemSkusEntity skusEntity = tbCfItemSkusDao.queryByOrderNum(i + 1, itemId);
if (skusEntity != null) { if (skusEntity != null) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<select id="queryObject" resultType="com.platform.entity.TbCfItemParamEntity"> <select id="queryObject" resultType="com.platform.entity.TbCfItemParamEntity">
select select
`id`, `id`,
`param_name`, `param_name`,
...@@ -23,42 +23,52 @@ ...@@ -23,42 +23,52 @@
from tb_cf_item_param from tb_cf_item_param
where id = #{id} where id = #{id}
</select> </select>
<select id="queryParamByItemId" resultType="com.platform.entity.TbCfItemParamEntity">
<select id="queryList" resultType="com.platform.entity.TbCfItemParamEntity"> select
select `id`,
`id`, `param_name`,
`param_name`, `param_value`,
`param_value`, `item_id`,
`item_id`, `create_time`,
`create_time`, `update_time`
`update_time`
from tb_cf_item_param from tb_cf_item_param
WHERE 1=1 where item_id = #{itemId}
<if test="name != null and name.trim() != ''"> </select>
AND name LIKE concat('%',#{name},'%') <select id="queryList" resultType="com.platform.entity.TbCfItemParamEntity">
</if> select
`id`,
`param_name`,
`param_value`,
`item_id`,
`create_time`,
`update_time`
from tb_cf_item_param
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose> <choose>
<when test="sidx != null and sidx.trim() != ''"> <when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order} order by ${sidx} ${order}
</when> </when>
<otherwise> <otherwise>
order by id desc order by id desc
</otherwise> </otherwise>
</choose> </choose>
<if test="offset != null and limit != null"> <if test="offset != null and limit != null">
limit #{offset}, #{limit} limit #{offset}, #{limit}
</if> </if>
</select> </select>
<select id="queryTotal" resultType="int"> <select id="queryTotal" resultType="int">
select count(*) from tb_cf_item_param select count(*) from tb_cf_item_param
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND name LIKE concat('%',#{name},'%')
</if> </if>
</select> </select>
<insert id="save" parameterType="com.platform.entity.TbCfItemParamEntity"> <insert id="save" parameterType="com.platform.entity.TbCfItemParamEntity">
insert into tb_cf_item_param( insert into tb_cf_item_param(
`id`, `id`,
`param_name`, `param_name`,
...@@ -74,28 +84,32 @@ ...@@ -74,28 +84,32 @@
#{createTime}, #{createTime},
#{updateTime}) #{updateTime})
</insert> </insert>
<update id="update" parameterType="com.platform.entity.TbCfItemParamEntity"> <update id="update" parameterType="com.platform.entity.TbCfItemParamEntity">
update tb_cf_item_param update tb_cf_item_param
<set> <set>
<if test="paramName != null">`param_name` = #{paramName}, </if> <if test="paramName != null">`param_name` = #{paramName},</if>
<if test="paramValue != null">`param_value` = #{paramValue}, </if> <if test="paramValue != null">`param_value` = #{paramValue},</if>
<if test="itemId != null">`item_id` = #{itemId}, </if> <if test="itemId != null">`item_id` = #{itemId},</if>
<if test="createTime != null">`create_time` = #{createTime}, </if> <if test="createTime != null">`create_time` = #{createTime},</if>
<if test="updateTime != null">`update_time` = #{updateTime}</if> <if test="updateTime != null">`update_time` = #{updateTime}</if>
</set> </set>
where id = #{id} where id = #{id}
</update> </update>
<delete id="delete"> <delete id="delete">
delete from tb_cf_item_param where id = #{value} delete from tb_cf_item_param where id = #{value}
</delete> </delete>
<delete id="deleteBatch"> <delete id="deleteByItemId">
delete from tb_cf_item_param where id in delete from tb_cf_item_param where item_id = #{itemId}
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete> </delete>
<delete id="deleteBatch">
delete from tb_cf_item_param where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -78,99 +78,94 @@ let vm = new Vue({ ...@@ -78,99 +78,94 @@ let vm = new Vue({
isSelectedArr: [], //选中标签的数组 isSelectedArr: [], //选中标签的数组
//2020年4月9日 //2020年4月9日
showAttributeImg:false, //显示属性图片模态框 showAttributeImg: false, //显示属性图片模态框
AttributeImgArr:[], AttributeImgArr: [],
skuListsIndex:null,//sku选中索引 skuListsIndex: null,//sku选中索引
disabledChangeAttribute:false,//禁止改变商品属性 disabledChangeAttribute: false,//禁止改变商品属性
showBatch:false,//显示批量操作模态框 showBatch: false,//显示批量操作模态框
selectBtnArr:[ selectBtnArr: [
{isSelected:false,title:'全选'}, {isSelected: false, title: '全选'},
{isSelected:false,title:'反选'}, {isSelected: false, title: '反选'},
{isSelected:false,title:'取消选择'} {isSelected: false, title: '取消选择'}
], ],
allAttributes:[],//所有具体属性 allAttributes: [],//所有具体属性
batchAmount:0, batchAmount: 0,
batchCount:0, batchCount: 0,
//2020年5月20日 商品参数 //2020年5月20日 商品参数
paramster:[ paramster: []
{
paramName:'shell fabric', //面料
paramValue:'dacron' //涤纶
}
]
}, },
methods: { methods: {
//预览 //预览
preview(e){ preview(e) {
window.open(`https://www.afrieshop.com/product_detail?pid=${e}&from=backstage management system&from_fullPath=${window.location.herf}`,'_blank'); window.open(`https://www.afrieshop.com/product_detail?pid=${e}&from=backstage management system&from_fullPath=${window.location.herf}`, '_blank');
}, },
cancelSelectImg(){ cancelSelectImg() {
this.prevItem[this.skuListsIndex].skuImg=null; this.prevItem[this.skuListsIndex].skuImg = null;
this.showAttributeImg = false; this.showAttributeImg = false;
}, },
changeBatch(e,flag){ changeBatch(e, flag) {
if(flag==='amount'){ if (flag === 'amount') {
this.batchAmount=e.target.value; this.batchAmount = e.target.value;
}else{ } else {
this.batchCount=e.target.value; this.batchCount = e.target.value;
} }
}, },
//批量操作 //批量操作
saveBatchData(){ saveBatchData() {
let activeImgPath = ''; let activeImgPath = '';
this.AttributeImgArr.map( item => { this.AttributeImgArr.map(item => {
item.isSelected?activeImgPath=item.img_path:null; item.isSelected ? activeImgPath = item.img_path : null;
}); });
this.allAttributes.forEach( item => { this.allAttributes.forEach(item => {
if(item.isSelected){ if (item.isSelected) {
item.amount = this.batchAmount; item.amount = this.batchAmount;
item.count = this.batchCount; item.count = this.batchCount;
item.skuImg = activeImgPath; item.skuImg = activeImgPath;
return false; return false;
} }
}) })
this.prevItem.map( item => item.isSelected =false); this.prevItem.map(item => item.isSelected = false);
this.prevItem.map( item => { this.prevItem.map(item => {
this.allAttributes.map( _item => { this.allAttributes.map(_item => {
if(_item.isSelected&&item.skuDesc.includes(_item.text)){ if (_item.isSelected && item.skuDesc.includes(_item.text)) {
item.isSelected = true; item.isSelected = true;
} }
}) })
}) })
this.prevItem.map( (item,index) => { this.prevItem.map((item, index) => {
if(item.isSelected){ if (item.isSelected) {
item.skuImg = activeImgPath; item.skuImg = activeImgPath;
item.skuPrice = this.batchAmount; item.skuPrice = this.batchAmount;
item.skuCount = this.batchCount; item.skuCount = this.batchCount;
} }
}) })
this.prevItem.map( item => delete item.isSelected); this.prevItem.map(item => delete item.isSelected);
this.showBatch = false; this.showBatch = false;
}, },
//批处理图片选择 //批处理图片选择
BatchSelectImg(item,index){ BatchSelectImg(item, index) {
this.AttributeImgArr.map( (_item,_index) => index!==_index?_item.isSelected = false:null); this.AttributeImgArr.map((_item, _index) => index !== _index ? _item.isSelected = false : null);
this.AttributeImgArr[index].isSelected = !this.AttributeImgArr[index].isSelected; this.AttributeImgArr[index].isSelected = !this.AttributeImgArr[index].isSelected;
}, },
//批量处理单选属性 //批量处理单选属性
selectAttr(e,index){ selectAttr(e, index) {
this.allAttributes[index].isSelected = !this.allAttributes[index].isSelected; this.allAttributes[index].isSelected = !this.allAttributes[index].isSelected;
}, },
//显示批量处理模态框 //显示批量处理模态框
showBatchModel(){ showBatchModel() {
this.$refs.amount.$el.children[1].value = this.batchAmount = null; this.$refs.amount.$el.children[1].value = this.batchAmount = null;
this.$refs.count.$el.children[1].value = this.batchCount = null; this.$refs.count.$el.children[1].value = this.batchCount = null;
this.showBatch = true; this.showBatch = true;
//获取所有具体属性 //获取所有具体属性
this.allAttributes = []; this.allAttributes = [];
this.attrItem[0].categoryDesc.split(',').map( _item => this.allAttributes.push({ this.attrItem[0].categoryDesc.split(',').map(_item => this.allAttributes.push({
text:_item, text: _item,
isSelected:false, isSelected: false,
amount:null, amount: null,
count:null, count: null,
skuImg:null skuImg: null
})); }));
// this.attrItem.map( item => item.categoryDesc.split(',').map( _item => this.allAttributes.push({ // this.attrItem.map( item => item.categoryDesc.split(',').map( _item => this.allAttributes.push({
// text:_item, // text:_item,
...@@ -181,40 +176,40 @@ let vm = new Vue({ ...@@ -181,40 +176,40 @@ let vm = new Vue({
// })) ); // })) );
}, },
//切换批量选择按钮 //切换批量选择按钮
changeSelectBtnArr(item,index){ changeSelectBtnArr(item, index) {
this.selectBtnArr.map( (_item,_index) => _index!==index?_item.isSelected = false:null); this.selectBtnArr.map((_item, _index) => _index !== index ? _item.isSelected = false : null);
this.selectBtnArr[index].isSelected = !this.selectBtnArr[index].isSelected; this.selectBtnArr[index].isSelected = !this.selectBtnArr[index].isSelected;
if(index===0){ if (index === 0) {
this.allAttributes.map( item => item.isSelected = true); this.allAttributes.map(item => item.isSelected = true);
}else if(index===1){ } else if (index === 1) {
this.allAttributes.map( item => item.isSelected = !item.isSelected); this.allAttributes.map(item => item.isSelected = !item.isSelected);
}else{ } else {
this.allAttributes.map( item => item.isSelected = false); this.allAttributes.map(item => item.isSelected = false);
} }
}, },
selectImg(url){ selectImg(url) {
// console.log(this.prevItem[this.skuListsIndex]); // console.log(this.prevItem[this.skuListsIndex]);
this.prevItem[this.skuListsIndex].skuImg = url; this.prevItem[this.skuListsIndex].skuImg = url;
this.$forceUpdate(); this.$forceUpdate();
this.showAttributeImg = false; this.showAttributeImg = false;
}, },
//单条sku选择图片 //单条sku选择图片
HandleSelectAttributeImg(e,i){ HandleSelectAttributeImg(e, i) {
if(!this.disabledChangeAttribute){ if (!this.disabledChangeAttribute) {
window.alert('请先确认商品规格后再操作。(确认商品规格后将不可再次编辑规格数据)'); window.alert('请先确认商品规格后再操作。(确认商品规格后将不可再次编辑规格数据)');
}else{ } else {
this.showAttributeImg = true; this.showAttributeImg = true;
this.skuListsIndex = i; this.skuListsIndex = i;
} }
}, },
//删除属性图片 //删除属性图片
removeAttributeImg(e,i,notShowMessage){ removeAttributeImg(e, i, notShowMessage) {
this.$delete(this.AttributeImgArr,i); this.$delete(this.AttributeImgArr, i);
this.delAttributeImg(e,notShowMessage); this.delAttributeImg(e, notShowMessage);
}, },
//删除图片 //删除图片
delAttributeImg(url,notShowMessage){ delAttributeImg(url, notShowMessage) {
Ajax.request({ Ajax.request({
url: "../api/upload/delFile?url=" + url, url: "../api/upload/delFile?url=" + url,
async: false, async: false,
...@@ -222,21 +217,21 @@ let vm = new Vue({ ...@@ -222,21 +217,21 @@ let vm = new Vue({
contentType: "application/json", contentType: "application/json",
successCallback: function (resultData) { successCallback: function (resultData) {
// console.log(resultData); // console.log(resultData);
!notShowMessage?iview.Message.success(resultData.success):null; !notShowMessage ? iview.Message.success(resultData.success) : null;
} }
}); });
}, },
//处理属性图片上传成功回调 //处理属性图片上传成功回调
handleAttributeImgSuccess(e){ handleAttributeImgSuccess(e) {
this.AttributeImgArr.push({ this.AttributeImgArr.push({
img_path:e, img_path: e,
isSelected:false isSelected: false
}); });
console.log(e); console.log(e);
// this.delAttributeImg(e); // this.delAttributeImg(e);
}, },
//控制属性图片模块框 //控制属性图片模块框
isShowAttributeContainer(Bool){ isShowAttributeContainer(Bool) {
this.showAttributeImg = Bool; this.showAttributeImg = Bool;
}, },
//获取二级分类 //获取二级分类
...@@ -279,7 +274,14 @@ let vm = new Vue({ ...@@ -279,7 +274,14 @@ let vm = new Vue({
vm.reload(); vm.reload();
}, },
add: function () { add: function () {
this.AttributeImgArr.length=0; this.AttributeImgArr.length = 0;
this.paramster.length=0;
this.paramster.push({
paramName: '',
paramValue: ''
});
vm.showList = false; vm.showList = false;
vm.title = "新增"; vm.title = "新增";
vm.tbCfStationItem = {}; vm.tbCfStationItem = {};
...@@ -301,14 +303,19 @@ let vm = new Vue({ ...@@ -301,14 +303,19 @@ let vm = new Vue({
vm.getInfo(itemId); vm.getInfo(itemId);
}, },
saveOrUpdate: function (event) { saveOrUpdate: function (event) {
if(vm.prevItem.length===0){ if (vm.prevItem.length === 0) {
console.log(123); console.log(123);
alert('请编辑完属性后再保存'); alert('请编辑完属性后再保存');
}else{ } else {
let resArr = []; let resArr = [];
this.prevItem.forEach(item => { this.prevItem.forEach(item => {
resArr.push(item) resArr.push(item)
}) })
let paramArr = [];
this.paramster.forEach(item => {
paramArr.push(item)
})
vm.tbCfStationItem.paramster = this.paramster;
let label = null; let label = null;
vm.tbCfStationItem.itemLabel = this.isSelectedArr.map(item => item.id).join(','); vm.tbCfStationItem.itemLabel = this.isSelectedArr.map(item => item.id).join(',');
vm.tbCfStationItem.prevItem = resArr vm.tbCfStationItem.prevItem = resArr
...@@ -318,7 +325,7 @@ let vm = new Vue({ ...@@ -318,7 +325,7 @@ let vm = new Vue({
vm.tbCfStationItem.itemImg = vm.uploadList.map(res => res).join(';'); vm.tbCfStationItem.itemImg = vm.uploadList.map(res => res).join(';');
vm.tbCfStationItem.itemDesc = encodeURI(UE.getEditor('itemDesc').getContent()); // 富文本取值 vm.tbCfStationItem.itemDesc = encodeURI(UE.getEditor('itemDesc').getContent()); // 富文本取值
vm.tbCfStationItem.itemDesc = vm.tbCfStationItem.itemDesc.replace(/&nbsp;/g, " "); vm.tbCfStationItem.itemDesc = vm.tbCfStationItem.itemDesc.replace(/&nbsp;/g, " ");
vm.tbCfStationItem.skuImgs = vm.AttributeImgArr.map( item => item.img_path).join(';'); vm.tbCfStationItem.skuImgs = vm.AttributeImgArr.map(item => item.img_path).join(';');
let url = vm.tbCfStationItem.itemId == null ? "../tbcfstationitem/save" : "../tbcfstationitem/update"; let url = vm.tbCfStationItem.itemId == null ? "../tbcfstationitem/save" : "../tbcfstationitem/update";
Ajax.request({ Ajax.request({
url: url, url: url,
...@@ -384,6 +391,14 @@ let vm = new Vue({ ...@@ -384,6 +391,14 @@ let vm = new Vue({
async: true, async: true,
successCallback: function (r) { successCallback: function (r) {
r.code === 0 && (() => { r.code === 0 && (() => {
_this.paramster = []
//回显参数
r.tbCfStationItem.paramList.map(item => {
_this.paramster.push({
paramName: item.paramName,
paramValue: item.paramValue
})
})
_this.attrItem = [] _this.attrItem = []
// let _option = JSON.parse(localStorage.getItem('option')) // let _option = JSON.parse(localStorage.getItem('option'))
//回显属性 //回显属性
...@@ -398,20 +413,20 @@ let vm = new Vue({ ...@@ -398,20 +413,20 @@ let vm = new Vue({
_this.tmdSkudata = r.tbCfStationItem.itemSkusList _this.tmdSkudata = r.tbCfStationItem.itemSkusList
r.tbCfStationItem.itemSkusList.map(item => { r.tbCfStationItem.itemSkusList.map(item => {
_this.prevItem.push({ _this.prevItem.push({
skuImg:null, skuImg: null,
skuName: item.skuName, skuName: item.skuName,
skuDesc: item.skuDesc, skuDesc: item.skuDesc,
skuPrice: item.skuPrice, skuPrice: item.skuPrice,
skuCount: item.skuCount, skuCount: item.skuCount,
skuImg:item.skuImg, skuImg: item.skuImg,
skuCode:item.skuCode skuCode: item.skuCode
}) })
}) })
if(r.tbCfStationItem.item.skuImgs){ if (r.tbCfStationItem.item.skuImgs) {
r.tbCfStationItem.item.skuImgs.split(';').map( item => { r.tbCfStationItem.item.skuImgs.split(';').map(item => {
vm.AttributeImgArr.push({ vm.AttributeImgArr.push({
img_path: item, img_path: item,
isSelected:false isSelected: false
}) })
}) })
} }
...@@ -462,15 +477,15 @@ let vm = new Vue({ ...@@ -462,15 +477,15 @@ let vm = new Vue({
}); });
}, },
back(){ back() {
//清除未保存商品的图片 //清除未保存商品的图片
if(!vm.tbCfStationItem.itemId){ if (!vm.tbCfStationItem.itemId) {
this.AttributeImgArr.map( (item,index) => { this.AttributeImgArr.map((item, index) => {
this.delAttributeImg(item.img_path,true); this.delAttributeImg(item.img_path, true);
}) })
setTimeout(()=>{ setTimeout(() => {
this.AttributeImgArr = []; this.AttributeImgArr = [];
},0) }, 0)
} }
this.reload(); this.reload();
}, },
...@@ -543,7 +558,7 @@ let vm = new Vue({ ...@@ -543,7 +558,7 @@ let vm = new Vue({
/** ******************************************************************************************** */ /** ******************************************************************************************** */
vhandleSuccess(response, file, fileList) { vhandleSuccess(response, file, fileList) {
// "http://diaosaas-prod.oss-cn-shenzhen.aliyuncs.com/education/155728894307110106.jpg" // "http://diaosaas-prod.oss-cn-shenzhen.aliyuncs.com/education/155728894307110106.jpg"
console.log('shangchuan',response) console.log('shangchuan', response)
vm.uploadList.push(response); vm.uploadList.push(response);
$("#itemImg").show(); $("#itemImg").show();
}, },
...@@ -699,7 +714,7 @@ let vm = new Vue({ ...@@ -699,7 +714,7 @@ let vm = new Vue({
product(skuArr).forEach((item, index) => { product(skuArr).forEach((item, index) => {
this.prevItem.push({ this.prevItem.push({
skuImg:null, skuImg: null,
skuName: skuName, skuName: skuName,
skuDesc: item, skuDesc: item,
skuPrice: this.default_price, skuPrice: this.default_price,
...@@ -805,13 +820,13 @@ let vm = new Vue({ ...@@ -805,13 +820,13 @@ let vm = new Vue({
* 2020年5月20日 * 2020年5月20日
* 新增产品参数 * 新增产品参数
*/ */
addProductParams(){ addProductParams() {
this.paramster.push({ this.paramster.push({
paramName:null, paramName: null,
paramValue:null paramValue: null
}) })
}, },
delParamster(i){ delParamster(i) {
let arr = new Array(); let arr = new Array();
this.paramster.map((item, index) => { this.paramster.map((item, index) => {
if (i !== index) { if (i !== index) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论