Commit 1b729564 authored by mengwenhao's avatar mengwenhao

fix:商品-下架按钮显示/商品价格复显

parent e09d6425
......@@ -63,7 +63,7 @@
show-word-limit
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.goods_name"
@blur="()=>{this.checkSameName();}"
@blur="checkSameName"
></el-input>
<span v-else>{{ goodsObj.goods_name }}</span>
</el-form-item>
......@@ -402,6 +402,7 @@
<el-input-number
v-if="$route.params.operation === 'EDIT'"
:min="0"
:precision="0"
v-model="goodsObj.rule_limit"
></el-input-number>
<span v-else>{{ goodsObj.rule_limit }}</span>
......@@ -682,9 +683,10 @@ export default {
optionsValue: [], // 商品分类的值
// 商品回显信息
goodsObj: {
introduce: "", // 商品介绍
introduce: "" // 商品介绍
},
originalGoodsName: "", // 原商品名
isGoodsNameRepeat: false, // 商品名称是否重复
descPicUrlList: [], // 商品详情图回显列表
......@@ -757,7 +759,6 @@ export default {
const res = await getGoodsList();
if (res.code !== 0) return this.$message.error(res.reason);
this.optionList = res.result;
console.log(res);
} catch (error) {
console.error(error);
}
......@@ -774,6 +775,8 @@ export default {
const { goods_info, record_list } = res.result;
this.goodsObj = goods_info;
this.recordLits = record_list;
// 初始商品名称
this.originalGoodsName = goods_info.goods_name;
// 渲染过期时间
this.expirationTime = goods_info.expiration_time;
// 初始化门店id
......@@ -815,7 +818,6 @@ export default {
uploadPicture (response, storageList) {
const responseURL = `${response.result.bucket}/${response.result.object_id}`;
storageList.push(responseURL);
console.log("已上传的列表", storageList);
},
// 删除图片的公共方法
deletePicture (file, fileList, storageList) {
......@@ -824,7 +826,6 @@ export default {
storageList.splice(i, 1);
}
}
console.log(storageList);
},
// 格式化日期
......@@ -862,7 +863,6 @@ export default {
page_size: 5
};
const res = await getShopsList(query);
console.log(res);
if (res.code !== 0) return this.$message.error(res.reason);
this.shopsList = res.result;
this.shopsCount = res.count;
......@@ -876,7 +876,6 @@ export default {
});
this.shopIds = "";
this.shopIds = shopList.join(",");
console.log(this.shopIds);
},
// 添加新门店
......@@ -915,7 +914,6 @@ export default {
if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("添加门店成功!");
this.addShopShow = false;
console.log(res);
},
// 删除已选择门店
......@@ -927,7 +925,6 @@ export default {
return item.sub_shop_id;
});
this.shopIds = shopIdsList.join(",");
console.log(this.shopIds);
},
// 商品列表换页
......@@ -948,12 +945,10 @@ export default {
// 商品分类列表变化
optionsChange (value) {
this.optionsValue = value;
console.log("商品分类id", this.optionsValue);
},
// 检查商品名称是否重复
async checkSameName () {
console.log(1);
const res = await checkGoodsName({
life_account_id: this.goodsObj.life_account_id,
goods_name: this.goodsObj.goods_name,
......@@ -963,9 +958,12 @@ export default {
if (res.code !== 0) return this.$message.error(res.reason);
if (res.result.can_use) {
this.isGoodsNameRepeat = true;
} else if (this.originalGoodsName === this.goodsObj.goods_name) {
this.isGoodsNameRepeat = true;
} else {
this.isGoodsNameRepeat = false;
}
console.log("商品名称是否可用", this.isGoodsNameRepeat);
},
// 商品详情图上传成功时
......@@ -1070,20 +1068,30 @@ export default {
// 更改售价
salePrice () {
const parsePrice = parseFloat(this.goodsObj.price).toFixed(2);
if (this.goodsObj.price.length === 0) {
this.goodsObj.price = 0;
}
this.goodsObj.price = parseFloat(this.goodsObj.price).toFixed(2);
if (typeof parsePrice !== "number") {
this.goodsObj.price = 0;
return this.$message.error("售价必为数字");
}
this.goodsObj.price = parsePrice;
},
// 更改原价
perPrice () {
const parseOriginalPrice = parseFloat(
this.goodsObj.original_price
).toFixed(2);
if (this.goodsObj.original_price.length === 0) {
this.goodsObj.original_price = 0;
}
this.goodsObj.original_price = parseFloat(
this.goodsObj.original_price
).toFixed(2);
if (typeof parseOriginalPrice !== "number") {
this.goodsObj.original_price = 0;
return this.$message.error("原价必为数字");
}
this.goodsObj.original_price = parseOriginalPrice;
},
// 审核通过
......@@ -1115,6 +1123,7 @@ export default {
// 保存修改信息
async saveDetailMessage () {
await this.checkSameName(); // 检验商品名称是否可用
const query = {
goods_spu_id: this.goodsObj.goods_spu_id, // 商品id
category_1_id: this.optionsValue[0], // 商品一级分类id
......@@ -1140,28 +1149,31 @@ export default {
// 必填校验
if (!this.goodsObj.goods_spu_id) {
return this.$message.error("未传入商品id");
};
}
if (!query.category_1_id || !query.category_2_id) {
return this.$message.error("请选择商品分类");
};
}
if (!query.goods_name) {
return this.$message.error("请填写商品名称");
};
}
if (!this.isGoodsNameRepeat) {
return this.$message.error("商品名称被占用,请重新更换商品名称");
};
}
if (!query.expiration_time) {
return this.$message.error("过期时间未填写,请填写后再提交");
};
}
if (query.rule_limit === "") {
return this.$message.error("请填写单人可购买上限");
};
if (typeof parseInt(query.rule_limit) !== "number") {
}
if (typeof this.goodsObj.rule_limit !== "number") {
return this.$message.error("单人可购买上限只能为数字格式");
}
if (typeof query.rule_limit !== "number") {
return this.$message.error("单人可购上线只可为数值");
};
}
if (!query.rule_desc) {
return this.$message.error("请填写使用规则描述");
};
}
if (!query.rule_refund) {
return this.$message.error("请填写退款规则");
}
......@@ -1174,11 +1186,10 @@ export default {
if (query.price.length === 0) {
return this.$message.error("请填写售价(保留两位小数)");
}
console.log(typeof parseInt(query.original_price));
if (typeof parseInt(query.original_price) !== "number") {
if (typeof query.original_price !== "number") {
return this.$message.error("原价价格必须为数字");
}
if (typeof parseInt(query.price) !== "number") {
if (typeof query.price !== "number") {
return this.$message.error("售价价格必须为数字格式");
}
......
.goods {
width: 100%;
height: 100%;
padding: 0 30px;
}
.goods .search_condition {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
align-items: center;
}
.goods .search_condition .search_button {
display: flex;
align-items: center;
justify-self: flex-end;
}
.goods .search_condition .search_button .el-form-item__content {
display: flex;
justify-content: space-around;
}
.goods .commodity_list {
margin-top: 30px;
}
.goods .pagination {
margin-top: 30px;
}
......@@ -135,15 +135,15 @@
>审核驳回</span>
&nbsp;&nbsp;&nbsp;
<span
v-if="scope.row.online_status == 0"
v-if="scope.row.online_status == 0 && scope.row.audit_status != 2"
style="color:#FF982C;"
>未上架</span>
<span
v-if="scope.row.online_status == 1"
v-if="scope.row.online_status == 1 && scope.row.audit_status != 2"
style="color:#5CC247;"
>已上架</span>
<span
v-if="scope.row.online_status == 2"
v-if="scope.row.online_status == 2 && scope.row.audit_status != 2"
style="color:#FD6B6F;"
>已下架</span>
</template>
......@@ -189,7 +189,7 @@
</el-popconfirm>
<el-popconfirm
v-if="scope.row.audit_status == 1 || scope.row.online_status == 1"
v-if=" scope.row.online_status != 2 && (scope.row.audit_status == 1 || scope.row.online_status == 1) "
title="您确定要下架该商品吗?"
cancelButtonType="default"
@confirm="
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment