更新商品编辑时价格有概率无法回显的bug
This commit is contained in:
parent
47fcd00bd2
commit
0ef83a8e79
|
@ -104,11 +104,11 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<u-modal :show="showSpecType" title="温馨提示" content="切换后商品原有规格将失效,是否继续?"
|
<u-modal :show="showSpecType" title="温馨提示" content="切换后商品原有规格将失效,是否继续?" show-cancel-button confirm-text="继续"
|
||||||
show-cancel-button confirm-text="继续" @confirm="changeSpecType2" @cancel="showSpecType=false"
|
@confirm="changeSpecType2" @cancel="showSpecType=false"></u-modal>
|
||||||
></u-modal>
|
|
||||||
</picker>
|
</picker>
|
||||||
<priceComponent v-if="setFormData.spec_type==0" :datas="setFormData.attrValue[0]" ref="priceRef" :product_id="product_id" :bar_code="code" @updateCode="updateCode">
|
<priceComponent v-if="setFormData.spec_type==0" :datas="setFormData.attrValue[0]" ref="priceRef"
|
||||||
|
:product_id="product_id" :bar_code="code" @updateCode="updateCode">
|
||||||
</priceComponent>
|
</priceComponent>
|
||||||
<view v-else class="popup_group" style="margin-top: 0;border-top: 1rpx solid #eeeeee;">
|
<view v-else class="popup_group" style="margin-top: 0;border-top: 1rpx solid #eeeeee;">
|
||||||
<view class="popup_group_item" @click="navToSpecGood()">
|
<view class="popup_group_item" @click="navToSpecGood()">
|
||||||
|
@ -278,14 +278,14 @@
|
||||||
this.showCommodity = true;;
|
this.showCommodity = true;;
|
||||||
this.initData();
|
this.initData();
|
||||||
this.initClasiffy();
|
this.initClasiffy();
|
||||||
if(this.import==1){
|
if (this.import == 1) {
|
||||||
this.getOpenerEventChannel().once('importAttrValue', (e) => {
|
this.getOpenerEventChannel().once('importAttrValue', (e) => {
|
||||||
this.attrValue = e.attrValue;
|
this.attrValue = e.attrValue;
|
||||||
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
|
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
|
||||||
this.attr = e.attr;
|
this.attr = e.attr;
|
||||||
uni.setStorageSync('attr', JSON.stringify(e.attr));
|
uni.setStorageSync('attr', JSON.stringify(e.attr));
|
||||||
this.setFormData = Object.assign({}, this.setFormData, e);
|
this.setFormData = Object.assign({}, this.setFormData, e);
|
||||||
this.$nextTick(()=>{
|
this.$nextTick(() => {
|
||||||
this.$refs.commodityRef?.setDatas({
|
this.$refs.commodityRef?.setDatas({
|
||||||
addGoodsSecoundData: {
|
addGoodsSecoundData: {
|
||||||
is_good: this.setFormData.is_good, // 是否推荐
|
is_good: this.setFormData.is_good, // 是否推荐
|
||||||
|
@ -301,8 +301,7 @@
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
} else if (this.product_id) {
|
||||||
else if(this.product_id){
|
|
||||||
this.initDataEditData();
|
this.initDataEditData();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -402,8 +401,10 @@
|
||||||
item => item
|
item => item
|
||||||
.category && item.category.cate_name).join(',') : '';
|
.category && item.category.cate_name).join(',') : '';
|
||||||
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name : '';
|
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name : '';
|
||||||
if(typeof res.data.content == 'string')res.data.content = JSON.parse(res.data.content);
|
if (res.data.content && typeof res.data.content == 'string') res.data.content = JSON.parse(res.data
|
||||||
|
.content);
|
||||||
//向组件注入数据
|
//向组件注入数据
|
||||||
|
this.$nextTick(() => {
|
||||||
this.$refs.commodityRef.setDatas({
|
this.$refs.commodityRef.setDatas({
|
||||||
addGoodsSecoundData: {
|
addGoodsSecoundData: {
|
||||||
is_good: res.data.is_good, // 是否推荐
|
is_good: res.data.is_good, // 是否推荐
|
||||||
|
@ -421,6 +422,7 @@
|
||||||
if (this.setFormData.spec_type == 0) {
|
if (this.setFormData.spec_type == 0) {
|
||||||
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
|
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
|
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
|
||||||
hideLoading();
|
hideLoading();
|
||||||
|
|
||||||
|
@ -432,20 +434,20 @@
|
||||||
},
|
},
|
||||||
initData() {
|
initData() {
|
||||||
// 获取品牌
|
// 获取品牌
|
||||||
categoryBrandlist(this.merId).then((res)=>{
|
categoryBrandlist(this.merId).then((res) => {
|
||||||
this.brand = res.data;
|
this.brand = res.data;
|
||||||
}).catch(e=>{
|
}).catch(e => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
// 获取平台分类
|
// 获取平台分类
|
||||||
categoryList(this.merId).then((res)=>{
|
categoryList(this.merId).then((res) => {
|
||||||
res.data.forEach((item1) => {
|
res.data.forEach((item1) => {
|
||||||
item1.children.forEach((item2) => {
|
item1.children.forEach((item2) => {
|
||||||
item2.children = null;
|
item2.children = null;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.platformClassificationData = res.data;
|
this.platformClassificationData = res.data;
|
||||||
}).catch(e=>{
|
}).catch(e => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -600,7 +602,7 @@
|
||||||
// return console.log('商品规格', this.setFormData.attr);
|
// return console.log('商品规格', this.setFormData.attr);
|
||||||
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
|
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
|
||||||
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
|
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
|
||||||
if(this.setFormData.spec_type==0){
|
if (this.setFormData.spec_type == 0) {
|
||||||
console.log('价格库存', this.$refs.priceRef.singleSpecification);
|
console.log('价格库存', this.$refs.priceRef.singleSpecification);
|
||||||
}
|
}
|
||||||
let postData = {
|
let postData = {
|
||||||
|
@ -612,27 +614,27 @@
|
||||||
},
|
},
|
||||||
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
|
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
|
||||||
};
|
};
|
||||||
if(this.setFormData.spec_type==0){
|
if (this.setFormData.spec_type == 0) {
|
||||||
postData.attrValue = [this.$refs.priceRef.singleSpecification];
|
postData.attrValue = [this.$refs.priceRef.singleSpecification];
|
||||||
}else postData.attrValue = this.setFormData.attrValue;
|
} else postData.attrValue = this.setFormData.attrValue;
|
||||||
postData.stock = postData.attrValue[0]?.stock||0;
|
postData.stock = postData.attrValue[0]?.stock || 0;
|
||||||
if(!postData.store_name||postData.store_name?.trim().length<=0)return Toast('请输入商品名称');
|
if (!postData.store_name || postData.store_name?.trim().length <= 0) return Toast('请输入商品名称');
|
||||||
if(!postData.imageList||postData.imageList?.length<2)return Toast('请上传2张以上商品图片');
|
if (!postData.imageList || postData.imageList?.length < 2) return Toast('请上传2张以上商品图片');
|
||||||
if(!postData.cate_name||postData.cate_name?.trim().length<=0)return Toast('请选择平台分类');
|
if (!postData.cate_name || postData.cate_name?.trim().length <= 0) return Toast('请选择平台分类');
|
||||||
if(!postData.unit_name||postData.unit_name?.trim().length<=0)return Toast('请输入商品单位');
|
if (!postData.unit_name || postData.unit_name?.trim().length <= 0) return Toast('请输入商品单位');
|
||||||
let userInfo = this.$store.state.app.userInfo;
|
let userInfo = this.$store.state.app.userInfo;
|
||||||
if(typeof userInfo == 'string')userInfo= JSON.parse(userInfo);
|
if (typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
|
||||||
let showFlag = '';
|
let showFlag = '';
|
||||||
postData.attrValue.forEach(t=>{
|
postData.attrValue.forEach(t => {
|
||||||
if(userInfo?.mer_info?.type_code=="TypeSupplyChain" && (!t.procure_price||+t.procure_price<=0) ){
|
if (userInfo?.mer_info?.type_code == "TypeSupplyChain" && (!t.procure_price || +t.procure_price <= 0)) {
|
||||||
showFlag = '批发价不能小于0'
|
showFlag = '批发价不能小于0'
|
||||||
}
|
}
|
||||||
if(!t.price||+t.price<=0) showFlag = '零售价不能小于0';
|
if (!t.price || +t.price <= 0) showFlag = '零售价不能小于0';
|
||||||
if(!t.stock||+t.stock<=0) showFlag = '库存不能小于0';
|
if (!t.stock || +t.stock <= 0) showFlag = '库存不能小于0';
|
||||||
if(!t.cost||+t.cost<=0) showFlag = '成本价不能小于0';
|
if (!t.cost || +t.cost <= 0) showFlag = '成本价不能小于0';
|
||||||
})
|
})
|
||||||
if(showFlag) {
|
if (showFlag) {
|
||||||
if(this.setFormData.spec_type==1) showFlag+=', 请点击设置多规格设置';
|
if (this.setFormData.spec_type == 1) showFlag += ', 请点击设置多规格设置';
|
||||||
return Toast(showFlag);
|
return Toast(showFlag);
|
||||||
}
|
}
|
||||||
Loading();
|
Loading();
|
||||||
|
@ -659,11 +661,10 @@
|
||||||
Modal('提交成功', '点击确定,返回商品管理', {
|
Modal('提交成功', '点击确定,返回商品管理', {
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if(this.import==1){
|
if (this.import == 1) {
|
||||||
uni.$emit('importAttrValueOK', this.setFormData.import_id);
|
uni.$emit('importAttrValueOK', this.setFormData.import_id);
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
}
|
} else uni.redirectTo({
|
||||||
else uni.redirectTo({
|
|
||||||
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
|
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -674,30 +675,30 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 选择规格
|
// 选择规格
|
||||||
changeSpecType(e){
|
changeSpecType(e) {
|
||||||
if(this.setFormData.spec_type!=e.detail.value){
|
if (this.setFormData.spec_type != e.detail.value) {
|
||||||
this.showSpecType = true;
|
this.showSpecType = true;
|
||||||
}
|
}
|
||||||
this.spec_type = e.detail.value;
|
this.spec_type = e.detail.value;
|
||||||
},
|
},
|
||||||
// 二次确认
|
// 二次确认
|
||||||
changeSpecType2(){
|
changeSpecType2() {
|
||||||
this.showSpecType = false;
|
this.showSpecType = false;
|
||||||
this.setFormData.spec_type = this.spec_type + '';
|
this.setFormData.spec_type = this.spec_type + '';
|
||||||
this.setFormData.attrValue = [];
|
this.setFormData.attrValue = [];
|
||||||
this.setFormData.attr = [];
|
this.setFormData.attr = [];
|
||||||
},
|
},
|
||||||
// 跳转多规格页面
|
// 跳转多规格页面
|
||||||
navToSpecGood(){
|
navToSpecGood() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/product/addGood/specGood?product_id=' + this.product_id,
|
url: '/pages/product/addGood/specGood?product_id=' + this.product_id,
|
||||||
success: (e) => {
|
success: (e) => {
|
||||||
// console.log(this.setFormData.attrValue, e);
|
// console.log(this.setFormData.attrValue, e);
|
||||||
e.eventChannel.emit('updateAttrValue', {
|
e.eventChannel.emit('updateAttrValue', {
|
||||||
attrValue: JSON.parse(JSON.stringify(this.setFormData.attrValue)),
|
attrValue: JSON.parse(JSON.stringify(this.setFormData.attrValue)),
|
||||||
attr: JSON.parse(JSON.stringify(this.setFormData.attr))
|
attr: JSON.parse(JSON.stringify(this.setFormData.attr))
|
||||||
});
|
});
|
||||||
uni.$once('updateSpecType', (e)=>{
|
uni.$once('updateSpecType', (e) => {
|
||||||
this.setFormData.attrValue = JSON.parse(JSON.stringify(e.attrValue));
|
this.setFormData.attrValue = JSON.parse(JSON.stringify(e.attrValue));
|
||||||
this.setFormData.attr = JSON.parse(JSON.stringify(e.attr));
|
this.setFormData.attr = JSON.parse(JSON.stringify(e.attr));
|
||||||
})
|
})
|
||||||
|
|
|
@ -165,7 +165,8 @@
|
||||||
else this.formList.splice(len-1, this.formList.length);
|
else this.formList.splice(len-1, this.formList.length);
|
||||||
},
|
},
|
||||||
setDatas(data){
|
setDatas(data){
|
||||||
this.singleSpecification = data;
|
console.log('收到', data);
|
||||||
|
this.singleSpecification = {...data};
|
||||||
},
|
},
|
||||||
input(val) {
|
input(val) {
|
||||||
this.singleSpecification = val
|
this.singleSpecification = val
|
||||||
|
|
Loading…
Reference in New Issue