添加商品功能完善
This commit is contained in:
parent
4ad36f8f15
commit
234d23d499
@ -39,3 +39,11 @@ export function updatePublishStatus(params) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createProduct(data) {
|
||||||
|
return request({
|
||||||
|
url:'/product/create',
|
||||||
|
method:'post',
|
||||||
|
data:data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
import AddProductSale from './components/addProductSale';
|
import AddProductSale from './components/addProductSale';
|
||||||
import AddProductAttr from './components/addProductAttr';
|
import AddProductAttr from './components/addProductAttr';
|
||||||
import AddProductRelation from './components/addProductRelation';
|
import AddProductRelation from './components/addProductRelation';
|
||||||
|
import {createProduct} from '@/api/product';
|
||||||
|
|
||||||
const defaultProductParam = {
|
const defaultProductParam = {
|
||||||
albumPics: '',
|
albumPics: '',
|
||||||
@ -132,7 +133,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
finishCommit() {
|
finishCommit() {
|
||||||
alert('finishCommit');
|
this.$confirm('是否要提交该产品', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
createProduct(this.productParam).then(response=>{
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '提交成功',
|
||||||
|
duration:1000
|
||||||
|
});
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,8 @@
|
|||||||
<el-card shadow="never" class="cardBg">
|
<el-card shadow="never" class="cardBg">
|
||||||
<div v-for="(item,index) in selectProductAttrPics">
|
<div v-for="(item,index) in selectProductAttrPics">
|
||||||
<span>{{item.name}}:</span>
|
<span>{{item.name}}:</span>
|
||||||
<single-upload v-model="item.pic" style="width: 300px;display: inline-block;margin-left: 10px"></single-upload>
|
<single-upload v-model="item.pic"
|
||||||
|
style="width: 300px;display: inline-block;margin-left: 10px"></single-upload>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -186,6 +187,25 @@
|
|||||||
this.handleProductAttrChange(this.value.productAttributeCategoryId);
|
this.handleProductAttrChange(this.value.productAttributeCategoryId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
selectProductPics: function (newValue) {
|
||||||
|
if (newValue == null || newValue.length === 0) {
|
||||||
|
this.value.pic = null;
|
||||||
|
this.value.albumPics = null;
|
||||||
|
} else {
|
||||||
|
this.value.pic = newValue[0];
|
||||||
|
this.value.albumPics = '';
|
||||||
|
if (newValue.length > 1) {
|
||||||
|
for (let i = 1; i < newValue.length; i++) {
|
||||||
|
this.value.albumPics += newValue[i];
|
||||||
|
if (i !== newValue.length - 1) {
|
||||||
|
this.value.albumPics += ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getProductAttrCateList() {
|
getProductAttrCateList() {
|
||||||
let param = {pageNum: 1, pageSize: 100};
|
let param = {pageNum: 1, pageSize: 100};
|
||||||
@ -335,6 +355,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//合并商品属性
|
||||||
|
mergeProductAttrValue() {
|
||||||
|
this.value.productAttributeValueList = [];
|
||||||
|
for (let i = 0; i < this.selectProductAttr.length; i++) {
|
||||||
|
let attr = this.selectProductAttr[i];
|
||||||
|
if (attr.handAddStatus === 1 && attr.options != null && attr.options.length > 0) {
|
||||||
|
this.value.productAttributeValueList.push({
|
||||||
|
productAttributeId: attr.id,
|
||||||
|
value: this.getOptionStr(attr.options)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < this.selectProductParam.length; i++) {
|
||||||
|
let param = this.selectProductParam[i];
|
||||||
|
this.value.productAttributeValueList.push({
|
||||||
|
productAttributeId: param.id,
|
||||||
|
value: param.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//合并商品属性图片
|
||||||
|
mergeProductAttrPics(){
|
||||||
|
for (let i = 0; i < this.selectProductAttrPics.length; i++) {
|
||||||
|
for (let j = 0; j < this.value.skuStockList.length; j++) {
|
||||||
|
if (this.value.skuStockList[j].sp1 === this.selectProductAttrPics[i].name) {
|
||||||
|
this.value.skuStockList[j].pic = this.selectProductAttrPics[i].pic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getOptionStr(arr) {
|
||||||
|
let str = '';
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
str += arr[i];
|
||||||
|
if (i != arr.length - 1) {
|
||||||
|
str += ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
},
|
||||||
handleRemoveProductSku(index, row) {
|
handleRemoveProductSku(index, row) {
|
||||||
let list = this.value.skuStockList;
|
let list = this.value.skuStockList;
|
||||||
if (list.length === 1) {
|
if (list.length === 1) {
|
||||||
@ -350,6 +410,8 @@
|
|||||||
this.$emit('prevStep')
|
this.$emit('prevStep')
|
||||||
},
|
},
|
||||||
handleNext() {
|
handleNext() {
|
||||||
|
this.mergeProductAttrValue();
|
||||||
|
this.mergeProductAttrPics();
|
||||||
this.$emit('nextStep')
|
this.$emit('nextStep')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,18 +422,22 @@
|
|||||||
.littleMarginLeft {
|
.littleMarginLeft {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.littleMarginTop {
|
.littleMarginTop {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.paramInput {
|
.paramInput {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.paramInputLabel {
|
.paramInputLabel {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 10px
|
padding-right: 10px
|
||||||
}
|
}
|
||||||
|
|
||||||
.cardBg {
|
.cardBg {
|
||||||
background: #F8F9FC;
|
background: #F8F9FC;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,10 @@
|
|||||||
<el-input v-model="value.subTitle"></el-input>
|
<el-input v-model="value.subTitle"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品品牌:" prop="brandId">
|
<el-form-item label="商品品牌:" prop="brandId">
|
||||||
<el-select v-model="value.brandId" placeholder="请选择品牌">
|
<el-select
|
||||||
|
v-model="value.brandId"
|
||||||
|
@change="handleBrandChange"
|
||||||
|
placeholder="请选择品牌">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in brandOptions"
|
v-for="item in brandOptions"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
@ -95,7 +98,6 @@
|
|||||||
} else {
|
} else {
|
||||||
this.value.productCategoryId = null;
|
this.value.productCategoryId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -136,6 +138,16 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
handleBrandChange(val) {
|
||||||
|
let brandName = '';
|
||||||
|
for (let i = 0; i < this.brandOptions.length; i++) {
|
||||||
|
if (this.brandOptions[i].value === val) {
|
||||||
|
brandName = this.brandOptions[i].label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.value.brandName = brandName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@
|
|||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
handleAddItem() {
|
handleAddItem() {
|
||||||
console.log("handleAddItem");
|
this.$router.push({path:'/pms/addProduct'});
|
||||||
},
|
},
|
||||||
handleBatchOperate() {
|
handleBatchOperate() {
|
||||||
if(this.operateType==null){
|
if(this.operateType==null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user