This commit is contained in:
weipengfei 2024-01-18 17:43:09 +08:00
parent 3fee32805d
commit d3e8fe6c96
5 changed files with 107 additions and 64 deletions

View File

@ -9,8 +9,8 @@ let httpApiThree
let wsApi
// 在打包之前请检查当前环境是否正确
const env = 'dev'; // 开发
// const env = 'prod'; // 生产
// const env = 'dev'; // 开发
const env = 'prod'; // 生产
// const env = 'prew'; // 预上线
switch (env) {

View File

@ -2,8 +2,8 @@
"name" : "惠农商户平台",
"appid" : "__UNI__1EE148C",
"description" : "",
"versionName" : "1.0.9",
"versionCode" : 109,
"versionName" : "1.1.2",
"versionCode" : 112,
"transformPx" : false,
/* 5+App */
"app-plus" : {

View File

@ -70,9 +70,9 @@
</view>
</view>
<!-- <view class="popup_group_item">
<view class="popup_group_item_label">商品单位</view>
<view class="popup_group_item_label">商品规格</view>
<view class="popup_group_item_value"><input v-model="setFormData.unit_name" type="text"
placeholder="请填写商品单位" /></view>
placeholder="请填写商品规格" /></view>
</view> -->
@ -107,13 +107,22 @@
<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" :tips="tips1" :datas="setFormData.attrValue[0]" ref="priceRef"
:product_id="product_id" :bar_code="code" :sku="'件'" @updateCode="updateCode">
</priceComponent>
<view style="height: 1rpx;"></view>
<priceComponent v-if="setFormData.spec_type==0" :tips="tips2" :datas="setFormData.attrValue[1]" ref="priceRef2"
:product_id="product_id" :bar_code="code" :sku="'个'" @updateCode="updateCode">
</priceComponent>
<block v-if="setFormData.spec_type==0">
<view v-for="(item, index) in setFormData.attrValue" v-show="!item.is_d_show" :key="index" class="head_close" style="margin-top: 20rpx;">
<view style="height: 1rpx;"></view>
<priceComponent :datas="item" ref="priceRef"
:product_id="product_id" :bar_code="code" @updateCode="updateCode">
</priceComponent>
<view v-if="setFormData.attrValue.length>1" class="delete_btn" @click="deleteByIndex(index)">
<image style="width: 50%;height: 50%;" src="../static/images/close.png"></image>
</view>
</view>
<view @click="pushAttrValue(setFormData.attrValue.length-1)" style="width: 710rpx;margin: 20rpx auto;text-align: center;background-color: #fff;padding: 20rpx 0;border-radius: 14rpx;">
+ 添加规格
</view>
<u-modal title="警告" content="删除后数据不可恢复,是否确认删除?" :show="showDelete" show-cancel-button @cancel="showDelete=false"
@confirm="deleteAttr()"></u-modal>
</block>
<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_label" style="flex: 1; text-align: center;">
@ -238,12 +247,16 @@
code: '', //
show: false, //
image: false, //
showDelete: false, //
deleteIndex: 0,
setFormData: {
store_name: '',
imageList: [],
attrValue: [],
attrValue: [
{}
],
cate_name: '', //
unit_name: '', //
unit_name: '', //
cate_id: '', // id
mer_cate_id: '', //
mer_cate_name: '', //
@ -370,6 +383,22 @@
}
},
methods: {
//
pushAttrValue(index){
let obj = JSON.parse(JSON.stringify(this.$refs['priceRef'][index].singleSpecification));
obj.sku = '';
this.setFormData.attrValue.push(obj);
},
//
deleteByIndex(index) {
this.deleteIndex = +index;
this.showDelete = true;
},
//
deleteAttr() {
this.setFormData.attrValue[this.deleteIndex].is_d_show = true;
this.showDelete = false;
},
//
initDataEditData() {
this.setFormData = {
@ -387,7 +416,7 @@
cate_name: '', //
mer_cate_id: '', //
mer_cate_name: '', //
unit_name: '', //
unit_name: '', //
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
@ -419,23 +448,9 @@
if (res.data.content && typeof res.data.content == 'string') res.data.content = JSON.parse(res.data
.content);
this.setFormData.once_min_count <= 0 ? this.setFormData.once_min_count = '' : null;
if(res.data.attr.length==1&&res.data.attr[0].value=='单位'&&res.data.attr[0].detail.length==2){ //
if(res.data.attr.length==1&&res.data.attr[0].value=='规格'){ //
this.setFormData.spec_type = 0;
}
if(res.data.attr.length==1&&res.data.attr[0].value=='单位'){
if(res.data.attrValue[0].sku=='件'||res.data.attrValue[1].sku=='个') {
this.tips1 = '提供给B端商户';
this.tips2 = '提供给C端用户';
}
else if(res.data.attrValue[0].sku=='个'||res.data.attrValue[1].sku=='件') {
this.tips1 = '提供给C端用户';
this.tips2 = '提供给B端商户';
}
else {
this.tips1 = '';
this.tips2 = '';
}
}
//
this.$nextTick(() => {
this.$refs.commodityRef.setDatas({
@ -452,10 +467,10 @@
}
})
//
if (this.setFormData.spec_type == 0) {
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
this.$refs.priceRef2.setDatas(res.data.attrValue[1]);
}
// if (this.setFormData.spec_type == 0) {
// this.$refs.priceRef.setDatas(res.data.attrValue[0]);
// this.$refs.priceRef2.setDatas(res.data.attrValue[1]);
// }
})
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
hideLoading();
@ -636,9 +651,9 @@
// return console.log('', this.setFormData.spec_type);
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
if (this.setFormData.spec_type == 0) {
console.log('价格库存', this.$refs.priceRef.singleSpecification);
}
// if (this.setFormData.spec_type == 0) {
// console.log('', this.$refs.priceRef.singleSpecification);
// }
let postData = {
...this.setFormData,
...this.$refs.commodityRef.addGoodsSecoundData,
@ -649,21 +664,30 @@
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
};
if (this.setFormData.spec_type == 0) {
postData.attrValue = [this.$refs.priceRef.singleSpecification, this.$refs.priceRef2.singleSpecification];
// console.log(this.$refs.priceRef);
let listarr = [];
this.$refs.priceRef.forEach((item, index)=>{
if(!this.setFormData.attrValue[index].is_d_show){
// console.log(item.singleSpecification, index);
listarr.push(item.singleSpecification);
}
})
postData.attrValue = listarr;
} 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('');
// 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);
let showFlag = '';
postData.attrValue.forEach(t => {
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.single_number || +t.single_number <= 0) showFlag = '零售价不能小于0';
if (!t.stock || +t.stock <= 0) showFlag = '库存不能小于0';
// if (!t.cost || +t.cost <= 0) showFlag = '0';
})
@ -675,20 +699,18 @@
if(this.setFormData.spec_type == 0){
postData.unit_name = '无'
postData.attr = [{
value: '单位',
detail: [
postData.attrValue[0].sku,
postData.attrValue[1].sku,
]
value: '规格',
detail: []
}]
postData.attrValue[0].detail = {
"单位": postData.attrValue[0].sku
},
postData.attrValue[1].detail = {
"单位": postData.attrValue[1].sku
},
postData.attr[0].detail = postData.attrValue.map(item=>item.sku);
postData.attrValue.forEach(item=>{
item.detail = {
"规格": item.sku
}
})
postData.spec_type = 1; //使
}
if(postData.attrValue.length==0)return Toast('请填写规格')
if (this.product_id) {
productUpdate(this.merId, this.product_id, postData)
.then(res => {
@ -736,7 +758,9 @@
changeSpecType2() {
this.showSpecType = false;
this.setFormData.spec_type = this.spec_type + '';
this.setFormData.attrValue = [];
this.setFormData.attrValue = [
{}
];
this.setFormData.attr = [];
},
//
@ -772,4 +796,23 @@
height: 20px;
margin: 30px auto;
}
.head_close {
position: relative;
.delete_btn {
position: absolute;
top: -15rpx;
right: 10rpx;
width: 40rpx;
height: 40rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: red;
color: #fff;
border-radius: 50%;
}
}
</style>

View File

@ -34,10 +34,11 @@
cost: '', //
stock: '', //
ot_price: '', //
procure_price: '', //
procure_price: '', //
bar_code: '', //
weight: '', //
volume: '', //
single_number: '', //
// image: '',
extension_one: '',
extension_two: ''
@ -46,10 +47,10 @@
formList: [
{
id: 0,
label: '单位',
label: '规格',
type: 'input',
model: 'sku',
holder: '请填写单位',
holder: '请填写规格名称',
require: true,
}, {
id: 1,
@ -146,15 +147,14 @@
// this.singleSpecification = this.$props.datas;
// this.$set(this, 'singleSpecification', this.$props.datas);
Object.keys(this.singleSpecification).forEach((key)=>{
this.singleSpecification[key] = this.$props.datas[key]
this.singleSpecification[key] = this.$props.datas[key] || ''
})
}
console.log(this.singleSpecification.sku);
if(!this.singleSpecification.sku) this.singleSpecification.sku = this.$props.sku + '';
// console.log(this.singleSpecification.sku);
let userInfo = this.$store.state.app.userInfo;
if(typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
//
//
// if(userInfo.mer_info?.type_code=="TypeSupplyChain"){
// let list = []
// this.formList = [...list, ...this.formList]

View File

@ -416,10 +416,10 @@
flag = false;
str = '库存不能小于等于0';
}
else if (!item.cost||+item.cost<=0) {
flag = false;
str = '成本价不能小于等于0';
}
// else if (!item.cost||+item.cost<=0) {
// flag = false;
// str = '0';
// }
else if ((!item.procure_price||+item.procure_price<=0) && this.userInfo.mer_info.type_code == 'TypeSupplyChain') {
flag = false;
str = '批发价不能小于等于0';