|
@@ -16,7 +16,7 @@ import { useShopInfo } from '/@/stores/shopInfo';
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
import TargetRuleDialog from '/@/views/efTools/automation/components/targetRuleDialog.vue';
|
|
import TargetRuleDialog from '/@/views/efTools/automation/components/targetRuleDialog.vue';
|
|
import { DocumentAdd } from '@element-plus/icons-vue';
|
|
import { DocumentAdd } from '@element-plus/icons-vue';
|
|
-import { allCampaignTypes, campaignStatus } from '/@/views/efTools/utils/enum';
|
|
|
|
|
|
+import { allCampaignTypes, campaignStatus, filterCampaignTypes } from '/@/views/efTools/utils/enum';
|
|
|
|
|
|
|
|
|
|
const shopInfo = useShopInfo();
|
|
const shopInfo = useShopInfo();
|
|
@@ -63,16 +63,14 @@ const xGridOne = ref(null);
|
|
const xGridTwo = ref(null);
|
|
const xGridTwo = ref(null);
|
|
let selectedAds = ref([]);
|
|
let selectedAds = ref([]);
|
|
|
|
|
|
-// 计算属性,动态生成可选的 campaignType
|
|
|
|
const filteredCampaignType = computed(() => {
|
|
const filteredCampaignType = computed(() => {
|
|
const selectedCampaignType = props.rowData.rule.campaignType;
|
|
const selectedCampaignType = props.rowData.rule.campaignType;
|
|
-
|
|
|
|
- // 如果 selectedCampaignType 有值,过滤出该值的选项
|
|
|
|
if (selectedCampaignType) {
|
|
if (selectedCampaignType) {
|
|
return allCampaignTypes.filter(item => item.value === selectedCampaignType);
|
|
return allCampaignTypes.filter(item => item.value === selectedCampaignType);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 否则,返回所有选项
|
|
|
|
|
|
+ else if (props.rowData.rule.type === 2 || props.rowData.rule.type === 5 || props.rowData.rule.type === 6){
|
|
|
|
+ return filterCampaignTypes;
|
|
|
|
+ }
|
|
return allCampaignTypes;
|
|
return allCampaignTypes;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -87,7 +85,6 @@ const selectedColumns = computed(() => [
|
|
]);
|
|
]);
|
|
|
|
|
|
const treeProps = computed(() => {
|
|
const treeProps = computed(() => {
|
|
- // activeModel.value = 'specified';
|
|
|
|
if (activeModel.value === 'adGroup' || activeModel.value === 'specified') {
|
|
if (activeModel.value === 'adGroup' || activeModel.value === 'specified') {
|
|
return {
|
|
return {
|
|
rowField: 'campaignId',
|
|
rowField: 'campaignId',
|
|
@@ -101,6 +98,7 @@ const treeProps = computed(() => {
|
|
const gridOptions = reactive({
|
|
const gridOptions = reactive({
|
|
border: 'inner',
|
|
border: 'inner',
|
|
height: 500,
|
|
height: 500,
|
|
|
|
+ loading:false,
|
|
rowConfig: {
|
|
rowConfig: {
|
|
isHover: true,
|
|
isHover: true,
|
|
keyField: 'campaignId',
|
|
keyField: 'campaignId',
|
|
@@ -112,10 +110,9 @@ const gridOptions = reactive({
|
|
checkStrictly: false,
|
|
checkStrictly: false,
|
|
checkMethod: ({ row }) => {
|
|
checkMethod: ({ row }) => {
|
|
if (activeModel.value === 'specified') {
|
|
if (activeModel.value === 'specified') {
|
|
- // 如果是 specified 模式,只有已选择的行可以被取消选中
|
|
|
|
return row.isSelected;
|
|
return row.isSelected;
|
|
}
|
|
}
|
|
- return true; // 其他模式下都可以选中
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
columns: computed(() => [
|
|
columns: computed(() => [
|
|
@@ -159,8 +156,7 @@ async function fetchAdCampaign() {
|
|
// searchAdCampaign.value = JSON.parse(savedAdCampaign);
|
|
// searchAdCampaign.value = JSON.parse(savedAdCampaign);
|
|
// }
|
|
// }
|
|
try {
|
|
try {
|
|
- loading.value = true;
|
|
|
|
- // const cachedSelectedAds = [...selectedAds.value];
|
|
|
|
|
|
+ gridOptions.loading = true;
|
|
if (profile.value.profile_id && templateId.value) {
|
|
if (profile.value.profile_id && templateId.value) {
|
|
const resp = await getRelationCampaign({
|
|
const resp = await getRelationCampaign({
|
|
profileId: profile.value.profile_id,
|
|
profileId: profile.value.profile_id,
|
|
@@ -179,19 +175,10 @@ async function fetchAdCampaign() {
|
|
} catch (error) {
|
|
} catch (error) {
|
|
ElMessage.error('请求广告活动数据失败');
|
|
ElMessage.error('请求广告活动数据失败');
|
|
} finally {
|
|
} finally {
|
|
- loading.value = false;
|
|
|
|
|
|
+ gridOptions.loading = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-// 处理表格复选框选择变化(是否为树形结构)
|
|
|
|
-// const handleGridChange = (event) => {
|
|
|
|
-// if (activeModel.value == 'specified' || activeModel.value == 'adGroup') {
|
|
|
|
-// handleSelectionChange(event);
|
|
|
|
-// } else {
|
|
|
|
-// handelSelect(event);
|
|
|
|
-// }
|
|
|
|
-// };
|
|
|
|
-
|
|
|
|
function handleGridChange({ records, row, checked }) {
|
|
function handleGridChange({ records, row, checked }) {
|
|
if (activeModel.value === 'specified') {
|
|
if (activeModel.value === 'specified') {
|
|
if (row) {
|
|
if (row) {
|
|
@@ -200,12 +187,12 @@ function handleGridChange({ records, row, checked }) {
|
|
if (row.campaignGroupInfo) {
|
|
if (row.campaignGroupInfo) {
|
|
// 如果是父节点,清空所有子节点的 keywordInfo 和 campaignTargetInfo
|
|
// 如果是父节点,清空所有子节点的 keywordInfo 和 campaignTargetInfo
|
|
row.campaignGroupInfo.forEach(group => {
|
|
row.campaignGroupInfo.forEach(group => {
|
|
- group.keywordInfo = []; // 清空每个子节点的关键词信息
|
|
|
|
- group.campaignTargetInfo = []; // 清空每个子节点的定向目标信息
|
|
|
|
|
|
+ group.keywordInfo = [];
|
|
|
|
+ group.campaignTargetInfo = [];
|
|
});
|
|
});
|
|
} else if (row.keywordInfo || row.campaignTargetInfo) {
|
|
} else if (row.keywordInfo || row.campaignTargetInfo) {
|
|
- row.keywordInfo = []; // 清空关键词信息
|
|
|
|
- row.campaignTargetInfo = []; // 清空定向目标信息
|
|
|
|
|
|
+ row.keywordInfo = [];
|
|
|
|
+ row.campaignTargetInfo = [];
|
|
}
|
|
}
|
|
updateSelectedAds();
|
|
updateSelectedAds();
|
|
}
|
|
}
|
|
@@ -245,9 +232,7 @@ function handelSelect({ records }) {
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
-// 处理一开始selectedAds.value为空时能正常
|
|
|
|
function updateSelectedAds() {
|
|
function updateSelectedAds() {
|
|
- // 获取当前选中广告组
|
|
|
|
const filteredAds = gridOptions.data
|
|
const filteredAds = gridOptions.data
|
|
.filter(ad => ad.campaignGroupInfo && ad.campaignGroupInfo.some(group => group.isSelected))
|
|
.filter(ad => ad.campaignGroupInfo && ad.campaignGroupInfo.some(group => group.isSelected))
|
|
.map(ad => ({
|
|
.map(ad => ({
|
|
@@ -255,7 +240,6 @@ function updateSelectedAds() {
|
|
campaignGroupInfo: ad.campaignGroupInfo.filter(group => group.isSelected),
|
|
campaignGroupInfo: ad.campaignGroupInfo.filter(group => group.isSelected),
|
|
page: currentPage.value
|
|
page: currentPage.value
|
|
}));
|
|
}));
|
|
- // 合并新选中的广告组与现有的 selectedAds
|
|
|
|
selectedAds.value = [
|
|
selectedAds.value = [
|
|
...selected.value, // 保留已存在的选中广告
|
|
...selected.value, // 保留已存在的选中广告
|
|
...filteredAds
|
|
...filteredAds
|
|
@@ -272,7 +256,7 @@ function handleSelectionChange({ records }) {
|
|
const parentCampaignMap = new Map();
|
|
const parentCampaignMap = new Map();
|
|
records.forEach(record => {
|
|
records.forEach(record => {
|
|
if (record.adGroupId) {
|
|
if (record.adGroupId) {
|
|
- // 这是一个广告组(子节点)
|
|
|
|
|
|
+ // 子节点
|
|
const parentCampaign = gridOptions.data.find(campaign =>
|
|
const parentCampaign = gridOptions.data.find(campaign =>
|
|
campaign.campaignGroupInfo.some(group => group.adGroupId === record.adGroupId)
|
|
campaign.campaignGroupInfo.some(group => group.adGroupId === record.adGroupId)
|
|
);
|
|
);
|
|
@@ -330,7 +314,6 @@ function handleSelectTarget(row) {
|
|
function handleConfirm({ campaignInfo, targetType }) {
|
|
function handleConfirm({ campaignInfo, targetType }) {
|
|
if (!selectedTargetedRow.value) return;
|
|
if (!selectedTargetedRow.value) return;
|
|
|
|
|
|
- // 找到父级广告活动
|
|
|
|
const parentCampaign = gridOptions.data.find(campaign =>
|
|
const parentCampaign = gridOptions.data.find(campaign =>
|
|
campaign.campaignGroupInfo.some(group => group.adGroupId === selectedTargetedRow.value.adGroupId)
|
|
campaign.campaignGroupInfo.some(group => group.adGroupId === selectedTargetedRow.value.adGroupId)
|
|
);
|
|
);
|
|
@@ -344,7 +327,7 @@ function handleConfirm({ campaignInfo, targetType }) {
|
|
} else if (targetType === 'target') {
|
|
} else if (targetType === 'target') {
|
|
group.campaignTargetInfo = campaignInfo;
|
|
group.campaignTargetInfo = campaignInfo;
|
|
}
|
|
}
|
|
- group.isSelected = true; // 更新子节点的选择状态
|
|
|
|
|
|
+ group.isSelected = true;
|
|
group.targetLength = (group.keywordInfo?.length || 0) + (group.campaignTargetInfo?.length || 0);
|
|
group.targetLength = (group.keywordInfo?.length || 0) + (group.campaignTargetInfo?.length || 0);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -384,9 +367,7 @@ async function removeSpecificAd(row) {
|
|
}).filter(ad => ad.campaignGroupInfo && ad.campaignGroupInfo.length > 0);
|
|
}).filter(ad => ad.campaignGroupInfo && ad.campaignGroupInfo.length > 0);
|
|
// 更新 selected.value
|
|
// 更新 selected.value
|
|
selected.value = selected.value.map(ad => {
|
|
selected.value = selected.value.map(ad => {
|
|
- // 仅在父节点存在时进行过滤
|
|
|
|
if (ad.campaignGroupInfo) {
|
|
if (ad.campaignGroupInfo) {
|
|
- // 过滤掉与 row.adGroupId 匹配的子节点
|
|
|
|
const filteredGroupInfo = ad.campaignGroupInfo.filter(group => group.adGroupId !== row.adGroupId);
|
|
const filteredGroupInfo = ad.campaignGroupInfo.filter(group => group.adGroupId !== row.adGroupId);
|
|
return {
|
|
return {
|
|
...ad,
|
|
...ad,
|
|
@@ -399,8 +380,6 @@ async function removeSpecificAd(row) {
|
|
} else {
|
|
} else {
|
|
// 删除父节点(广告活动)
|
|
// 删除父节点(广告活动)
|
|
selectedAds.value = selectedAds.value.filter(ad => ad.campaignId !== row.campaignId);
|
|
selectedAds.value = selectedAds.value.filter(ad => ad.campaignId !== row.campaignId);
|
|
- console.log("=>(adActivityDialog.vue:394) selectedAds.value", selectedAds.value);
|
|
|
|
- // 更新 selected.value
|
|
|
|
selected.value = selected.value.filter(ad => ad.campaignId !== row.campaignId);
|
|
selected.value = selected.value.filter(ad => ad.campaignId !== row.campaignId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -417,7 +396,6 @@ async function removeSpecificAd(row) {
|
|
const parentRow = xGridOne.value.data.find(ad => ad.campaignId === row.campaignId);
|
|
const parentRow = xGridOne.value.data.find(ad => ad.campaignId === row.campaignId);
|
|
if (parentRow && parentRow.campaignGroupInfo) {
|
|
if (parentRow && parentRow.campaignGroupInfo) {
|
|
parentRow.campaignGroupInfo.forEach(group => {
|
|
parentRow.campaignGroupInfo.forEach(group => {
|
|
- // 将子节点的 isSelected 设置为 false
|
|
|
|
group.isSelected = false;
|
|
group.isSelected = false;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -454,15 +432,12 @@ const removedAd = async (row) => {
|
|
};
|
|
};
|
|
|
|
|
|
function removeAllSelectedAds() {
|
|
function removeAllSelectedAds() {
|
|
- // 清空 selectedAds 中的所有值
|
|
|
|
selectedAds.value = [];
|
|
selectedAds.value = [];
|
|
|
|
|
|
const $grid = xGridOne.value;
|
|
const $grid = xGridOne.value;
|
|
if ($grid) {
|
|
if ($grid) {
|
|
- // 清除表格中所有行的勾选状态
|
|
|
|
$grid.clearCheckboxRow();
|
|
$grid.clearCheckboxRow();
|
|
|
|
|
|
- // 循环遍历 gridOptions.data,设置所有子节点的 isSelected 为 false 并清空相关信息
|
|
|
|
gridOptions.data.forEach(ad => {
|
|
gridOptions.data.forEach(ad => {
|
|
if (ad.campaignGroupInfo) {
|
|
if (ad.campaignGroupInfo) {
|
|
ad.campaignGroupInfo.forEach(group => {
|
|
ad.campaignGroupInfo.forEach(group => {
|
|
@@ -804,14 +779,8 @@ onMounted(() => {
|
|
}
|
|
}
|
|
|
|
|
|
.campaign-type {
|
|
.campaign-type {
|
|
- /* width: 35px; */
|
|
|
|
- /* text-align: center; */
|
|
|
|
- /* height: 22px; */
|
|
|
|
- /* font-size: 13px; */
|
|
|
|
- /* font-weight: 400; */
|
|
|
|
color: #fff;
|
|
color: #fff;
|
|
border-color: #fff;
|
|
border-color: #fff;
|
|
- /* line-height: 21px; */
|
|
|
|
border-radius: 12px;
|
|
border-radius: 12px;
|
|
margin-right: 4px;
|
|
margin-right: 4px;
|
|
}
|
|
}
|
|
@@ -843,7 +812,6 @@ onMounted(() => {
|
|
.btn-link {
|
|
.btn-link {
|
|
font-size: 13px;
|
|
font-size: 13px;
|
|
color: #0085ff;
|
|
color: #0085ff;
|
|
- /* ling-heigt: 23px; */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
.flex-container {
|
|
.flex-container {
|