产品修改功能完善

This commit is contained in:
zhh 2018-06-05 17:08:27 +08:00
parent 75b5f54842
commit 187582e2b3
6 changed files with 114 additions and 15 deletions

View File

@ -47,3 +47,10 @@ export function createProduct(data) {
}) })
} }
export function getProduct(id) {
return request({
url:'/product/updateInfo/'+id,
method:'get',
})
}

View File

@ -153,7 +153,11 @@
name: "ProductAttrDetail", name: "ProductAttrDetail",
components: {SingleUpload, MultiUpload, Tinymce}, components: {SingleUpload, MultiUpload, Tinymce},
props: { props: {
value: Object value: Object,
isEdit: {
type: Boolean,
default: false
}
}, },
data() { data() {
return { return {
@ -182,6 +186,9 @@
} }
}, },
created() { created() {
if(this.isEdit){
this.handleEditCreated();
}
this.getProductAttrCateList(); this.getProductAttrCateList();
if (this.value.productAttributeCategoryId != null) { if (this.value.productAttributeCategoryId != null) {
this.handleProductAttrChange(this.value.productAttributeCategoryId); this.handleProductAttrChange(this.value.productAttributeCategoryId);
@ -207,6 +214,9 @@
} }
}, },
methods: { methods: {
handleEditCreated(){
},
getProductAttrCateList() { getProductAttrCateList() {
let param = {pageNum: 1, pageSize: 100}; let param = {pageNum: 1, pageSize: 100};
fetchProductAttrCateList(param).then(response => { fetchProductAttrCateList(param).then(response => {
@ -224,13 +234,21 @@
if (type === 0) { if (type === 0) {
this.selectProductAttr = []; this.selectProductAttr = [];
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
let options = [];
let values=[];
if(this.isEdit){
if(list[i].handAddStatus===1){
options = this.getEditAttrOptions(list[i].id);
}
// values = this.getEditAttrValues(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: values,
options: [] options: options
}); });
} }
} else { } else {
@ -247,6 +265,48 @@
} }
}); });
}, },
//
getEditAttrOptions(id){
let options=[];
for(let i=0;i<this.value.productAttributeValueList.length;i++){
let attrValue = this.value.productAttributeValueList[i];
if(attrValue.productAttributeId===id){
let strArr = attrValue.value.split(',');
for(let j=0;j<strArr.length;j++){
options.push(strArr[j]);
}
break;
}
}
return options;
},
//
getEditAttrValues(index){
let values=[];
if(index===0){
for(let i=0;i<this.value.skuStockList.length;i++){
let sku=this.value.skuStockList[i];
if(sku.sp1!=null&&values.indexOf(sku.sp1)>-1){
values.push(sku.sp1);
}
}
}else if(index===1){
for(let i=0;i<this.value.skuStockList.length;i++){
let sku=this.value.skuStockList[i];
if(sku.sp2!=null&&values.indexOf(sku.sp2)>-1){
values.push(sku.sp2);
}
}
}else{
for(let i=0;i<this.value.skuStockList.length;i++){
let sku=this.value.skuStockList[i];
if(sku.sp3!=null&&values.indexOf(sku.sp3)>-1){
values.push(sku.sp3);
}
}
}
return values;
},
handleProductAttrChange(value) { handleProductAttrChange(value) {
this.getProductAttrList(0, value); this.getProductAttrList(0, value);
this.getProductAttrList(1, value); this.getProductAttrList(1, value);

View File

@ -9,28 +9,28 @@
<product-info-detail <product-info-detail
v-show="showStatus[0]" v-show="showStatus[0]"
v-model="productParam" v-model="productParam"
:is-edit="isEdit"
@nextStep="nextStep"> @nextStep="nextStep">
</product-info-detail> </product-info-detail>
<product-sale-detail <product-sale-detail
v-show="showStatus[1]" v-show="showStatus[1]"
v-model="productParam" v-model="productParam"
:is-edit="isEdit"
@nextStep="nextStep" @nextStep="nextStep"
@prevStep="prevStep" @prevStep="prevStep">
>
</product-sale-detail> </product-sale-detail>
<product-attr-detail <product-attr-detail
v-show="showStatus[2]" v-show="showStatus[2]"
v-model="productParam" v-model="productParam"
:is-edit="isEdit"
@nextStep="nextStep" @nextStep="nextStep"
@prevStep="prevStep" @prevStep="prevStep">
>
</product-attr-detail> </product-attr-detail>
<product-relation-detail <product-relation-detail
v-show="showStatus[3]" v-show="showStatus[3]"
v-model="productParam" v-model="productParam"
@prevStep="prevStep" @prevStep="prevStep"
@finishCommit="finishCommit" @finishCommit="finishCommit">
>
</product-relation-detail> </product-relation-detail>
</el-card> </el-card>
</template> </template>
@ -39,7 +39,7 @@
import ProductSaleDetail from './ProductSaleDetail'; import ProductSaleDetail from './ProductSaleDetail';
import ProductAttrDetail from './ProductAttrDetail'; import ProductAttrDetail from './ProductAttrDetail';
import ProductRelationDetail from './ProductRelationDetail'; import ProductRelationDetail from './ProductRelationDetail';
import {createProduct} from '@/api/product'; import {createProduct,getProduct} from '@/api/product';
const defaultProductParam = { const defaultProductParam = {
albumPics: '', albumPics: '',

View File

@ -62,11 +62,16 @@
<script> <script>
import {fetchListWithChildren} from '@/api/productCate' import {fetchListWithChildren} from '@/api/productCate'
import {fetchList as fetchBrandList} from '@/api/brand' import {fetchList as fetchBrandList} from '@/api/brand'
import {getProduct} from '@/api/product';
export default { export default {
name: "ProductInfoDetail", name: "ProductInfoDetail",
props: { props: {
value: Object value: Object,
isEdit: {
type: Boolean,
default: false
}
}, },
data() { data() {
return { return {
@ -88,6 +93,9 @@
}; };
}, },
created() { created() {
if(this.isEdit){
this.handleEditCreated();
}
this.getProductCateList(); this.getProductCateList();
this.getBrandList(); this.getBrandList();
}, },
@ -101,6 +109,16 @@
} }
}, },
methods: { methods: {
//
handleEditCreated(){
getProduct(this.$route.query.id).then(response=>{
if(response.data.productCategoryId!=null){
this.selectProductCateValue.push(response.data.cateParentId);
this.selectProductCateValue.push(response.data.productCategoryId);
}
this.$emit('input',response.data);
});
},
getProductCateList() { getProductCateList() {
fetchListWithChildren().then(response => { fetchListWithChildren().then(response => {
let list = response.data; let list = response.data;

View File

@ -169,7 +169,11 @@
export default { export default {
name: "ProductSaleDetail", name: "ProductSaleDetail",
props: { props: {
value: Object value: Object,
isEdit: {
type: Boolean,
default: false
}
}, },
data() { data() {
return { return {
@ -184,14 +188,18 @@
} }
}, },
created(){ created(){
fetchMemberLevelList({defaultStatus:0}).then(response=>{ if(this.isEdit){
this.handleEditCreated();
}else{
fetchMemberLevelList({defaultStatus:0}).then(response=>{
let memberPriceList=[]; let memberPriceList=[];
for(let i=0;i<response.data.length;i++){ for(let i=0;i<response.data.length;i++){
let item = response.data[i]; let item = response.data[i];
memberPriceList.push({memberLevelId:item.id,memberLevelName:item.name}) memberPriceList.push({memberLevelId:item.id,memberLevelName:item.name})
} }
this.value.memberPriceList=memberPriceList; this.value.memberPriceList=memberPriceList;
}); });
}
}, },
watch: { watch: {
selectServiceList: function (newValue) { selectServiceList: function (newValue) {
@ -211,6 +219,12 @@
} }
}, },
methods:{ methods:{
handleEditCreated(){
let ids = this.value.serviceIds.split(',');
for(let i=0;i<ids.length;i++){
this.selectServiceList.push(Number(ids[i]));
}
},
handleRemoveProductLadder(index,row){ handleRemoveProductLadder(index,row){
let productLadderList = this.value.productLadderList; let productLadderList = this.value.productLadderList;
if(productLadderList.length===1){ if(productLadderList.length===1){

View File

@ -460,7 +460,7 @@
}); });
}, },
handleUpdateProduct(index,row){ handleUpdateProduct(index,row){
this.$router.push({path:'/pms/addProduct',query:{id:row.id}}); this.$router.push({path:'/pms/updateProduct',query:{id:row.id}});
}, },
updatePublishStatus(publishStatus, ids) { updatePublishStatus(publishStatus, ids) {
let params = new URLSearchParams(); let params = new URLSearchParams();