提交 0cf89f67 authored 作者: huaxinzhu's avatar huaxinzhu

添加商品09

上级 2e6905be
......@@ -5,58 +5,70 @@
<span class="tip-span">所有商品价格均为含税价,必须开具发票</span>
</p>
<!-- <div v-if="(!orgGoodsPam.pamTableList || orgGoodsPam.pamTableList.length === 0)">-->
<!-- <el-table-->
<!-- border-->
<!-- size="small"-->
<!-- :data="noSpecTable"-->
<!-- style="width: 80%"-->
<!-- >-->
<!-- <el-table-column align="center" prop="hh1" label="协议价">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh1" placeholder="请输入协议价"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column align="center" prop="hh2" label="结算价">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh2" :disabled="true" placeholder="根据结算价自动计算"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column align="center" prop="hh3" label="指导价">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh3" placeholder="请输入指导价"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column align="center" prop="hh4" label="市场价">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh4" placeholder="请输入市场价"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column align="center" prop="hh5" label="库存量">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh5" placeholder="请输入库存量"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column align="center" prop="hh6" label="库存预警">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh6" placeholder="请输入预警值"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column align="center" prop="hh7" label="图片">-->
<!-- <template slot-scope="scope">-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
<!-- </div>-->
<div v-for="(item,index) in orgGoodsPam.pamTableList" :key="index" class="single-spe-con">
<div v-show="(!orgGoodsPam.pamTableList || orgGoodsPam.pamTableList.length === 0)">
<el-table
border
size="small"
:data="singleSpecTable"
style="width: 80%;margin-right:10%;"
>
<el-table-column align="center" prop="js_price" label="协议价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.js_price" placeholder="请输入协议价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="sl_price" label="结算价">
<template slot-scope="scope">
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.sl_price" :disabled="true" placeholder="根据结算价自动计算"></el-input>-->
<span>{{ scope.row.sl_price = scope.row.js_price ? scope.row.js_price : '' }}</span>
</template>
</el-table-column>
<el-table-column align="center" prop="price" label="指导价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.price" placeholder="请输入指导价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="sc_price" label="市场价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.sc_price" placeholder="请输入市场价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="stock" label="库存量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.stock" placeholder="请输入库存量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="weight" label="重量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.weight" placeholder="请输入重量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="imgs" label="图片">
<template slot-scope="scope">
<!-------------->
<el-upload
action="/"
class="uploadData50"
list-type="picture-card"
:limit="5"
:on-exceed="limit5"
:file-list="singleSpecImgList"
:http-request="(file)=> { return upLoadSingleSpecImg(file,scope.row) }"
:on-remove=" (file) => { return removeSingleSpeImg(file,scope.row)}"
></el-upload>
<!-------------->
</template>
</el-table-column>
</el-table>
</div>
<div v-show="orgGoodsPam.pamTableList.length > 0" v-for="(item,index) in orgGoodsPam.pamTableList" :key="index" class="single-spe-con">
<p style="margin: 10px 0;color: #333;font-size: 14px;font-weight: 400;">
<span v-if="orgGoodsPam.pamNameList.length === 1">
<span v-show="orgGoodsPam.pamNameList.length === 1">
{{ orgGoodsPam.pamNameList[0].specName }} <span></span>{{ orgGoodsPam.pamDataList[index]}}
</span>
<span v-else="orgGoodsPam.pamNameList.length > 1">
<span v-show="orgGoodsPam.pamNameList.length > 1">
<span v-for="(itemv,indexv) in orgGoodsPam.pamNameList" style="margin-right:20px;">
{{ orgGoodsPam.pamNameList[indexv].specName }} <span></span>{{ orgGoodsPam.pamDataList[index][indexv]}}
</span>
......@@ -68,39 +80,55 @@
:data="item"
style="width: 80%"
>
<el-table-column align="center" prop="hh1" label="协议价">
<el-table-column align="center" prop="js_price" label="协议价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.hh1" placeholder="请输入协议价"></el-input>
<el-input size="mini" style="width:90%" v-model="scope.row.js_price" placeholder="请输入协议价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="hh2" label="结算价">
<el-table-column align="center" prop="sl_price" label="结算价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.hh2" :disabled="true" placeholder="根据结算价自动计算"></el-input>
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh2" :disabled="true" placeholder="根据结算价自动计算"></el-input>-->
<span>{{ scope.row.sl_price = scope.row.js_price ? scope.row.js_price : '' }}</span>
</template>
</el-table-column>
<el-table-column align="center" prop="hh3" label="指导价">
<el-table-column align="center" prop="price" label="指导价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.hh3" placeholder="请输入指导价"></el-input>
<el-input size="mini" style="width:90%" v-model="scope.row.price" placeholder="请输入指导价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="hh4" label="市场价">
<el-table-column align="center" prop="sc_price" label="市场价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.hh4" placeholder="请输入市场价"></el-input>
<el-input size="mini" style="width:90%" v-model="scope.row.sc_price" placeholder="请输入市场价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="hh5" label="库存量">
<el-table-column align="center" prop="stock" label="库存量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.hh5" placeholder="请输入库存量"></el-input>
<el-input size="mini" style="width:90%" v-model="scope.row.stock" placeholder="请输入库存量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="hh6" label="库存预警">
<el-table-column align="center" prop="weight" label="重量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.hh6" placeholder="请输入预警值"></el-input>
<el-input size="mini" style="width:90%" v-model="scope.row.weight" placeholder="请输入重量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="hh7" label="图片">
<el-table-column align="center" prop="thumb" label="图片">
<template slot-scope="scope">
<span
v-show="!scope.row.thumb"
class="span-img"
@click="upPreSpeImg(index,scope.row)"
></span>
<span v-show="scope.row.thumb" class="span-img-con">
<img
class="spec-img"
:src="scope.row.thumb"
alt=""
@click="changeSpeImg(index,scope.row)"
/>
<span class="span-img-del el-icon-delete del-span-block" @click="hxz"></span>
</span>
<input type="file" style="display: none;" :ref=" 'hxz' + index " accept="image/*" @change="changeIMG(index,scope.row)">
</template>
</el-table-column>
</el-table>
......@@ -110,6 +138,7 @@
</template>
<script>
import { UploadImg } from '@/api/module/goods';
export default {
name: 'goodsparameter',
props: {
......@@ -122,20 +151,7 @@ export default {
return {
orgGoodsPam: {},
preTableTitle: [],
noSpecTable: [
{
hh1: '',
hh2: '',
hh3: '',
hh4: '',
hh5: '',
hh6: '',
hh7: '',
}
],
// 规格名称数组
// goodsSpecNameList: [],
// // 每一个规格,都是一张表格
isHoverSpeImg: false,
// goodsPam:[
// {
// speNameList:[ '颜色','尺码' ],
......@@ -150,21 +166,22 @@ export default {
// hh7: '',
// }],
// },
// {
// speNameList:[ '颜色','尺码' ],
// goodsParametersList: [],
// goodsPamPreTable: [ {
// hh1: '',
// hh2: '',
// hh3: '',
// hh4: '',
// hh5: '',
// hh6: '',
// hh7: '',
// } ]}
// ],
// goodsPamPreTable: [],
// goodsPamPreObj:
/** 无规格 数据 */
singleSpecTable: [
{
js_price: '', // 协议价
sl_price: '', // 结算价
price: '', // 指导价
sc_price: '', // 市场价
stock: '', // 库存
weight: '', // 重量 g
imgs: '', // 图片
}
],
singleSpecImgList: [],
} // return end
},
watch:{
......@@ -172,37 +189,197 @@ export default {
//debugger
this.orgGoodsPam = val;
//console.log(175,this.orgGoodsPam);
//this.preTableTitle = [];
// this.orgGoodsPam.pamDataList.forEach((item)=> {
// let preTitle = '';
// if (!Array.isArray(item)) {
// preTitle = this.orgGoodsPam.pamNameList[0].specName + ':' + item;
// }else {
// item.forEach((itemI,indexI)=> {
// preTitle += (this.orgGoodsPam.pamNameList[indexI].specName + " " + itemI) + " ";
// });
// }
// this.preTableTitle.push(preTitle);
// });
},
},
created() {
//this.orgGoodsPam = this.parameterdata;
},
mounted() {
//console.log("9999",this.goodsPamPreList);
},
methods: {
// ------ 无规格,上传图片相关 ------
limit5() {
this.$message({type: 'warning',message: '只能上传5张图片'});
},
// 上传 无规格组合 的图片
upLoadSingleSpecImg(param) {
// this.loading = true;
//debugger
this.getBase64(param.file).then((res) => {
let result = res.split(",");
this.Base64img = result[1];
let data = {"img_data": this.Base64img}
UploadImg(data).then(res => {
// this.loading = false;
if (res && res.code == 1) {
this.singleSpecImgList.push({ url: res.data.image_url });
this.singleSpecTable[0].imgs = [];
this.singleSpecImgList.forEach(item=> {
this.singleSpecTable[0].imgs.push(item.url)
})
this.$message({ message:'上传成功',type:'success'});
}else {
this.singleSpecImgList = [];
this.$message({ message:'上传失败,请重新上传',type:'error'});
}
})
});
},
// 删除 无规格组合 的图片
removeSingleSpeImg(file) {
if(file.status === "success") {
for(let i = 0; i < this.singleSpecImgList.length; i++) {
if(file.uid === this.singleSpecImgList[i].uid) {
this.singleSpecImgList.splice(i,1);
this.singleSpecTable[0].imgs.splice(i,1);
}
}
this.$message({ type: 'success', message: '删除成功!' });
}
},
/** 规格组合 上传图片 */
// 上传图片
upPreSpeImg(index, row) {
let domRef = "hxz" + index;
//console.log(domRef,this.$refs[domRef][0]);
this.$refs[domRef][0].value = '';
this.$refs[domRef][0].click();
},
// 更换 某一个规格的图片
changeSpeImg(index, row) {
this.upPreSpeImg(index,row);
},
// 真正的上传图片方法,原生input
changeIMG(index, row) {
let curRow = row;
let inputDom = "hxz" + index;
let file = this.$refs[inputDom][0].files[0];
if( file.size > 1024 * 1024 * 3 ) {
this.$message({ type: 'error',message: '规格图片不能大于 3 M'});
return;
}
this.getBase64(file).then((res) => {
let result = res.split(",");
this.Base64img = result[1];
let data = {"img_data": this.Base64img}
UploadImg(data).then(res => {
// this.loading = false;
if (res && res.code == 1) {
curRow.thumb = res.data.image_url;
// this.singleSpecImgList.push({'url': res.data.image_url})
this.$message({ message:'上传成功',type:'success'});
}else {
this.$message({ message:'上传失败,请重新上传',type:'error'});
}
})
});
console.log(3333,file);
},
hxz() {
},
speImgHover(index,row) {
this.isHoverSpeImg = true;
},
speImgLeave(index, row) {
this.isHoverSpeImg = false;
},
// -- 通用 方法 --
// 图片转换为 base64
getBase64(file) {
return new Promise(function (resolve, reject) {
let reader = new FileReader();
let imgResult = "";
reader.readAsDataURL(file);
reader.onload = function () {
imgResult = reader.result;
};
reader.onerror = function (error) {
reject(error);
};
reader.onloadend = function () {
resolve(imgResult);
};
});
},
} // methods end
}
</script>
<style scoped>
<style lang="scss" type="text/stylus" scoped>
.span-img {
margin: 0;
padding: 0;
display : inline-block;
width:50px;
height:50px;
position: relative;
top:4px;
cursor: pointer;
border-radius: 6px;
border: 1px dashed #c0ccda;
background-color : #fbfdff;
}
.span-img:hover {
border: 1px dashed #1890ff;
}
.spec-img {
width: 100%;
height: 100%;
border-radius: 6px;
cursor: pointer;
position: relative;
border: none;
}
.span-img-con {
margin: 0;
padding: 0;
display : inline-block;
width:50px;
height:50px;
position: relative;
top:4px;
cursor: pointer;
border-radius: 6px;
border: 1px solid #c0ccda;
}
.span-img-del {
position: absolute;
display : inline-block;
width: 18px;
height: 18px;
font-size: 18px;
color: #333;
line-height : 18px;
top: 50%;
left: 50%;
margin-top: -9px;
margin-left: -9px;
}
.del-span-block {
display : none;
}
.span-img-del:hover {
color: #F56C6C;
}
.span-img-con:hover > .del-span-block {
display : block;
}
p {
margin: 0;
padding: 0;
......@@ -231,4 +408,37 @@ p {
color: #909399;
font-size: 12px;
}
// 上传图片样式
.uploadData50 {
display: inline-block;
/deep/ .el-upload--picture-card {
width: 50px;
height: 50px;
}
/deep/ .el-upload {
width: 50px;
height: 50px;
line-height: 50px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item {
width: 50px;
height: 50px;
line-height: 50px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item-thumbnail {
width: 50px;
height: 50px;
line-height: 50px;
}
/deep/ .avatar {
width: 50px;
height: 50px;
}
}
</style>
......@@ -11,7 +11,6 @@
size="small"
style="width: 300px"
filterable
default-first-option
:clearable="true"
@change="speNameChange(speItem.specName,index)"
......@@ -33,7 +32,7 @@
</div>
<div class="spe-params-con">
<div style="display: inline-block" v-for="(itemSV,indexSV) in speItem.specValue" :key="indexSV">
<el-input v-model="itemSV.value" size="small" placeholder="请输入规格参数" class="spe-params-input-item" @blur="paramNameInputBlur()">
<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>
</el-input>
</div>
......@@ -137,7 +136,6 @@ export default {
specValue: [{value: ''}]
};
this.$set(this.speData,this.speData.length,specsGroup);
//this.speNameListChange();
},
/** 删除 规格数据 */
deleteSpe(index) {
......@@ -147,101 +145,31 @@ export default {
type: 'warning'
}).then(async() => {
this.speData.splice(index,1);
//this.speNameListChange();
//this.paramNameInputBlur();
this.specCalcResult();
}).catch(() => {})
},
//
/**
* 规格名称,值改变时, 将id值转化为 label(name)的处理
* val 为当前options的值
* index 为当前第几个规格
* 因后台保存规格的中文名字,顾需要将 value值找到对应的label值
* */
/** 规格名称,值改变时, 此组件 lable 和 value 绑定同一个值 */
speNameChange(val,index) {
console.log(1111111,val);
//
// let obj = { specName: '' };
// if( this.speData[index].specName === currentOptions.id ) {
// this.speData[index].specName = currentOptions.name;
// obj.specName = currentOptions.name;
// this.speNameList[index] = obj;
// }
//
// if(this.speData.length > 1 ) {
// let restSpeData = [];
// let coypSpeData = this.speData.concat();
// coypSpeData.splice(index,1);
// restSpeData = coypSpeData;
// for( let i = 0; i < restSpeData.length; i++ ) {
// if( restSpeData[i].specName === this.speData[index].specName ) {
// this.speData[index].specName = '';
// this.speNameList.splice(index,1);
// this.$message({type: 'error',message: '此规格名称已经存在,请重新选取或命名'});
// break;
// }
// }
// }
// console.log("改变触发:所有值",this.speData);
// console.log("改变触发:",this.speNameList);
},
// 规格名称,有变化时,出规格名称下拉操作以外的其他操作
speNameListChange(index) {
//debugger
this.speNameList = [];
let obj = { specName: '' };
for(let i = 0; i < this.speData.length; i++) {
if(this.speData[i].specName) {
obj.specName = this.speData[i].specName;
this.speNameList.push(obj);
if( val ) {
// 当有多个值的时候,才校验,规格名称是否重复
if( this.speData.length > 1 ) {
let coypSpeData = [];
coypSpeData = this.speData.concat();
coypSpeData.splice(index,1);
for(let i = 0; i < coypSpeData.length; i++) {
if( val === coypSpeData[i].specName ) {
this.speData[index].specName = '';
this.$message({type: 'error',message: '此规格名称已经使用,请重新选取或新增其他规格名称'});
break;
}
}
//console.log(20000,this.speNameList);
// for(let i = 0; i < this.speData.length; i++) {
// if(this.speData[i].specName) {
// let obj = {specName: ''};
// for(let j = 0; j < this.speData[i].specValue.length; j++) {
// if( this.speData[i].specValue[j].value !== '' ) {
// obj.specName = this.speData[i].specName;
// break
// }
// }
// this.speNameList.push(obj);
// }
// }
//
// if(this.speNameList.length > 0) {
// this.speNameList.forEach((item,indexs)=> {
// if(!this.speNameList.specName) {
// this.speNameList.splice(indexs,1);
// }
// });
// }
// console.log(206,this.speNameList);
// this.speData.forEach((item)=> {
// let obj = {specName: ''};
// if(item.specName) {
// for(let i = 0; i < item.specValue.length; i++) {
// if(item.specValue[i].value !== '') {
// obj.specName = item.specName;
// break;
// }
// }
// this.speNameList.push(obj);
// }
// });
}
}
// 重新 计算 规格组合数据
this.specCalcResult();
},
// 添加规格参数
addSpeParam(index) {
let valueObj = { value: ''}
......@@ -249,9 +177,13 @@ export default {
},
/** 删除 规格参数 */
deleteSpeParam(index,indexSV) {
// 先判断,删除前是否有值,如果是空,则没有必要再次计算
if( this.speData[index].specValue[indexSV].value ) {
this.speData[index].specValue.splice(indexSV,1);
this.specCalcResult();
}else {
this.speData[index].specValue.splice(indexSV,1);
//console.log(119,this.speData[index].specValue);
//this.paramNameInputBlur();
}
},
/**
* 规格名称 下拉框 出现/隐藏 触发
......@@ -303,12 +235,10 @@ export default {
let options = JSON.parse(window.localStorage.getItem('localSpeOptions'));
this.speOptions = options;
}
},
/* 增加 规格名称 */
addSpeName(index) {
this.addSpecNameDialog = true;
// console.log(index);
},
// 添加规格名称,对话框的退出
......@@ -349,68 +279,65 @@ export default {
},
/** 规格参数 失焦时,进行笛卡尔积算法,并渲染 商品售价 */
paramNameInputBlur() {
paramNameInputBlur(index,indexSV) {
// // 如果失焦的input中有值,才再次计算
// if( this.speData[index].specValue[indexSV].value ) {
this.specCalcResult();
// }
},
/** 规格参数 变化时,对数据进行处理后,再进行笛卡尔积算法,最终计算出商品售价的数据 */
specCalcResult() {
// 商品规格原始数据
let orgSpeData = this.deepClone(this.speData);
// 进行数据处理后的数据,
let proSpeData = this.processData(orgSpeData);
console.log("看看处理的数据",proSpeData);
let fuck = this.cartesian(proSpeData);
console.log("笛卡尔积的结果:",fuck);
return
// // 商品规格原始数据
// let orgSpeData = this.deepClone(this.speData);
// // 进行数据处理后的数据,
// let proSpeData = this.processData(orgSpeData);
// 需要将 所有规格名称,提出一个数组集合,
this.speNameList = [];
orgSpeData.forEach((item,index)=> {
if( item.specName ) {
let obj = { specName: '' };
// 注意, item.specValue是否一定为一个长度大于 1 的数组
if( item.specValue.length > 0) {
for(let i = 0; i < item.specValue.length; i++) {
if( item.specValue[i].value ) {
obj.specName = item.specName;
this.speNameList.push(obj);
break;
}
}
}
}
})
// console.log("处理后的数据",proSpeData);
// console.log("处理后的nameList",this.speNameList);
// debugger
// console.log("失焦触发:",this.speData);
// console.log("失焦触发,不生成表格的条件:",proSpeData);
// this.speNameListChange();
// console.log(319,this.speNameList);
//debugger
// 笛卡尔积 生成所有规格组合数据
// if(proSpeData.length > 0) {
// proSpeData.forEach((item,index) => {
// if(item.length <= 0) {
// proSpeData.splice(index,1);
// }
// });
//
// let goodsParametersList = this.cartesian(proSpeData);
//
// // 组织数据 结构
// if(this.speNameList.length > 0 && goodsParametersList.length > 0) {
// // 所有数据
// let goodsPam = {
// pamNameList: [],
// pamDataList: [],
// pamTableList: [],
// };
// goodsPam.pamNameList = this.speNameList;
// goodsPam.pamDataList = goodsParametersList;
//
// goodsParametersList.forEach((item)=> {
// let prePamTable = [
// { hh1:'', hh2:'', hh3:'', hh4:'', hh5:'', hh6:'', hh7:'' }
// ];
// goodsPam.pamTableList.push(prePamTable)
// });
// this.$emit('calcSpeTable',goodsPam);
// }else {
// let goodsPam = {
// pamNameList: [],
// pamDataList: [],
// pamTableList: [],
// };
// this.$emit('calcSpeTable',goodsPam);
// }
// }
// 当处理后的数据,是一个空数组,则不需要再进行 笛卡尔积 计算,可以直接给出计算结果
if (proSpeData.length === 0) {
let goodsPam = {
pamNameList: [],
pamDataList: [],
pamTableList: [],
};
this.$emit('calcSpeTable', goodsPam);
} else {
let goodsParametersList = this.cartesian(proSpeData);
let goodsPam = {
pamNameList: [],
pamDataList: [],
pamTableList: [],
};
goodsPam.pamNameList = this.speNameList;
goodsPam.pamDataList = goodsParametersList;
goodsParametersList.forEach((item)=> {
let prePamTable = [
{ js_price:'', sl_price:'', price:'', sc_price:'', stock:'', weight:'', thumb:'' }
];
goodsPam.pamTableList.push(prePamTable)
});
this.$emit('calcSpeTable',goodsPam);
}
},
/** 重新计算 */
// hxz() {
//
// },
/** 数据处理为,二维数组,供笛卡尔积算法方法使用,对空数据进行过滤 */
processData(list) {
......@@ -418,10 +345,7 @@ export default {
if (list && list.length > 0) {
for (let i = 0; i < list.length; i++) {
let childList = [];
// for (let j = 0; j < list[i].specValue.length; j++) {
// childList.push(list[i].specValue[j].value);
// }
// result.push(childList);
if(list[i].specName) {
for(let j = 0; j < list[i].specValue.length; j++) {
if(list[i].specValue[j].value) {
......@@ -429,32 +353,17 @@ export default {
}
}
}
if(childList.length > 0) {
result.push(childList);
}
}
}
return result;
},
/** 笛卡尔积算法 */
cartesian(arr) {
// if(arr.length < 2) {
// let res = [];
// arr.forEach((item) => {
// res.push(item);
// });
// return res
// }else {
// return [].reduce.call(arr, function(col, set) {
// let res = [];
// col.forEach( c => {
// set.forEach(s => {
// let t = [].concat(Array.isArray(c) ? c : [c]);
// t.push(s);
// res.push(t);
// });
// });
// return res
// });
// }
if(arr.length < 2) {
return arr[0] || [];
}else {
......@@ -505,11 +414,11 @@ export default {
padding: 0 12px 0 0;
box-sizing: border-box;
}
.el-form-item-h__label:before {
content: '*';
color: #ff4949;
margin-right: 4px;
}
/*.el-form-item-h__label:before {*/
/* content: '';*/
/* color: #ff4949;*/
/* margin-right: 4px;*/
/*}*/
.el-form-item-h__content {
margin-left: 150px;
position: relative;
......
......@@ -240,24 +240,81 @@
//
save() {
// 此处变量 有顺序 校验时,电梯至某处
// 商品信息 是否填写完整
//let isGoodsInfoMsg = this.$refs['goodsInfo'].validateGoodsInfoForm();
let isGoodsInfoMsg = this.$refs['goodsInfo'].validateGoodsInfoForm();
// 商品规格 无需校验
// 商品售价,通过获取的数据,分别进行判断
let isGoodsPrice = true;
let spsjData = this.$refs.goodsparameter.singleSpecTable;
let spsjData2 = this.$refs.goodsparameter.orgGoodsPam;
//debugger
// 如果有,则说明有规格组合数据
if ( spsjData2.pamTableList && spsjData2.pamTableList.length > 0 ) {
//console.log(25522,spsjData2);
for(let i = 0; i < spsjData2.pamTableList.length; i++) {
console.log("外");
// for(let itemKey in spsjData2.pamTableList[i]) {
// console.log('内', spsjData2.pamTableList[i][itemKey])
// }
let obj = {};
obj = spsjData2.pamTableList[i];
for(let itemKey in obj) {
console.log('内', itemKey)
}
// for(let itemKey in spsjData2.pamTableList[i]) {
// if ( !spsjData2.pamTableList[i][itemKey] || spsjData2.pamTableList[i][itemKey].length === 0 ) {
// isGoodsPrice = false;
// break
// }else {
// isGoodsPrice = true;
// }
// }
// if( !isGoodsPrice ) {
// break
// }
}
}else {
// 无规格组合数据
let slingleSpeObj = spsjData[0];
for (let key in slingleSpeObj) {
if ( !slingleSpeObj[key] || (slingleSpeObj[key].length === 0) ) {
isGoodsPrice = false;
break
} else {
isGoodsPrice = true;
}
}
}
// 商品详情 是否填写完整
let isGoodsDetailsImgMsg = this.$refs.goodsdetailsimg.description ? true : false;
// 售后服务 是否填写完整
let isGoodsAfterSaleMsg = this.$refs['goodsaftersale'].validateGoodsAfterSaleForm();
// 商品售价,由商品规格决定,
// 如果 没有填写商品规格,那么商品售价应该获取
// console.log(258,spsjData2,spsjData);
// return;
// // 商品详情
//let isGoodsDetailsImgMsg = this.$refs.goodsdetailsimg.description ? true : false;
// // 售后服务 是否填写完整
// let isGoodsAfterSaleMsg = this.$refs['goodsaftersale'].validateGoodsAfterSaleForm();
//
// //console.log(212,this.$refs.goodsaftersale.goodsAfterSaleForm) // 主动获取子组件数据
//
// if(!isGoodsInfoMsg) {
// this.$message({type:'error',message:'商品信息未填写完整'});
// this.setFloorNavMountClick(0);
// return
// }
if(!isGoodsPrice) {
this.$message({type:'error',message:'商品售价未填写完整'});
this.setFloorNavMountClick(2);
return
}
// if(!isGoodsDetailsImgMsg) {
// this.$message({type:'error',message:'请先上传描述商品详情的图片'});
// this.setFloorNavMountClick(3);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论