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

添加商品 提测

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