Commit e09d6425 authored by mengwenhao's avatar mengwenhao

fix:修改价格校验标准

parent a9f986e4
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
show-word-limit show-word-limit
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.goods_name" v-model="goodsObj.goods_name"
@blur="()=>{this.checkSameName();}"
></el-input> ></el-input>
<span v-else>{{ goodsObj.goods_name }}</span> <span v-else>{{ goodsObj.goods_name }}</span>
</el-form-item> </el-form-item>
...@@ -163,7 +164,6 @@ ...@@ -163,7 +164,6 @@
<el-input <el-input
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
type="textarea" type="textarea"
:readonly="true"
:autosize="{ minRows: 4 }" :autosize="{ minRows: 4 }"
v-model="goodsObj.introduce" v-model="goodsObj.introduce"
></el-input> ></el-input>
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
<el-popover <el-popover
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
placement="bottom" placement="bottom"
:width="600" :width="800"
trigger="click" trigger="click"
> >
<template #reference> <template #reference>
...@@ -307,7 +307,11 @@ ...@@ -307,7 +307,11 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="联系电话:"> <el-form-item label="联系电话:">
<el-input v-model="shopForm.connect_phone"></el-input> <el-input
v-model="shopForm.connect_phone"
maxlength="11"
show-word-limit
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="地址:"> <el-form-item label="地址:">
<el-input v-model="shopForm.address"></el-input> <el-input v-model="shopForm.address"></el-input>
...@@ -329,7 +333,7 @@ ...@@ -329,7 +333,7 @@
type="primary" type="primary"
@click="addShop" @click="addShop"
>保存</el-button> >保存</el-button>
<el-button @click="addShopShow = false">取消</el-button> <el-button @click="closeAddShops">取消</el-button>
</section> </section>
</el-popover> </el-popover>
</el-popover> </el-popover>
...@@ -678,7 +682,7 @@ export default { ...@@ -678,7 +682,7 @@ export default {
optionsValue: [], // 商品分类的值 optionsValue: [], // 商品分类的值
// 商品回显信息 // 商品回显信息
goodsObj: { goodsObj: {
introduce: "" introduce: "", // 商品介绍
}, },
isGoodsNameRepeat: false, // 商品名称是否重复 isGoodsNameRepeat: false, // 商品名称是否重复
...@@ -890,20 +894,22 @@ export default { ...@@ -890,20 +894,22 @@ export default {
}; };
if (!query.shop_name) { if (!query.shop_name) {
return this.$message.error("请填写门店名称"); return this.$message.error("请填写门店名称");
}; }
if (!query.address) { if (!query.address) {
return this.$message.error("请填写门店地址"); return this.$message.error("请填写门店地址");
}; }
if (!query.phone) { if (!query.phone) {
return this.$message.error("请填写联系电话"); return this.$message.error("请填写联系电话");
} }
if (!query.longitude || !query.latitude) { if (!query.longitude || !query.latitude) {
return this.$message.error("请填写地理定位"); return this.$message.error("请填写地理定位");
}; }
if (!/([0-9]{3,4}-)?[0-9]{7,8}/.test(query.phone) && !/^[1][3,4,5,7,8,9][0-9]{9}$/.test(query.phone)) { if (
!/([0-9]{3,4}-)?[0-9]{7,8}/.test(query.phone) &&
!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(query.phone)
) {
return this.$message.error("联系电话格式不正确"); return this.$message.error("联系电话格式不正确");
}; }
const res = await postAddShop(query); const res = await postAddShop(query);
if (res.code !== 0) return this.$message.error(res.reason); if (res.code !== 0) return this.$message.error(res.reason);
...@@ -930,6 +936,15 @@ export default { ...@@ -930,6 +936,15 @@ export default {
this.getShops(); this.getShops();
}, },
// 取消新建门店
closeAddShops () {
this.shopForm.shop_name = "";
this.shopForm.address = "";
this.shopForm.connect_phone = "";
this.shopForm.deep_place = "";
this.addShopShow = false;
},
// 商品分类列表变化 // 商品分类列表变化
optionsChange (value) { optionsChange (value) {
this.optionsValue = value; this.optionsValue = value;
...@@ -938,6 +953,7 @@ export default { ...@@ -938,6 +953,7 @@ export default {
// 检查商品名称是否重复 // 检查商品名称是否重复
async checkSameName () { async checkSameName () {
console.log(1);
const res = await checkGoodsName({ const res = await checkGoodsName({
life_account_id: this.goodsObj.life_account_id, life_account_id: this.goodsObj.life_account_id,
goods_name: this.goodsObj.goods_name, goods_name: this.goodsObj.goods_name,
...@@ -978,8 +994,8 @@ export default { ...@@ -978,8 +994,8 @@ export default {
// 剩余库存量更改 // 剩余库存量更改
hasNumber () { hasNumber () {
if (!this.goodsObj.inventory_rest || this.goodsObj.inventory_rest < 0) { if (!this.goodsObj.inventory_rest || this.goodsObj.inventory_rest < 0) {
this.goodsObj.inventory_rest = 0 this.goodsObj.inventory_rest = 0;
}; }
}, },
// 选择时间 // 选择时间
...@@ -1055,16 +1071,16 @@ export default { ...@@ -1055,16 +1071,16 @@ export default {
// 更改售价 // 更改售价
salePrice () { salePrice () {
if (this.goodsObj.price.length === 0) { if (this.goodsObj.price.length === 0) {
this.goodsObj.price = 0 this.goodsObj.price = 0;
}; }
this.goodsObj.price = parseFloat(this.goodsObj.price).toFixed(2); this.goodsObj.price = parseFloat(this.goodsObj.price).toFixed(2);
}, },
// 更改原价 // 更改原价
perPrice () { perPrice () {
if (this.goodsObj.original_price.length === 0) { if (this.goodsObj.original_price.length === 0) {
this.goodsObj.original_price = 0 this.goodsObj.original_price = 0;
}; }
this.goodsObj.original_price = parseFloat( this.goodsObj.original_price = parseFloat(
this.goodsObj.original_price this.goodsObj.original_price
).toFixed(2); ).toFixed(2);
...@@ -1121,7 +1137,6 @@ export default { ...@@ -1121,7 +1137,6 @@ export default {
}; };
console.log(query); console.log(query);
this.checkSameName();
// 必填校验 // 必填校验
if (!this.goodsObj.goods_spu_id) { if (!this.goodsObj.goods_spu_id) {
return this.$message.error("未传入商品id"); return this.$message.error("未传入商品id");
...@@ -1138,33 +1153,38 @@ export default { ...@@ -1138,33 +1153,38 @@ export default {
if (!query.expiration_time) { if (!query.expiration_time) {
return this.$message.error("过期时间未填写,请填写后再提交"); return this.$message.error("过期时间未填写,请填写后再提交");
}; };
if (!query.rule_limit) { if (query.rule_limit === "") {
return this.$message.error("请填写单人可购买上限"); return this.$message.error("请填写单人可购买上限");
}; };
if (typeof parseInt(query.rule_limit) !== "number") {
return this.$message.error("单人可购上线只可为数值");
};
if (!query.rule_desc) { if (!query.rule_desc) {
return this.$message.error("请填写使用规则描述"); return this.$message.error("请填写使用规则描述");
}; };
if (!query.rule_refund) { if (!query.rule_refund) {
return this.$message.error("请填写退款规则"); return this.$message.error("请填写退款规则");
}; }
if (!query.inventory_add.length === 0) { if (query.inventory_add.length === 0) {
return this.$message.error("请填写库存剩余量"); return this.$message.error("请填写库存剩余量");
}; }
if (!query.original_price) { if (query.original_price.length === 0) {
return this.$message.error("请填写原价(保留两位小数)"); return this.$message.error("请填写原价(保留两位小数)");
}; }
if (typeof query.original_price !== "number") { if (query.price.length === 0) {
return this.$message.error("请填写售价(保留两位小数)");
}
console.log(typeof parseInt(query.original_price));
if (typeof parseInt(query.original_price) !== "number") {
return this.$message.error("原价价格必须为数字"); return this.$message.error("原价价格必须为数字");
}; }
if (typeof query.price !== "number") { if (typeof parseInt(query.price) !== "number") {
return this.$message.error("售价价格必须为数字格式"); return this.$message.error("售价价格必须为数字格式");
}; }
if (!query.price) {
return this.$message.error("请填写现价(保留两位小数)");
};
if (!query.sub_shop_ids) { if (!query.sub_shop_ids) {
return this.$message.error("请填写门店id"); return this.$message.error("请填写门店id");
}; }
const res = await editGoods(query); const res = await editGoods(query);
if (res.code !== 0) { if (res.code !== 0) {
......
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