产品修改功能完善
This commit is contained in:
parent
75b5f54842
commit
187582e2b3
@ -47,3 +47,10 @@ export function createProduct(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getProduct(id) {
|
||||
return request({
|
||||
url:'/product/updateInfo/'+id,
|
||||
method:'get',
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,11 @@
|
||||
name: "ProductAttrDetail",
|
||||
components: {SingleUpload, MultiUpload, Tinymce},
|
||||
props: {
|
||||
value: Object
|
||||
value: Object,
|
||||
isEdit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -182,6 +186,9 @@
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(this.isEdit){
|
||||
this.handleEditCreated();
|
||||
}
|
||||
this.getProductAttrCateList();
|
||||
if (this.value.productAttributeCategoryId != null) {
|
||||
this.handleProductAttrChange(this.value.productAttributeCategoryId);
|
||||
@ -207,6 +214,9 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleEditCreated(){
|
||||
|
||||
},
|
||||
getProductAttrCateList() {
|
||||
let param = {pageNum: 1, pageSize: 100};
|
||||
fetchProductAttrCateList(param).then(response => {
|
||||
@ -224,13 +234,21 @@
|
||||
if (type === 0) {
|
||||
this.selectProductAttr = [];
|
||||
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({
|
||||
id: list[i].id,
|
||||
name: list[i].name,
|
||||
handAddStatus: list[i].handAddStatus,
|
||||
inputList: list[i].inputList,
|
||||
values: [],
|
||||
options: []
|
||||
values: values,
|
||||
options: options
|
||||
});
|
||||
}
|
||||
} 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) {
|
||||
this.getProductAttrList(0, value);
|
||||
this.getProductAttrList(1, value);
|
||||
|
@ -9,28 +9,28 @@
|
||||
<product-info-detail
|
||||
v-show="showStatus[0]"
|
||||
v-model="productParam"
|
||||
:is-edit="isEdit"
|
||||
@nextStep="nextStep">
|
||||
</product-info-detail>
|
||||
<product-sale-detail
|
||||
v-show="showStatus[1]"
|
||||
v-model="productParam"
|
||||
:is-edit="isEdit"
|
||||
@nextStep="nextStep"
|
||||
@prevStep="prevStep"
|
||||
>
|
||||
@prevStep="prevStep">
|
||||
</product-sale-detail>
|
||||
<product-attr-detail
|
||||
v-show="showStatus[2]"
|
||||
v-model="productParam"
|
||||
:is-edit="isEdit"
|
||||
@nextStep="nextStep"
|
||||
@prevStep="prevStep"
|
||||
>
|
||||
@prevStep="prevStep">
|
||||
</product-attr-detail>
|
||||
<product-relation-detail
|
||||
v-show="showStatus[3]"
|
||||
v-model="productParam"
|
||||
@prevStep="prevStep"
|
||||
@finishCommit="finishCommit"
|
||||
>
|
||||
@finishCommit="finishCommit">
|
||||
</product-relation-detail>
|
||||
</el-card>
|
||||
</template>
|
||||
@ -39,7 +39,7 @@
|
||||
import ProductSaleDetail from './ProductSaleDetail';
|
||||
import ProductAttrDetail from './ProductAttrDetail';
|
||||
import ProductRelationDetail from './ProductRelationDetail';
|
||||
import {createProduct} from '@/api/product';
|
||||
import {createProduct,getProduct} from '@/api/product';
|
||||
|
||||
const defaultProductParam = {
|
||||
albumPics: '',
|
||||
|
@ -62,11 +62,16 @@
|
||||
<script>
|
||||
import {fetchListWithChildren} from '@/api/productCate'
|
||||
import {fetchList as fetchBrandList} from '@/api/brand'
|
||||
import {getProduct} from '@/api/product';
|
||||
|
||||
export default {
|
||||
name: "ProductInfoDetail",
|
||||
props: {
|
||||
value: Object
|
||||
value: Object,
|
||||
isEdit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -88,6 +93,9 @@
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if(this.isEdit){
|
||||
this.handleEditCreated();
|
||||
}
|
||||
this.getProductCateList();
|
||||
this.getBrandList();
|
||||
},
|
||||
@ -101,6 +109,16 @@
|
||||
}
|
||||
},
|
||||
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() {
|
||||
fetchListWithChildren().then(response => {
|
||||
let list = response.data;
|
||||
|
@ -169,7 +169,11 @@
|
||||
export default {
|
||||
name: "ProductSaleDetail",
|
||||
props: {
|
||||
value: Object
|
||||
value: Object,
|
||||
isEdit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -184,14 +188,18 @@
|
||||
}
|
||||
},
|
||||
created(){
|
||||
fetchMemberLevelList({defaultStatus:0}).then(response=>{
|
||||
if(this.isEdit){
|
||||
this.handleEditCreated();
|
||||
}else{
|
||||
fetchMemberLevelList({defaultStatus:0}).then(response=>{
|
||||
let memberPriceList=[];
|
||||
for(let i=0;i<response.data.length;i++){
|
||||
let item = response.data[i];
|
||||
memberPriceList.push({memberLevelId:item.id,memberLevelName:item.name})
|
||||
}
|
||||
this.value.memberPriceList=memberPriceList;
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selectServiceList: function (newValue) {
|
||||
@ -211,6 +219,12 @@
|
||||
}
|
||||
},
|
||||
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){
|
||||
let productLadderList = this.value.productLadderList;
|
||||
if(productLadderList.length===1){
|
||||
|
@ -460,7 +460,7 @@
|
||||
});
|
||||
},
|
||||
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) {
|
||||
let params = new URLSearchParams();
|
||||
|
Loading…
x
Reference in New Issue
Block a user