提交 ee67d0b6 authored 作者: huaxinzhu's avatar huaxinzhu

添加商品 提测

上级 0cf89f67
......@@ -17,6 +17,15 @@ export function GetCategory(query) {
params: query
})
}
// 经营类目
export function NewGetCategory(query) {
return request({
url: '/system/goodsNew/businessList',
method: 'get',
params: query
})
}
// 查询运费模板
// export function GetFreight(query) {
// return request({
......@@ -48,10 +57,19 @@ export function Onsale(data) {
})
}
// 新增goods
// 新增goods - old
// export function addGoods(data) {
// return request({
// url: '/system/goods/add',
// method: 'post',
// data: data
// })
// }
// 新增商品
export function addGoods(data) {
return request({
url: '/system/goods/add',
url: '/system/goodsNew/addGoods',
method: 'post',
data: data
})
......
......@@ -86,7 +86,7 @@
// let query = { page: 1, limit: 50 };
GetFreight().then(res => {
if(res.data) {
this.freightOptions = res.data.list;
this.freightOptions = res.data;
}else {
this.freightOptions = ''
}
......
<template>
<div class="goods-img">
<el-form ref="goodsDeForm" :model="goodsDeForm" label-width="150px" size="small">
<el-form-item label="商品详情:" prop="spxq">
<el-form-item label="商品详情:" prop="description">
<span class="tip-span up-img-tip" style="display: block;line-height: 34px;">上传图片详情,用于商品详情页展示</span>
<el-upload
class="avatar-uploader2"
......@@ -14,7 +14,7 @@
><i class="el-icon-plus" />
</el-upload>
<input class="uploadImg" style="display: none;" type="file" ref="file" accept="image/*" @change="fileChange($event)" name="file" multiple id="file">
<quill-editor class="quill-editor-class" ref="myTextEditor" v-model="description" :options="editorOption" @change="onEditorChange" style="height:500px;margin-bottom:20px;"></quill-editor>
<quill-editor class="quill-editor-class" ref="myTextEditor" v-model="goodsDeForm.description" :options="editorOption" @change="onEditorChange" style="height:500px;margin-bottom:20px;"></quill-editor>
</el-form-item>
</el-form>
</div>
......@@ -43,12 +43,13 @@
return {
loading: false,
goodsDeForm: {
spxq: ''
description: '',
},
// goodsDeRules: {
// spxq:[{required: true, message: '请上传商品详情图片', validator: checkImg}]
// description:[{required: true, message: '请上传商品详情图片', validator: checkImg}]
// },
description: '',
goodsDetailsImgFileList: [],
editorOption: {
placeholder: '',
......@@ -90,10 +91,10 @@
let result = res.split(",");
this.Base64img = result[1];
let data = {"img_data": this.Base64img}
debugger
//debugger
// this.loading = true;
UploadImg(data).then(res => {
debugger
//debugger
if (res && res.code === 1) {
this.index++;
this.goodsDetailsImgFileList.push({'url': res.data.image_url});
......@@ -119,7 +120,7 @@
},
//
onEditorChange({editor, html, text}) {
this.description = html;
this.goodsDeForm.description = html;
},
onEditorBlur(){//失去焦点事件
......
......@@ -143,23 +143,25 @@
categoryList: [], // 商品分类 id集合的数组
goods_des: '', // 关键词
goods_name: '', // 商品标题
// category_id: '',
category_id: '',
producing_area: '', // 产地
deliver_area: '', // 发货地
unit: '', // 单位
goods_brand: '', // 品牌
web_url: '', // 外部链接
out_goods_id: '', // 商品编码
imgs: '' // 商品图片
imgs: [] // 商品图片
},
goodsInfoRules: {
categoryStr: [{required: true, message: '商品分类不能为空', trigger: 'blur'}],
goods_name: [
{required: true, message: '请输入商品名称', trigger: 'blur'},
{min: 3, max: 30, message: '商品标题限制在30字以内', trigger: 'blur'}
{min: 3, max: 30, message: '商品标题限制在3字符以上,30个字符以下', trigger: 'blur'}
],
goods_des: [{required: true, message: '商品关键词不能为空', trigger: 'blur'}],
producing_area:[{required: true, message: '请选择商品产地', trigger: 'change'}],
deliver_area: [{required: true, message: '请选择商品发货地', trigger: 'change'}],
unit: [{required: true, message: '商品单位不能为空', trigger: 'blur'}],
goods_brand: [{required: true, message: '请选择商品品牌', trigger: 'change'}],
imgs: [{required: true, message: '请上传商品图片', validator: categoryIdCheck}]
},
......@@ -184,22 +186,22 @@
},
components: {},
watch: {
'goodsImgFileList': {
handler(val, oldVal) {
if(val.length > 0) {
this.goodsInfoForm.imgs = '';
let imgArr = [];
val.forEach(item => {
imgArr.push(item.url);
})
this.goodsInfoForm.imgs = imgArr.toString();
}else if(val.length === 0){
this.goodsInfoForm.imgs = '';
}
console.log(123,this.goodsInfoForm.imgs);
},
deep: true
}
// 'goodsImgFileList': {
// handler(val, oldVal) {
// if(val.length > 0) {
// this.goodsInfoForm.imgs = '';
// let imgArr = [];
// val.forEach(item => {
// imgArr.push(item.url);
// })
// this.goodsInfoForm.imgs = imgArr.toString();
// }else if(val.length === 0){
// this.goodsInfoForm.imgs = '';
// }
// //console.log(123,this.goodsInfoForm.imgs);
// },
// deep: true
// }
// serviceagsTags: {
// handler(val, oldVal) {
// this.$set(this.goodsInfoForm, 'serviceagsTags', val)
......@@ -211,6 +213,7 @@
//深拷贝一份最开始的数据,为初始化准备
this.goodsInfoDataClone = this.deepClone(this.goodsinfodata);
this.goodsInfoForm.categoryStr = this.goodsinfodata.categoryStr;
this.goodsInfoForm.categoryList = this.goodsinfodata.categoryList;
// console.log("父组件传过来的",this.goodsinfodata)
// console.log("1111",this.goodsInfoForm)
// 获取 省
......@@ -256,6 +259,7 @@
// console.log(222,this.SSQGoodsList);
},
lazyLoad(node, resolve) {
//debugger
this.getSSQArea(node, resolve);
},
getSSQArea(node, resolve) {
......@@ -368,7 +372,7 @@
},
// 上传 商品图片
uploadGoodsImg(param) {
console.log(327,param);
//console.log(327,param);
this.getBase64(param.file).then( res => {
let result = res.split(",");
this.Base64img = result[1];
......@@ -378,6 +382,9 @@
if(res.data) {
urlObj.url = res.data.image_url;
this.goodsImgFileList.push(urlObj);
this.goodsImgFileList.forEach(item=> {
this.goodsInfoForm.imgs.push(item.url)
})
this.$message({type:'success',message:'图片上传成功'});
// 只清除一次,不浪费哦
if(this.goodsImgFileList.length === 1) {
......@@ -409,6 +416,7 @@
for (let i = 0; i < this.goodsImgFileList.length; i++) {
if (file.uid === this.goodsImgFileList[i].uid) {
this.goodsImgFileList.splice(i, 1)
this.goodsImgFileList.imgs.splice(i, 1);
}
}
if(this.goodsImgFileList.length === 0) {
......
......@@ -44,7 +44,7 @@
<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="图片">
<el-table-column align="center" prop="imgs9" label="图片">
<template slot-scope="scope">
<!-------------->
<el-upload
......@@ -66,11 +66,11 @@
<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-show="orgGoodsPam.pamNameList.length === 1">
{{ orgGoodsPam.pamNameList[0].specName }} <span></span>{{ orgGoodsPam.pamDataList[index]}}
{{ orgGoodsPam.pamNameList[0].spec_name }} <span></span>{{ orgGoodsPam.pamDataList[index]}}
</span>
<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]}}
{{ orgGoodsPam.pamNameList[indexv].spec_name }} <span></span>{{ orgGoodsPam.pamDataList[index][indexv]}}
</span>
</span>
</p>
......@@ -178,7 +178,7 @@ export default {
sc_price: '', // 市场价
stock: '', // 库存
weight: '', // 重量 g
imgs: '', // 图片
imgs9: [], // 图片
}
],
singleSpecImgList: [],
......@@ -188,6 +188,8 @@ export default {
'parameterdata': function(val) {
//debugger
this.orgGoodsPam = val;
// this.orgGoodsPam
//console.log(175,this.orgGoodsPam);
},
},
......@@ -214,9 +216,9 @@ export default {
// this.loading = false;
if (res && res.code == 1) {
this.singleSpecImgList.push({ url: res.data.image_url });
this.singleSpecTable[0].imgs = [];
this.singleSpecTable[0].imgs9 = [];
this.singleSpecImgList.forEach(item=> {
this.singleSpecTable[0].imgs.push(item.url)
this.singleSpecTable[0].imgs9.push(item.url)
})
this.$message({ message:'上传成功',type:'success'});
......@@ -233,7 +235,7 @@ export default {
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.singleSpecTable[0].imgs9.splice(i,1);
}
}
this.$message({ type: 'success', message: '删除成功!' });
......@@ -281,7 +283,7 @@ export default {
});
console.log(3333,file);
//console.log(3333,file);
},
hxz() {
......
......@@ -7,13 +7,13 @@
<div>
<el-select
:ref="'speNameDom' + index "
v-model="speItem.specName"
v-model="speItem.spec_name"
size="small"
style="width: 300px"
filterable
default-first-option
:clearable="true"
@change="speNameChange(speItem.specName,index)"
@change="speNameChange(speItem.spec_name,index)"
@visible-change='bv=> visibleChange(bv,"speNameDom",index)'
>
<el-option
......@@ -31,7 +31,7 @@
<!--<span>数据填写不完整</span>-->
</div>
<div class="spe-params-con">
<div style="display: inline-block" v-for="(itemSV,indexSV) in speItem.specValue" :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)">
<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>
......@@ -88,9 +88,8 @@ export default {
return {
speData: [], // 商品规格总数据
specsGroup: {
specName: '', // 规格名称
score: '',
specValue: []
spec_name: '', // 规格名称
spec_value: []
},
speParamName:{
......@@ -111,10 +110,10 @@ export default {
};
},
created() {
this.$set(this.specsGroup.specValue,this.specsGroup.specValue.length,this.speParamName);
this.$set(this.specsGroup.spec_value,this.specsGroup.spec_value.length,this.speParamName);
this.speData = [];
this.$set(this.speData,this.speData.length,this.specsGroup);
//console.log(71,this.specsGroup.specValue);
//console.log(71,this.specsGroup.spec_value);
},
mounted() {
/** 先获取 本地存储的localStorage **/
......@@ -131,9 +130,8 @@ export default {
/** 添加规格*/
addSpe() {
let specsGroup = {
specName: '', // 规格名称
score: '',
specValue: [{value: ''}]
spec_name: '', // 规格名称
spec_value: [{value: ''}]
};
this.$set(this.speData,this.speData.length,specsGroup);
},
......@@ -158,8 +156,8 @@ export default {
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 = '';
if( val === coypSpeData[i].spec_name ) {
this.speData[index].spec_name = '';
this.$message({type: 'error',message: '此规格名称已经使用,请重新选取或新增其他规格名称'});
break;
}
......@@ -173,16 +171,16 @@ export default {
// 添加规格参数
addSpeParam(index) {
let valueObj = { value: ''}
this.$set(this.speData[index].specValue,this.speData[index].specValue.length,valueObj);
this.$set(this.speData[index].spec_value,this.speData[index].spec_value.length,valueObj);
},
/** 删除 规格参数 */
deleteSpeParam(index,indexSV) {
// 先判断,删除前是否有值,如果是空,则没有必要再次计算
if( this.speData[index].specValue[indexSV].value ) {
this.speData[index].specValue.splice(indexSV,1);
if( this.speData[index].spec_value[indexSV].value ) {
this.speData[index].spec_value.splice(indexSV,1);
this.specCalcResult();
}else {
this.speData[index].specValue.splice(indexSV,1);
this.speData[index].spec_value.splice(indexSV,1);
}
},
/**
......@@ -281,7 +279,7 @@ export default {
/** 规格参数 失焦时,进行笛卡尔积算法,并渲染 商品售价 */
paramNameInputBlur(index,indexSV) {
// // 如果失焦的input中有值,才再次计算
// if( this.speData[index].specValue[indexSV].value ) {
// if( this.speData[index].spec_value[indexSV].value ) {
this.specCalcResult();
// }
},
......@@ -295,13 +293,13 @@ export default {
// 需要将 所有规格名称,提出一个数组集合,
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;
if( item.spec_name ) {
let obj = { spec_name: '' };
// 注意, item.spec_value是否一定为一个长度大于 1 的数组
if( item.spec_value.length > 0) {
for(let i = 0; i < item.spec_value.length; i++) {
if( item.spec_value[i].value ) {
obj.spec_name = item.spec_name;
this.speNameList.push(obj);
break;
}
......@@ -331,7 +329,7 @@ export default {
goodsPam.pamDataList = goodsParametersList;
goodsParametersList.forEach((item)=> {
let prePamTable = [
{ js_price:'', sl_price:'', price:'', sc_price:'', stock:'', weight:'', thumb:'' }
{ js_price:'', sl_price:'', price:'', sc_price:'', stock:'', weight:'', thumb:'',spec_values: [] }
];
goodsPam.pamTableList.push(prePamTable)
});
......@@ -346,10 +344,10 @@ export default {
for (let i = 0; i < list.length; i++) {
let childList = [];
if(list[i].specName) {
for(let j = 0; j < list[i].specValue.length; j++) {
if(list[i].specValue[j].value) {
childList.push(list[i].specValue[j].value);
if(list[i].spec_name) {
for(let j = 0; j < list[i].spec_value.length; j++) {
if(list[i].spec_value[j].value) {
childList.push(list[i].spec_value[j].value);
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论