Commit 47740529 authored by pengyunqian's avatar pengyunqian

update:bugfile

parent 45347a81
......@@ -61,7 +61,7 @@
</el-table-column>
<el-table-column
align="center"
prop="commission_mode"
prop="good_count"
label="关联商品数"
>
</el-table-column>
......@@ -70,12 +70,26 @@
prop="first_commission_value"
label="一级分销金额"
>
<template #default="scope">
<span>
{{ scope.row.first_commission_value + "%" }}
</span>
</template>
</el-table-column>
<el-table-column
align="center"
prop="second_commission_value"
label="二级分销金额"
>
<template #default="scope">
<span>
{{
scope.row.second_commission_value
? scope.row.second_commission_value + "%"
: "0%"
}}
</span>
</template>
</el-table-column>
<el-table-column align="center" prop="online_status" label="状态">
<template #default="scope">
......@@ -185,7 +199,8 @@
</el-form-item>
<el-form-item label="一级佣金:" prop="first_commission_value">
<el-input
v-model.number="ruleForm.first_commission_value"
v-model="ruleForm.first_commission_value"
@input="changeValue($event, 'first_commission_value')"
:disabled="shopStart !== 0"
>
<template #append>%</template>
......@@ -193,7 +208,8 @@
</el-form-item>
<el-form-item label="二级佣金: " prop="second_commission_value">
<el-input
v-model.number="ruleForm.second_commission_value"
v-model="ruleForm.second_commission_value"
@input="changeValue($event, 'second_commission_value')"
:disabled="shopStart !== 0"
>
<template #append>%</template>
......@@ -289,21 +305,25 @@
</div>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="cancel" style="width: 150px">{{
shopStart == 0 ? "取消" : "返回"
}}</el-button>
<el-button
type="primary"
@click="addList"
style="width: 150px"
v-if="shopStart == 0"
>确 定</el-button
style="width: 150px"
>保存</el-button
>
<!-- {{
shopStart == 0 ? "返回" : "返回"
}} -->
<el-button type="primary" @click="cancel" style="width: 150px"
>返回</el-button
>
</span>
</template>
</el-dialog>
</template>
<script>
import Layout from "../layout/index.vue";
import {
getMarketingList,
getFindGoodsList,
......@@ -327,19 +347,22 @@ function debounce(callback, delay) {
}
export default {
name: "GoodsRetail",
components: {
Layout,
},
data() {
// var commission = (rule, value, callback) => {
// // if (!value) {
// // return callback(new Error("请填写一级佣金"));
// // }
// setTimeout(() => {
// if (!Number.isInteger(value)) {
// callback(new Error("请输入数字值"));
// } else {
// callback();
// }
// }, 100);
// };
var commission = (rule, value, callback) => {
if (
this.ruleForm.first_commission_value +
this.ruleForm.second_commission_value >
50 ||
value > 50
) {
callback(new Error("一级佣金与二级佣金之和不可大于50%"));
} else {
callback();
}
};
return {
tableData: [],
// 详情页
......@@ -386,25 +409,20 @@ export default {
rules: {
marketing_name: [
{ required: true, message: "请输入活动名称", trigger: "blur" },
{ min: 1, max: 50, message: "长度在 50个字符内", trigger: "blur" },
{ min: 1, max: 50, message: "活动名称不能大于50", trigger: "blur" },
],
first_commission_value: [
{
required: true,
// validator: commission,
message: "请填写一级佣金",
trigger: "blur",
},
{ type: "number", message: "必须为数值型" },
// { validator: commission, trigger: "change" },
{ validator: commission },
],
second_commission_value: [
{ type: "number", message: "必须为数值型" },
// {
// validator: commission,
// trigger: "change",
// },
{ validator: commission },
],
},
allList: [],
......@@ -418,6 +436,12 @@ export default {
};
},
methods: {
changeValue(value, level) {
if (value && value.indexOf(".") !== value.length - 1 && parseFloat(value))
this.ruleForm[level] = parseFloat(value);
else if (value && value.indexOf(".") === value.length - 1) return;
else this.ruleForm[level] = "";
},
// 查看详情列表
async handleClick(row) {
this.dialogFormVisible = true;
......@@ -451,33 +475,6 @@ export default {
ElMessage.error("请求获取营销活动失败");
}
},
// 关闭状态
// async handelClose(row) {
// try {
// await updateMarketingList({
// marketing_id: row.marketing_id,
// online_status: 2,
// });
// this.getMarketingList();
// ElMessage.success("状态已关闭");
// } catch (error) {
// ElMessage.error("请求关闭失败" + error.message);
// }
// },
//启用状态
// async handelEnable(row) {
// try {
// // const res = await updateMarketingList({
// await updateMarketingList({
// marketing_id: row.marketing_id,
// online_status: 1,
// });
// this.getMarketingList();
// ElMessage("状态已启用");
// } catch (error) {
// ElMessage("请求开启状态失败");
// }
// },
// 开启关闭
handelEnable: debounce(async function (row, type) {
try {
......@@ -485,7 +482,6 @@ export default {
marketing_id: row.marketing_id,
online_status: type,
});
// const res = {code:4150007,reason:"更新失败",status:"failed"}
if (res.code !== 0) {
ElMessage.error(res.reason);
} else {
......@@ -591,71 +587,56 @@ export default {
},
// 添加活动列表
async addList() {
console.log(this.ruleForm.goods_sku_id);
if (this.ruleForm.goods_sku_id.length <= 0) {
ElMessage("请选择商品");
return;
} else {
var goods_sku_id =
this.ruleForm.goods_sku_id && this.ruleForm.goods_sku_id.join(",");
}
// console.log(goods_sku_id);
let { marketing_name, first_commission_value, second_commission_value } =
this.ruleForm;
let [start_time, end_time] = this.timeSelect;
if (
!marketing_name ||
!first_commission_value ||
!start_time ||
!end_time
) {
ElMessage("请填写完整");
return;
}
let addParams = {
goods_sku_id,
marketing_name,
first_commission_value,
second_commission_value,
start_time: this.formatTime(start_time),
end_time: this.formatTime(end_time),
};
// let resList = [];
// // 遍历选择的商品
// this.allList.forEach((item) => {
// // 判断该活动是否是开启状态且时间与选择时间冲突
// if (item.online_status == 1 && new Date(item.end_time) > start_time) {
// // 如果开启且重复,根据活动id请求获取这个活动的详情,判断这个活动的关联商品是否与选择商品重复
// resList.push(getMarketingInfo({ marketing_id: item.marketing_id }));
// }
// });
// let skuList = await Promise.all(resList);
// skuList = skuList.map((item) => item.result.goods_list);
// skuList = skuList.flat();
// console.log(skuList);
// const ok = this.ruleForm.goods_sku_id.every((skuId) => {
// // 遍历所有的活动,判断选择的商品是否符合条件
// return !skuList.find((item) => {
// console.log(item.goods_sku_id, skuId);
// return item.goods_sku_id == skuId;
// });
// });
// if (ok) {
try {
const res = await getAddMarketingList(addParams);
if (res.status == "success") {
this.getMarketingList();
this.dialogFormVisible = false;
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
console.log(this.ruleForm.goods_sku_id);
if (this.ruleForm.goods_sku_id.length <= 0) {
ElMessage("请选择商品");
return;
} else {
var goods_sku_id =
this.ruleForm.goods_sku_id &&
this.ruleForm.goods_sku_id.join(",");
}
// console.log(goods_sku_id);
let {
marketing_name,
first_commission_value,
second_commission_value,
} = this.ruleForm;
let [start_time, end_time] = this.timeSelect;
if (
!marketing_name ||
!first_commission_value ||
!start_time ||
!end_time
) {
ElMessage("请填写完整");
return;
}
let addParams = {
goods_sku_id,
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),
};
try {
const res = await getAddMarketingList(addParams);
if (res.status == "success") {
this.getMarketingList();
this.dialogFormVisible = false;
} else {
ElMessage(res.reason);
}
} catch (error) {
ElMessage.error("请求创建活动失败");
}
} else {
ElMessage(res.reason);
return false;
}
// this.ruleIdForm = res.result;
} catch (error) {
ElMessage.error("请求创建活动失败");
}
// } else {
// ElMessage("已有该关联商品,请重新选择");
// }
});
},
// 清空
......@@ -695,8 +676,6 @@ export default {
display: flex;
width: 100%;
height: 100%;
.retail {
}
.but_one {
margin-left: 10px;
}
......
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