Commit 5ab3a7a3 authored by liwenhong's avatar liwenhong

fix:分销回滚

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