|
@@ -4,7 +4,7 @@
|
|
* @Description:广告关联活动弹窗
|
|
* @Description:广告关联活动弹窗
|
|
* @Author: xinyan
|
|
* @Author: xinyan
|
|
*/
|
|
*/
|
|
-import { onMounted, ref, watch } from 'vue';
|
|
|
|
|
|
+import { computed, onMounted, ref, watch } from 'vue';
|
|
import { getAdGroupList, getRelationCampaign } from '/@/views/efTools/automation/api';
|
|
import { getAdGroupList, getRelationCampaign } from '/@/views/efTools/automation/api';
|
|
import { storeToRefs } from 'pinia';
|
|
import { storeToRefs } from 'pinia';
|
|
import { useShopInfo } from '/@/stores/shopInfo';
|
|
import { useShopInfo } from '/@/stores/shopInfo';
|
|
@@ -15,6 +15,9 @@ const props = defineProps({
|
|
type: [String, Number],
|
|
type: [String, Number],
|
|
required: true,
|
|
required: true,
|
|
},
|
|
},
|
|
|
|
+ activeModel: {
|
|
|
|
+ type: String,
|
|
|
|
+ },
|
|
modelValue: {
|
|
modelValue: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
required: true,
|
|
required: true,
|
|
@@ -24,6 +27,7 @@ const emits = defineEmits(['update:modelValue']);
|
|
const shopInfo = useShopInfo();
|
|
const shopInfo = useShopInfo();
|
|
const { profile } = storeToRefs(shopInfo);
|
|
const { profile } = storeToRefs(shopInfo);
|
|
const { templateId } = toRefs(props);
|
|
const { templateId } = toRefs(props);
|
|
|
|
+const { activeModel } = toRefs(props);
|
|
|
|
|
|
const dialogVisible = ref(props.modelValue);
|
|
const dialogVisible = ref(props.modelValue);
|
|
//筛选条件
|
|
//筛选条件
|
|
@@ -52,7 +56,7 @@ const total = ref(0);
|
|
|
|
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
const refTable = ref(null);
|
|
const refTable = ref(null);
|
|
-const selectedAds = ref([]);
|
|
|
|
|
|
+let selectedAds = ref([]);
|
|
let selections = []; // 添加选中的项
|
|
let selections = []; // 添加选中的项
|
|
|
|
|
|
function handleCurrentChange(newPage) {
|
|
function handleCurrentChange(newPage) {
|
|
@@ -68,9 +72,12 @@ function handleSizeChange(newSize) {
|
|
fetchAdCampaign();
|
|
fetchAdCampaign();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+let isRestoringSelection = false;
|
|
|
|
+
|
|
async function fetchAdCampaign() {
|
|
async function fetchAdCampaign() {
|
|
try {
|
|
try {
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
|
+ const cachedSelectedAds = [...selectedAds.value];
|
|
const resp = await getRelationCampaign({
|
|
const resp = await getRelationCampaign({
|
|
profileId: profile.value.profile_id,
|
|
profileId: profile.value.profile_id,
|
|
templateId: templateId.value,
|
|
templateId: templateId.value,
|
|
@@ -82,15 +89,18 @@ async function fetchAdCampaign() {
|
|
limit: pageSize.value,
|
|
limit: pageSize.value,
|
|
});
|
|
});
|
|
adCampaignName.value = resp.data;
|
|
adCampaignName.value = resp.data;
|
|
|
|
+
|
|
total.value = resp.total;
|
|
total.value = resp.total;
|
|
currentPage.value = resp.page;
|
|
currentPage.value = resp.page;
|
|
- // 恢复勾选状态
|
|
|
|
|
|
+ // 开始恢复勾选状态
|
|
|
|
+ isRestoringSelection = true;
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
adCampaignName.value.forEach(item => {
|
|
adCampaignName.value.forEach(item => {
|
|
- if (selectedAds.value.some(ad => ad.campaignId === item.campaignId)) {
|
|
|
|
|
|
+ if (cachedSelectedAds.some(ad => ad.campaignId === item.campaignId)) {
|
|
refTable.value.toggleRowSelection(item, true);
|
|
refTable.value.toggleRowSelection(item, true);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ isRestoringSelection = false;
|
|
});
|
|
});
|
|
} catch (error) {
|
|
} catch (error) {
|
|
ElMessage.error('请求广告活动数据失败');
|
|
ElMessage.error('请求广告活动数据失败');
|
|
@@ -100,6 +110,8 @@ async function fetchAdCampaign() {
|
|
}
|
|
}
|
|
|
|
|
|
function handleSelectionChange(selection) {
|
|
function handleSelectionChange(selection) {
|
|
|
|
+ if (isRestoringSelection) return; // 恢复勾选时跳过该方法
|
|
|
|
+
|
|
selections = selection;
|
|
selections = selection;
|
|
const newSelections = selections.filter(
|
|
const newSelections = selections.filter(
|
|
(sel) => !selectedAds.value.some((added) => added.campaignId === sel.campaignId)
|
|
(sel) => !selectedAds.value.some((added) => added.campaignId === sel.campaignId)
|
|
@@ -230,6 +242,13 @@ watch(dialogVisible, (newValue) => {
|
|
emits('update:modelValue', newValue);
|
|
emits('update:modelValue', newValue);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+const treeProps = computed(() => {
|
|
|
|
+ if (activeModel.value === 'adGroup' || activeModel.value === 'specified') {
|
|
|
|
+ return { children: 'campaignGroupInfo' };
|
|
|
|
+ }
|
|
|
|
+ return {};
|
|
|
|
+});
|
|
|
|
+
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
//fetchAdGroupList();
|
|
//fetchAdGroupList();
|
|
});
|
|
});
|
|
@@ -244,8 +263,8 @@ onMounted(() => {
|
|
title="关联广告活动"
|
|
title="关联广告活动"
|
|
width="1158px"
|
|
width="1158px"
|
|
>
|
|
>
|
|
- <div style="display: flex;">
|
|
|
|
- <div style="width: 50%;">
|
|
|
|
|
|
+ <div class="container">
|
|
|
|
+ <div class="container-left">
|
|
<el-input v-model="searchAdCampaign" placeholder="请输入广告活动" style="width: 100%;"
|
|
<el-input v-model="searchAdCampaign" placeholder="请输入广告活动" style="width: 100%;"
|
|
@change="fetchAdCampaign()"></el-input>
|
|
@change="fetchAdCampaign()"></el-input>
|
|
<div class="custom-inline">
|
|
<div class="custom-inline">
|
|
@@ -257,7 +276,7 @@ onMounted(() => {
|
|
></el-option>
|
|
></el-option>
|
|
</el-select>
|
|
</el-select>
|
|
|
|
|
|
- <el-select v-model="selectedAdGroup" placeholder="广告组合" style="margin-bottom: 10px;">
|
|
|
|
|
|
+ <el-select v-model="selectedAdGroup" clearable placeholder="广告组合" style="margin-bottom: 10px;">
|
|
<el-option
|
|
<el-option
|
|
v-for="item in adGroups"
|
|
v-for="item in adGroups"
|
|
:key="item.value"
|
|
:key="item.value"
|
|
@@ -280,14 +299,18 @@ onMounted(() => {
|
|
v-loading="loading"
|
|
v-loading="loading"
|
|
:cell-style="cellStyle"
|
|
:cell-style="cellStyle"
|
|
:data="adCampaignName"
|
|
:data="adCampaignName"
|
|
|
|
+ :row-key="'campaignId'"
|
|
:header-cell-style="headerCellStyle"
|
|
:header-cell-style="headerCellStyle"
|
|
height="400"
|
|
height="400"
|
|
style="width: 100%;"
|
|
style="width: 100%;"
|
|
|
|
+ :tree-props="treeProps"
|
|
|
|
+ v-bind="activeModel === 'adGroup' || activeModel === 'specified' ? treeProps : {}"
|
|
@selection-change="handleSelectionChange"
|
|
@selection-change="handleSelectionChange"
|
|
>
|
|
>
|
|
- <el-table-column label="广告活动名称" prop="campaignName">
|
|
|
|
|
|
+ <el-table-column label="广告活动名称">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-tag
|
|
<el-tag
|
|
|
|
+ v-if="scope.row.campaignType"
|
|
:color="scope.row.campaignType === 'sb' ? '#0163d2' : (scope.row.campaignType === 'sp' ? '#ff7424' : '#365672')"
|
|
:color="scope.row.campaignType === 'sb' ? '#0163d2' : (scope.row.campaignType === 'sp' ? '#ff7424' : '#365672')"
|
|
class="campaign-type"
|
|
class="campaign-type"
|
|
disable-transitions
|
|
disable-transitions
|
|
@@ -295,6 +318,7 @@ onMounted(() => {
|
|
{{ scope.row.campaignType }}
|
|
{{ scope.row.campaignType }}
|
|
</el-tag>
|
|
</el-tag>
|
|
{{ scope.row.campaignName }}
|
|
{{ scope.row.campaignName }}
|
|
|
|
+ {{ scope.row.adGroupName }}
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column type="selection" width="55"></el-table-column>
|
|
<el-table-column type="selection" width="55"></el-table-column>
|
|
@@ -313,19 +337,21 @@ onMounted(() => {
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- <div style="flex: 1; padding-left: 20px;">
|
|
|
|
|
|
+ <div class="container-right">
|
|
<h3>已选择({{ selectedAds.length }})</h3>
|
|
<h3>已选择({{ selectedAds.length }})</h3>
|
|
<el-table
|
|
<el-table
|
|
:cell-style="cellStyle"
|
|
:cell-style="cellStyle"
|
|
:data="selectedAds"
|
|
:data="selectedAds"
|
|
:header-cell-style="headerCellStyle"
|
|
:header-cell-style="headerCellStyle"
|
|
height="484"
|
|
height="484"
|
|
|
|
+ :tree-props="treeProps"
|
|
|
|
+ v-bind="activeModel === 'adGroup' || activeModel === 'specified' ? treeProps : {}"
|
|
style="width: 100%; margin-top: 20px;"
|
|
style="width: 100%; margin-top: 20px;"
|
|
>
|
|
>
|
|
<el-table-column label="广告活动" prop="campaignName">
|
|
<el-table-column label="广告活动" prop="campaignName">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-tag
|
|
<el-tag
|
|
|
|
+ v-if="scope.row.campaignType"
|
|
:color="scope.row.campaignType === 'sb' ? '#0163d2' : (scope.row.campaignType === 'sp' ? '#ff7424' : '#365672')"
|
|
:color="scope.row.campaignType === 'sb' ? '#0163d2' : (scope.row.campaignType === 'sp' ? '#ff7424' : '#365672')"
|
|
class="campaign-type"
|
|
class="campaign-type"
|
|
disable-transitions
|
|
disable-transitions
|
|
@@ -333,6 +359,7 @@ onMounted(() => {
|
|
{{ scope.row.campaignType }}
|
|
{{ scope.row.campaignType }}
|
|
</el-tag>
|
|
</el-tag>
|
|
{{ scope.row.campaignName }}
|
|
{{ scope.row.campaignName }}
|
|
|
|
+ {{ scope.row.adGroupName }}
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column
|
|
<el-table-column
|
|
@@ -387,4 +414,28 @@ onMounted(() => {
|
|
margin-right: 4px;
|
|
margin-right: 4px;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+.container {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ border: 1px solid #d6dbe2;
|
|
|
|
+ border-radius: 4px;
|
|
|
|
+ display: flex;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ align-content: center;
|
|
|
|
+ flex-wrap: nowrap;
|
|
|
|
+ flex-direction: row;
|
|
|
|
+ /* padding: 10px; */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.container-left {
|
|
|
|
+ width: 50%;
|
|
|
|
+ border-right: 1px solid #d6dbe2;
|
|
|
|
+ padding: 15px
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.container-right {
|
|
|
|
+ flex: 1;
|
|
|
|
+ padding: 15px
|
|
|
|
+}
|
|
|
|
+
|
|
</style>
|
|
</style>
|