提交 7ad35de0 authored 作者: huaxinzhu's avatar huaxinzhu

1、商品规格-库存不能一键应用bug修复;商品编辑,数据格式修改;

上级 7cb6808a
......@@ -57,7 +57,7 @@
name: "goodsimg",
props: {
imgdata: {
type: Array,
type: Object,
required: true
}
},
......@@ -81,11 +81,16 @@
},
watch: {
imgdata(curVal, oldVal) {
console.log(84,curVal);
if (curVal) {
curVal.ruleFormdialogImageUrl.forEach((itemName, nindex) => {
this.ruleFormdialogImageUrl.push({'url': itemName.thumbnailM})
})
this.ruleFormdialogImageUrlplus.push({'url': curVal.ruleFormdialogImageUrlplus})
if(curVal.ruleFormdialogImageUrl) {
curVal.ruleFormdialogImageUrl.forEach((itemName, nindex) => {
this.ruleFormdialogImageUrl.push({'url': itemName.thumbnailM})
})
}
if(this.ruleFormdialogImageUrlplus) {
this.ruleFormdialogImageUrlplus.push({'url': curVal.ruleFormdialogImageUrlplus});
}
}
},
picall: {
......
......@@ -246,7 +246,7 @@
deep: true
},
infomationdatas(curVal, oldVal) {
console.log("商品信息子组件:",curVal);
//console.log("商品信息子组件:",curVal);
if (curVal) {
this.ruleForm = curVal;
if(curVal.freightId == 0) {
......@@ -254,17 +254,17 @@
}else {
this.ruleForm.resource = '1';
}
this.content = this.ruleForm.description;
// 初始化
this.serviceagsTags = [];
this.ruleForm.serviceagsTags.forEach((val) => {
if (val) {
let nid = parseInt(val);
this.serviceagsTags.push(nid);
}
})
if(this.ruleForm.serviceagsTags) {
this.ruleForm.serviceagsTags.forEach((val) => {
if (val) {
let nid = parseInt(val);
this.serviceagsTags.push(nid);
}
})
}
}
}
},
......@@ -291,8 +291,6 @@
this.serviceagsTags.splice(index3,1)
}
}
console.log(307,this.ruleForm);
},
// 运费模板类型,change事件
freightIdTypeChange(val) {
......
......@@ -206,8 +206,8 @@
<el-input placeholder="" v-model="scope.row.jsPrice"></el-input>
</template>
</el-table-column>
<el-table-column prop="kucun" label="库存">
<template slot="header" slot-scope="scope" align="center">
<el-table-column prop="kucun" label="库存" align="center">
<template slot="header" slot-scope="scope">
<p class="table_p">库存</p>
<el-input placeholder="" v-model="goodsNowStock"
><el-button
......@@ -241,7 +241,6 @@
</el-table-column>
</el-table>
<!-- <el-button type="primary" @click="handleinfomationclick('ruleForm')">下一步</el-button>-->
<el-button >重置</el-button>
</div>
</div>
......@@ -305,7 +304,6 @@ export default {
// this.driver = new Driver()
this.$dragging.$on("dragged", (value) => {
//因为我这在排序的时候不需要做处理,所以空着就行
// debugger;
});
},
watch:{
......@@ -320,83 +318,80 @@ export default {
},
deep:true
},
guidedata(curVal,oldVal){
if(curVal){
if(curVal.goodsSpec){
this.checked = true
}
// 规格
this.shopType = curVal.specName?curVal.specName:[],
this.shopType.forEach((item, index) => {
this.shopType[index]['specValue'] = []
curVal.specValue.forEach((itemName, nindex) => {
if(itemName.specNameId == item.id){
this.shopType[index]['specValue'].push(itemName)
guidedata(curVal,oldVal){
if(curVal){
if(curVal.goodsSpec){
this.checked = true
}
// 规格
this.shopType = curVal.specName;
if(this.shopType) {
this.shopType.forEach((item, index) => {
this.shopType[index]['specValue'] = []
if(curVal.specValue) {
curVal.specValue.forEach((itemName, nindex) => {
if(itemName.specNameId == item.id){
this.shopType[index]['specValue'].push(itemName)
}
})
}
})
})
//笛卡尔乘积title
this.clgoodspace(curVal)
//笛卡尔积值
this.tableData7 = curVal.specOption
this.tableData7.forEach((element, index) => {
this.tableData7[index]["goodsNowStock"] = element.stock
});
})
}
}
},
this.clgoodspace(curVal);
//笛卡尔积值
this.tableData7 = curVal.specOption;
}
},
},
methods: {
guidInput(val){
this.$forceUpdate()
},
// 处理回显数据
clgoodspace(goodsspace){
this.shopTypes = JSON.parse(JSON.stringify(this.shopType));
let specName = goodsspace.specName
let specValue = goodsspace.specValue
let specOption = goodsspace.specOption
specName.forEach((item)=>{
this.tablearr.push(item.specName)
specValue.forEach((itemchild)=>{
clgoodspace(goodsspace){
this.shopTypes = JSON.parse(JSON.stringify(this.shopType));
let specName = goodsspace.specName;
let specValue = goodsspace.specValue;
let specOption = goodsspace.specOption;
if(specName) {
specName.forEach((item)=>{
this.tablearr.push(item.specName)
specValue.forEach((itemchild)=>{
if(item.id ==itemchild.specNameId){
itemchild['specName'] =item.specName
itemchild['specName'] =item.specName
}
})
})
specOption.forEach(item=>{
let goodsarr = item.specValueIds.split('_')
goodsarr.forEach(itemchild=>{
specValue.forEach(itemgoodschild=>{
if(itemchild == itemgoodschild.id){
item[itemgoodschild.specName] = itemgoodschild.value
}
})
})
}
if(specOption) {
specOption.forEach(item=>{
let goodsarr = item.specValueIds.split('_')
goodsarr.forEach(itemchild=>{
specValue.forEach(itemgoodschild=>{
if(itemchild == itemgoodschild.id){
item[itemgoodschild.specName] = itemgoodschild.value
}
})
})
})
this.tableData7 = specOption
this.getSpanArr(this.tableData7);
},
})
}
this.tableData7 = specOption;
this.getSpanArr(this.tableData7);
},
// 不能删
descartes,
handleinfomationclick(formName) {
let arrlist = JSON.stringify(this.tableData7); //可以将json对象转换成json对符串
let listarr = JSON.parse(arrlist); //可以将json字符串转换成json对象
this.processguidelist(listarr);
this.$emit('guideclicks',this.arrtdall,this.shopType)
},
processguidelist(obj) {
// listobj["goodsNowStock"] = "";
// listobj["jsPrice"] = "";
// listobj["price"] = "";
// listobj["scPrice"] = "";
// listobj["wlPrice"] = "";
// listobj["pywlPrice"] = "";
// listobj["weight"] = "";
let arrtdall = []
let arrtdall = []
obj.forEach((item, index) => {
let objtd = {}
let arrtd = []
......@@ -416,11 +411,6 @@ export default {
deletearrinput(index) {
this.shopType.splice(index, 1);
},
weightall() {
this.tableData7.forEach((element, index) => {
this.tableData7[index].weight = this.weight;
});
},
jsPriceall() {
this.tableData7.forEach((element, index) => {
this.tableData7[index].jsPrice = this.jsPrice;
......@@ -436,11 +426,18 @@ export default {
this.tableData7[index].scPrice = this.scPrice;
});
},
// 一键 库存
goodsNowStockall() {
this.tableData7.forEach((element, index) => {
this.tableData7[index].goodsNowStock = this.goodsNowStock;
});
},
// 一键 重量
weightall() {
this.tableData7.forEach((element, index) => {
this.tableData7[index].weight = this.weight;
});
},
//删除规格项
deleteinput(index, indexs) {
this.shopType[index].specValue.splice(indexs, 1);
......@@ -625,7 +622,6 @@ export default {
},
//计算位置的方法
getSpanArr(data) {
// debugger
this.spanArrS = {};
this.spanArr = [];
this.pos = "";
......
......@@ -44,7 +44,7 @@
loading: false,
applyStatus: '',
title: "添加新商品",
imgdate: [],
imgdate: {},
guidedate: {},
parameterdate: {},
params: {
......@@ -67,8 +67,8 @@
methods: {
// 运费模板
getFreight() {
GetFreight(this.queryParams).then(response => {
this.expressTemplateList = response.data;
GetFreight(this.queryParams).then(res => {
this.expressTemplateList = res.data;
this.expressTemplateIdList = this.expressTemplateList.filter(function(item) {
return item.Id;
})
......@@ -85,64 +85,75 @@
genGoodsInfo(goodsId) {
this.loading = true;
const goods_id = goodsId;
getGoods(goods_id).then(response => {
//console.log(89,response);
if(response.data.code === 1 && response.data.data) {
this.goodsOnsale = response.data.data.isOnsale;
getGoods(goods_id).then(res => {
console.log(9999,res);
if(res.code === 1 && res.data) {
this.goodsOnsale = res.data.isOnsale;
// 对发货时效单独处理
if(response.data.data.Delayompensate == 0) {
response.data.data.Delayompensate = '';
if(res.data.Delayompensate == 0) {
res.data.Delayompensate = '';
}
//response.data.data.freightId 返回的值类型有 0(string/number)|| ‘全国包邮通用模板’(string)|| 310(number)
//res.data.freightId 返回的值类型有 0(string/number)|| ‘全国包邮通用模板’(string)|| 310(number)
let resourceType = '1'; // 为了单元框正常显示,先给一个默认值,// 字符串 ‘0’,代表 数据为单独运费
let serviceagsTagsVal = [];
if(response.data.data.ServiceagsTags) {
serviceagsTagsVal = JSON.parse(response.data.data.ServiceagsTags);
if(res.data.ServiceagsTags) {
serviceagsTagsVal = JSON.parse(res.data.ServiceagsTags);
}
// 库存,后台返回字段更换,提前处理 specOption
if( res.data.goodsSpecs.specOption && res.data.goodsSpecs.specOption.length > 0) {
res.data.goodsSpecs.specOption.forEach(function(item){
if(item.stock) {
item['goodsNowStock'] = item.stock;
}
});
}
this.infomationdata = {
goodsId: response.data.data.goodsId,
goodsName: response.data.data.goodsName,
categoryId: response.data.data.categoryId,
scPrice: response.data.data.scPrice / 100,
price: response.data.data.price / 100,
jsPrice: response.data.data.jsPrice / 100,
goodsNowStock: response.data.data.goodsNowStock,
producingArea: response.data.data.producingArea,
weight: response.data.data.weight,
unit: response.data.data.unit,
goodsBrand: response.data.data.goodsBrand,
wlPrice: response.data.data.wlPrice,
pywlPrice: response.data.data.pywlPrice,
goodsId: res.data.goodsId,
goodsName: res.data.goodsName,
categoryId: res.data.categoryId,
scPrice: res.data.scPrice / 100,
price: res.data.price / 100,
jsPrice: res.data.jsPrice / 100,
goodsNowStock: res.data.goodsNowStock,
producingArea: res.data.producingArea,
weight: res.data.weight,
unit: res.data.unit,
goodsBrand: res.data.goodsBrand,
wlPrice: res.data.wlPrice,
pywlPrice: res.data.pywlPrice,
resource: resourceType,
Delayompensate: response.data.data.Delayompensate,
aftersaleTime: response.data.data.aftersaleTime,
mark: response.data.data.mark,
Delayompensate: res.data.Delayompensate,
aftersaleTime: res.data.aftersaleTime,
mark: res.data.mark,
serviceagsTags: serviceagsTagsVal,
description: response.data.data.description,
freightId: response.data.data.freightId,
outGoodsId: response.data.data.outGoodsId,
description: res.data.description,
freightId: res.data.freightId,
outGoodsId: res.data.outGoodsId,
};
this.guidedate = response.data.data.goodsSpecs;
this.guidedate["goodsSpec"] = response.data.data.goodsSpec;
this.parameterdata = response.data.data.Params;
this.guidedate = res.data.goodsSpecs;
this.guidedate["goodsSpec"] = res.data.goodsSpec;
this.parameterdata = res.data.Params ? res.data.Params : {};
this.imgdate = {
"ruleFormdialogImageUrl": response.data.data.image,
"ruleFormdialogImageUrlplus": response.data.data.defaultImage
"ruleFormdialogImageUrl": res.data.image,
"ruleFormdialogImageUrlplus": res.data.defaultImage
};
}else if(response.data.code === 0) {
if(response.data.msg) {
this.$message({type:'error',message: response.data.msg});
}else if(res.code === 0) {
if(res.msg) {
this.$message({type:'error',message: res.msg});
}else {
this.$message({type:'error',message: '数据出错啦'});
}
}
this.loading = false;
});
},
info() {
addgoods(this.listQuery).then(response => {
this.list = response.data.items
this.total = response.data.total
addgoods(this.listQuery).then(res => {
this.list = res.data.items
this.total = res.data.total
this.listLoading = false
})
},
......@@ -166,6 +177,20 @@
guideclick(type, specsGroup) {
this.params["specs"] = type;
this.params["specsGroup"] = specsGroup;
// 浮点处理
if(this.params.specs && this.params.specs.length > 0) {
for(let i = 0; i < this.params.specs.length; i++) {
if(this.params.specs[i].jsPrice ) {
this.params.specs[i].jsPrice = this.params.specs[i].jsPrice * 100;
}
if(this.params.specs[i].price ) {
this.params.specs[i].price = this.params.specs[i].price * 100;
}
if(this.params.specs[i].scPrice ) {
this.params.specs[i].scPrice = this.params.specs[i].scPrice * 100;
}
}
}
},
//参数
parameterclick(type) {
......@@ -265,10 +290,10 @@
}
}
this.loading = true;
addGoods(this.params).then(response => {
if (response.code === 1) {
addGoods(this.params).then(res => {
if (res.code === 1) {
this.$message({
message: response.msg,
message: res.msg,
type: 'success'
});
this.$emit('closeDialog',false);
......@@ -280,9 +305,9 @@
this.$router.push({
path: redUrl
});
} else if(response.code === 0) {
if(response.msg) {
this.$message.error(response.msg);
} else if(res.code === 0) {
if(res.msg) {
this.$message.error(res.msg);
}else {
this.$message.error("操作失败!");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论