Commit ce9d8020 authored by 徐光星's avatar 徐光星

feat: 校验抢购活动和秒杀活动同渠道下多个活动ID的情况

parent 1b34c413
<template>
<div class="seckillActivityContainer">
<Button style="margin-bottom: 4px" @click="showRules">规则说明</Button>
<Button style="margin-bottom: 4px" @click="showRules" size="small">规则说明</Button>
<div>
<Button style="margin-bottom: 4px" type="primary" @click="openDialog">填写活动ID</Button>
</div>
......@@ -72,15 +72,47 @@ export default {
console.log('get activity base info = ', res)
if (res) {
// 判断活动类型是否符合当前组件
const invalidArr = res.filter(item => !item.activityTemplateType || (item.activityTemplateType && item.activityTemplateType != 1) )
if (invalidArr.length) {
let ids = '';
invalidArr.map(item => {
ids += `${item.id},`
})
this.$Notice.error({ title: '提示', desc: `以下活动id不符合当前活动组件: ${ids}`});
this.$Notice.error({ title: '提示', desc: `以下活动id不符合当前活动类型: ${ids}`});
return;
}
// 判断填入的活动ID是否存在重复的渠道ID的情况
const normalKey = 'common';
const validArr = res.filter(item => item.activityTemplateType && item.activityTemplateType == 1);
const channel2Id = {};
validArr.map(item => {
if (item.kaChannelNo) {
if (channel2Id[item.kaChannelNo]) {
const arr = channel2Id[item.kaChannelNo];
arr.push(item.id);
channel2Id[item.kaChannelNo] = arr;
} else {
channel2Id[item.kaChannelNo] = [item.id]
}
} else {
if (channel2Id[normalKey]) {
const arr = channel2Id[normalKey];
arr.push(item.id);
channel2Id[normalKey] = channel2Id[normalKey].push(item.id);
} else {
channel2Id[normalKey] = [item.id]
}
}
return item;
})
console.log(channel2Id, 'channel2Id')
for (let i in channel2Id) {
if (channel2Id[i].length > 1) {
this.$Notice.error({ title: '提示', desc: `${i == 'common' ? '通用渠道' : '渠道' + i}存在重复的活动ID: ${channel2Id[i].join(',')}`});
return;
}
}
}
this.showModal = false;
this.activityInfoId = this.cacheId;
......
......@@ -3,7 +3,7 @@
<!-- <Select v-model="activityInfoId" filterable>
<Option v-for="item in list" :value="item.id" :key="item.id">{{ `id ${item.id} - ${item.title}` }}</Option>
</Select> -->
<Button style="margin-bottom: 4px" @click="showRules">规则说明</Button>
<Button style="margin-bottom: 4px" @click="showRules" size="small">规则说明</Button>
<div>
<Button style="margin-bottom: 4px" type="primary" @click="openDialog">填写活动ID</Button>
</div>
......@@ -73,15 +73,47 @@ export default {
console.log('get activity base info = ', res)
if (res) {
// 判断活动类型是否符合当前组件
const invalidArr = res.filter(item => !item.activityTemplateType || (item.activityTemplateType && item.activityTemplateType != 11) )
if (invalidArr.length) {
let ids = '';
invalidArr.map(item => {
ids += `${item.id},`
})
this.$Notice.error({ title: '提示', desc: `以下活动id不符合当前活动组件: ${ids}`});
this.$Notice.error({ title: '提示', desc: `以下活动id不符合当前活动类型: ${ids}`});
return;
}
// 判断填入的活动ID是否存在重复的渠道ID的情况
const normalKey = 'common';
const validArr = res.filter(item => item.activityTemplateType && item.activityTemplateType == 1);
const channel2Id = {};
validArr.map(item => {
if (item.kaChannelNo) {
if (channel2Id[item.kaChannelNo]) {
const arr = channel2Id[item.kaChannelNo];
arr.push(item.id);
channel2Id[item.kaChannelNo] = arr;
} else {
channel2Id[item.kaChannelNo] = [item.id]
}
} else {
if (channel2Id[normalKey]) {
const arr = channel2Id[normalKey];
arr.push(item.id);
channel2Id[normalKey] = channel2Id[normalKey].push(item.id);
} else {
channel2Id[normalKey] = [item.id]
}
}
return item;
})
console.log(channel2Id, 'channel2Id')
for (let i in channel2Id) {
if (channel2Id[i].length > 1) {
this.$Notice.error({ title: '提示', desc: `${i == 'common' ? '通用渠道' : '渠道' + i}存在重复的活动ID: ${channel2Id[i].join(',')}`});
return;
}
}
}
this.showModal = false;
this.activityInfoId = this.cacheId;
......
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