diff --git a/src/api/product.js b/src/api/product.js
index d38fedf..5f3da13 100644
--- a/src/api/product.js
+++ b/src/api/product.js
@@ -39,3 +39,11 @@ export function updatePublishStatus(params) {
})
}
+export function createProduct(data) {
+ return request({
+ url:'/product/create',
+ method:'post',
+ data:data
+ })
+}
+
diff --git a/src/views/pms/product/add.vue b/src/views/pms/product/add.vue
index ee0171e..02fe3f3 100644
--- a/src/views/pms/product/add.vue
+++ b/src/views/pms/product/add.vue
@@ -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();
+ });
+ })
}
}
}
diff --git a/src/views/pms/product/components/addProductAttr.vue b/src/views/pms/product/components/addProductAttr.vue
index e0fb82f..a986885 100644
--- a/src/views/pms/product/components/addProductAttr.vue
+++ b/src/views/pms/product/components/addProductAttr.vue
@@ -98,26 +98,27 @@
-
- {{item.name}}:
-
-
+
+ {{item.name}}:
+
+
-
-
{{item.name}}:
-
-
-
-
-
-
+
+
{{item.name}}:
+
+
+
+
+
+
@@ -150,7 +151,7 @@
export default {
name: "addProductAttr",
- components:{SingleUpload,MultiUpload,Tinymce},
+ components: {SingleUpload, MultiUpload, Tinymce},
props: {
value: Object
},
@@ -161,20 +162,20 @@
//选中的商品属性
selectProductAttr: [],
//选中的商品参数
- selectProductParam:[],
+ selectProductParam: [],
//选中的商品属性图片
- selectProductAttrPics:[],
+ selectProductAttrPics: [],
//可手动添加的商品属性
- addProductAttrValue:'',
+ addProductAttrValue: '',
//选中的商品图片
- selectProductPics:[],
+ selectProductPics: [],
//商品富文本详情激活类型
- activeHtmlName:'pc'
+ activeHtmlName: 'pc'
}
},
computed: {
hasAttrPic() {
- if(this.selectProductAttrPics.length<1){
+ if (this.selectProductAttrPics.length < 1) {
return false;
}
return true;
@@ -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};
@@ -206,9 +226,9 @@
for (let i = 0; i < list.length; i++) {
this.selectProductAttr.push({
id: list[i].id,
- name:list[i].name,
+ name: list[i].name,
handAddStatus: list[i].handAddStatus,
- inputList:list[i].inputList,
+ inputList: list[i].inputList,
values: [],
options: []
});
@@ -218,10 +238,10 @@
for (let i = 0; i < list.length; i++) {
this.selectProductParam.push({
id: list[i].id,
- name:list[i].name,
+ name: list[i].name,
value: null,
- inputType:list[i].inputType,
- inputList:list[i].inputList
+ inputType: list[i].inputType,
+ inputList: list[i].inputList
});
}
}
@@ -282,33 +302,33 @@
} else if (this.selectProductAttr.length === 2) {
let values0 = this.selectProductAttr[0].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++) {
- if(values1.length===0){
+ if (values1.length === 0) {
skuList.push({
sp1: values0[i]
});
continue;
}
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({
sp1: values0[i],
sp2: values1[j]
@@ -326,15 +346,55 @@
}
}
},
- refreshProductAttrPics(){
- this.selectProductAttrPics=[];
+ refreshProductAttrPics() {
+ this.selectProductAttrPics = [];
if (this.selectProductAttr.length >= 1) {
let values = this.selectProductAttr[0].values;
- for(let i=0;i 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) {
@@ -343,13 +403,15 @@
list.splice(index, 1);
}
},
- getParamInputList(inputList){
+ getParamInputList(inputList) {
return inputList.split(',');
},
- handlePrev(){
+ handlePrev() {
this.$emit('prevStep')
},
- handleNext(){
+ handleNext() {
+ this.mergeProductAttrValue();
+ this.mergeProductAttrPics();
this.$emit('nextStep')
}
}
@@ -360,19 +422,23 @@
.littleMarginLeft {
margin-left: 10px;
}
+
.littleMarginTop {
margin-top: 10px;
}
- .paramInput{
+
+ .paramInput {
width: 250px;
}
- .paramInputLabel{
+
+ .paramInputLabel {
display: inline-block;
width: 100px;
text-align: right;
padding-right: 10px
}
- .cardBg{
+
+ .cardBg {
background: #F8F9FC;
}
diff --git a/src/views/pms/product/components/addProductInfo.vue b/src/views/pms/product/components/addProductInfo.vue
index a2079e1..e774474 100644
--- a/src/views/pms/product/components/addProductInfo.vue
+++ b/src/views/pms/product/components/addProductInfo.vue
@@ -14,7 +14,10 @@
-
+