Commit 3e10460b authored by lijin's avatar lijin

modified

parent 3a040af1
......@@ -894,63 +894,31 @@ export default {
try {
let taskData = {}
if (this.form.templateType === 1) {
// 使用现有模板
// 检查是否修改了模板配置
const templateModified = this.isTemplateModified()
if (templateModified) {
// 创建一个修改后的临时模板
const modifiedTemplate = {
name: this.selectedTemplate.name + ' (修改版)',
campaign_type: this.form.campaign_type,
appStore: this.form.appStore,
daily_budget: this.form.daily_budget,
bidding_type: this.form.bidding_type,
target_roas: this.form.target_roas,
app_groups: this.form.app_groups,
location_groups: this.form.location_groups,
material_groups: this.form.material_groups,
title_groups: this.form.title_groups,
description_groups: this.form.description_groups,
is_temp: 1, // 标记为临时模板
original_template_id: this.form.campaignTemplateId // 记录原始模板ID
}
taskData = {
id: this.form.id,
tempTemplate: modifiedTemplate,
useModifiedTemplate: true
}
} else {
// 没有修改模板,直接使用原模板
taskData = {
id: this.form.id,
campaignTemplateId: this.form.campaignTemplateId
}
}
} else {
// 使用临时模板,创建临时模板并使用
const templateData = {
name: this.form.tempTemplateName,
campaign_type: this.form.campaign_type,
appStore: this.form.appStore,
app_store: this.form.appStore,
daily_budget: this.form.daily_budget,
bidding_type: this.form.bidding_type,
target_roas: this.form.target_roas,
app_groups: this.form.app_groups,
location_groups: this.form.location_groups,
material_groups: this.form.material_groups,
title_groups: this.form.title_groups,
description_groups: this.form.description_groups,
is_temp: 1 // 标记为临时模板
}
taskData = {
id: this.form.id,
tempTemplate: templateData
}
}
// 将应用列表数据转换为接口所需格式
taskData.apps = this.appListData.map(app => ({
pkg: app.appId,
campaignCount: app.campaignCount || 1
}));
// 将地域组数据转换为接口所需格式
taskData.locationGroups = this.selectedLocationGroups.map(group => ({
locationGroupId: group.id,
campaignCount: group.campaignCount || 1
}));
// 标题组、描述组、素材组保持数组格式
taskData.titleGroups = this.form.title_groups;
taskData.descriptionGroups = this.form.description_groups;
taskData.materialGroups = this.form.material_groups;
let response
if (this.isEdit) {
......@@ -958,13 +926,14 @@ export default {
} else {
response = await createCampaignTask(taskData)
}
console.log('提交结果:', response)
if (response.data && response.data.code === 200) {
if (response.status === 200) {
this.$message.success(this.isEdit ? '更新成功' : '创建成功')
this.dialogVisible = false
this.fetchData()
} else {
this.$message.error(response.data.message || '操作失败')
this.$message.error(response.msg || '操作失败')
}
} catch (error) {
console.error('提交失败:', error)
......@@ -976,44 +945,7 @@ export default {
})
},
// 检查模板是否被修改
isTemplateModified() {
if (!this.selectedTemplate) return false
const template = this.selectedTemplate
// 比较各个字段值是否有变化
if (template.campaign_type !== this.form.campaign_type) return true
if (template.appStore !== this.form.appStore) return true
if (template.daily_budget !== this.form.daily_budget) return true
if (template.bidding_type !== this.form.bidding_type) return true
if (template.target_roas !== this.form.target_roas) return true
// 比较数组是否有变化
const compareArrays = (arr1, arr2) => {
if (!arr1 && !arr2) return true
if (!arr1 || !arr2) return false
if (arr1.length !== arr2.length) return false
// 排序后比较各元素
const sorted1 = [...arr1].sort()
const sorted2 = [...arr2].sort()
for (let i = 0; i < sorted1.length; i++) {
if (sorted1[i] !== sorted2[i]) return false
}
return true
}
if (!compareArrays(template.app_groups, this.form.app_groups)) return true
if (!compareArrays(template.location_groups, this.form.location_groups)) return true
if (!compareArrays(template.material_groups, this.form.material_groups)) return true
if (!compareArrays(template.title_groups, this.form.title_groups)) return true
if (!compareArrays(template.description_groups, this.form.description_groups)) return true
return false
},
showErrorReason() {
this.errorReasonVisible = true;
......@@ -1393,6 +1325,8 @@ export default {
async fetchAppsForSelector() {
try {
this.appsLoading = true; // 显示加载状态
const params = {
platformId: 5,
menuCode: "game.Overview,android",
......@@ -1400,10 +1334,15 @@ export default {
const response = await getSelectApps(params);
if (response.status === 200) {
this.selectApps = response.result.data || [];
} else {
console.error("获取应用列表失败:", response);
this.$message.error("获取应用列表失败");
}
} catch (error) {
console.error("获取应用列表失败:", error);
this.$message.error("获取应用列表失败");
} finally {
this.appsLoading = false; // 隐藏加载状态
}
},
......@@ -1439,7 +1378,7 @@ export default {
}
// 检查是否已经存在
const exists = this.appListData.some(item => item.appId === appInfo.pkg || item.id === appInfo.id);
const exists = this.appListData.some(item => item.appId === appInfo.value || item.id === appInfo.id);
if (exists) {
this.$message.warning('该应用已经在列表中');
return;
......
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