Commit 5ab3a7a3 authored by liwenhong's avatar liwenhong

fix:分销回滚

parent abc6f351
......@@ -381,14 +381,6 @@
></el-input>
<span v-else>{{ goodsObj.original_price }}</span>
</el-form-item>
<el-form-item label="结算价">
<el-input
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.clear_price"
@change="perPrice"
></el-input>
<span v-else>{{ goodsObj.clear_price }}</span>
</el-form-item>
<h4 style="margin:20px 0">库存信息</h4>
<el-form-item label="剩余库存量:">
<span>{{ goodsObj.inventory_rest }}</span>
......@@ -1175,14 +1167,23 @@ export default {
},
// 更改原价
perPrice (val) {
if (val.length === 0) val = 0;
const parseOriginalPrice = Number(val).toFixed(2);
val = Number(parseOriginalPrice);
if (typeof val === "number" &&isNaN(val)) {
val = 0;
return this.$message.error("原价价格必为数字");
perPrice () {
if (!this.goodsObj.original_price || this.goodsObj.original_price == 0) {
this.$nextTick(() => {
this.goodsObj.original_price = "";
})
}
const parseOriginalPrice = Number(this.goodsObj.original_price).toFixed(
2
);
this.goodsObj.original_price = Number(parseOriginalPrice);
// if (
// typeof this.goodsObj.original_price === "number" &&
// isNaN(this.goodsObj.original_price)
// ) {
// this.goodsObj.original_price = "";
// return this.$message.error("原价价格必为数字");
// }
},
// 审核通过
......@@ -1299,10 +1300,6 @@ export default {
}
console.log(query);
// 是否该商品关联的分销活动满足售价-分销总金额>=结算价
// if (query.price - d >= query.clear_price) {
// return this.$message.error("请至少选择一个门店");
// }
const res = await editGoods(query);
if (res.code !== 0) {
......
......@@ -200,12 +200,6 @@
></el-input>
<div style="margin: 20px 0"></div>
</el-form-item>
<el-form-item prop="commission_mode" label="金额计算方式:">
<el-radio-group v-model="ruleForm.commission_mode">
<el-radio :label="2">按金额</el-radio>
<el-radio :label="1">按比例</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="上线佣金:" prop="first_commission_value">
<el-input
v-model="ruleForm.first_commission_value"
......@@ -213,9 +207,7 @@
@input="changeValue($event, 'first_commission_value')"
:disabled="shopStart !== 0"
>
<template #append>{{
ruleForm.commission_mode == 1 ? "%" : "¥"
}}</template>
<template #append>%</template>
</el-input>
</el-form-item>
<el-form-item label="分享者佣金: " prop="second_commission_value">
......@@ -225,9 +217,7 @@
@input="changeValue($event, 'second_commission_value')"
:disabled="shopStart !== 0"
>
<template #append>{{
ruleForm.commission_mode == 1 ? "%" : "¥"
}}</template>
<template #append>%</template>
</el-input>
</el-form-item>
<el-form-item label="活动生效时间:">
......@@ -344,13 +334,13 @@ import {
getFindGoodsList,
getAddMarketingList,
getMarketingInfo,
updateMarketingList
updateMarketingList,
} from "@/service/Goods/goods";
import { ElMessage } from "element-plus";
// 开启关闭防抖
function debounce(callback, delay) {
let timer = null;
return function(...args) {
return function (...args) {
if (timer) {
clearTimeout(timer);
}
......@@ -363,16 +353,15 @@ function debounce(callback, delay) {
export default {
name: "GoodsRetail",
components: {
Layout
Layout,
},
data() {
var commission = (rule, value, callback) => {
if (
this.ruleForm.commission_mode == 1 &&
(this.ruleForm.first_commission_value +
this.ruleForm.first_commission_value +
this.ruleForm.second_commission_value >
50 ||
value > 50)
value > 50
) {
callback(new Error("上线佣金与分享者佣金之和不可大于50%"));
} else {
......@@ -387,14 +376,14 @@ export default {
first_commission_value: "",
second_commission_value: "",
start_time: "",
end_time: ""
end_time: "",
},
goods_list: [],
options: [
{ value: 0, label: "全部" },
{ value: 1, label: "启用" },
{ value: 2, label: "关闭" },
{ value: 3, label: "到期" }
{ value: 3, label: "到期" },
],
// 搜索条件
retailActivitie: {
......@@ -404,43 +393,42 @@ export default {
online_status: [],
page: 1,
page_size: 20,
count: 0
count: 0,
},
ruleForm: {
marketing_name: "",
commission_mode: 1,
first_commission_value: "",
second_commission_value: "",
start_time: "",
end_time: "",
goods_spu_id: []
goods_spu_id: [],
},
timeSelect: [],
ruleIdForm: {
life_account_id: "",
goods_spu_id: "",
start_time: "",
end_time: ""
end_time: "",
},
rules: {
marketing_name: [
{ required: true, message: "请输入活动名称", trigger: "blur" },
{ min: 1, max: 50, message: "活动名称不能大于50", trigger: "blur" }
{ min: 1, max: 50, message: "活动名称不能大于50", trigger: "blur" },
],
second_commission_value: [
{
required: true,
message: "请填写分享者佣金",
trigger: "blur"
trigger: "blur",
},
{ type: "number", message: "必须为数值型" },
{ validator: commission }
{ validator: commission },
],
first_commission_value: [
{ type: "number", message: "必须为数值型" },
{ validator: commission }
]
{ validator: commission },
],
},
allList: [],
dialogFormVisible: false,
......@@ -449,7 +437,7 @@ export default {
endTime: "",
marketing_id: "",
marketing_info: {},
disabled: false
disabled: false,
};
},
methods: {
......@@ -493,11 +481,11 @@ export default {
}
},
// 开启关闭
handelEnable: debounce(async function(row, type) {
handelEnable: debounce(async function (row, type) {
try {
const res = await updateMarketingList({
marketing_id: row.marketing_id,
online_status: type
online_status: type,
});
if (res.code !== 0) {
ElMessage.error(res.reason);
......@@ -522,7 +510,7 @@ export default {
goods_sku_id: "",
online_status: [],
page: 1,
page_size: 20
page_size: 20,
}),
this.$refs[retailActivitie].resetFields();
this.getMarketingList({});
......@@ -580,7 +568,7 @@ export default {
goods_spu_id,
life_account_id,
start_time,
end_time
end_time,
};
try {
// 发请求
......@@ -593,18 +581,18 @@ export default {
}
},
selectGoodsChange(e) {
this.ruleForm.goods_spu_id = e.map(item => item.goods_sku_id);
this.ruleForm.goods_spu_id = e.map((item) => item.goods_sku_id);
},
async getAllList() {
let all = await getMarketingList({
page: 1,
page_size: this.retailActivitie.count
page_size: this.retailActivitie.count,
});
this.allList = all.result;
},
// 添加活动列表
async addList() {
this.$refs.ruleForm.validate(async valid => {
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
console.log(this.ruleForm.goods_spu_id);
if (this.ruleForm.goods_spu_id.length <= 0) {
......@@ -618,8 +606,7 @@ export default {
let {
marketing_name,
first_commission_value,
commission_mode,
second_commission_value
second_commission_value,
} = this.ruleForm;
let [start_time, end_time] = this.timeSelect || [];
if (
......@@ -633,12 +620,11 @@ export default {
}
let addParams = {
goods_sku_id,
commission_mode,
marketing_name,
first_commission_value: first_commission_value + "",
second_commission_value: second_commission_value + "",
start_time: this.formatTime(start_time),
end_time: this.formatTime(end_time)
end_time: this.formatTime(end_time),
};
try {
const res = await getAddMarketingList(addParams);
......@@ -665,7 +651,7 @@ export default {
second_commission_value: "",
start_time: "",
end_time: "",
goods_spu_id: []
goods_spu_id: [],
}),
(this.timeSelect = []),
(this.goods_list = []),
......@@ -673,7 +659,7 @@ export default {
life_account_id: "",
goods_spu_id: "",
start_time: "",
end_time: ""
end_time: "",
});
},
// 取消
......@@ -681,12 +667,12 @@ export default {
this.dialogFormVisible = false;
this.resetDate();
this.getMarketingList();
}
},
},
created() {
this.getMarketingList();
this.getAllList();
}
},
};
</script>
<style lang="less" scoped>
......
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