fix:解决样本库复制联系方式无法获取的问题
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="link-container">
|
<div class="link-container">
|
||||||
<div>
|
<div>
|
||||||
<channel-list :activeChannel="activeChannel" @selectChannel="selectChannel"></channel-list>
|
<channel-list
|
||||||
|
ref="channelListRef"
|
||||||
|
:activeChannel="activeChannel"
|
||||||
|
@selectChannel="selectChannel">
|
||||||
|
</channel-list>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<channel-setting :channel="channel"></channel-setting>
|
<channel-setting :channel="channel"></channel-setting>
|
||||||
@@ -19,21 +23,26 @@ import { getPublishDetail } from '@/api/accurate'
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const channel = ref({})
|
const channel = ref({})
|
||||||
let activeChannel = ref('')
|
let activeChannel = ref('')
|
||||||
|
const channelListRef = ref(null) // 添加对 ChannelList 组件的引用
|
||||||
// 处理复制投放的数据
|
|
||||||
const handleRecordData = (record) => {
|
|
||||||
channel.value = JSON.parse(record)
|
|
||||||
activeChannel.value = channel.value.appCategory
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取详情数据
|
// 获取详情数据
|
||||||
const getDetail = async (surveyPublishId) => {
|
const getDetail = async (surveyPublishId) => {
|
||||||
try {
|
try {
|
||||||
const res = await getPublishDetail({ surveyPublishId })
|
const res = await getPublishDetail({ surveyPublishId })
|
||||||
console.log(res.data);
|
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
channel.value = res.data
|
// 先获取基础数据
|
||||||
activeChannel.value = res.data.launchChannelId
|
const baseData = res.data
|
||||||
|
activeChannel.value = baseData.launchChannelId
|
||||||
|
|
||||||
|
// 从 ChannelList 组件获取补充数据
|
||||||
|
const supplementData = channelListRef.value?.getChannelSupplementData(baseData.launchChannelId)
|
||||||
|
console.log(supplementData);
|
||||||
|
// 合并数据,优先使用基础数据,缺失字段使用补充数据
|
||||||
|
channel.value = {
|
||||||
|
...baseData,
|
||||||
|
contactPerson: baseData.contactPerson || supplementData?.contactPerson,
|
||||||
|
contactPersonPhone: baseData.contactPersonPhone || supplementData?.contactPersonPhone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取详情失败:', error)
|
console.error('获取详情失败:', error)
|
||||||
|
|||||||
@@ -72,6 +72,13 @@ const selectChannel = (channel) => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getChannelList();
|
getChannelList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 暴露方法给父组件使用
|
||||||
|
defineExpose({
|
||||||
|
getChannelSupplementData: (launchChannelId) => {
|
||||||
|
return channelList.value.find(item => item.appId === launchChannelId) || {}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user