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 { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
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 { downloadBlob } from '@/api/client'
|
||||||
import type { Channel, Message } from '@/api/types'
|
import type { Channel, Message } from '@/api/types'
|
||||||
import MessageBubble from '@/components/MessageBubble.vue'
|
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 winEnd = computed(() => dateRange.value[1].getTime())
|
||||||
const keyword = ref('')
|
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 {
|
function onDateChange(): void {
|
||||||
loadInitial()
|
loadInitial()
|
||||||
}
|
}
|
||||||
|
|
||||||
const subtitle = computed(() => {
|
const subtitle = computed(() => {
|
||||||
|
const ownerLabel = ownerNickname.value
|
||||||
|
? `${ownerNickname.value}(${props.ownerId})`
|
||||||
|
: props.ownerId
|
||||||
let s =
|
let s =
|
||||||
`渠道:${channelLabel(channelTyped.value)} · 归属账号:${props.ownerId}` +
|
`渠道:${channelLabel(channelTyped.value)} · 归属账号:${ownerLabel}` +
|
||||||
(total.value > 0 ? ` · 共 ${total.value} 条` : '')
|
(total.value > 0 ? ` · 共 ${total.value} 条` : '')
|
||||||
s += ` · 时段:${formatTime(winStart.value)} ~ ${formatTime(winEnd.value)}`
|
s += ` · 时段:${formatTime(winStart.value)} ~ ${formatTime(winEnd.value)}`
|
||||||
return s
|
return s
|
||||||
@@ -302,12 +319,14 @@ watch(
|
|||||||
() => {
|
() => {
|
||||||
loadInitial()
|
loadInitial()
|
||||||
loadTalkerName()
|
loadTalkerName()
|
||||||
|
loadOwnerNickname()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadInitial()
|
loadInitial()
|
||||||
loadTalkerName()
|
loadTalkerName()
|
||||||
|
loadOwnerNickname()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user