添加商品功能完善
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 AddProductAttr from './components/addProductAttr';
|
||||
import AddProductRelation from './components/addProductRelation';
|
||||
import {createProduct} from '@/api/product';
|
||||
|
||||
const defaultProductParam = {
|
||||
albumPics: '',
|
||||
@ -132,7 +133,20 @@
|
||||
}
|
||||
},
|
||||
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">
|
||||
<div v-for="(item,index) in selectProductAttrPics">
|
||||
<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>
|
||||
</el-card>
|
||||
</el-form-item>
|
||||
@ -186,6 +187,25 @@
|
||||
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: {
|
||||
getProductAttrCateList() {
|
||||
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) {
|
||||
let list = this.value.skuStockList;
|
||||
if (list.length === 1) {
|
||||
@ -350,6 +410,8 @@
|
||||
this.$emit('prevStep')
|
||||
},
|
||||
handleNext() {
|
||||
this.mergeProductAttrValue();
|
||||
this.mergeProductAttrPics();
|
||||
this.$emit('nextStep')
|
||||
}
|
||||
}
|
||||
@ -360,18 +422,22 @@
|
||||
.littleMarginLeft {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.littleMarginTop {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.paramInput {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.paramInputLabel {
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
padding-right: 10px
|
||||
}
|
||||
|
||||
.cardBg {
|
||||
background: #F8F9FC;
|
||||
}
|
||||
|
@ -14,7 +14,10 @@
|
||||
<el-input v-model="value.subTitle"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品品牌:" prop="brandId">
|
||||
<el-select v-model="value.brandId" placeholder="请选择品牌">
|
||||
<el-select
|
||||
v-model="value.brandId"
|
||||
@change="handleBrandChange"
|
||||
placeholder="请选择品牌">
|
||||
<el-option
|
||||
v-for="item in brandOptions"
|
||||
:key="item.value"
|
||||
@ -95,7 +98,6 @@
|
||||
} else {
|
||||
this.value.productCategoryId = null;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -136,6 +138,16 @@
|
||||
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();
|
||||
},
|
||||
handleAddItem() {
|
||||
console.log("handleAddItem");
|
||||
this.$router.push({path:'/pms/addProduct'});
|
||||
},
|
||||
handleBatchOperate() {
|
||||
if(this.operateType==null){
|
||||
|
Loading…
x
Reference in New Issue
Block a user