Commit a10d50a5 authored by lijin's avatar lijin

modified

parent fa54412e
......@@ -200,15 +200,15 @@
<div class="group-detail-title">应用组中的应用列表</div>
<el-table :data="appListData" size="mini" border style="width: 100%">
<el-table-column prop="name" label="应用名称"></el-table-column>
<el-table-column prop="appId" label="应用ID"></el-table-column>
<el-table-column prop="appId" label="包名"></el-table-column>
<el-table-column prop="platform" label="平台">
<template slot-scope="scope">
{{ scope.row.platform === 2 ? 'iOS' : (scope.row.platform === 3 ? 'Android' : '其他') }}
</template>
</el-table-column>
<el-table-column label="操作" width="150" align="center">
<el-table-column label="计划数" width="200" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleAppFilter(scope.row)">针对此应用</el-button>
<el-input-number v-model="scope.row.campaignCount" :min="1" @change="updateAppCampaignCount(scope.row, $event)" size="mini"></el-input-number>
</template>
</el-table-column>
</el-table>
......@@ -228,11 +228,9 @@
{{ getLocationGroupCountries(scope.row).length }} 个国家
</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center">
<el-table-column label="计划数" width="200" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" @click="viewLocationGroup(scope.row)">查看</el-button>
<el-button type="text" size="small" @click="editLocationGroup(scope.row)">修改</el-button>
<el-button type="text" size="small" @click="removeLocationGroup(scope.row)">移除</el-button>
<el-input-number v-model="scope.row.campaignCount" :min="1" @change="updateLocationGroupCampaignCount(scope.row, $event)" size="mini"></el-input-number>
</template>
</el-table-column>
</el-table>
......@@ -338,20 +336,20 @@
<el-table-column label="投放国家" min-width="150" sortable>
<template slot-scope="scope">
<div class="table-countries-container">
<template v-if="scope.row.countries && scope.row.countries.length > 0">
<template v-if="scope.row.countryCodes && scope.row.countryCodes.length > 0">
<el-tag
v-for="(country, index) in typeof scope.row.countries === 'string' ?
JSON.parse(scope.row.countries) : scope.row.countries"
:key="country.code"
v-for="(country, index) in typeof scope.row.countryCodes === 'string' ?
JSON.parse(scope.row.countryCodes) : scope.row.countryCodes"
:key="country"
v-if="index < 5"
size="mini"
class="country-tag"
type="primary"
effect="light">
{{ country.code }}
{{ country }}
</el-tag>
<span v-if="(typeof scope.row.countries === 'string' ?
JSON.parse(scope.row.countries) : scope.row.countries).length > 5"
<span v-if="(typeof scope.row.countryCodes === 'string' ?
JSON.parse(scope.row.countryCodes) : scope.row.countryCodes).length > 5"
class="more-countries">...</span>
</template>
<span v-else class="no-countries-text">无国家信息</span>
......@@ -1143,8 +1141,8 @@ export default {
// 获取地域组数据
const locationGroupRes = await axios.get(process.env.PUTIN_API + '/location-groups')
if (locationGroupRes.data && locationGroupRes.data.code === 200 && locationGroupRes.data.data) {
this.locationGroupOptions = locationGroupRes.data.data
if (locationGroupRes.status === 200) {
this.locationGroupOptions = locationGroupRes.data.result.data
}
// 获取素材组数据
......@@ -1197,7 +1195,8 @@ export default {
platform: app.pkg.toLowerCase().includes('.ios') ? 2 : 3,
id: app.id,
description: app.description,
operateType: app.operateType
operateType: app.operateType,
campaignCount: 1 // 添加计划数字段,默认为1
}));
} else {
console.error('获取应用组应用列表失败:', response);
......@@ -1209,6 +1208,26 @@ export default {
}
},
// 更新应用的计划数
updateAppCampaignCount(app, value) {
// 验证输入值
if (value < 1) {
this.$message.warning('计划数最小为1');
// 重置为1
const index = this.appListData.findIndex(item => item.appId === app.appId);
if (index !== -1) {
this.appListData[index].campaignCount = 1;
}
return;
}
// 更新计划数
const index = this.appListData.findIndex(item => item.appId === app.appId);
if (index !== -1) {
this.appListData[index].campaignCount = value;
}
},
handleLocationGroupsChange(value) {
// 处理地域组变化后的逻辑
if (value && value.length > 0) {
......@@ -1220,16 +1239,64 @@ export default {
async fetchSelectedLocationGroups(locationGroupIds) {
try {
// 打印地域组选项,便于调试
console.log('地域组选项:', this.locationGroupOptions);
this.selectedLocationGroups = locationGroupIds.map(id => {
const group = this.locationGroupOptions.find(item => item.id === id);
return group || { id: id, name: `地域组 ${id}` };
// 确保ID为数字类型进行比较
const numId = Number(id);
// 尝试在选项中找到对应的地域组
const group = this.locationGroupOptions.find(item => Number(item.id) === numId);
console.log(`查找地域组ID: ${id}, 找到: ${group}`);
if (group) {
return {
id: group.id,
name: group.name || `地域组 ${id}`, // 确保有名称,如果没有则使用ID
campaignCount: 1,
countryCodes: group.countryCodes || []
};
} else {
return {
id: id,
name: `地域组 ${id}`,
campaignCount: 1,
countryCodes: []
};
}
});
// 打印选中的地域组,便于调试
console.log('选中的地域组:', this.selectedLocationGroups);
} catch (error) {
console.error('获取地域组数据失败:', error);
this.$message.error('获取地域组数据失败');
}
},
// 更新地域组的计划数
updateLocationGroupCampaignCount(group, value) {
// 验证输入值
if (value < 1) {
this.$message.warning('计划数最小为1');
// 重置为1
const index = this.selectedLocationGroups.findIndex(item => item.id === group.id);
if (index !== -1) {
this.selectedLocationGroups[index].campaignCount = 1;
}
return;
}
// 更新计划数
const index = this.selectedLocationGroups.findIndex(item => item.id === group.id);
if (index !== -1) {
this.selectedLocationGroups[index].campaignCount = value;
}
},
viewLocationGroup(group) {
// 实现查看地域组详情逻辑
this.$alert(`地域组 "${group.name}" 详情`, '地域组详情', {
......@@ -1255,7 +1322,7 @@ export default {
getLocationGroupCountries(group) {
// 获取地域组国家列表
// 由于我们没有完整的API,这里返回一个模拟数据
return group.countries || [];
return group.countryCodes || [];
},
handleAppFilter(app) {
......
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