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