Commit e0d63de7 authored by gengshaojing's avatar gengshaojing

fix: 商品去重

parent 4f5f1b64
<template> <template>
<div class="releaseProducBox"> <div class="releaseProducBox">
<div class="releaseProduc"> <div class="releaseProduc">
<h4 class="headTitle">发布活动</h4> <h4 class="headTitle">发布活动</h4>
<el-steps <el-steps class="steps" :active="active" finish-status="success" space="30%" :align-center="true">
class="steps" <el-step title="信息编辑" @click="step1"></el-step>
:active="active" <el-step title="添加商品" @click="step2"></el-step>
finish-status="success" <el-step title="拼单设置" @click="step3"></el-step>
space="30%" </el-steps>
:align-center="true" <div class="content">
> <infoEditing ref="infoEdit" v-show="active === 1" :infoEditArr="infoEditArr" />
<el-step title="信息编辑" @click="step1"></el-step> <addProduc ref="addProduc" v-show="active === 2" :addProduc="addProducArr" :editInfo="infoEditArr" :stepTwoTitle="stepTwoTitle" />
<el-step title="添加商品" @click="step2"></el-step> <spellOrderSet
<el-step title="拼单设置" @click="step3"></el-step> ref="spellOrderSet"
</el-steps> v-show="active === 3"
<div class="content"> :spellOrderSetArr="spellOrderSetArr"
<infoEditing :startTime="startTime"
ref="infoEdit" :endTime="endTime"
v-show="active === 1" @getTakeTakePlaceListFromChild="getTakeTakePlaceListFromChild"
:infoEditArr="infoEditArr" />
/> </div>
<addProduc </div>
ref="addProduc" <div class="stepsBtn">
v-show="active === 2" <el-button @click="prev" v-show="active >= 2" style="margin-right: 20px">上一步</el-button>
:addProduc="addProducArr" <el-button @click="next" v-show="active < 3" style="margin-right: 20px">下一步</el-button>
:editInfo="infoEditArr" <el-button @click="cancel" v-show="active == 1">取消</el-button>
:stepTwoTitle="stepTwoTitle" <el-button @click="confirmRelease" v-show="active == 3" type="primary">确认发布</el-button>
/> </div>
<spellOrderSet
ref="spellOrderSet"
v-show="active === 3"
:spellOrderSetArr="spellOrderSetArr"
:startTime="startTime"
:endTime="endTime"
@getTakeTakePlaceListFromChild="getTakeTakePlaceListFromChild"
/>
</div>
</div> </div>
<div class="stepsBtn">
<el-button @click="prev" v-show="active >= 2" style="margin-right: 20px"
>上一步</el-button
>
<el-button @click="next" v-show="active < 3" style="margin-right: 20px"
>下一步</el-button
>
<el-button @click="cancel" v-show="active == 1">取消</el-button>
<el-button @click="confirmRelease" v-show="active == 3" type="primary"
>确认发布</el-button
>
</div>
</div>
</template> </template>
<script> <script>
import dayJs from "dayjs"; import dayJs from "dayjs";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import infoEditing from "./components/infoEditing.vue"; import infoEditing from "./components/infoEditing.vue";
import addProduc from "./components/addProduc.vue"; import addProduc from "./components/addProduc.vue";
import spellOrderSet from "./components/spellOrderSet.vue"; import spellOrderSet from "./components/spellOrderSet.vue";
import { getCookie } from "@/utils/util"; import { getCookie } from "@/utils/util";
import { import { addMarketing, marketingInfo, updateMarketing } from "../../../service/Activity/index";
addMarketing, export default {
marketingInfo, components: {
updateMarketing infoEditing,
} from "../../../service/Activity/index"; addProduc,
export default { spellOrderSet,
components: { },
infoEditing, data() {
addProduc, return {
spellOrderSet active: 1, // 步骤条状态
}, infoEditArr: [], // 信息编辑数据
data() { addProducArr: [], // 添加商品
return { goodsSkuIDArr: [], // 接收goods_sku_id
active: 1, // 步骤条状态 spellOrderSetArr: [],
infoEditArr: [], // 信息编辑数据 startDate: "", // 开始时间
addProducArr: [], // 添加商品 endDate: "", // 结束时间
goodsSkuIDArr: [], // 接收goods_sku_id takePlaceIDArr: [],
spellOrderSetArr: [], startTime: "",
startDate: "", // 开始时间 endTime: "",
endDate: "", // 结束时间 stepTwoTitle: "", // 传给addProduct的title
takePlaceIDArr: [], };
startTime: "", },
endTime: "",
stepTwoTitle: "" // 传给addProduct的title
};
},
methods: { methods: {
// 步骤条点击事件 // 步骤条点击事件
step1() { step1() {
if (this.$route.query.marketing_id != undefined) { if (this.$route.query.marketing_id != undefined) {
this.active = 1; this.active = 1;
} }
}, },
step2() { step2() {
if (this.$route.query.marketing_id != undefined) { if (this.$route.query.marketing_id != undefined) {
if (this.$refs.infoEdit.infoEditForm.title == "") { if (this.$refs.infoEdit.infoEditForm.title == "") {
ElMessage.error("请填写商品标题"); ElMessage.error("请填写商品标题");
return; return;
} }
this.active = 2; this.active = 2;
} }
}, },
step3() { step3() {
if (this.$route.query.marketing_id != undefined) { if (this.$route.query.marketing_id != undefined) {
if (this.$refs.infoEdit.infoEditForm.title == "") { if (this.$refs.infoEdit.infoEditForm.title == "") {
ElMessage.error("请填写商品标题"); ElMessage.error("请填写商品标题");
return; return;
} else if (this.$refs.addProduc.comTableData.length == 0) { } else if (this.$refs.addProduc.comTableData.length == 0) {
ElMessage.error("请至少选择一个商品"); ElMessage.error("请至少选择一个商品");
return; return;
} else { } else {
this.active = 3; this.active = 3;
} }
} }
}, },
// 上一步 // 上一步
prev() { prev() {
this.active--; this.active--;
}, },
// 下一步 // 下一步
next() { next() {
if (this.active === 1) { if (this.active === 1) {
if (this.$refs.infoEdit.infoEditForm.title == "") { if (this.$refs.infoEdit.infoEditForm.title == "") {
ElMessage.error("请填写商品标题"); ElMessage.error("请填写商品标题");
return; return;
} }
this.stepTwoTitle = this.$refs.infoEdit.infoEditForm.title; this.stepTwoTitle = this.$refs.infoEdit.infoEditForm.title;
this.active = 2; this.active = 2;
} else if (this.active === 2) { } else if (this.active === 2) {
if (this.$refs.addProduc.comTableData.length == 0) { if (this.$refs.addProduc.comTableData.length == 0) {
ElMessage.error("请至少选择一个商品"); ElMessage.error("请至少选择一个商品");
return; return;
} }
this.addProducArr = this.$refs.addProduc.comTableData; this.addProducArr = this.$refs.addProduc.comTableData;
this.active = 3; this.active = 3;
} }
}, },
// 获取营销活动详情 // 获取营销活动详情
async marketingInfoMet() { async marketingInfoMet() {
let marketingId = this.$route.query.marketing_id; let marketingId = this.$route.query.marketing_id;
if (marketingId == undefined) { if (marketingId == undefined) {
return; return;
} }
let params = { let params = {
marketing_id: marketingId, marketing_id: marketingId,
marketing_type: "4" marketing_type: "4",
}; };
const res = await marketingInfo(params); const res = await marketingInfo(params);
this.infoEditArr = res.result.marketing_info; this.infoEditArr = res.result.marketing_info;
this.addProducArr = res.result.goods_list; this.addProducArr = res.result.goods_list;
this.spellOrderSetArr = res.result.take_place; this.spellOrderSetArr = res.result.take_place;
this.startTime = res.result.marketing_info.start_time; this.startTime = res.result.marketing_info.start_time;
this.endTime = res.result.marketing_info.end_time; this.endTime = res.result.marketing_info.end_time;
localStorage.setItem("propData", JSON.stringify(this.infoEditArr)); localStorage.setItem("propData", JSON.stringify(this.infoEditArr));
}, },
// 取消 // 取消
cancel() { cancel() {
this.$router.go(-1); this.$router.go(-1);
}, },
// 确认发布 // 确认发布
async confirmRelease() { async confirmRelease() {
function getUrlParms(path, name) { function getUrlParms(path, name) {
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i"); var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
if (reg.test(path)) return unescape(RegExp.$2.replace(/\+/g, " ")); if (reg.test(path)) return unescape(RegExp.$2.replace(/\+/g, " "));
return ""; return "";
} }
let list = this.$refs.infoEdit.picSubmitList.map(item => { let list = this.$refs.infoEdit.picSubmitList.map((item) => {
let rs = getUrlParms(item.url, "url"); let rs = getUrlParms(item.url, "url");
return rs; return rs;
}); });
let picList = list.join(","); let picList = list.join(",");
for (var i in this.addProducArr) { for (var i in this.addProducArr) {
this.goodsSkuIDArr.push(this.addProducArr[i].goods_sku_id); this.goodsSkuIDArr.push(this.addProducArr[i].goods_sku_id);
} }
this.startDate = this.$refs.spellOrderSet.startDate; this.goodsSkuIDArr = [...new Set(this.goodsSkuIDArr)];
this.endDate = this.$refs.spellOrderSet.endDate; this.startDate = this.$refs.spellOrderSet.startDate;
let params = { this.endDate = this.$refs.spellOrderSet.endDate;
marketing_id: let params = {
this.$route.query.marketing_id == undefined marketing_id: this.$route.query.marketing_id == undefined ? "" : this.$route.query.marketing_id,
? "" goods_sku_id: this.goodsSkuIDArr.join(","),
: this.$route.query.marketing_id, marketing_name: this.$refs.infoEdit.infoEditForm.title,
goods_sku_id: this.goodsSkuIDArr.join(","), marketing_type: "4",
marketing_name: this.$refs.infoEdit.infoEditForm.title, op_cur_user: getCookie("username"),
marketing_type: "4", start_time: dayJs(this.startDate).format("YYYY-MM-DD HH:mm:ss"),
op_cur_user: getCookie('username'), end_time: dayJs(this.endDate).format("YYYY-MM-DD HH:mm:ss"),
start_time: dayJs(this.startDate).format("YYYY-MM-DD HH:mm:ss"), pindan_pic: picList,
end_time: dayJs(this.endDate).format("YYYY-MM-DD HH:mm:ss"), pindan_desc: this.$refs.infoEdit.infoEditForm.desc,
pindan_pic: picList, take_place_ids: this.takePlaceIDArr,
pindan_desc: this.$refs.infoEdit.infoEditForm.desc, };
take_place_ids: this.takePlaceIDArr if (this.$route.query.marketing_id == undefined) {
}; const res = await addMarketing(params);
if (this.$route.query.marketing_id == undefined) { if (res.code === 0) {
const res = await addMarketing(params); ElMessage.success({
if (res.code === 0) { message: "添加成功",
ElMessage.success({ type: "success",
message: "添加成功", });
type: "success" this.$router.push({ path: "/op/activity/manage" });
}); } else {
this.$router.push({ path: "/op/activity/manage" }); ElMessage.error(res.reason);
} else { }
ElMessage.error(res.reason); } else {
} const res = await updateMarketing(params);
} else { if (res.code === 0) {
const res = await updateMarketing(params); ElMessage.success({
if (res.code === 0) { message: "修改成功",
ElMessage.success({ type: "success",
message: "修改成功", });
type: "success" this.$router.push({ path: "/op/activity/manage" });
}); } else {
this.$router.push({ path: "/op/activity/manage" }); ElMessage.error(res.reason);
} else { }
ElMessage.error(res.reason); }
} },
} getTakeTakePlaceListFromChild(val) {
}, this.takePlaceIDArr = val;
getTakeTakePlaceListFromChild(val) { },
this.takePlaceIDArr = val; },
} created() {
}, this.marketingInfoMet();
created() { },
this.marketingInfoMet(); };
}
};
</script> </script>
<style lang="less" scope> <style lang="less" scope>
.releaseProduc { .releaseProduc {
height: 100%; height: 100%;
padding: 30px; padding: 30px;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
@media screen and (max-width: 800px) { @media screen and (max-width: 800px) {
// form表单 // form表单
.releaseProduc { .releaseProduc {
padding: 0; padding: 0;
} }
} }
.headTitle { .headTitle {
height: 30px; height: 30px;
width: 75%; width: 75%;
font-size: 18px; font-size: 18px;
margin: 0 auto 40px auto; margin: 0 auto 40px auto;
} }
.steps { .steps {
height: 60px; height: 60px;
} }
/* 内容cotent */ /* 内容cotent */
.content { .content {
flex-grow: 1; flex-grow: 1;
} }
.steps { .steps {
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-bottom: 35px; margin-bottom: 35px;
} }
.steps /deep/ .el-step__icon { .steps /deep/ .el-step__icon {
width: 50px; width: 50px;
height: 50px; height: 50px;
} }
.steps /deep/ .el-step.is-horizontal .el-step__line { .steps /deep/ .el-step.is-horizontal .el-step__line {
top: 25px; top: 25px;
} }
.stepsBtn { .stepsBtn {
width: 100%; width: 100%;
height: 80px; height: 80px;
line-height: 80px; line-height: 80px;
background: white; background: white;
/* position: fixed; /* position: fixed;
bottom: 0px; */ bottom: 0px; */
text-align: center; text-align: center;
z-index: 999; z-index: 999;
} }
</style> </style>
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