提交 45560afb authored 作者: huaxinzhu's avatar huaxinzhu

商品bug修复

上级 bcdbc843
...@@ -213,7 +213,7 @@ export default { ...@@ -213,7 +213,7 @@ export default {
'parameterdata': function(val) { 'parameterdata': function(val) {
//debugger //debugger
this.orgGoodsPam = val; this.orgGoodsPam = val;
console.log("监听",this.orgGoodsPam); //console.log("监听",this.orgGoodsPam);
}, },
}, },
created() { created() {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<div class="spe-params-con"> <div class="spe-params-con">
<div style="display: inline-block" v-for="(itemSV,indexSV) in speItem.spec_value" :key="indexSV"> <div style="display: inline-block" v-for="(itemSV,indexSV) in speItem.spec_value" :key="indexSV">
<el-input v-model="itemSV.value" size="small" placeholder="请输入规格参数" class="spe-params-input-item" @blur="paramNameInputBlur(index,indexSV)"> <el-input v-model="itemSV.value" size="small" placeholder="请输入规格参数" class="spe-params-input-item" @blur="paramNameInputBlur(index,indexSV)">
<i v-if="indexSV !== 0" slot="suffix" class="el-input__icon el-icon-delete el-icon-delete-h" @click="deleteSpeParam(index,indexSV)"></i> <i v-if="speItem.spec_value.length !== 1" slot="suffix" class="el-input__icon el-icon-delete el-icon-delete-h" @click="deleteSpeParam(index,indexSV)"></i>
</el-input> </el-input>
</div> </div>
......
...@@ -164,7 +164,6 @@ ...@@ -164,7 +164,6 @@
if( this.option && this.option !== 0 ) { if( this.option && this.option !== 0 ) {
let data = { goodsId: this.option}; let data = { goodsId: this.option};
getGoodsNew(data).then(res => { getGoodsNew(data).then(res => {
//console.log("编辑接口返回", res);
if(res.data) { if(res.data) {
this.isShowGoodsDetails = true; this.isShowGoodsDetails = true;
// 商品信息 // 商品信息
...@@ -211,8 +210,6 @@ ...@@ -211,8 +210,6 @@
item.sl_price = item.js_price / 100; item.sl_price = item.js_price / 100;
item.price = item.price / 100; item.price = item.price / 100;
item.sc_price = item.sc_price / 100; item.sc_price = item.sc_price / 100;
// item.stock = item.stock;
// item.weight = item.weight;
prePriceArr = []; prePriceArr = [];
prePriceArr.push(item); prePriceArr.push(item);
this.parameterdata.pamTableList.push( prePriceArr ); this.parameterdata.pamTableList.push( prePriceArr );
...@@ -272,13 +269,9 @@ ...@@ -272,13 +269,9 @@
methods: { methods: {
// 规格子组件,传给父组件的数据 // 规格子组件,传给父组件的数据
calcSpeTable(data) { calcSpeTable(data) {
//debugger
// let hax = "-1g";
// console.log( Number(hax));
// return
// 第一步,获取原来的值 // 第一步,获取原来的值
let spsjData2 = this.$refs.goodsparameter.orgGoodsPam; let spsjData2 = this.$refs.goodsparameter.orgGoodsPam;
let spsjData2Clone = this.deepClone(spsjData2);
// 第二步,重新渲染dom // 第二步,重新渲染dom
if(data.pamTableList.length > 0) { if(data.pamTableList.length > 0) {
...@@ -292,11 +285,12 @@ ...@@ -292,11 +285,12 @@
} }
// 第三步,重新赋值 // 第三步,重新赋值
if(data.pamTableList.length > 0 && spsjData2.pamTableList.length > 0) { if(data.pamTableList.length > 0 && spsjData2Clone.pamTableList.length > 0) {
for(let i = 0; i < data.pamTableList.length; i++) { for(let i = 0; i < data.pamTableList.length; i++) {
for(let j = 0; j < spsjData2.pamTableList.length; j++) { for(let j = 0; j < spsjData2Clone.pamTableList.length; j++) {
if( data.pamTableList[i][0].spec_values[0] === spsjData2.pamTableList[j][0].spec_values[0] ) { // 这两个值,如果不转 toString(),就不相等,??
data.pamTableList[i] = spsjData2.pamTableList[j]; if( (data.pamTableList[i][0].spec_values).toString() === (spsjData2Clone.pamTableList[j][0].spec_values).toString() ) {
data.pamTableList[i] = spsjData2Clone.pamTableList[j];
} }
} }
} }
...@@ -338,10 +332,7 @@ ...@@ -338,10 +332,7 @@
} }
NewGetCategory(limboNode).then(res => { NewGetCategory(limboNode).then(res => {
let result = {}; let result = {};
//debugger
if (level === 0) { if (level === 0) {
result = res.data result = res.data
result.forEach(item => { result.forEach(item => {
...@@ -402,10 +393,6 @@ ...@@ -402,10 +393,6 @@
// 保存/提交 // 保存/提交
save() { save() {
// console.log(401,)
//
// return;
//debugger
// 此处变量 有顺序 校验时,电梯至某处 // 此处变量 有顺序 校验时,电梯至某处
// 商品信息 是否填写完整 // 商品信息 是否填写完整
...@@ -415,23 +402,36 @@ ...@@ -415,23 +402,36 @@
// 商品售价,通过获取的数据,分别进行判断 // 商品售价,通过获取的数据,分别进行判断
let isGoodsPrice = true; let isGoodsPrice = true;
let goodsPriceMsg = '';
let spsjData1 = this.$refs.goodsparameter.singleSpecTable; let spsjData1 = this.$refs.goodsparameter.singleSpecTable;
let spsjData2 = this.$refs.goodsparameter.orgGoodsPam; let spsjData2 = this.$refs.goodsparameter.orgGoodsPam;
//debugger
// 如果有,则说明有规格组合数据 // 如果有,则说明有规格组合数据
if ( spsjData2.pamTableList && spsjData2.pamTableList.length > 0 ) { if ( spsjData2.pamTableList && spsjData2.pamTableList.length > 0 ) {
for(let i = 0; i < spsjData2.pamTableList.length; i++) { for(let i = 0; i < spsjData2.pamTableList.length; i++) {
let itemObj = spsjData2.pamTableList[i][0]; let itemObj = spsjData2.pamTableList[i][0];
for (let itemKey in itemObj) { for (let itemKey in itemObj) {
// 有多余字段,可能为空,需要对有效字段单独判断 // 有多余字段,可能为空,需要对有效字段单独判断
if ( (itemObj['js_price'] === '') || (itemObj['sl_price'] === '') || (itemObj['price'] === '') || (itemObj['sc_price'] === '') || (itemObj['stock'] === '') || (itemObj['weight'] === '') ) { // Number后,有三中情况:0,正数,负数,NaN
if( !Number(itemObj['sl_price']) || Number(itemObj['sl_price']) <0 ) {
goodsPriceMsg = '[ 商品售价 ]中,协议价不能为空,并且只能填大于0的数值'
isGoodsPrice = false;
break
} else if ( !Number(itemObj['price']) || Number(itemObj['price']) <0 ) {
goodsPriceMsg = '[ 商品售价 ]中,指导价不能为空,并且只能填大于0的数值'
isGoodsPrice = false; isGoodsPrice = false;
break break
} else if( !Number(itemObj['sc_price']) || Number(itemObj['sc_price']) <0 ) {
goodsPriceMsg = '[ 商品售价 ]中,市场价不能为空,并且只能填大于0的数值'
isGoodsPrice = false;
} else if ( !Number(itemObj['stock']) || Number(itemObj['stock']) <0 ) {
goodsPriceMsg = '[ 商品售价 ]中,库存量不能为空,并且只能填大于0的整数'
isGoodsPrice = false;
} else { } else {
goodsPriceMsg = '';
isGoodsPrice = true; isGoodsPrice = true;
} }
} }
if (!isGoodsPrice) { if (!isGoodsPrice) {
break break
...@@ -440,20 +440,21 @@ ...@@ -440,20 +440,21 @@
}else { }else {
// 无规格组合数据 // 无规格组合数据
let slingleSpeObj = spsjData1[0]; let slingleSpeObj = spsjData1[0];
for (let key in slingleSpeObj) { if ( !Number(slingleSpeObj['sl_price']) || Number(slingleSpeObj['sl_price']) <0 ) {
if ( (slingleSpeObj['js_price'] === '') || (slingleSpeObj['sl_price'] === '') || (slingleSpeObj['price'] === '') || (slingleSpeObj['sc_price'] === '') || (slingleSpeObj['stock'] === '') || (slingleSpeObj['weight'] === '') ) { goodsPriceMsg = '[ 商品售价 ]中,协议价不能为空,并且只能填大于0的数值'
isGoodsPrice = false; isGoodsPrice = false;
break } else if ( !Number(slingleSpeObj['price']) || Number(slingleSpeObj['price']) <0 ) {
} else { goodsPriceMsg = '[ 商品售价 ]中,指导价不能为空,并且只能填大于0的数值'
// 所有校验通过,对价格进行处理,*100 isGoodsPrice = false;
// if ( key === 'js_price' || key === 'sl_price' || key === 'price' || key === 'sc_price') { } else if ( !Number(slingleSpeObj['sc_price']) || Number(slingleSpeObj['sc_price']) <0 ) {
// slingleSpeObj[key] = slingleSpeObj[key] * 100; goodsPriceMsg = '[ 商品售价 ]中,市场价不能为空,并且只能填大于0的数值'
// } isGoodsPrice = false;
// if ( key === 'stock') { } else if ( !Number(slingleSpeObj['stock']) || Number(slingleSpeObj['stock']) <0 ) {
// slingleSpeObj[key] = Number(slingleSpeObj[key]); goodsPriceMsg = '[ 商品售价 ]中,库存量不能为空,并且只能填大于0的整数'
// } isGoodsPrice = false;
isGoodsPrice = true; } else {
} goodsPriceMsg = ''
isGoodsPrice = true;
} }
} }
...@@ -470,9 +471,11 @@ ...@@ -470,9 +471,11 @@
} }
if(!isGoodsPrice) { if(!isGoodsPrice) {
this.$message({type:'error',message:'商品售价未填写完整'}); if ( goodsPriceMsg ) {
this.setFloorNavMountClick(2); this.$message({type:'error',message: goodsPriceMsg });
return this.setFloorNavMountClick(2);
return
}
} }
if(!isGoodsDetailsImgMsg) { if(!isGoodsDetailsImgMsg) {
...@@ -527,7 +530,6 @@ ...@@ -527,7 +530,6 @@
this.goodsAllData.stags = this.goodsAllData.stags.toString(); this.goodsAllData.stags = this.goodsAllData.stags.toString();
} }
// 价格数字需要 乘以100 // 价格数字需要 乘以100
if(this.goodsAllData.specs_group && this.goodsAllData.specs_group.length > 0) { if(this.goodsAllData.specs_group && this.goodsAllData.specs_group.length > 0) {
this.goodsAllData.specs_group.forEach((item)=> { this.goodsAllData.specs_group.forEach((item)=> {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论