添加商品功能完善
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();
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,26 +98,27 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="属性图片:" v-if="hasAttrPic">
|
<el-form-item label="属性图片:" v-if="hasAttrPic">
|
||||||
<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"
|
||||||
</div>
|
style="width: 300px;display: inline-block;margin-left: 10px"></single-upload>
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品参数:">
|
<el-form-item label="商品参数:">
|
||||||
<el-card shadow="never" class="cardBg">
|
<el-card shadow="never" class="cardBg">
|
||||||
<div v-for="(item,index) in selectProductParam" :class="{littleMarginTop:index!==0}">
|
<div v-for="(item,index) in selectProductParam" :class="{littleMarginTop:index!==0}">
|
||||||
<div class="paramInputLabel">{{item.name}}:</div>
|
<div class="paramInputLabel">{{item.name}}:</div>
|
||||||
<el-select v-if="item.inputType===1" class="paramInput" v-model="selectProductParam[index].value">
|
<el-select v-if="item.inputType===1" class="paramInput" v-model="selectProductParam[index].value">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in getParamInputList(item.inputList)"
|
v-for="item in getParamInputList(item.inputList)"
|
||||||
:key="item"
|
:key="item"
|
||||||
:label="item"
|
:label="item"
|
||||||
:value="item">
|
:value="item">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-input v-else class="paramInput" v-model="selectProductParam[index].value"></el-input>
|
<el-input v-else class="paramInput" v-model="selectProductParam[index].value"></el-input>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品相册:">
|
<el-form-item label="商品相册:">
|
||||||
@ -150,7 +151,7 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "addProductAttr",
|
name: "addProductAttr",
|
||||||
components:{SingleUpload,MultiUpload,Tinymce},
|
components: {SingleUpload, MultiUpload, Tinymce},
|
||||||
props: {
|
props: {
|
||||||
value: Object
|
value: Object
|
||||||
},
|
},
|
||||||
@ -161,20 +162,20 @@
|
|||||||
//选中的商品属性
|
//选中的商品属性
|
||||||
selectProductAttr: [],
|
selectProductAttr: [],
|
||||||
//选中的商品参数
|
//选中的商品参数
|
||||||
selectProductParam:[],
|
selectProductParam: [],
|
||||||
//选中的商品属性图片
|
//选中的商品属性图片
|
||||||
selectProductAttrPics:[],
|
selectProductAttrPics: [],
|
||||||
//可手动添加的商品属性
|
//可手动添加的商品属性
|
||||||
addProductAttrValue:'',
|
addProductAttrValue: '',
|
||||||
//选中的商品图片
|
//选中的商品图片
|
||||||
selectProductPics:[],
|
selectProductPics: [],
|
||||||
//商品富文本详情激活类型
|
//商品富文本详情激活类型
|
||||||
activeHtmlName:'pc'
|
activeHtmlName: 'pc'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
hasAttrPic() {
|
hasAttrPic() {
|
||||||
if(this.selectProductAttrPics.length<1){
|
if (this.selectProductAttrPics.length < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -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};
|
||||||
@ -206,9 +226,9 @@
|
|||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
this.selectProductAttr.push({
|
this.selectProductAttr.push({
|
||||||
id: list[i].id,
|
id: list[i].id,
|
||||||
name:list[i].name,
|
name: list[i].name,
|
||||||
handAddStatus: list[i].handAddStatus,
|
handAddStatus: list[i].handAddStatus,
|
||||||
inputList:list[i].inputList,
|
inputList: list[i].inputList,
|
||||||
values: [],
|
values: [],
|
||||||
options: []
|
options: []
|
||||||
});
|
});
|
||||||
@ -218,10 +238,10 @@
|
|||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
this.selectProductParam.push({
|
this.selectProductParam.push({
|
||||||
id: list[i].id,
|
id: list[i].id,
|
||||||
name:list[i].name,
|
name: list[i].name,
|
||||||
value: null,
|
value: null,
|
||||||
inputType:list[i].inputType,
|
inputType: list[i].inputType,
|
||||||
inputList:list[i].inputList
|
inputList: list[i].inputList
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,33 +302,33 @@
|
|||||||
} else if (this.selectProductAttr.length === 2) {
|
} else if (this.selectProductAttr.length === 2) {
|
||||||
let values0 = this.selectProductAttr[0].values;
|
let values0 = this.selectProductAttr[0].values;
|
||||||
let values1 = this.selectProductAttr[1].values;
|
let values1 = this.selectProductAttr[1].values;
|
||||||
for (let i = 0; i < values0.length; i++) {
|
|
||||||
if(values1.length===0){
|
|
||||||
skuList.push({
|
|
||||||
sp1: values0[i]
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (let j = 0; j < values1.length; j++) {
|
|
||||||
skuList.push({
|
|
||||||
sp1: values0[i],
|
|
||||||
sp2: values1[j]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let values0 = this.selectProductAttr[0].values;
|
|
||||||
let values1 = this.selectProductAttr[1].values;
|
|
||||||
let values2 = this.selectProductAttr[2].values;
|
|
||||||
for (let i = 0; i < values0.length; i++) {
|
for (let i = 0; i < values0.length; i++) {
|
||||||
if(values1.length===0){
|
if (values1.length === 0) {
|
||||||
skuList.push({
|
skuList.push({
|
||||||
sp1: values0[i]
|
sp1: values0[i]
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (let j = 0; j < values1.length; j++) {
|
for (let j = 0; j < values1.length; j++) {
|
||||||
if(values2.length===0){
|
skuList.push({
|
||||||
|
sp1: values0[i],
|
||||||
|
sp2: values1[j]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let values0 = this.selectProductAttr[0].values;
|
||||||
|
let values1 = this.selectProductAttr[1].values;
|
||||||
|
let values2 = this.selectProductAttr[2].values;
|
||||||
|
for (let i = 0; i < values0.length; i++) {
|
||||||
|
if (values1.length === 0) {
|
||||||
|
skuList.push({
|
||||||
|
sp1: values0[i]
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (let j = 0; j < values1.length; j++) {
|
||||||
|
if (values2.length === 0) {
|
||||||
skuList.push({
|
skuList.push({
|
||||||
sp1: values0[i],
|
sp1: values0[i],
|
||||||
sp2: values1[j]
|
sp2: values1[j]
|
||||||
@ -326,15 +346,55 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refreshProductAttrPics(){
|
refreshProductAttrPics() {
|
||||||
this.selectProductAttrPics=[];
|
this.selectProductAttrPics = [];
|
||||||
if (this.selectProductAttr.length >= 1) {
|
if (this.selectProductAttr.length >= 1) {
|
||||||
let values = this.selectProductAttr[0].values;
|
let values = this.selectProductAttr[0].values;
|
||||||
for(let i=0;i<values.length;i++){
|
for (let i = 0; i < values.length; i++) {
|
||||||
this.selectProductAttrPics.push({name:values[i],pic:null})
|
this.selectProductAttrPics.push({name: values[i], pic: null})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//合并商品属性
|
||||||
|
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) {
|
||||||
@ -343,13 +403,15 @@
|
|||||||
list.splice(index, 1);
|
list.splice(index, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getParamInputList(inputList){
|
getParamInputList(inputList) {
|
||||||
return inputList.split(',');
|
return inputList.split(',');
|
||||||
},
|
},
|
||||||
handlePrev(){
|
handlePrev() {
|
||||||
this.$emit('prevStep')
|
this.$emit('prevStep')
|
||||||
},
|
},
|
||||||
handleNext(){
|
handleNext() {
|
||||||
|
this.mergeProductAttrValue();
|
||||||
|
this.mergeProductAttrPics();
|
||||||
this.$emit('nextStep')
|
this.$emit('nextStep')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,19 +422,23 @@
|
|||||||
.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;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -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