feat(chat): 归属账号显示昵称(账号表查询,昵称+ID并列,回退原始ID)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import { getCustomers, getGroups, getMessages } from '@/api'
|
||||
import { getAccounts, getCustomers, getGroups, getMessages } from '@/api'
|
||||
import { downloadBlob } from '@/api/client'
|
||||
import type { Channel, Message } from '@/api/types'
|
||||
import MessageBubble from '@/components/MessageBubble.vue'
|
||||
@@ -134,13 +134,30 @@ const winStart = computed(() => dateRange.value[0].getTime())
|
||||
const winEnd = computed(() => dateRange.value[1].getTime())
|
||||
const keyword = ref('')
|
||||
|
||||
/** 归属账号昵称(账号表查,回退原始 id)。 */
|
||||
const ownerNickname = ref<string | null>(null)
|
||||
|
||||
async function loadOwnerNickname(): Promise<void> {
|
||||
ownerNickname.value = null
|
||||
try {
|
||||
const res = await getAccounts({ channel: channelTyped.value, page: 1, page_size: 100 })
|
||||
const acc = res.items.find(a => a.account_id === props.ownerId)
|
||||
ownerNickname.value = acc?.nickname || acc?.user_name || null
|
||||
} catch {
|
||||
ownerNickname.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function onDateChange(): void {
|
||||
loadInitial()
|
||||
}
|
||||
|
||||
const subtitle = computed(() => {
|
||||
const ownerLabel = ownerNickname.value
|
||||
? `${ownerNickname.value}(${props.ownerId})`
|
||||
: props.ownerId
|
||||
let s =
|
||||
`渠道:${channelLabel(channelTyped.value)} · 归属账号:${props.ownerId}` +
|
||||
`渠道:${channelLabel(channelTyped.value)} · 归属账号:${ownerLabel}` +
|
||||
(total.value > 0 ? ` · 共 ${total.value} 条` : '')
|
||||
s += ` · 时段:${formatTime(winStart.value)} ~ ${formatTime(winEnd.value)}`
|
||||
return s
|
||||
@@ -302,12 +319,14 @@ watch(
|
||||
() => {
|
||||
loadInitial()
|
||||
loadTalkerName()
|
||||
loadOwnerNickname()
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
loadInitial()
|
||||
loadTalkerName()
|
||||
loadOwnerNickname()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user